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

@ -77,6 +77,7 @@ const MyriadProBoldFactors = [
0.97579, 0.97579, 0.97579, 0.9332, 1.05993, 0.94039, 0.94039, 0.94039,
0.94039, 0.99793, 0.94039, 0.938, 0.938, 0.938, 0.938, 0.99793, 0.95776,
];
const MyriadProBoldLineHeight = 1.2;
// Factors to rescale LiberationSans-BoldItalic.ttf to have the same
// metrics as MyriadPro-BoldIt.otf.
@ -143,6 +144,7 @@ const MyriadProBoldItalicFactors = [
0.89544, 1.0051, 0.89364, 0.89364, 0.89364, 0.89364, 0.97276, 0.89364, 0.9,
0.9, 0.9, 0.9, 0.97276, 0.86842,
];
const MyriadProBoldItalicLineHeight = 1.2;
// Factors to rescale LiberationSans-Italic.ttf to have the same
// metrics as MyriadPro-It.otf.
@ -208,6 +210,7 @@ const MyriadProItalicFactors = [
0.979, 0.979, 0.979, 0.979, 0.882, 0.93559, 0.882, 0.882, 0.882, 0.882,
0.88465, 0.882, 0.83, 0.83, 0.83, 0.83, 0.88465, 0.84596,
];
const MyriadProItalicLineHeight = 1.2;
// Factors to rescale LiberationSans-Regular.ttf to have the same
// metrics as MyriadPro-Regular.otf.
@ -273,10 +276,15 @@ const MyriadProRegularFactors = [
1.01915, 0.926, 0.96705, 0.942, 0.942, 0.942, 0.942, 0.92241, 0.942, 0.856,
0.856, 0.856, 0.856, 0.92241, 0.92761,
];
const MyriadProRegularLineHeight = 1.2;
export {
MyriadProBoldFactors,
MyriadProBoldItalicFactors,
MyriadProBoldItalicLineHeight,
MyriadProBoldLineHeight,
MyriadProItalicFactors,
MyriadProItalicLineHeight,
MyriadProRegularFactors,
MyriadProRegularLineHeight,
};