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

XFA - Don't move glyphes in private area with non-truetype fonts #13390

Merged
merged 1 commit into from
May 17, 2021
Merged
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
32 changes: 17 additions & 15 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2667,12 +2667,20 @@ class Font {
glyphZeroId = font.numGlyphs - 1;
}
const mapping = font.getGlyphMapping(properties);
const newMapping = adjustMapping(
mapping,
font.hasGlyphId.bind(font),
glyphZeroId
);
this.toFontChar = newMapping.toFontChar;
let newMapping = null;
let newCharCodeToGlyphId = mapping;

// When `cssFontInfo` is set, the font is used to render text in the HTML
// view (e.g. with Xfa) so nothing must be moved in the private use area.
if (!properties.cssFontInfo) {
newMapping = adjustMapping(
mapping,
font.hasGlyphId.bind(font),
glyphZeroId
);
this.toFontChar = newMapping.toFontChar;
newCharCodeToGlyphId = newMapping.charCodeToGlyphId;
}
const numGlyphs = font.numGlyphs;

function getCharCodes(charCodeToGlyphId, glyphId) {
Expand Down Expand Up @@ -2700,7 +2708,7 @@ class Font {
}

const seacs = font.seacs;
if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
if (newMapping && SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
const matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
const charset = font.getCharset();
const seacMap = Object.create(null);
Expand Down Expand Up @@ -2754,15 +2762,9 @@ class Font {
// PostScript Font Program
builder.addTable("CFF ", font.data);
// OS/2 and Windows Specific metrics
builder.addTable(
"OS/2",
createOS2Table(properties, newMapping.charCodeToGlyphId)
);
builder.addTable("OS/2", createOS2Table(properties, newCharCodeToGlyphId));
// Character to glyphs mapping
builder.addTable(
"cmap",
createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
);
builder.addTable("cmap", createCmapTable(newCharCodeToGlyphId, numGlyphs));
// Font header
builder.addTable(
"head",
Expand Down