mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 17:01:17 +01:00
[subset] Handle seac operands returned by a subroutine (#6463)
A subroutine can push all four seac operands, return, and leave the glyph's own endchar to consume them. Treat callsubr and callgsubr immediately before endchar as possible seac suffixes even when no subroutine contains endchar. Add a synthetic CFF1 regression font for the operand-only subroutine case. Assisted-by: OpenAI Codex
This commit is contained in:
1 parent
2c0df50ce1
commit
c305720f01
4 files changed
+14
No files matched your search
@@ -654,6 +654,10 @@ _cff1_charstring_may_end_in_seac (const hb_ubytes_t &str,
|
||||
if (end >= 5 && str[end - 5] == OpCode_fixedcs)
|
||||
return true;
|
||||
|
||||
/* A subroutine can leave the seac operands on the shared stack. */
|
||||
if (last == OpCode_callsubr || last == OpCode_callgsubr)
|
||||
return true;
|
||||
|
||||
/* Escaped operators include stack-preserving dotsection. */
|
||||
return end >= 2 && str[end - 2] == OpCode_escape;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -4,6 +4,7 @@ from pathlib import Path
|
||||
from fontTools.fontBuilder import FontBuilder
|
||||
from fontTools.misc.psCharStrings import T2CharString
|
||||
from fontTools.cffLib import SubrsIndex, FDSelect
|
||||
from fontTools.ttLib import TTFont
|
||||
|
||||
OUT = Path(__file__).parent / "fonts"
|
||||
|
||||
@@ -90,3 +91,11 @@ f.setupCFF2(
|
||||
private = f.font["CFF2"].cff.topDictIndex[0].FDArray[0].Private
|
||||
private.BlueValues = [[i] + [0] * 40 for i in range(14)]
|
||||
f.save(OUT / "cff2_long_private_blends.otf")
|
||||
|
||||
# A local subroutine can leave seac operands on the shared stack before the
|
||||
# glyph's own endchar.
|
||||
f = TTFont(OUT / "cff1_seac_subr_endchar.otf")
|
||||
top = f["CFF "].cff.topDictIndex[0]
|
||||
top.Private.Subrs[0].setProgram([0, 0, 65, 194, "return"])
|
||||
top.CharStrings["Aacute"].setProgram([-107, "callsubr", "endchar"])
|
||||
f.save(OUT / "cff1_seac_subr_operands.otf")
|
||||
@@ -274,6 +274,7 @@ test_subset_cff1_seac_precheck (void)
|
||||
const char *fonts[] = {
|
||||
"fonts/cff1_seac_dotsection.otf",
|
||||
"fonts/cff1_seac_subr_endchar.otf",
|
||||
"fonts/cff1_seac_subr_operands.otf",
|
||||
};
|
||||
|
||||
for (unsigned int i = 0; i < G_N_ELEMENTS (fonts); i++)
|
||||
|
||||
Reference in new issue
Block a user