@@ -57,6 +57,7 @@ import {
5757} from "./standard_fonts.js" ;
5858import { IdentityToUnicodeMap , ToUnicodeMap } from "./to_unicode_map.js" ;
5959import { CFFFont } from "./cff_font.js" ;
60+ import { compileFontInfo } from "./obj_bin_transform_core.js" ;
6061import { FontRendererFactory } from "./font_renderer.js" ;
6162import { getFontBasicMetrics } from "./metrics.js" ;
6263import { GlyfTable } from "./glyf.js" ;
@@ -80,7 +81,7 @@ const EXPORT_DATA_PROPERTIES = [
8081 "bbox" ,
8182 "black" ,
8283 "bold" ,
83- "charProcOperatorList" ,
84+ // "charProcOperatorList" is handled separately, since it's not compiled.
8485 "cssFontInfo" ,
8586 "data" ,
8687 "defaultVMetrics" ,
@@ -973,6 +974,8 @@ class Font {
973974
974975 #glyphCache = new Map ( ) ;
975976
977+ charProcOperatorList ;
978+
976979 constructor ( name , file , properties , evaluatorOptions ) {
977980 this . name = name ;
978981 this . psName = null ;
@@ -1147,28 +1150,26 @@ class Font {
11471150 return shadow ( this , "renderer" , renderer ) ;
11481151 }
11491152
1150- exportData ( ) {
1153+ #getExportData ( props ) {
11511154 const data = Object . create ( null ) ;
1152- for ( const prop of EXPORT_DATA_PROPERTIES ) {
1155+ for ( const prop of props ) {
11531156 const value = this [ prop ] ;
11541157 // Ignore properties that haven't been explicitly set.
11551158 if ( value !== undefined ) {
11561159 data [ prop ] = value ;
11571160 }
11581161 }
1162+ return data ;
1163+ }
11591164
1160- if ( ! this . fontExtraProperties ) {
1161- return { data } ;
1162- }
1163-
1164- const extra = Object . create ( null ) ;
1165- for ( const prop of EXPORT_DATA_EXTRA_PROPERTIES ) {
1166- const value = this [ prop ] ;
1167- if ( value !== undefined ) {
1168- extra [ prop ] = value ;
1169- }
1170- }
1171- return { data, extra } ;
1165+ exportData ( ) {
1166+ return {
1167+ buffer : compileFontInfo ( this . #getExportData( EXPORT_DATA_PROPERTIES ) ) ,
1168+ charProcOperatorList : this . charProcOperatorList ,
1169+ extra : this . fontExtraProperties
1170+ ? this . #getExportData( EXPORT_DATA_EXTRA_PROPERTIES )
1171+ : undefined ,
1172+ } ;
11721173 }
11731174
11741175 fallbackToSystemFont ( properties ) {
0 commit comments