@@ -31,7 +31,11 @@ import {
3131} from "../shared/util.js" ;
3232import { CMapFactory , IdentityCMap } from "./cmap.js" ;
3333import { Cmd , Dict , EOF , isName , Name , Ref , RefSet } from "./primitives.js" ;
34- import { compileType3Glyph , FontFlags } from "./fonts_utils.js" ;
34+ import {
35+ compileType3Glyph ,
36+ FontFlags ,
37+ normalizeFontName ,
38+ } from "./fonts_utils.js" ;
3539import { ErrorFont , Font } from "./fonts.js" ;
3640import {
3741 fetchBinaryData ,
@@ -4238,16 +4242,17 @@ class PartialEvaluator {
42384242 let defaultWidth = 0 ;
42394243 let widths = Object . create ( null ) ;
42404244 let monospace = false ;
4245+
4246+ let fontName = normalizeFontName ( name ) ;
42414247 const stdFontMap = getStdFontMap ( ) ;
4242- let lookupName = stdFontMap [ name ] || name ;
4248+ fontName = stdFontMap [ fontName ] || fontName ;
42434249 const Metrics = getMetrics ( ) ;
42444250
4245- if ( ! ( lookupName in Metrics ) ) {
4251+ const glyphWidths =
4252+ Metrics [ fontName ] ??
42464253 // Use default fonts for looking up font metrics if the passed
42474254 // font is not a base font
4248- lookupName = this . isSerifFont ( name ) ? "Times-Roman" : "Helvetica" ;
4249- }
4250- const glyphWidths = Metrics [ lookupName ] ;
4255+ Metrics [ this . isSerifFont ( name ) ? "Times-Roman" : "Helvetica" ] ;
42514256
42524257 if ( typeof glyphWidths === "number" ) {
42534258 defaultWidth = glyphWidths ;
@@ -4458,7 +4463,7 @@ class PartialEvaluator {
44584463 }
44594464
44604465 // Using base font name as a font name.
4461- baseFontName = baseFontName . name . replaceAll ( / [ , _ ] / g , "-" ) ;
4466+ baseFontName = normalizeFontName ( baseFontName . name ) ;
44624467 const metrics = this . getBaseFontMetrics ( baseFontName ) ;
44634468
44644469 // Simulating descriptor flags attribute
0 commit comments