/
githubmirror
/
pdf.js
Обзор
Документация
Войти
/
githubmirror
/
pdf.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/font/font_post_spec.js
93 строки
75 KB
Jonas Jenwald
Use the `toBeTrue()` matcher consistently in the unit/font/integration tests
26 июл 2026, 00:52
26 июл 2026, 00:52
62d211e
Код
Авторство
О чём код?
import { ttx, verifyTtxOutput } from "./fontutils.js"; import { CMapFactory } from "../../src/core/cmap.js"; import { Font } from "../../src/core/fonts.js"; import { Name } from "../../src/core/primitives.js"; import { Stream } from "../../src/core/stream.js"; import { ToUnicodeMap } from "../../src/core/to_unicode_map.js"; describe("font_post", function () { const font2109 = Uint8Array.fromBase64( // eslint-disable-next-line max-len "AAEAAAAMAIAAAwBAT1MvMgVKk3wAAADMAAAATmN2dCBsduxjAAABGgAAADpmcGdtT8I0ggAAAVQAAAAUZ2x5ZgUI920AAAFoAAA6smhlYWS059ujAAA8GgAAADZoaGVhvAJFCwAAPFAAAAAkaG10eDPBQ7AAADx0AAADtGxvY2EJxgAAAABAKAAAA7htYXhwGgK … [Строка слишком длинная. Вы можете скачать файл] ); const font2189 = Uint8Array.fromBase64( // eslint-disable-next-line max-len "AAEAAAANAIAAAwBQT1MvMh4+B14AAADcAAAATmNtYXDgP1MtAAABKgAABDpjdnQgLo0mKQAABWQAAAB8ZnBnbc8o3EMAAAXgAAADMGdseWahy/nuAAAJEAAAEjRoZWFkm0JpbAAAG0QAAAA2aGhlYQy+mqoAABt6AAAAJGhtdHjH3jT1AAAbngAAA5Rsb2NhOW8 … [Строка слишком длинная. Вы можете скачать файл] ); const font2374 = Uint8Array.fromBase64( // eslint-disable-next-line max-len "AAEAAAANAIAAAwBQT1MvMhBzLe8AAADcAAAAVmNtYXDxf/RCAAABNAAAAexjdnQg8yzagQAAAyAAAAfGZnBnbcOmHQEAAAroAAAGMWdseWaod7EbAAARHAAAAHZoZWFkz3sdgwAAEZQAAAA2aGhlYRLvEvYAABHMAAAAJGhtdHixQhbKAAAR8AAAGihsb2NhAAM … [Строка слишком длинная. Вы можете скачать файл] ); describe("post table removal on bad post table values", function () { it("has invalid version number", async function () { const cMap = await CMapFactory.create({ encoding: Name.get("Identity-H"), }); const font = new Font( "font", new Stream(font2109), { loadedName: "font", type: "CIDFontType2", differences: [], defaultEncoding: [], cMap, toUnicode: new ToUnicodeMap([]), xHeight: 0, capHeight: 0, italicAngle: 0, }, {} ); const output = await ttx(font.data); verifyTtxOutput(output); expect(/<post>\s*<formatType value="3\.0"\/>/.test(output)).toBeTrue(); }); it("has invalid glyph name indexes", async function () { const font = new Font( "font", new Stream(font2189), { loadedName: "font", type: "TrueType", differences: [], defaultEncoding: [], toUnicode: new ToUnicodeMap([]), xHeight: 0, capHeight: 0, italicAngle: 0, }, {} ); const output = await ttx(font.data); verifyTtxOutput(output); expect(/<post>\s*<formatType value="3\.0"\/>/.test(output)).toBeTrue(); }); it("has right amount of glyphs specified", async function () { const font = new Font( "font", new Stream(font2374), { loadedName: "font", type: "TrueType", differences: [], defaultEncoding: [], toUnicode: new ToUnicodeMap([]), xHeight: 0, capHeight: 0, italicAngle: 0, }, {} ); const output = await ttx(font.data); verifyTtxOutput(output); expect(/<post>\s*<formatType value="3\.0"\/>/.test(output)).toBeTrue(); }); }); });