[HarfBuzz] harfbuzz: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Thu Sep 6 02:32:09 UTC 2018
src/hb-ot-hdmx-table.hh | 14 ++++++++++----
test/api/fonts/Roboto-Regular.multihdmx.a.ttf |binary
test/api/fonts/Roboto-Regular.multihdmx.abc.ttf |binary
test/api/test-subset-hdmx.c | 20 ++++++++++++++++++++
4 files changed, 30 insertions(+), 4 deletions(-)
New commits:
commit 21bf147054f6b5bd1c430c0e02a8c4058ed229a1
Author: Garret Rieger <grieger at google.com>
Date: Wed Sep 5 18:04:52 2018 -0700
[subset] Fix hdmx subsetted size calculation.
diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh
index c523c420..87dd6d01 100644
--- a/src/hb-ot-hdmx-table.hh
+++ b/src/hb-ot-hdmx-table.hh
@@ -88,8 +88,13 @@ struct DeviceRecord
{
TRACE_SERIALIZE (this);
- if (unlikely (!c->allocate_size<DeviceRecord> (get_size (subset_view.len()))))
+ unsigned int size = get_size (subset_view.len());
+ if (unlikely (!c->allocate_size<DeviceRecord> (size)))
+ {
+ DEBUG_MSG (SUBSET, nullptr, "Couldn't allocate enough space for DeviceRecord: %d.",
+ size);
return_trace (false);
+ }
this->pixel_size.set (subset_view.source_device_record->pixel_size);
this->max_width.set (subset_view.source_device_record->max_width);
@@ -160,14 +165,14 @@ struct hdmx
return_trace (true);
}
- static inline size_t get_subsetted_size (hb_subset_plan_t *plan)
+ static inline size_t get_subsetted_size (const hdmx *source_hdmx, hb_subset_plan_t *plan)
{
- return min_size + DeviceRecord::get_size (plan->glyphs.len);
+ return min_size + source_hdmx->num_records * DeviceRecord::get_size (plan->glyphs.len);
}
inline bool subset (hb_subset_plan_t *plan) const
{
- size_t dest_size = get_subsetted_size (plan);
+ size_t dest_size = get_subsetted_size (this, plan);
hdmx *dest = (hdmx *) malloc (dest_size);
if (unlikely (!dest))
{
@@ -180,6 +185,7 @@ struct hdmx
if (!hdmx_prime || !hdmx_prime->serialize (&c, this, plan))
{
free (dest);
+ DEBUG_MSG(SUBSET, nullptr, "Failed to serialize write new hdmx.");
return false;
}
c.end_serialize ();
diff --git a/test/api/fonts/Roboto-Regular.multihdmx.a.ttf b/test/api/fonts/Roboto-Regular.multihdmx.a.ttf
new file mode 100644
index 00000000..dd82178f
Binary files /dev/null and b/test/api/fonts/Roboto-Regular.multihdmx.a.ttf differ
diff --git a/test/api/fonts/Roboto-Regular.multihdmx.abc.ttf b/test/api/fonts/Roboto-Regular.multihdmx.abc.ttf
new file mode 100644
index 00000000..03dd8b6b
Binary files /dev/null and b/test/api/fonts/Roboto-Regular.multihdmx.abc.ttf differ
diff --git a/test/api/test-subset-hdmx.c b/test/api/test-subset-hdmx.c
index 22fcb411..8a1e821a 100644
--- a/test/api/test-subset-hdmx.c
+++ b/test/api/test-subset-hdmx.c
@@ -51,6 +51,25 @@ test_subset_hdmx_simple_subset (void)
}
static void
+test_subset_hdmx_multiple_device_records (void)
+{
+ hb_face_t *face_abc = hb_subset_test_open_font ("fonts/Roboto-Regular.multihdmx.abc.ttf");
+ hb_face_t *face_a = hb_subset_test_open_font ("fonts/Roboto-Regular.multihdmx.a.ttf");
+
+ hb_set_t *codepoints = hb_set_create ();
+ hb_face_t *face_abc_subset;
+ hb_set_add (codepoints, 'a');
+ face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
+ hb_set_destroy (codepoints);
+
+ hb_subset_test_check (face_a, face_abc_subset, HB_TAG ('h','d','m','x'));
+
+ hb_face_destroy (face_abc_subset);
+ hb_face_destroy (face_abc);
+ hb_face_destroy (face_a);
+}
+
+static void
test_subset_hdmx_invalid (void)
{
hb_face_t *face = hb_subset_test_open_font("fonts/crash-ccc61c92d589f895174cdef6ff2e3b20e9999a1a");
@@ -115,6 +134,7 @@ main (int argc, char **argv)
hb_test_init (&argc, &argv);
hb_test_add (test_subset_hdmx_simple_subset);
+ hb_test_add (test_subset_hdmx_multiple_device_records);
hb_test_add (test_subset_hdmx_invalid);
hb_test_add (test_subset_hdmx_fails_sanitize);
hb_test_add (test_subset_hdmx_noop);
More information about the HarfBuzz
mailing list