mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-30 18:13:53 +01:00
[layout] Use 32-bit lookup offsets in LookupList2
Make the GSUB/GPOS v1.2 LookupList2 path use LookupList<MediumTypes>, so the lookup count remains 16-bit while per-lookup offsets are widened to 32 bits. Runtime lookup access now branches between the lower and upper lookup-list layouts. As of June 2026, the proposed GSUB/GPOS v1.2 spec points LookupList2 at LookupList, which would leave per-lookup offsets at 16 bits. Note that HarfBuzz intentionally widens those offsets because the proposed shape is not suitable for beyond-64k fonts. Keep the graph repacker on lower GSUB/GPOS tables for now, since it walks the raw lookup-list object layout. Testing: meson compile -C build util/hb-subset test-repacker Testing: meson test -C build --suite shape --suite subset Testing: build/util/hb-shape /tmp/fonttools-noto-sans-lookuplist2/NotoSans-merged.ttf 'test' Testing: build/util/hb-shape /tmp/fonttools-noto-sans-lookuplist2/NotoSans-merged.ttf 'කොහොමද' Testing: build/util/hb-shape /tmp/fonttools-noto-sans-lookuplist2/NotoSans-merged.ttf 'क्षि' Assisted-by: OpenAI Codex
This commit is contained in:
1 parent
b1c5f20ef8
commit
882ce8e6f3
3 files changed
+38
-19
No files matched your search
@@ -433,6 +433,9 @@ struct GSTAR : public OT::GSUBGPOS
|
||||
|
||||
unsigned get_lookup_list_index (graph_t& graph)
|
||||
{
|
||||
if (version.to_int () >= 0x00010002u)
|
||||
return (unsigned) -1;
|
||||
|
||||
return graph.index_for_offset (graph.root_idx (),
|
||||
get_lookup_list_field_offset());
|
||||
}
|
||||
@@ -441,6 +444,9 @@ struct GSTAR : public OT::GSUBGPOS
|
||||
void find_lookups (graph_t& graph,
|
||||
hb_hashmap_t<unsigned, Lookup*>& lookups /* OUT */)
|
||||
{
|
||||
if (version.to_int () >= 0x00010002u)
|
||||
return;
|
||||
|
||||
unsigned lookup_list_idx = get_lookup_list_index (graph);
|
||||
const LookupList<Types>* lookupList =
|
||||
(const LookupList<Types>*) graph.object (lookup_list_idx).head;
|
||||
|
||||
@@ -1432,7 +1432,7 @@ struct Lookup
|
||||
};
|
||||
|
||||
template <typename Types>
|
||||
using LookupList = List16OfOffsetTo<Lookup, typename Types::HBUINT>;
|
||||
using LookupList = List16OfOffsetTo<Lookup, typename Types::HBLUINT>;
|
||||
|
||||
template <typename TLookup, typename OffsetType>
|
||||
struct LookupOffsetList : List16OfOffsetTo<TLookup, OffsetType>
|
||||
|
||||
@@ -4644,10 +4644,15 @@ struct hb_ot_layout_lookup_accelerator_t
|
||||
struct GSUBGPOS
|
||||
{
|
||||
using LookupListT = LookupList<SmallTypes>;
|
||||
using LookupList2T = LookupList<MediumTypes>;
|
||||
template <typename TLookup>
|
||||
using TLookupList = List16OfOffset16To<TLookup>;
|
||||
using TLookupList = List16OfOffsetTo<TLookup, typename SmallTypes::HBLUINT>;
|
||||
template <typename TLookup>
|
||||
using TLookupOffsetList = LookupOffsetList<TLookup, HBUINT16>;
|
||||
using TLookupList2 = List16OfOffsetTo<TLookup, typename MediumTypes::HBLUINT>;
|
||||
template <typename TLookup>
|
||||
using TLookupOffsetList = LookupOffsetList<TLookup, typename SmallTypes::HBLUINT>;
|
||||
template <typename TLookup>
|
||||
using TLookupOffsetList2 = LookupOffsetList<TLookup, typename MediumTypes::HBLUINT>;
|
||||
|
||||
size_t get_size () const
|
||||
{
|
||||
@@ -4677,14 +4682,6 @@ struct GSUBGPOS
|
||||
#endif
|
||||
return this + featureList;
|
||||
}
|
||||
const LookupListT &get_lookup_list () const
|
||||
{
|
||||
#ifndef HB_NO_BEYOND_64K
|
||||
if (version.to_int () >= 0x00010002u && lookupList2) return this + lookupList2;
|
||||
#endif
|
||||
return this + lookupList;
|
||||
}
|
||||
|
||||
template <typename TLookup>
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
@@ -4812,9 +4809,21 @@ struct GSUBGPOS
|
||||
}
|
||||
|
||||
unsigned int get_lookup_count () const
|
||||
{ return get_lookup_list ().len; }
|
||||
{
|
||||
#ifndef HB_NO_BEYOND_64K
|
||||
if (version.to_int () >= 0x00010002u && lookupList2)
|
||||
return (this + lookupList2).len;
|
||||
#endif
|
||||
return (this + lookupList).len;
|
||||
}
|
||||
const Lookup& get_lookup (unsigned int i) const
|
||||
{ return get_lookup_list ()[i]; }
|
||||
{
|
||||
#ifndef HB_NO_BEYOND_64K
|
||||
if (version.to_int () >= 0x00010002u && lookupList2)
|
||||
return (this + lookupList2)[i];
|
||||
#endif
|
||||
return (this + lookupList)[i];
|
||||
}
|
||||
const FeatureVariations &get_feature_variations () const
|
||||
{
|
||||
return (version.to_int () >= 0x00010001u && hb_barrier ()) ? this+featureVars : Null (FeatureVariations);
|
||||
@@ -5055,8 +5064,8 @@ struct GSUBGPOS
|
||||
|
||||
#ifndef HB_NO_BEYOND_64K
|
||||
template <typename TLookup>
|
||||
const Offset32To<TLookupList<TLookup>>& typed_lookup_list2_offset () const
|
||||
{ return reinterpret_cast<const Offset32To<TLookupList<TLookup>>&> (lookupList2); }
|
||||
const Offset32To<TLookupList2<TLookup>>& typed_lookup_list2_offset () const
|
||||
{ return reinterpret_cast<const Offset32To<TLookupList2<TLookup>>&> (lookupList2); }
|
||||
#endif
|
||||
|
||||
template <typename TLookup>
|
||||
@@ -5068,8 +5077,8 @@ struct GSUBGPOS
|
||||
|
||||
#ifndef HB_NO_BEYOND_64K
|
||||
template <typename TLookup>
|
||||
const Offset32To<TLookupOffsetList<TLookup>>& subset_lookup_list2_offset () const
|
||||
{ return reinterpret_cast<const Offset32To<TLookupOffsetList<TLookup>>&> (lookupList2); }
|
||||
const Offset32To<TLookupOffsetList2<TLookup>>& subset_lookup_list2_offset () const
|
||||
{ return reinterpret_cast<const Offset32To<TLookupOffsetList2<TLookup>>&> (lookupList2); }
|
||||
#endif
|
||||
|
||||
const Offset16To<RecordListOfFeature>& subset_feature_list_offset () const
|
||||
@@ -5127,8 +5136,12 @@ struct GSUBGPOS
|
||||
Offset32To<FeatureList>
|
||||
featureList2; /* 32-bit offset to FeatureList table.
|
||||
* Introduced in version 0x00010002. */
|
||||
Offset32To<LookupListT>
|
||||
lookupList2; /* 32-bit offset to LookupList table.
|
||||
Offset32To<LookupList2T>
|
||||
lookupList2; /* 32-bit offset to LookupList table with
|
||||
* 32-bit lookup offsets.
|
||||
* The June 2026 proposed spec points this to
|
||||
* a LookupList instead; that was not suitable
|
||||
* for beyond-64k fonts.
|
||||
* Introduced in version 0x00010002. */
|
||||
#endif
|
||||
public:
|
||||
|
||||
Reference in new issue
Block a user