mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-28 23:28:16 +02:00
XFA - Get line height from the font
- when the CSS line-height property is set to 'normal' then the value depends of the user agent. So use a line height based on the font itself and if for any reasons this value is not available use 1.2 as default. - it's a partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1717681.
This commit is contained in:
parent
9441245320
commit
e82446fa5a
9 changed files with 70 additions and 34 deletions
|
@ -28,7 +28,7 @@ import {
|
|||
XmlObject,
|
||||
} from "./xfa_object.js";
|
||||
import { $buildXFAObject, NamespaceIds } from "./namespaces.js";
|
||||
import { fixTextIndent, getFonts, measureToString } from "./html_utils.js";
|
||||
import { fixTextIndent, measureToString, setFontFamily } from "./html_utils.js";
|
||||
import { getMeasurement, HTMLResult } from "./utils.js";
|
||||
|
||||
const XHTML_NS_ID = NamespaceIds.xhtml.id;
|
||||
|
@ -92,7 +92,7 @@ const StyleMapping = new Map([
|
|||
["margin-right", value => measureToString(getMeasurement(value))],
|
||||
["margin-top", value => measureToString(getMeasurement(value))],
|
||||
["text-indent", value => measureToString(getMeasurement(value))],
|
||||
["font-family", (value, fontFinder) => getFonts(value, fontFinder)],
|
||||
["font-family", value => value],
|
||||
]);
|
||||
|
||||
const spacesRegExp = /\s+/g;
|
||||
|
@ -128,6 +128,18 @@ function mapStyle(styleStr, fontFinder) {
|
|||
}
|
||||
}
|
||||
|
||||
if (style.fontFamily) {
|
||||
setFontFamily(
|
||||
{
|
||||
typeface: style.fontFamily,
|
||||
weight: style.fontWeight || "normal",
|
||||
posture: style.fontStyle || "normal",
|
||||
},
|
||||
fontFinder,
|
||||
style
|
||||
);
|
||||
}
|
||||
|
||||
fixTextIndent(style);
|
||||
return style;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue