mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08: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:
parent
8f6965b197
commit
ae842e1c3a
8 changed files with 214 additions and 40 deletions
|
@ -59,6 +59,7 @@ import {
|
|||
import { IdentityToUnicodeMap, ToUnicodeMap } from "./to_unicode_map.js";
|
||||
import { CFFFont } from "./cff_font.js";
|
||||
import { FontRendererFactory } from "./font_renderer.js";
|
||||
import { getFontBasicMetrics } from "./metrics.js";
|
||||
import { GlyfTable } from "./glyf.js";
|
||||
import { IdentityCMap } from "./cmap.js";
|
||||
import { OpenTypeFileBuilder } from "./opentype_file_builder.js";
|
||||
|
@ -1074,6 +1075,21 @@ class Font {
|
|||
);
|
||||
|
||||
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
|
||||
|
||||
const fontBasicMetricsMap = getFontBasicMetrics();
|
||||
const metrics = fontBasicMetricsMap[fontName];
|
||||
if (metrics) {
|
||||
if (isNaN(this.ascent)) {
|
||||
this.ascent = metrics.ascent / PDF_GLYPH_SPACE_UNITS;
|
||||
}
|
||||
if (isNaN(this.descent)) {
|
||||
this.descent = metrics.descent / PDF_GLYPH_SPACE_UNITS;
|
||||
}
|
||||
if (isNaN(this.capHeight)) {
|
||||
this.capHeight = metrics.capHeight / PDF_GLYPH_SPACE_UNITS;
|
||||
}
|
||||
}
|
||||
|
||||
this.bold = fontName.search(/bold/gi) !== -1;
|
||||
this.italic =
|
||||
fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue