summaryrefslogtreecommitdiff
path: root/src/cairo-truetype-subset.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-03-03 11:21:35 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2009-03-03 11:21:35 +0000
commita8158d443e6a4bafae28a46b883cbdcfd5789eec (patch)
treee98abba8c71cefaefaafb053dd8f9abb057d87fe /src/cairo-truetype-subset.c
parente4b1f871e9cbb04590df5dc6f6f7854642fa0340 (diff)
[truetype] Move the sizeof asserts to compile time.
Eliminate the need for a runtime test on the sizeof the private structures by performing the check at compile time. This was provoked by Ginn Chenn noting that the test was including a private header.
Diffstat (limited to 'src/cairo-truetype-subset.c')
-rw-r--r--src/cairo-truetype-subset.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index d01b0895..31e39710 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -94,6 +94,21 @@ struct _cairo_truetype_font {
};
+/*
+ * Test that the structs we define for TrueType tables have the
+ * correct size, ie. they are not padded.
+ */
+#define check(T, S) COMPILE_TIME_ASSERT (sizeof (T) == (S))
+check (tt_head_t, 54);
+check (tt_hhea_t, 36);
+check (tt_maxp_t, 32);
+check (tt_name_record_t, 12);
+check (tt_name_t, 18);
+check (tt_name_t, 18);
+check (tt_composite_glyph_t, 18);
+check (tt_glyph_data_t, 28);
+#undef check
+
static cairo_status_t
cairo_truetype_font_use_glyph (cairo_truetype_font_t *font,
unsigned short glyph,