1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

XFA - Fix text positions (bug 1718741)

- font line height is taken into account by acrobat when it isn't with masterpdfeditor: I extracted a font from a pdf, modified some ascent/descent properties thanks to ttx and the reinjected the font in the pdf: only Acrobat is taken it into account. So in this patch, line heights for some substituted fonts are added.
  - it seems that Acrobat is using a line height of 1.2 when the line height in the font is not enough (it's the only way I found to fix correctly bug 1718741).
   - don't use flex in wrapper container (which was causing an horizontal overflow in the above bug).
   - consequently, the above fixes introduced a lot of small regressions, so in order to see real improvements on reftests, I fixed the regressions in this patch:
     - replace margin by padding in some case where padding is a part of a container dimensions;
     - remove some flex display: some containers are wrongly sized when rendered;
     - set letter-spacing to 0.01px: it helps to be sure that text is not broken because of not enough width in Firefox.
This commit is contained in:
Calixte Denizet 2021-07-09 17:29:21 +02:00
parent 0afc785c7d
commit 58e1f51688
15 changed files with 220 additions and 103 deletions

View file

@ -16,14 +16,22 @@
import {
CalibriBoldFactors,
CalibriBoldItalicFactors,
CalibriBoldItalicLineHeight,
CalibriBoldLineHeight,
CalibriItalicFactors,
CalibriItalicLineHeight,
CalibriRegularFactors,
CalibriRegularLineHeight,
} from "./calibri_factors.js";
import {
HelveticaBoldFactors,
HelveticaBoldItalicFactors,
HelveticaBoldItalicLineHeight,
HelveticaBoldLineHeight,
HelveticaItalicFactors,
HelveticaItalicLineHeight,
HelveticaRegularFactors,
HelveticaRegularLineHeight,
} from "./helvetica_factors.js";
import {
LiberationSansBoldItalicWidths,
@ -34,14 +42,22 @@ import {
import {
MyriadProBoldFactors,
MyriadProBoldItalicFactors,
MyriadProBoldItalicLineHeight,
MyriadProBoldLineHeight,
MyriadProItalicFactors,
MyriadProItalicLineHeight,
MyriadProRegularFactors,
MyriadProRegularLineHeight,
} from "./myriadpro_factors.js";
import {
SegoeuiBoldFactors,
SegoeuiBoldItalicFactors,
SegoeuiBoldItalicLineHeight,
SegoeuiBoldLineHeight,
SegoeuiItalicFactors,
SegoeuiItalicLineHeight,
SegoeuiRegularFactors,
SegoeuiRegularLineHeight,
} from "./segoeui_factors.js";
import { getLookupTableFactory } from "./core_utils.js";
import { normalizeFontName } from "./fonts_utils.js";
@ -51,21 +67,25 @@ const getXFAFontMap = getLookupTableFactory(function (t) {
name: "LiberationSans-Regular",
factors: MyriadProRegularFactors,
baseWidths: LiberationSansRegularWidths,
lineHeight: MyriadProRegularLineHeight,
};
t["MyriadPro-Bold"] = {
name: "LiberationSans-Bold",
factors: MyriadProBoldFactors,
baseWidths: LiberationSansBoldWidths,
lineHeight: MyriadProBoldLineHeight,
};
t["MyriadPro-It"] = {
name: "LiberationSans-Italic",
factors: MyriadProItalicFactors,
baseWidths: LiberationSansItalicWidths,
lineHeight: MyriadProItalicLineHeight,
};
t["MyriadPro-BoldIt"] = {
name: "LiberationSans-BoldItalic",
factors: MyriadProBoldItalicFactors,
baseWidths: LiberationSansBoldItalicWidths,
lineHeight: MyriadProBoldItalicLineHeight,
};
t.ArialMT =
t.Arial =
@ -90,61 +110,73 @@ const getXFAFontMap = getLookupTableFactory(function (t) {
name: "LiberationSans-Regular",
factors: CalibriRegularFactors,
baseWidths: LiberationSansRegularWidths,
lineHeight: CalibriRegularLineHeight,
};
t["Calibri-Bold"] = {
name: "LiberationSans-Bold",
factors: CalibriBoldFactors,
baseWidths: LiberationSansBoldWidths,
lineHeight: CalibriBoldLineHeight,
};
t["Calibri-Italic"] = {
name: "LiberationSans-Italic",
factors: CalibriItalicFactors,
baseWidths: LiberationSansItalicWidths,
lineHeight: CalibriItalicLineHeight,
};
t["Calibri-BoldItalic"] = {
name: "LiberationSans-BoldItalic",
factors: CalibriBoldItalicFactors,
baseWidths: LiberationSansBoldItalicWidths,
lineHeight: CalibriBoldItalicLineHeight,
};
t["Segoeui-Regular"] = {
name: "LiberationSans-Regular",
factors: SegoeuiRegularFactors,
baseWidths: LiberationSansRegularWidths,
lineHeight: SegoeuiRegularLineHeight,
};
t["Segoeui-Bold"] = {
name: "LiberationSans-Bold",
factors: SegoeuiBoldFactors,
baseWidths: LiberationSansBoldWidths,
lineHeight: SegoeuiBoldLineHeight,
};
t["Segoeui-Italic"] = {
name: "LiberationSans-Italic",
factors: SegoeuiItalicFactors,
baseWidths: LiberationSansItalicWidths,
lineHeight: SegoeuiItalicLineHeight,
};
t["Segoeui-BoldItalic"] = {
name: "LiberationSans-BoldItalic",
factors: SegoeuiBoldItalicFactors,
baseWidths: LiberationSansBoldItalicWidths,
lineHeight: SegoeuiBoldItalicLineHeight,
};
t["Helvetica-Regular"] = {
name: "LiberationSans-Regular",
factors: HelveticaRegularFactors,
baseWidths: LiberationSansRegularWidths,
lineHeight: HelveticaRegularLineHeight,
};
t["Helvetica-Bold"] = {
name: "LiberationSans-Bold",
factors: HelveticaBoldFactors,
baseWidths: LiberationSansBoldWidths,
lineHeight: HelveticaBoldLineHeight,
};
t["Helvetica-Italic"] = {
name: "LiberationSans-Italic",
factors: HelveticaItalicFactors,
baseWidths: LiberationSansItalicWidths,
lineHeight: HelveticaItalicLineHeight,
};
t["Helvetica-BoldItalic"] = {
name: "LiberationSans-BoldItalic",
factors: HelveticaBoldItalicFactors,
baseWidths: LiberationSansBoldItalicWidths,
lineHeight: HelveticaBoldItalicLineHeight,
};
});