File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 1616/** @typedef {import("./display_utils").PageViewport } PageViewport */
1717/** @typedef {import("./api").TextContent } TextContent */
1818
19- import { AbortException , Util , warn } from "../shared/util.js" ;
19+ import {
20+ AbortException ,
21+ FeatureTest ,
22+ shadow ,
23+ Util ,
24+ warn ,
25+ } from "../shared/util.js" ;
2026import { setLayerDimensions } from "./display_utils.js" ;
2127
2228/**
@@ -152,6 +158,24 @@ class TextLayer {
152158 }
153159 }
154160
161+ static get fontFamilyMap ( ) {
162+ const { isWindows, isFirefox } = FeatureTest . platform ;
163+ return shadow (
164+ this ,
165+ "fontFamilyMap" ,
166+ new Map ( [
167+ [
168+ "sans-serif" ,
169+ `${ isWindows && isFirefox ? "Calibri, " : "" } sans-serif` ,
170+ ] ,
171+ [
172+ "monospace" ,
173+ `${ isWindows && isFirefox ? "Lucida Console, " : "" } monospace` ,
174+ ] ,
175+ ] )
176+ ) ;
177+ }
178+
155179 /**
156180 * Render the textLayer.
157181 * @returns {Promise }
@@ -300,9 +324,12 @@ class TextLayer {
300324 angle += Math . PI / 2 ;
301325 }
302326
303- const fontFamily =
327+ let fontFamily =
304328 ( this . #fontInspectorEnabled && style . fontSubstitution ) ||
305329 style . fontFamily ;
330+
331+ // Workaround for bug 1922063.
332+ fontFamily = TextLayer . fontFamilyMap . get ( fontFamily ) || fontFamily ;
306333 const fontHeight = Math . hypot ( tx [ 2 ] , tx [ 3 ] ) ;
307334 const fontAscent =
308335 fontHeight * TextLayer . #getAscent( fontFamily , this . #lang) ;
Original file line number Diff line number Diff line change @@ -636,9 +636,18 @@ class FeatureTest {
636636 ) {
637637 return shadow ( this , "platform" , {
638638 isMac : navigator . platform . includes ( "Mac" ) ,
639+ isWindows : navigator . platform . includes ( "Win" ) ,
640+ isFirefox :
641+ ( typeof PDFJSDev !== "undefined" && PDFJSDev . test ( "MOZCENTRAL" ) ) ||
642+ ( typeof navigator ?. userAgent === "string" &&
643+ navigator . userAgent . includes ( "Firefox" ) ) ,
639644 } ) ;
640645 }
641- return shadow ( this , "platform" , { isMac : false } ) ;
646+ return shadow ( this , "platform" , {
647+ isMac : false ,
648+ isWindows : false ,
649+ isFirefox : false ,
650+ } ) ;
642651 }
643652
644653 static get isCSSRoundSupported ( ) {
You can’t perform that action at this time.
0 commit comments