1616import {
1717 assert ,
1818 bytesToString ,
19+ DrawOPS ,
20+ FeatureTest ,
1921 FONT_IDENTITY_MATRIX ,
2022 FormatError ,
2123 unreachable ,
@@ -169,16 +171,16 @@ function compileGlyf(code, cmds, font) {
169171 function moveTo ( x , y ) {
170172 if ( firstPoint ) {
171173 // Close the current subpath in adding a straight line to the first point.
172- cmds . add ( "L" , firstPoint ) ;
174+ cmds . add ( DrawOPS . lineTo , firstPoint ) ;
173175 }
174176 firstPoint = [ x , y ] ;
175- cmds . add ( "M" , [ x , y ] ) ;
177+ cmds . add ( DrawOPS . moveTo , [ x , y ] ) ;
176178 }
177179 function lineTo ( x , y ) {
178- cmds . add ( "L" , [ x , y ] ) ;
180+ cmds . add ( DrawOPS . lineTo , [ x , y ] ) ;
179181 }
180182 function quadraticCurveTo ( xa , ya , x , y ) {
181- cmds . add ( "Q" , [ xa , ya , x , y ] ) ;
183+ cmds . add ( DrawOPS . quadraticCurveTo , [ xa , ya , x , y ] ) ;
182184 }
183185
184186 let i = 0 ;
@@ -355,16 +357,16 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
355357 function moveTo ( x , y ) {
356358 if ( firstPoint ) {
357359 // Close the current subpath in adding a straight line to the first point.
358- cmds . add ( "L" , firstPoint ) ;
360+ cmds . add ( DrawOPS . lineTo , firstPoint ) ;
359361 }
360362 firstPoint = [ x , y ] ;
361- cmds . add ( "M" , [ x , y ] ) ;
363+ cmds . add ( DrawOPS . moveTo , [ x , y ] ) ;
362364 }
363365 function lineTo ( x , y ) {
364- cmds . add ( "L" , [ x , y ] ) ;
366+ cmds . add ( DrawOPS . lineTo , [ x , y ] ) ;
365367 }
366368 function bezierCurveTo ( x1 , y1 , x2 , y2 , x , y ) {
367- cmds . add ( "C" , [ x1 , y1 , x2 , y2 , x , y ] ) ;
369+ cmds . add ( DrawOPS . curveTo , [ x1 , y1 , x2 , y2 , x , y ] ) ;
368370 }
369371
370372 const stack = [ ] ;
@@ -749,7 +751,7 @@ class Commands {
749751 for ( let i = 0 , ii = args . length ; i < ii ; i += 2 ) {
750752 Util . applyTransform ( args , currentTransform , i ) ;
751753 }
752- this . cmds . push ( ` ${ cmd } ${ args . join ( " " ) } ` ) ;
754+ this . cmds . push ( cmd , ... args ) ;
753755 } else {
754756 this . cmds . push ( cmd ) ;
755757 }
@@ -771,8 +773,13 @@ class Commands {
771773 this . currentTransform = this . transformStack . pop ( ) || [ 1 , 0 , 0 , 1 , 0 , 0 ] ;
772774 }
773775
774- getSVG ( ) {
775- return this . cmds . join ( "" ) ;
776+ getPath ( ) {
777+ if ( typeof PDFJSDev !== "undefined" && PDFJSDev . test ( "MOZCENTRAL" ) ) {
778+ return new Float16Array ( this . cmds ) ;
779+ }
780+ return new (
781+ FeatureTest . isFloat16ArraySupported ? Float16Array : Float32Array
782+ ) ( this . cmds ) ;
776783 }
777784}
778785
@@ -834,9 +841,9 @@ class CompiledFont {
834841 const cmds = new Commands ( ) ;
835842 cmds . transform ( fontMatrix . slice ( ) ) ;
836843 this . compileGlyphImpl ( code , cmds , glyphId ) ;
837- cmds . add ( "Z" ) ;
844+ cmds . add ( DrawOPS . closePath ) ;
838845
839- return cmds . getSVG ( ) ;
846+ return cmds . getPath ( ) ;
840847 }
841848
842849 compileGlyphImpl ( ) {
0 commit comments