mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-28 23:28:16 +02:00
XFA - Match font family correctly
- partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1716980; - some pdf can contain an invalid font family (e.g. 'Windings 3') so in this case remove the space; - the font family in typeface attribute doesn't always match the one defined in the FontDescriptor dictionary.
This commit is contained in:
parent
248efb16a7
commit
7cdbc98716
13 changed files with 221 additions and 57 deletions
|
@ -23,7 +23,6 @@ import {
|
|||
$extra,
|
||||
$finalize,
|
||||
$flushHTML,
|
||||
$fonts,
|
||||
$getAvailableSpace,
|
||||
$getChildren,
|
||||
$getContainedChildren,
|
||||
|
@ -31,6 +30,7 @@ import {
|
|||
$getParent,
|
||||
$getSubformParent,
|
||||
$getTemplateRoot,
|
||||
$globalData,
|
||||
$hasItem,
|
||||
$hasSettableValue,
|
||||
$ids,
|
||||
|
@ -1441,7 +1441,7 @@ class Draw extends XFAObject {
|
|||
|
||||
if ((this.w === "" || this.h === "") && this.value) {
|
||||
const maxWidth = this.w === "" ? availableSpace.width : this.w;
|
||||
const fonts = this[$getTemplateRoot]()[$fonts];
|
||||
const fontFinder = this[$globalData].fontFinder;
|
||||
let font = this.font;
|
||||
if (!font) {
|
||||
let parent = this[$getParent]();
|
||||
|
@ -1464,7 +1464,7 @@ class Draw extends XFAObject {
|
|||
const res = layoutText(
|
||||
this.value.exData[$content],
|
||||
font,
|
||||
fonts,
|
||||
fontFinder,
|
||||
maxWidth
|
||||
);
|
||||
width = res.width;
|
||||
|
@ -1472,7 +1472,7 @@ class Draw extends XFAObject {
|
|||
} else {
|
||||
const text = this.value[$text]();
|
||||
if (text) {
|
||||
const res = layoutText(text, font, fonts, maxWidth);
|
||||
const res = layoutText(text, font, fontFinder, maxWidth);
|
||||
width = res.width;
|
||||
height = res.height;
|
||||
}
|
||||
|
@ -2660,7 +2660,7 @@ class Font extends XFAObject {
|
|||
style.fontSize = fontSize;
|
||||
}
|
||||
|
||||
style.fontFamily = getFonts(this.typeface);
|
||||
style.fontFamily = getFonts(this.typeface, this[$globalData].fontFinder);
|
||||
|
||||
if (this.underline !== 0) {
|
||||
style.textDecoration = "underline";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue