Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use widths defined by font for standard fonts. #12725

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1319,11 +1319,12 @@ var Font = (function FontClosure() {
let fontName = name.replace(/[,_]/g, "-").replace(/\s/g, "");
var stdFontMap = getStdFontMap(),
nonStdFontMap = getNonStdFontMap();
var isStandardFont =
!!stdFontMap[fontName] ||
!!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
const isStandardFont = !!stdFontMap[fontName];
const isMappedToStandardFont = !!(
nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]
);

fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
this.bold = fontName.search(/bold/gi) !== -1;
this.italic =
fontName.search(/oblique/gi) !== -1 ||
Expand All @@ -1334,9 +1335,9 @@ var Font = (function FontClosure() {
this.black = name.search(/Black/g) !== -1;

// if at least one width is present, remeasure all chars when exists
this.remeasure = Object.keys(this.widths).length > 0;
this.remeasure = !isStandardFont && Object.keys(this.widths).length > 0;
if (
isStandardFont &&
(isStandardFont || isMappedToStandardFont) &&
type === "CIDFontType2" &&
this.cidEncoding.startsWith("Identity-")
) {
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@
!issue6298.pdf
!issue6889.pdf
!bug1001080.pdf
!bug1671312_reduced.pdf
!issue6108.pdf
!issue6113.pdf
!openoffice.pdf
Expand Down
Binary file added test/pdfs/bug1671312_reduced.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,12 @@
"link": false,
"type": "text"
},
{ "id": "bug1671312_reduced",
"file": "pdfs/bug1671312_reduced.pdf",
"md5": "db13fe3f03a7d0bd0e248f5c2bcb2a5d",
"rounds": 1,
"type": "eq"
},
{ "id": "issue7020",
"file": "pdfs/issue7020.pdf",
"md5": "93b464e21c649e64ae92eeafe99fc31b",
Expand Down