[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Jul 22 07:57:17 PDT 2013
src/hb-uniscribe.cc | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
New commits:
commit 8b427c78efa988ed27a2a394146d73f59688707b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Jul 22 10:57:05 2013 -0400
[uniscribe] Sanitize font file
diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index 27112a5..5176abd 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -314,6 +314,8 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
* full, PS. All of them point to the same name data with our unique name.
*/
+ blob = OT::Sanitizer<OT::OpenTypeFontFile>::sanitize (blob);
+
unsigned int length, new_length, name_str_len;
const char *orig_sfnt_data = hb_blob_get_data (blob, &length);
@@ -364,6 +366,8 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
unsigned int face_count = file.get_face_count ();
for (unsigned int face_index = 0; face_index < face_count; face_index++)
{
+ /* Note: doing multiple edits (ie. TTC) can be unsafe. There may be
+ * toe-stepping. But we don't really care. */
const OT::OpenTypeFontFace &face = file.get_face (face_index);
unsigned int index;
if (face.find_table_index (HB_OT_TAG_name, &index))
commit 12ff69df21ac91ae21860db7000d9f9973d3da1a
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Jul 22 10:52:12 2013 -0400
[uniscribe] Handle TTC when renaming font
diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index 93c0529..27112a5 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -360,20 +360,25 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name)
}
/* Adjust name table entry to point to new name table */
- OT::OpenTypeFontFace *face = (OT::OpenTypeFontFace *) (new_sfnt_data);
- unsigned int index;
- if (face->find_table_index (HB_OT_TAG_name, &index))
+ const OT::OpenTypeFontFile &file = * (OT::OpenTypeFontFile *) (new_sfnt_data);
+ unsigned int face_count = file.get_face_count ();
+ for (unsigned int face_index = 0; face_index < face_count; face_index++)
{
- OT::TableRecord &record = const_cast<OT::TableRecord &> (face->get_table (index));
- record.checkSum.set_for_data (&name, name_table_length);
- record.offset.set (name_table_offset);
- record.length.set (name_table_length);
- }
- else
- {
- free (new_sfnt_data);
- hb_blob_destroy (blob);
- return NULL;
+ const OT::OpenTypeFontFace &face = file.get_face (face_index);
+ unsigned int index;
+ if (face.find_table_index (HB_OT_TAG_name, &index))
+ {
+ OT::TableRecord &record = const_cast<OT::TableRecord &> (face.get_table (index));
+ record.checkSum.set_for_data (&name, name_table_length);
+ record.offset.set (name_table_offset);
+ record.length.set (name_table_length);
+ }
+ else if (face_index == 0) /* Fail if first face doesn't have 'name' table. */
+ {
+ free (new_sfnt_data);
+ hb_blob_destroy (blob);
+ return NULL;
+ }
}
/* The checkSumAdjustment field in the 'head' table is now wrong,
More information about the HarfBuzz
mailing list