@@ -16,8 +16,9 @@ use crate::util::{is_number, avg, CellContent};
1616use crate :: text:: { concat_text} ;
1717use std:: mem:: take;
1818use table:: Table ;
19+ use font:: { Encoder , Glyph } ;
1920
20- pub fn build ( spans : & [ TextSpan ] , bbox : RectF , lines : & [ [ f32 ; 4 ] ] ) -> Node {
21+ pub fn build < E : Encoder > ( spans : & [ TextSpan < E > ] , bbox : RectF , lines : & [ [ f32 ; 4 ] ] ) -> Node {
2122 if spans. len ( ) == 0 {
2223 return Node :: singleton ( & [ ] ) ;
2324 }
@@ -180,7 +181,7 @@ impl Span {
180181 }
181182}
182183
183- pub fn split2 ( boxes : & mut [ ( RectF , usize ) ] , spans : & [ TextSpan ] , lines_info : & Lines ) -> Node {
184+ pub fn split2 < E : Encoder > ( boxes : & mut [ ( RectF , usize ) ] , spans : & [ TextSpan < E > ] , lines_info : & Lines ) -> Node {
184185 use std:: mem:: replace;
185186
186187 #[ derive( Debug ) ]
@@ -383,7 +384,7 @@ pub enum NodeTag {
383384 Complex ,
384385}
385386
386- pub fn items ( mut flow : & mut Flow , spans : & [ TextSpan ] , node : & Node , x_anchor : f32 ) {
387+ pub fn items < E : Encoder > ( mut flow : & mut Flow , spans : & [ TextSpan < E > ] , node : & Node , x_anchor : f32 ) {
387388 match * node {
388389 Node :: Final { ref indices } => {
389390 if indices. len ( ) > 0 {
@@ -534,10 +535,10 @@ pub fn items(mut flow: &mut Flow, spans: &[TextSpan], node: &Node, x_anchor: f32
534535}
535536
536537
537- pub fn render ( w : & mut String , spans : & [ TextSpan ] , node : & Node , bbox : RectF ) {
538+ pub fn render < E : Encoder > ( w : & mut String , spans : & [ TextSpan < E > ] , node : & Node , bbox : RectF ) {
538539 _render ( w, spans, node, bbox, 0 )
539540}
540- fn _render ( w : & mut String , spans : & [ TextSpan ] , node : & Node , bbox : RectF , level : usize ) {
541+ fn _render < E : Encoder > ( w : & mut String , spans : & [ TextSpan < E > ] , node : & Node , bbox : RectF , level : usize ) {
541542 use std:: fmt:: Write ;
542543
543544 match * node {
@@ -596,7 +597,7 @@ fn _render(w: &mut String, spans: &[TextSpan], node: &Node, bbox: RectF, level:
596597 }
597598}
598599
599- fn split ( boxes : & mut [ ( RectF , usize ) ] , spans : & [ TextSpan ] , lines : & Lines ) -> Node {
600+ fn split < E : Encoder > ( boxes : & mut [ ( RectF , usize ) ] , spans : & [ TextSpan < E > ] , lines : & Lines ) -> Node {
600601 let num_boxes = boxes. len ( ) ;
601602 if num_boxes < 2 {
602603 return Node :: singleton ( boxes) ;
@@ -925,13 +926,13 @@ impl TriCount {
925926 }
926927 }
927928}
928- fn classify < ' a > ( spans : impl Iterator < Item =& ' a TextSpan > ) -> Class {
929+ fn classify < ' a , E : Encoder + ' a > ( spans : impl Iterator < Item =& ' a TextSpan < E > > ) -> Class {
929930 use pdf_render:: FontEntry ;
930931
931932 let mut bold = TriCount :: new ( ) ;
932933 let mut numeric = TriCount :: new ( ) ;
933934 let mut uniform = TriCount :: new ( ) ;
934- let mut first_font: * const FontEntry = std:: ptr:: null ( ) ;
935+ let mut first_font: * const FontEntry < E > = std:: ptr:: null ( ) ;
935936
936937 for s in spans {
937938 numeric. add ( is_number ( & s. text ) ) ;
0 commit comments