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 vertical variant of a char when it's in a missing vertical font (bug 1905623) #18369

Merged
merged 1 commit into from
Jul 4, 2024
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
8 changes: 8 additions & 0 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import { CFFCompiler, CFFParser } from "./cff_parser.js";
import {
FontFlags,
getVerticalPresentationForm,
MacStandardGlyphOrdering,
normalizeFontName,
recoverGlyphName,
Expand Down Expand Up @@ -3366,6 +3367,13 @@ class Font {
}
}

if (this.missingFile && this.vertical && fontChar.length === 1) {
const vertical = getVerticalPresentationForm()[fontChar.charCodeAt(0)];
if (vertical) {
fontChar = unicode = String.fromCharCode(vertical);
}
}

glyph = new Glyph(
charcode,
fontChar,
Expand Down
40 changes: 40 additions & 0 deletions src/core/fonts_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import { getEncoding, StandardEncoding } from "./encodings.js";
import { getGlyphsUnicode } from "./glyphlist.js";
import { getLookupTableFactory } from "./core_utils.js";
import { getUnicodeForGlyph } from "./unicode.js";
import { info } from "../shared/util.js";

Expand Down Expand Up @@ -168,8 +169,47 @@ function normalizeFontName(name) {
return name.replaceAll(/[,_]/g, "-").replaceAll(/\s/g, "");
}

const getVerticalPresentationForm = getLookupTableFactory(t => {
// This table has been found at
// https://searchfox.org/mozilla-central/rev/cbdfa503a87597b20719aae5f6a1efccd6cb3b7b/gfx/thebes/gfxHarfBuzzShaper.cpp#251-294
t[0x2013] = 0xfe32; // EN DASH
t[0x2014] = 0xfe31; // EM DASH
t[0x2025] = 0xfe30; // TWO DOT LEADER
t[0x2026] = 0xfe19; // HORIZONTAL ELLIPSIS
t[0x3001] = 0xfe11; // IDEOGRAPHIC COMMA
t[0x3002] = 0xfe12; // IDEOGRAPHIC FULL STOP
t[0x3008] = 0xfe3f; // LEFT ANGLE BRACKET
t[0x3009] = 0xfe40; // RIGHT ANGLE BRACKET
t[0x300a] = 0xfe3d; // LEFT DOUBLE ANGLE BRACKET
t[0x300b] = 0xfe3e; // RIGHT DOUBLE ANGLE BRACKET
t[0x300c] = 0xfe41; // LEFT CORNER BRACKET
t[0x300d] = 0xfe42; // RIGHT CORNER BRACKET
t[0x300e] = 0xfe43; // LEFT WHITE CORNER BRACKET
t[0x300f] = 0xfe44; // RIGHT WHITE CORNER BRACKET
t[0x3010] = 0xfe3b; // LEFT BLACK LENTICULAR BRACKET
t[0x3011] = 0xfe3c; // RIGHT BLACK LENTICULAR BRACKET
t[0x3014] = 0xfe39; // LEFT TORTOISE SHELL BRACKET
t[0x3015] = 0xfe3a; // RIGHT TORTOISE SHELL BRACKET
t[0x3016] = 0xfe17; // LEFT WHITE LENTICULAR BRACKET
t[0x3017] = 0xfe18; // RIGHT WHITE LENTICULAR BRACKET
t[0xfe4f] = 0xfe34; // WAVY LOW LINE
t[0xff01] = 0xfe15; // FULLWIDTH EXCLAMATION MARK
t[0xff08] = 0xfe35; // FULLWIDTH LEFT PARENTHESIS
t[0xff09] = 0xfe36; // FULLWIDTH RIGHT PARENTHESIS
t[0xff0c] = 0xfe10; // FULLWIDTH COMMA
t[0xff1a] = 0xfe13; // FULLWIDTH COLON
t[0xff1b] = 0xfe14; // FULLWIDTH SEMICOLON
t[0xff1f] = 0xfe16; // FULLWIDTH QUESTION MARK
t[0xff3b] = 0xfe47; // FULLWIDTH LEFT SQUARE BRACKET
t[0xff3d] = 0xfe48; // FULLWIDTH RIGHT SQUARE BRACKET
t[0xff3f] = 0xfe33; // FULLWIDTH LOW LINE
t[0xff5b] = 0xfe37; // FULLWIDTH LEFT CURLY BRACKET
t[0xff5d] = 0xfe38; // FULLWIDTH RIGHT CURLY BRACKET
});

export {
FontFlags,
getVerticalPresentationForm,
MacStandardGlyphOrdering,
normalizeFontName,
recoverGlyphName,
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/bug1905623.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://bugzilla.mozilla.org/attachment.cgi?id=9410429
10 changes: 10 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10113,5 +10113,15 @@
"rounds": 1,
"link": true,
"type": "eq"
},
{
"id": "bug1905623",
"file": "pdfs/bug1905623.pdf",
"md5": "6c180a4353bda6b3cb0c693c5e5b32c4",
"rounds": 1,
"link": true,
"firstPage": 2,
"lastPage": 2,
"type": "eq"
}
]