1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Use vertical variant of a char when it's in a missing vertical font (bug 1905623)

This commit is contained in:
Calixte Denizet 2024-07-02 22:38:10 +02:00
parent ccad2f889a
commit 832fc93aa4
4 changed files with 59 additions and 0 deletions

View file

@ -26,6 +26,7 @@ import {
import { CFFCompiler, CFFParser } from "./cff_parser.js";
import {
FontFlags,
getVerticalPresentationForm,
MacStandardGlyphOrdering,
normalizeFontName,
recoverGlyphName,
@ -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,

View file

@ -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";
@ -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,