2020-10-26 20:12:40 +09:00
|
|
|
import { decodeFontData, ttx, verifyTtxOutput } from "./fontutils.js";
|
|
|
|
import { CMapFactory } from "../../src/core/cmap.js";
|
2021-05-02 19:04:34 +09:00
|
|
|
import { Font } from "../../src/core/fonts.js";
|
2020-10-26 20:12:40 +09:00
|
|
|
import { Name } from "../../src/core/primitives.js";
|
|
|
|
import { Stream } from "../../src/core/stream.js";
|
2021-05-02 19:04:34 +09:00
|
|
|
import { ToUnicodeMap } from "../../src/core/to_unicode_map.js";
|
2012-11-08 02:11:36 +09:00
|
|
|
|
2020-10-26 20:12:40 +09:00
|
|
|
describe("font_post", function () {
|
2020-10-26 20:20:03 +09:00
|
|
|
const font2154 = decodeFontData(
|
2020-10-26 20:12:40 +09:00
|
|
|
// eslint-disable-next-line max-len
|
|
|
|
"AAEAAAANAIAAAwBQT1MvMpxkBm8AAADcAAAAVmNtYXDwD/A1AAABNAAAAC5jdnQgJsYFBAAAAWQAAADuZnBnbTQnXAoAAAJUAAACh2dseWbDL/rtAAAE3AAAAGBoZWFkxW7T6QAABTwAAAA2aGhlYQ37B2cAAAV0AAAAJGhtdHhvP0naAAAFmAAAA8hsb2NhFrAWsAAACWAAAAHmbWF4cAJLAyUAAAtIAAAAIG5hbWUnzzMmAAALaAAAA3pwb3N0AAMAAAAADuQAAAAgcHJlcFbFIB8AAA8EAAABhwABAxMBkAAFAAYFmgUzAAABJQWaBTMAAAOgAGYCEgAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAABHbHlmsUAAIPtPBeH94QAABeECBgAAACAAAAAAAAAAAAABAAMAAQAAAAwABAAiAAAABAAEAAEAAPAA//8AAPAA//8AAAABAAQAAAAAAAAFeQAIBYAAFQSP/9sD1AAVAAD/6wAA/+v/4f/3/s//9wTyAJP/K//nA/gAKAQ5ABEEVgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AC0D/AA1BDUAUgOLABIFFwAZBKgAOQRaADcEWgBQBAcAUAGNAAwCqgBzAz8AcQM/AD8EiABOCAAA6AJEAEgCRABhAkQAGwPeAEYD3gBfA94AEQSIAJ0EiACeBTMAzggAAM4JEQAyAd4AMQHeACgF0wBmBGcAZwMZACMDGQAjA4v/RAOL/0QD/AAfBG8AUARvAFAEbwBQA4sAGwJxADcDxQBIA4sAMwPFAFgEb//LBRcAGQUXABkFFwAZBRcAGQPFAEgCqgA1A4sABAQ1AF4CcQA3AqoAFARvABkCNwAzAxkAIwOLADMDiwAzBG8AXgKqAD8EbwAUA8UAWAP8ADUENQBSA4sAEgUXABkEqAA5AAAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAAAAAQAAAPIAWwAHAAAAAAACABAAQACWAAAApQKHAAYAAQAAAAoAfgABAAAAAAAAAMMAAAABAAAAAAADAA8AwwABAAAAAAAEAA8A0gABAAAAAAAGAA8A4QADAAEECQAAAYYA8AADAAEECQABAB4CdgADAAEECQACAA4ClAADAAEECQADAB4CogADAAEECQAEAB4CwAADAAEECQAGAB4C3lR5cGVmYWNlIFBvcnRpb25zIKkgVG
|
|
|
|
);
|
2020-10-26 20:20:03 +09:00
|
|
|
const font1282 = decodeFontData(
|
2020-10-26 20:12:40 +09:00
|
|
|
// eslint-disable-next-line max-len
|
|
|
|
"AAEAAAANAIAAAwBQT1MvMlJpU/gAAADcAAAATmNtYXCFppKjAAABLAAACnpjdnQglnDSdgAAC6gAAAYwZnBnbcx5WZoAABHYAAAGbmdseWYHpqdrAAAYSAAAEkZoZWFkzS3ungAAKpAAAAA2aGhlYRJtEaoAACrIAAAAJGhtdHjKonNAAAAq7AAAFKBsb2NhAFYgrgAAP4wAABSkbWF4cAnkAZUAAFQwAAAAIG5hbWWb1QwoAABUUAAAAPhwb3N0AAMAAAAAVUgAAAAgcHJlcFL+xOkAAFVoAAAK/wAABAABkAAFAAAEAAQAAAAEAAQABAAAAAQAAGYCEgwAAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAA/Pz8/AEDwIPAACAACAADMCAwDmAAAAAAAAQADAAEAAAAMAAQKbgAAAAQABAABAADlJv//AADgAP//AAAAAQAEAAAAAQACAAMABAAFAAYABwAIAAkACgALAAwADQAOAA8AEAARABIAEwAUABUAFgAXABgAGQAaABsAHAAdAB4AHwAgACEAIgAjACQAJQAmACcAKAApACoAKwAsAC0ALgAvADAAMQAyADMANAA1ADYANwA4ADkAOgA7ADwAPQA+AD8AQABBAEIAQwBEAEUARgBHAEgASQBKAEsATABNAE4ATwBQAFEAUgBTAFQAVQBWAFcAWABZAFoAWwBcAF0AXgBfAGAAYQBiAGMAZABlAGYAZwBoAGkAagBrAGwAbQBuAG8AcABxAHIAcwB0AHUAdgB3AHgAeQB6AHsAfAB9AH4AfwCAAIEAggCDAIQAhQCGAIcAiACJAIoAiwCMAI0AjgCPAJAAkQCSAJMAlACVAJYAlwCYAJkAmgCbAJwAnQ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8AuQC0AMgAFwBEAJ
|
|
|
|
);
|
|
|
|
|
|
|
|
describe("OS/2 table removal on bad post table values", function () {
|
2021-04-19 20:26:39 +09:00
|
|
|
it("has invalid version number", async function () {
|
2020-10-26 20:20:03 +09:00
|
|
|
const font = new Font("font", new Stream(font2154), {
|
2020-10-26 20:12:40 +09:00
|
|
|
loadedName: "font",
|
|
|
|
type: "TrueType",
|
2013-01-31 03:01:32 +09:00
|
|
|
differences: [],
|
2016-02-29 01:20:29 +09:00
|
|
|
defaultEncoding: [],
|
2020-10-26 20:12:40 +09:00
|
|
|
toUnicode: new ToUnicodeMap([]),
|
2021-06-27 22:19:02 +09:00
|
|
|
xHeight: 0,
|
|
|
|
capHeight: 0,
|
|
|
|
italicAngle: 0,
|
2012-11-08 02:11:36 +09:00
|
|
|
});
|
2021-04-19 20:26:39 +09:00
|
|
|
const output = await ttx(font.data);
|
|
|
|
|
|
|
|
verifyTtxOutput(output);
|
2022-07-11 02:16:21 +09:00
|
|
|
expect(
|
|
|
|
/<OS_2>\s*<!--.*\r?\n.*-->\s*<version value="3"\/>/.test(output)
|
|
|
|
).toEqual(true);
|
2012-11-08 02:11:36 +09:00
|
|
|
});
|
|
|
|
|
2021-04-19 20:26:39 +09:00
|
|
|
it("has invalid selection attributes presence", async function () {
|
|
|
|
const cMap = await CMapFactory.create({
|
2020-10-26 20:12:40 +09:00
|
|
|
encoding: Name.get("Identity-H"),
|
2012-11-08 02:11:36 +09:00
|
|
|
});
|
2021-04-19 20:26:39 +09:00
|
|
|
const font = new Font("font", new Stream(font1282), {
|
|
|
|
loadedName: "font",
|
|
|
|
type: "CIDFontType2",
|
|
|
|
differences: [],
|
|
|
|
defaultEncoding: [],
|
|
|
|
cMap,
|
|
|
|
toUnicode: new ToUnicodeMap([]),
|
2021-06-27 22:19:02 +09:00
|
|
|
xHeight: 0,
|
|
|
|
capHeight: 0,
|
|
|
|
italicAngle: 0,
|
2021-04-19 20:26:39 +09:00
|
|
|
});
|
|
|
|
const output = await ttx(font.data);
|
|
|
|
|
|
|
|
verifyTtxOutput(output);
|
2022-07-11 02:16:21 +09:00
|
|
|
expect(
|
|
|
|
/<OS_2>\s*<!--.*\r?\n.*-->\s*<version value="3"\/>/.test(output)
|
|
|
|
).toEqual(true);
|
2012-11-08 02:11:36 +09:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|