@@ -26,6 +26,7 @@ import {
2626 warn ,
2727} from "../shared/util.js" ;
2828import { CFFParser } from "./cff_parser.js" ;
29+ import { compileFontPathInfo } from "./obj_bin_transform_core.js" ;
2930import { getGlyphsUnicode } from "./glyphlist.js" ;
3031import { isNumberArray } from "./core_utils.js" ;
3132import { StandardEncoding } from "./encodings.js" ;
@@ -781,9 +782,9 @@ class Commands {
781782}
782783
783784class CompiledFont {
784- #compiledGlyphs = new Map ( ) ;
785+ #compiledCharCodes = new Set ( ) ;
785786
786- #compiledCharCodeToGlyphId = new Map ( ) ;
787+ #compiledGlyphs = new Map ( ) ;
787788
788789 constructor ( fontMatrix ) {
789790 if (
@@ -806,22 +807,29 @@ class CompiledFont {
806807 ) ;
807808 }
808809
809- getPathJs ( unicode ) {
810+ getPath ( unicode ) {
810811 const { charCode, glyphId } = lookupCmap ( this . cmap , unicode ) ;
811812
813+ if (
814+ this . #compiledGlyphs. has ( glyphId ) &&
815+ this . #compiledCharCodes. has ( charCode )
816+ ) {
817+ return null ; // Previously compiled.
818+ }
819+
812820 const path = this . #compiledGlyphs. getOrInsertComputed ( glyphId , ( ) => {
813821 try {
814822 return this . compileGlyph ( this . glyphs [ glyphId ] , glyphId ) ;
815823 } catch ( ex ) {
816824 return ex ; // Avoid attempting to re-compile a corrupt glyph.
817825 }
818826 } ) ;
819- this . #compiledCharCodeToGlyphId . getOrInsert ( charCode , glyphId ) ;
827+ this . #compiledCharCodes . add ( charCode ) ;
820828
821829 if ( path instanceof Error ) {
822830 throw path ;
823831 }
824- return path ;
832+ return compileFontPathInfo ( path ) ;
825833 }
826834
827835 compileGlyph ( code , glyphId ) {
@@ -854,14 +862,6 @@ class CompiledFont {
854862 compileGlyphImpl ( ) {
855863 unreachable ( "Children classes should implement this." ) ;
856864 }
857-
858- hasBuiltPath ( unicode ) {
859- const { charCode, glyphId } = lookupCmap ( this . cmap , unicode ) ;
860- return (
861- this . #compiledGlyphs. has ( glyphId ) &&
862- this . #compiledCharCodeToGlyphId. has ( charCode )
863- ) ;
864- }
865865}
866866
867867class TrueTypeCompiled extends CompiledFont {
0 commit comments