pdf.js.mirror/test/font/font_fpgm_spec.js
Tim van der Meij 3d4476ac53
Update ttx from version 2.5 to version 3.19.0
The current version 2.5 is from September 2014, which is almost 8 years
old now. The new version 3.19.0 is from November 2017, which is still
almost 5 years old, but is a step forward towards eventually using the
most recent version. Note that we currently can't update any further;
see #11802 for the details.

Fortunately using this newer version only required a few changes:

- The `ttx` output regexes needed updating to ignore comments that `ttx`
  now puts after some XML nodes (`<!-- ... -->` and `/* ... */`).
- The `ttx` invocation now explicitly uses `python2` (except on Windows
  where this alias doesn't exist) since otherwise the font tests can't
  be run on modern systems anymore given that `python` is nowadays an
  alias for `python3`, and it now points at the new location of the
  `ttx.py` file since the `Tools` folder got removed.
- The note about needing a 32-bit Python 2.6 version is dropped since
  it's obsolete: this version (and also the existing one already) work
  just fine on a 64-bit Python 2.7 as well.
2022-07-10 21:18:36 +02:00

41 lines
92 KiB
JavaScript

import { decodeFontData, 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_fpgm", function () {
const font2324 = decodeFontData(
// eslint-disable-next-line max-len
"AAEAAAANAIAAAwBQT1MvMlNlbJwAAADcAAAAYGNtYXDrAFO9AAABPAAALKxjdnQgAzYCuwAALegAAAAMZnBnbQgKVdkAAC30AAACaGdseWa+m03rAAAwXAAAOERoZWFk9BT7TwAAaKAAAAA4aGhlYQWlFpUAAGjYAAAAJGhtdHgPKyHAAABo/AAAUqRsb2NhBA9dxAAAu6AAAFKobWF4cBY1AjUAAQ5IAAAAIG5hbWXZdYwDAAEOaAAAAhBwb3N0AAMAAAABEHgAAAAgcHJlcFyRbmMAARCYAAAAVAADAiQB9AAFAAACigK7AAAAjAKKArsAAAHfADEBAgAAAAAGAAAAAAAAAOAAEAFQAP3/AAAAIAAAAAQqMjEqAAAAIP//A+j+1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table was truncated in the middle of functions", async function () {
const cMap = await CMapFactory.create({
encoding: Name.get("Identity-H"),
});
const font = new Font("font", new Stream(font2324), {
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(
/(ENDF\[ \]|SVTCA\[0\])\s*\/\*.*\*\/\s*<\/assembly>\s*<\/fpgm>/.test(
output
)
).toEqual(true);
});
});
});