Files
harfbuzz/src/hb-buffer-deserialize-json.hh
T
Behdad EsfahbodandClaude Sonnet 4.5 81ce4813c1 Lower CFF2 to CFF when subsetting to static instance (#5748)
* Add CFF2 to CFF1 converter for font instantiation

When instantiating a CFF2 variable font to a static instance, automatically
convert the output to CFF1 format instead of keeping it as CFF2. This is
appropriate since CFF2's variation features are no longer needed in static
fonts, and CFF1 is more widely supported.

The converter integrates with the CFF2 subsetter and triggers automatically
when pinned=true (i.e., when instantiating with normalized coordinates).

Converts table structure:
- CFF2 inline TopDict → CFF1 TopDict INDEX
- Adds Name INDEX and String INDEX
- Creates CID-keyed font with ROS operator (Adobe-Identity-0)
- Generates identity CID charset
- Removes variation operators (vstore, vsindex, blend)
- Reuses desubroutinized charstrings and subroutines

Focus is on structural conversion; charstring encoding details like
endchar/return operators and width encoding can be added incrementally.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Fix CFF2 to CFF1 converter table tag and serialization

Updates the CFF2 to CFF1 converter to properly output CFF format:
- Use plan->add_table() to output 'CFF ' tag instead of 'CFF2'
- Return false from subset() to signal CFF2 table not needed
- Use passed serializer instead of creating new one
- Change String INDEX to use push/copy/pop_pack pattern

Known issue: Output has 5 extra bytes before CFF header that need
investigation of serializer head/tail allocation patterns.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Fix CFF2 to CFF1 serialization order and header version

Fixes the INDEX serialization order and version field initialization:

- Reorder serialization to match CFF1 pattern: CFF header, then Name INDEX,
  then Top DICT INDEX. This eliminates extra bytes before the header.

- Fix version field by using cff->min_size instead of OT::cff1::min_size
  for nameIndex offset. This resolves the issue where major version was
  written as 0x00 instead of 0x01.

- Add String INDEX with "Adobe" and "Identity" strings (SIDs 391, 392)
  required by the ROS operator in CID-keyed fonts.

The CFF header now correctly starts at offset 0 with version 1.0.

Remaining issue: FDArray offset parsing error needs investigation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Improve FDArray serialization in CFF2 to CFF1 converter

Change FDArray serialization to use inferred template types and avoid
preprocessor issues with the likely() macro when using template syntax.

Progress:
- CFF header now at offset 0 with correct version 1.0 ✓
- String INDEX with ROS strings (Adobe, Identity) ✓
- ROS operator with correct SIDs ✓
- Serialization order matches CFF1 pattern ✓

Remaining issue:
- FDArray INDEX structure needs investigation - fontTools reports
  "unpack requires a buffer of 4 bytes" when reading FDArray offsets.
  May be related to INDEX offSize or data alignment.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* WIP: Add CFF2 to CFF1 converter for font instantiation

When a CFF2 variable font is fully instantiated (all axes pinned),
convert it to CFF1 format. This is work in progress.

Key changes:
- Add serialize_cff2_to_cff1() function to convert instantiated CFF2 to CFF1
- Use cff2_private_dict_op_serializer_t to instantiate Private DICT blends
- Add CFF1 table structures (Name INDEX, String INDEX for ROS, etc.)
- Create CID-keyed fonts with ROS operator (Adobe-Identity-0)
- Use subsetter's serializer with end_serialize() to resolve links

Current status:
- Private DICT instantiation works (blends evaluated correctly)
- CharStrings are properly flattened (verified: no blend operators remain)
- CFF1 table structure created but CharStrings INDEX validation fails in OTS
- Need to investigate CharStrings serialization format issue

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Add FDSelect and FDArray to Top DICT for CID-keyed fonts

CFF1 CID-keyed fonts require FDSelect and FDArray operators in the
Top DICT, even when there's only one Font DICT. CFF2 makes FDSelect
optional when there's a single FD, but CFF1 always requires it.

This commit:
- Always creates an FDSelect for CID-keyed CFF1 fonts (even with 1 FD)
- Explicitly serializes FDSelect and FDArray operators in Top DICT
- Avoids duplicating these operators when processing CFF2 Top DICT

Fixes font rendering - glyphs now have proper paths.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Use FDSelect3 (range-based) instead of FDSelect0

When creating a default FDSelect for single-FD CID fonts, use the
compact range-based FDSelect3 format instead of FDSelect0.

For a font with 254 glyphs mapping to FD 0:
- FDSelect0: 254 bytes (1 byte per glyph)
- FDSelect3: 8 bytes (format + nRanges + range + sentinel)

Saves 246 bytes (~1KB in this test font).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Update documentation with implementation status

Documents:
- What's implemented and working
- Known limitations (FontBBox, width, stack depth)
- Key conversion steps

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Copy FontBBox from head table

Instead of calculating from scratch, copy the font bounding box
directly from the head table (xMin, yMin, xMax, yMax).

Before: FontBBox value="0 0 0 0"
After:  FontBBox value="-175 -250 1178 899"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* [CFF2->CFF1] Add width optimization and encoding

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* [CFF2->CFF1] Port O(n) width optimization algorithm

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* [cff2-to-cff1] Add command capture infrastructure for specialization

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* [cff2-to-cff1] Implement CharString specialization with stack depth control

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* [cff2-to-cff1] Add generalization phase for stack safety

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* [cff2-to-cff1] Update documentation to reflect completed features

Removed outdated limitations that have been implemented:
✓ FontBBox (now copied from head table)
✓ Width handling (O(n) optimization + CharString encoding)
✓ Stack depth control (generalize→specialize with maxstack=48)

Added new features to implementation status:
- CharString specialization
- Width optimization and encoding
- Stack depth control

Remaining limitations are now accurate (only CID-keyed, no curve
specialization/peephole optimizations).

* [cff2-to-cff1] Remove CID-keyed 'limitation' from docs

CID-keyed output is by design, not a limitation:
- Variable fonts (CFF2) are instantiated to CID-keyed CFF1
- We explicitly add ROS operator to make output CID-keyed
- This is the correct behavior for instantiated fonts

Changed section from 'KNOWN LIMITATIONS' to 'FUTURE ENHANCEMENTS'
to better reflect that curve/peephole optimizations are optional
improvements, not missing functionality.

* [CFF2->CFF1] Add HB_SUBSET_FLAGS_DOWNGRADE_CFF2 flag

Make the CFF2→CFF1 converter opt-in via the HB_SUBSET_FLAGS_DOWNGRADE_CFF2
flag (disabled by default). This gives users control over whether variable
font instantiation produces CFF2 (default) or CFF1 (for compatibility).

Changes:
- Add HB_SUBSET_FLAGS_DOWNGRADE_CFF2 flag to hb-subset.h
- Gate CFF2→CFF1 conversion on flag check in hb-subset-cff2.cc
- Add --downgrade-cff2 command-line option to hb-subset tool

The flag enables converting instantiated variable fonts from CFF2 to CFF1,
providing compatibility with older renderers that don't support CFF2.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* [CFF2->CFF1] Deduplicate CFF1Font string constant

Define CFF1_DEFAULT_FONT_NAME constant once in hb-subset-cff2-to-cff1.hh
and use it in both the plan creation and serialization code.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* [CFF2->CFF1] Fix swapped horizontal/vertical logic in specializer

The specialization logic for rmoveto/rlineto to h/v variants was backwards:
- When dx=0 and dy!=0, movement is VERTICAL (vmoveto/vlineto), not horizontal
- When dy=0 and dx!=0, movement is HORIZONTAL (hmoveto/hlineto), not vertical

This was causing completely garbled outlines in converted fonts. The fix
corrects the operator selection to match the actual movement direction.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17 13:42:08 -07:00

736 lines
20 KiB
C++

#line 1 "hb-buffer-deserialize-json.rl"
/*
* Copyright © 2013 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Google Author(s): Behdad Esfahbod
*/
#ifndef HB_BUFFER_DESERIALIZE_JSON_HH
#define HB_BUFFER_DESERIALIZE_JSON_HH
#include "hb.hh"
#line 36 "hb-buffer-deserialize-json.hh"
static const unsigned char _deserialize_json_trans_keys[] = {
0u, 0u, 9u, 34u, 97u, 121u, 120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u,
9u, 125u, 9u, 125u, 9u, 93u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u,
9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 9u, 125u,
120u, 121u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 34u, 34u,
9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u, 9u, 125u, 108u, 108u, 34u, 34u, 9u, 58u,
9u, 57u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 34u, 92u, 9u, 125u,
34u, 92u, 9u, 125u, 9u, 125u, 34u, 34u, 9u, 58u, 9u, 57u, 48u, 57u, 9u, 125u,
34u, 34u, 9u, 58u, 9u, 57u, 9u, 125u, 98u, 98u, 9u, 123u, 9u, 123u, 9u, 123u,
0
};
static const char _deserialize_json_key_spans[] = {
0, 26, 25, 2, 1, 50, 49, 10,
117, 117, 85, 117, 1, 50, 49, 10,
117, 117, 1, 1, 50, 49, 117, 117,
2, 1, 50, 49, 10, 117, 117, 1,
50, 49, 10, 117, 117, 1, 1, 50,
49, 117, 117, 1, 50, 49, 59, 117,
59, 117, 117, 1, 50, 49, 10, 117,
1, 50, 49, 117, 1, 115, 115, 115
};
static const short _deserialize_json_index_offsets[] = {
0, 0, 27, 53, 56, 58, 109, 159,
170, 288, 406, 492, 610, 612, 663, 713,
724, 842, 960, 962, 964, 1015, 1065, 1183,
1301, 1304, 1306, 1357, 1407, 1418, 1536, 1654,
1656, 1707, 1757, 1768, 1886, 2004, 2006, 2008,
2059, 2109, 2227, 2345, 2347, 2398, 2448, 2508,
2626, 2686, 2804, 2922, 2924, 2975, 3025, 3036,
3154, 3156, 3207, 3257, 3375, 3377, 3493, 3609
};
static const char _deserialize_json_indicies[] = {
0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 2, 1, 3, 1, 4, 5,
1, 6, 7, 8, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
9, 1, 8, 10, 10, 1, 11, 12,
1, 13, 1, 13, 13, 13, 13, 13,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 13, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 14, 1, 14, 14,
14, 14, 14, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 14, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 15, 1, 1, 16, 17, 17,
17, 17, 17, 17, 17, 17, 17, 1,
18, 19, 19, 19, 19, 19, 19, 19,
19, 19, 1, 20, 20, 20, 20, 20,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 20, 1, 1, 1, 1, 1,
1, 1, 1, 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72, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 73,
1, 1, 1, 75, 75, 75, 75, 75,
75, 75, 75, 75, 75, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
74, 1, 76, 1, 76, 76, 76, 76,
76, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 76, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 77, 1, 77,
77, 77, 77, 77, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 77, 1,
78, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 79, 80,
80, 80, 80, 80, 80, 80, 80, 80,
1, 82, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 81, 81, 81, 81, 81,
81, 81, 81, 83, 81, 84, 84, 84,
84, 84, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 84, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
85, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1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, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 25, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 104, 1, 0
};
static const char _deserialize_json_trans_targs[] = {
1, 0, 2, 3, 18, 24, 37, 43,
51, 56, 60, 4, 12, 5, 6, 7,
8, 11, 8, 11, 9, 1, 10, 9,
10, 63, 13, 14, 15, 16, 17, 16,
17, 9, 1, 10, 19, 20, 21, 22,
23, 9, 1, 10, 23, 25, 31, 26,
27, 28, 29, 30, 29, 30, 9, 1,
10, 32, 33, 34, 35, 36, 35, 36,
9, 1, 10, 38, 39, 40, 41, 42,
9, 1, 10, 42, 44, 45, 46, 49,
50, 46, 47, 48, 9, 1, 10, 9,
1, 10, 50, 52, 53, 54, 9, 55,
55, 57, 58, 49, 59, 59, 61, 62,
1
};
static const char _deserialize_json_trans_actions[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 0, 0, 2, 2, 2, 0,
0, 3, 0, 0, 1, 1, 1, 0,
0, 4, 4, 4, 0, 0, 0, 1,
1, 5, 5, 5, 0, 0, 0, 0,
0, 1, 1, 1, 0, 0, 6, 6,
6, 0, 0, 1, 1, 1, 0, 0,
7, 7, 7, 0, 0, 0, 1, 1,
8, 8, 8, 0, 0, 0, 1, 9,
9, 0, 10, 0, 11, 11, 11, 12,
12, 12, 10, 0, 0, 1, 1, 1,
0, 0, 0, 13, 13, 14, 0, 0,
15
};
static const int deserialize_json_start = 61;
static const int deserialize_json_first_final = 61;
static const int deserialize_json_error = 0;
static const int deserialize_json_en_main = 61;
#line 115 "hb-buffer-deserialize-json.rl"
static hb_bool_t
_hb_buffer_deserialize_json (hb_buffer_t *buffer,
const char *buf,
unsigned int buf_len,
const char **end_ptr,
hb_font_t *font)
{
const char *p = buf, *pe = buf + buf_len;
/* Ensure we have positions. */
(void) hb_buffer_get_glyph_positions (buffer, nullptr);
const char *tok = nullptr;
int cs;
hb_glyph_info_t info = {0};
hb_glyph_position_t pos = {0};
#line 601 "hb-buffer-deserialize-json.hh"
{
cs = deserialize_json_start;
}
#line 606 "hb-buffer-deserialize-json.hh"
{
int _slen;
int _trans;
const unsigned char *_keys;
const char *_inds;
if ( p == pe )
goto _test_eof;
if ( cs == 0 )
goto _out;
_resume:
_keys = _deserialize_json_trans_keys + (cs<<1);
_inds = _deserialize_json_indicies + _deserialize_json_index_offsets[cs];
_slen = _deserialize_json_key_spans[cs];
_trans = _inds[ _slen > 0 && _keys[0] <=(*p) &&
(*p) <= _keys[1] ?
(*p) - _keys[0] : _slen ];
cs = _deserialize_json_trans_targs[_trans];
if ( _deserialize_json_trans_actions[_trans] == 0 )
goto _again;
switch ( _deserialize_json_trans_actions[_trans] ) {
case 15:
#line 38 "hb-buffer-deserialize-json.rl"
{
hb_memset (&info, 0, sizeof (info));
hb_memset (&pos , 0, sizeof (pos ));
}
break;
case 3:
#line 43 "hb-buffer-deserialize-json.rl"
{
buffer->add_info (info);
if (unlikely (!buffer->successful))
return false;
buffer->pos[buffer->len - 1] = pos;
*end_ptr = p;
}
break;
case 1:
#line 51 "hb-buffer-deserialize-json.rl"
{
tok = p;
}
break;
case 10:
#line 55 "hb-buffer-deserialize-json.rl"
{ if (unlikely (!buffer->ensure_glyphs ())) return false; }
break;
case 14:
#line 56 "hb-buffer-deserialize-json.rl"
{ if (unlikely (!buffer->ensure_unicode ())) return false; }
break;
case 11:
#line 58 "hb-buffer-deserialize-json.rl"
{
/* TODO Unescape \" and \\ if found. */
if (!hb_font_glyph_from_string (font,
tok+1, p - tok - 2, /* Skip "" */
&info.codepoint))
return false;
}
break;
case 12:
#line 66 "hb-buffer-deserialize-json.rl"
{ if (!parse_uint (tok, p, &info.codepoint)) return false; }
break;
case 5:
#line 67 "hb-buffer-deserialize-json.rl"
{ if (!parse_uint (tok, p, &info.cluster )) return false; }
break;
case 6:
#line 68 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.x_offset )) return false; }
break;
case 7:
#line 69 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.y_offset )) return false; }
break;
case 2:
#line 70 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.x_advance)) return false; }
break;
case 4:
#line 71 "hb-buffer-deserialize-json.rl"
{ if (!parse_int (tok, p, &pos.y_advance)) return false; }
break;
case 8:
#line 72 "hb-buffer-deserialize-json.rl"
{ if (!parse_uint (tok, p, &info.mask )) return false; }
break;
case 9:
#line 51 "hb-buffer-deserialize-json.rl"
{
tok = p;
}
#line 55 "hb-buffer-deserialize-json.rl"
{ if (unlikely (!buffer->ensure_glyphs ())) return false; }
break;
case 13:
#line 51 "hb-buffer-deserialize-json.rl"
{
tok = p;
}
#line 56 "hb-buffer-deserialize-json.rl"
{ if (unlikely (!buffer->ensure_unicode ())) return false; }
break;
#line 716 "hb-buffer-deserialize-json.hh"
}
_again:
if ( cs == 0 )
goto _out;
if ( ++p != pe )
goto _resume;
_test_eof: {}
_out: {}
}
#line 136 "hb-buffer-deserialize-json.rl"
*end_ptr = p;
return p == pe;
}
#endif /* HB_BUFFER_DESERIALIZE_JSON_HH */