1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

[api-minor] Annotations - Adjust the font size in text field in considering the total width (bug 1721335)

- it aims to fix #14502 and bug 1721335;
 - Acrobat and Pdfium do the same;
 - it'll avoid to have truncated data when printed;
 - change the factor to compute font size in using field height: lineHeight = 1.35*fontSize
  - this is the value used by Acrobat.
 - in order to not have truncated strings on the bottom, add few basic metrics for standard fonts.
This commit is contained in:
Calixte Denizet 2022-01-27 22:51:30 +01:00
parent 8f6965b197
commit ae842e1c3a
8 changed files with 214 additions and 40 deletions

View file

@ -2967,4 +2967,91 @@ const getMetrics = getLookupTableFactory(function (t) {
});
});
export { getMetrics };
const getFontBasicMetrics = getLookupTableFactory(function (t) {
t.Courier = {
ascent: 629,
descent: -157,
capHeight: 562,
xHeight: -426,
};
t["Courier-Bold"] = {
ascent: 629,
descent: -157,
capHeight: 562,
xHeight: 439,
};
t["Courier-Oblique"] = {
ascent: 629,
descent: -157,
capHeight: 562,
xHeight: 426,
};
t["Courier-BoldOblique"] = {
ascent: 629,
descent: -157,
capHeight: 562,
xHeight: 426,
};
t.Helvetica = {
ascent: 718,
descent: -207,
capHeight: 718,
xHeight: 523,
};
t["Helvetica-Bold"] = {
ascent: 718,
descent: -207,
capHeight: 718,
xHeight: 532,
};
t["Helvetica-Oblique"] = {
ascent: 718,
descent: -207,
capHeight: 718,
xHeight: 523,
};
t["Helvetica-BoldOblique"] = {
ascent: 718,
descent: -207,
capHeight: 718,
xHeight: 532,
};
t["Times-Roman"] = {
ascent: 683,
descent: -217,
capHeight: 662,
xHeight: 450,
};
t["Times-Bold"] = {
ascent: 683,
descent: -217,
capHeight: 676,
xHeight: 461,
};
t["Times-Italic"] = {
ascent: 683,
descent: -217,
capHeight: 653,
xHeight: 441,
};
t["Times-BoldItalic"] = {
ascent: 683,
descent: -217,
capHeight: 669,
xHeight: 462,
};
t.Symbol = {
ascent: Math.NaN,
descent: Math.NaN,
capHeight: Math.NaN,
xHeight: Math.NaN,
};
t.ZapfDingbats = {
ascent: Math.NaN,
descent: Math.NaN,
capHeight: Math.NaN,
xHeight: Math.NaN,
};
});
export { getFontBasicMetrics, getMetrics };