File tree 2 files changed +39
-3
lines changed
2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 16
16
/** @typedef {import("./display_utils").PageViewport } PageViewport */
17
17
/** @typedef {import("./api").TextContent } TextContent */
18
18
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" ;
20
26
import { setLayerDimensions } from "./display_utils.js" ;
21
27
22
28
/**
@@ -152,6 +158,24 @@ class TextLayer {
152
158
}
153
159
}
154
160
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
+
155
179
/**
156
180
* Render the textLayer.
157
181
* @returns {Promise }
@@ -300,9 +324,12 @@ class TextLayer {
300
324
angle += Math . PI / 2 ;
301
325
}
302
326
303
- const fontFamily =
327
+ let fontFamily =
304
328
( this . #fontInspectorEnabled && style . fontSubstitution ) ||
305
329
style . fontFamily ;
330
+
331
+ // Workaround for bug 1922063.
332
+ fontFamily = TextLayer . fontFamilyMap . get ( fontFamily ) || fontFamily ;
306
333
const fontHeight = Math . hypot ( tx [ 2 ] , tx [ 3 ] ) ;
307
334
const fontAscent =
308
335
fontHeight * TextLayer . #getAscent( fontFamily , this . #lang) ;
Original file line number Diff line number Diff line change @@ -636,9 +636,18 @@ class FeatureTest {
636
636
) {
637
637
return shadow ( this , "platform" , {
638
638
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" ) ) ,
639
644
} ) ;
640
645
}
641
- return shadow ( this , "platform" , { isMac : false } ) ;
646
+ return shadow ( this , "platform" , {
647
+ isMac : false ,
648
+ isWindows : false ,
649
+ isFirefox : false ,
650
+ } ) ;
642
651
}
643
652
644
653
static get isCSSRoundSupported ( ) {
You can’t perform that action at this time.
0 commit comments