@@ -34,11 +34,19 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
34
34
35
35
// Limit canvas size to 5 mega-pixels on mobile.
36
36
// Support: Android, iOS
37
- ( function checkCanvasSizeLimitation ( ) {
37
+ ( function ( ) {
38
38
if ( isIOS || isAndroid ) {
39
39
compatibilityParams . maxCanvasPixels = 5242880 ;
40
40
}
41
41
} ) ( ) ;
42
+
43
+ // Don't use system fonts on Android (issue 18210).
44
+ // Support: Android
45
+ ( function ( ) {
46
+ if ( isAndroid ) {
47
+ compatibilityParams . useSystemFonts = false ;
48
+ }
49
+ } ) ( ) ;
42
50
}
43
51
44
52
const OptionKind = {
@@ -47,6 +55,7 @@ const OptionKind = {
47
55
API : 0x04 ,
48
56
WORKER : 0x08 ,
49
57
EVENT_DISPATCH : 0x10 ,
58
+ UNDEF_ALLOWED : 0x20 ,
50
59
PREFERENCE : 0x80 ,
51
60
} ;
52
61
@@ -377,6 +386,19 @@ const defaultOptions = {
377
386
: "../web/standard_fonts/" ,
378
387
kind : OptionKind . API ,
379
388
} ,
389
+ useSystemFonts : {
390
+ // On Android, there is almost no chance to have the font we want so we
391
+ // don't use the system fonts in this case (bug 1882613).
392
+ /** @type {boolean|undefined } */
393
+ value : (
394
+ typeof PDFJSDev === "undefined"
395
+ ? window . isGECKOVIEW
396
+ : PDFJSDev . test ( "GECKOVIEW" )
397
+ )
398
+ ? false
399
+ : undefined ,
400
+ kind : OptionKind . API + OptionKind . UNDEF_ALLOWED ,
401
+ } ,
380
402
verbosity : {
381
403
/** @type {number } */
382
404
value : 1 ,
@@ -464,6 +486,11 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING || LIB")) {
464
486
if ( kind & OptionKind . BROWSER ) {
465
487
throw new Error ( `Cannot mix "PREFERENCE" and "BROWSER" kind: ${ name } ` ) ;
466
488
}
489
+ if ( kind & OptionKind . UNDEF_ALLOWED ) {
490
+ throw new Error (
491
+ `Cannot have \`undefined\` value for "PREFERENCE" kind: ${ name } `
492
+ ) ;
493
+ }
467
494
if (
468
495
typeof compatibilityParams === "object" &&
469
496
compatibilityParams [ name ] !== undefined
@@ -480,6 +507,12 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING || LIB")) {
480
507
) {
481
508
throw new Error ( `Invalid value for "PREFERENCE" kind: ${ name } ` ) ;
482
509
}
510
+ } else if ( kind & OptionKind . BROWSER ) {
511
+ if ( kind & OptionKind . UNDEF_ALLOWED ) {
512
+ throw new Error (
513
+ `Cannot have \`undefined\` value for "BROWSER" kind: ${ name } `
514
+ ) ;
515
+ }
483
516
}
484
517
}
485
518
}
@@ -513,7 +546,13 @@ class AppOptions {
513
546
static set ( name , value ) {
514
547
const defaultOption = defaultOptions [ name ] ;
515
548
516
- if ( ! defaultOption || typeof value !== typeof defaultOption . value ) {
549
+ if (
550
+ ! defaultOption ||
551
+ ! (
552
+ typeof value === typeof defaultOption . value ||
553
+ defaultOption . kind & OptionKind . UNDEF_ALLOWED
554
+ )
555
+ ) {
517
556
return ;
518
557
}
519
558
userOptions [ name ] = value ;
@@ -526,7 +565,13 @@ class AppOptions {
526
565
const defaultOption = defaultOptions [ name ] ,
527
566
userOption = options [ name ] ;
528
567
529
- if ( ! defaultOption || typeof userOption !== typeof defaultOption . value ) {
568
+ if (
569
+ ! defaultOption ||
570
+ ! (
571
+ typeof userOption === typeof defaultOption . value ||
572
+ defaultOption . kind & OptionKind . UNDEF_ALLOWED
573
+ )
574
+ ) {
530
575
continue ;
531
576
}
532
577
if ( prefs ) {
@@ -554,9 +599,8 @@ class AppOptions {
554
599
555
600
if ( typeof PDFJSDev === "undefined" || PDFJSDev . test ( "GENERIC" ) ) {
556
601
// Re-apply a compatibility-value, if it exists, to the user-options.
557
- const val = compatibilityParams [ name ] ;
558
- if ( val !== undefined ) {
559
- userOptions [ name ] = val ;
602
+ if ( name in compatibilityParams ) {
603
+ userOptions [ name ] = compatibilityParams [ name ] ;
560
604
}
561
605
}
562
606
}
0 commit comments