[dfont] Re-enable and fix offset handling
Fixes https://github.com/harfbuzz/harfbuzz/pull/1085
This commit is contained in:
parent
a1814e2bec
commit
9479ffefbf
@ -163,11 +163,12 @@ _hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void
|
||||
return hb_blob_reference (data->blob);
|
||||
|
||||
const OT::OpenTypeFontFile &ot_file = *data->blob->as<OT::OpenTypeFontFile> ();
|
||||
const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index);
|
||||
unsigned int base_offset;
|
||||
const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index, &base_offset);
|
||||
|
||||
const OT::OpenTypeTable &table = ot_face.get_table_by_tag (tag);
|
||||
|
||||
hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, table.offset, table.length);
|
||||
hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, base_offset + table.offset, table.length);
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
@ -428,14 +428,19 @@ struct ResourceForkHeader
|
||||
return StructAtOffset<LArrayOf<HBUINT8> > (this, offset);
|
||||
}
|
||||
|
||||
inline const OpenTypeFontFace& get_face (unsigned int idx) const
|
||||
inline const OpenTypeFontFace& get_face (unsigned int idx, unsigned int *base_offset = nullptr) const
|
||||
{
|
||||
const ResourceMap &resource_map = this+map;
|
||||
for (unsigned int i = 0; i < resource_map.get_types_count (); ++i)
|
||||
{
|
||||
const ResourceTypeItem& type = resource_map.get_type (i);
|
||||
if (type.is_sfnt () && idx < type.get_resource_count ())
|
||||
return (OpenTypeFontFace&) get_data (type, idx).arrayZ;
|
||||
{
|
||||
const OpenTypeFontFace &face = (OpenTypeFontFace&) get_data (type, idx).arrayZ;
|
||||
if (base_offset)
|
||||
*base_offset = (const char *) &face - (const char *) this;
|
||||
return face;
|
||||
}
|
||||
}
|
||||
return Null (OpenTypeFontFace);
|
||||
}
|
||||
@ -502,12 +507,14 @@ struct OpenTypeFontFile
|
||||
case Typ1Tag:
|
||||
case TrueTypeTag: return 1;
|
||||
case TTCTag: return u.ttcHeader.get_face_count ();
|
||||
// case DFontTag: return u.rfHeader.get_face_count ();
|
||||
case DFontTag: return u.rfHeader.get_face_count ();
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
inline const OpenTypeFontFace& get_face (unsigned int i) const
|
||||
inline const OpenTypeFontFace& get_face (unsigned int i, unsigned int *base_offset = nullptr) const
|
||||
{
|
||||
if (base_offset)
|
||||
*base_offset = 0;
|
||||
switch (u.tag) {
|
||||
/* Note: for non-collection SFNT data we ignore index. This is because
|
||||
* Apple dfont container is a container of SFNT's. So each SFNT is a
|
||||
@ -517,7 +524,7 @@ struct OpenTypeFontFile
|
||||
case Typ1Tag:
|
||||
case TrueTypeTag: return u.fontFace;
|
||||
case TTCTag: return u.ttcHeader.get_face (i);
|
||||
// case DFontTag: return u.rfHeader.get_face (i);
|
||||
case DFontTag: return u.rfHeader.get_face (i, base_offset);
|
||||
default: return Null(OpenTypeFontFace);
|
||||
}
|
||||
}
|
||||
@ -544,7 +551,7 @@ struct OpenTypeFontFile
|
||||
case Typ1Tag:
|
||||
case TrueTypeTag: return_trace (u.fontFace.sanitize (c));
|
||||
case TTCTag: return_trace (u.ttcHeader.sanitize (c));
|
||||
// case DFontTag: return_trace (u.rfHeader.sanitize (c));
|
||||
case DFontTag: return_trace (u.rfHeader.sanitize (c));
|
||||
default: return_trace (true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user