Use widths defined by font for standard fonts.
There doesn't seem to be anything definitive about this in the spec, but from experimenting, it seems acrobat lets PDFs override the widths of the standard fonts.
This commit is contained in:
parent
00b4f86db3
commit
45d9ab6e45
@ -1319,11 +1319,12 @@ var Font = (function FontClosure() {
|
|||||||
let fontName = name.replace(/[,_]/g, "-").replace(/\s/g, "");
|
let fontName = name.replace(/[,_]/g, "-").replace(/\s/g, "");
|
||||||
var stdFontMap = getStdFontMap(),
|
var stdFontMap = getStdFontMap(),
|
||||||
nonStdFontMap = getNonStdFontMap();
|
nonStdFontMap = getNonStdFontMap();
|
||||||
var isStandardFont =
|
const isStandardFont = !!stdFontMap[fontName];
|
||||||
!!stdFontMap[fontName] ||
|
const isMappedToStandardFont = !!(
|
||||||
!!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
|
nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]
|
||||||
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
|
);
|
||||||
|
|
||||||
|
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
|
||||||
this.bold = fontName.search(/bold/gi) !== -1;
|
this.bold = fontName.search(/bold/gi) !== -1;
|
||||||
this.italic =
|
this.italic =
|
||||||
fontName.search(/oblique/gi) !== -1 ||
|
fontName.search(/oblique/gi) !== -1 ||
|
||||||
@ -1334,9 +1335,9 @@ var Font = (function FontClosure() {
|
|||||||
this.black = name.search(/Black/g) !== -1;
|
this.black = name.search(/Black/g) !== -1;
|
||||||
|
|
||||||
// if at least one width is present, remeasure all chars when exists
|
// 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 (
|
if (
|
||||||
isStandardFont &&
|
(isStandardFont || isMappedToStandardFont) &&
|
||||||
type === "CIDFontType2" &&
|
type === "CIDFontType2" &&
|
||||||
this.cidEncoding.startsWith("Identity-")
|
this.cidEncoding.startsWith("Identity-")
|
||||||
) {
|
) {
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -357,6 +357,7 @@
|
|||||||
!issue6298.pdf
|
!issue6298.pdf
|
||||||
!issue6889.pdf
|
!issue6889.pdf
|
||||||
!bug1001080.pdf
|
!bug1001080.pdf
|
||||||
|
!bug1671312_reduced.pdf
|
||||||
!issue6108.pdf
|
!issue6108.pdf
|
||||||
!issue6113.pdf
|
!issue6113.pdf
|
||||||
!openoffice.pdf
|
!openoffice.pdf
|
||||||
|
BIN
test/pdfs/bug1671312_reduced.pdf
Normal file
BIN
test/pdfs/bug1671312_reduced.pdf
Normal file
Binary file not shown.
@ -2259,6 +2259,12 @@
|
|||||||
"link": false,
|
"link": false,
|
||||||
"type": "text"
|
"type": "text"
|
||||||
},
|
},
|
||||||
|
{ "id": "bug1671312_reduced",
|
||||||
|
"file": "pdfs/bug1671312_reduced.pdf",
|
||||||
|
"md5": "db13fe3f03a7d0bd0e248f5c2bcb2a5d",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue7020",
|
{ "id": "issue7020",
|
||||||
"file": "pdfs/issue7020.pdf",
|
"file": "pdfs/issue7020.pdf",
|
||||||
"md5": "93b464e21c649e64ae92eeafe99fc31b",
|
"md5": "93b464e21c649e64ae92eeafe99fc31b",
|
||||||
|
Loading…
Reference in New Issue
Block a user