From b69f8c3a010ec6f4aa47c03a5e3dd7b69a051888 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Mon, 20 Sep 2010 14:59:52 +0100 Subject: [PATCH] truetype-subset: Pack the truetype structs Since these must have no padding, it makes sense to actually tell the compiler not to add any padding... --- src/cairo-compiler-private.h | 2 ++ src/cairo-truetype-subset-private.h | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h index e25ee1f..d96fdf0 100644 --- a/src/cairo-compiler-private.h +++ b/src/cairo-compiler-private.h @@ -174,10 +174,12 @@ #define cairo_pure __attribute__((pure)) #define cairo_const __attribute__((const)) #define cairo_always_inline inline __attribute__((always_inline)) +#define cairo_packed __attribute__((__packed__)) #else #define cairo_pure #define cairo_const #define cairo_always_inline inline +#define cairo_packed #endif #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) diff --git a/src/cairo-truetype-subset-private.h b/src/cairo-truetype-subset-private.h index aed60d0..2dacd99 100644 --- a/src/cairo-truetype-subset-private.h +++ b/src/cairo-truetype-subset-private.h @@ -68,19 +68,19 @@ #define TT_TAG_prep MAKE_TT_TAG('p','r','e','p') /* All tt_* structs are big-endian */ -typedef struct _tt_cmap_index { +typedef struct cairo_packed _tt_cmap_index { uint16_t platform; uint16_t encoding; uint32_t offset; } tt_cmap_index_t; -typedef struct _tt_cmap { +typedef struct cairo_packed _tt_cmap { uint16_t version; uint16_t num_tables; tt_cmap_index_t index[1]; } tt_cmap_t; -typedef struct _segment_map { +typedef struct cairo_packed _segment_map { uint16_t format; uint16_t length; uint16_t version; @@ -91,7 +91,7 @@ typedef struct _segment_map { uint16_t endCount[1]; } tt_segment_map_t; -typedef struct _tt_head { +typedef struct cairo_packed _tt_head { int16_t version_1; int16_t version_2; int16_t revision_1; @@ -121,7 +121,7 @@ typedef struct _tt_head { int16_t glyph_data_format; } tt_head_t; -typedef struct _tt_hhea { +typedef struct cairo_packed _tt_hhea { int16_t version_1; int16_t version_2; int16_t ascender; /* FWORD */ @@ -138,7 +138,7 @@ typedef struct _tt_hhea { uint16_t num_hmetrics; } tt_hhea_t; -typedef struct _tt_maxp { +typedef struct cairo_packed _tt_maxp { int16_t version_1; int16_t version_2; uint16_t num_glyphs; @@ -157,7 +157,7 @@ typedef struct _tt_maxp { uint16_t max_component_depth; } tt_maxp_t; -typedef struct _tt_name_record { +typedef struct cairo_packed _tt_name_record { uint16_t platform; uint16_t encoding; uint16_t language; @@ -166,7 +166,7 @@ typedef struct _tt_name_record { uint16_t offset; } tt_name_record_t; -typedef struct _tt_name { +typedef struct cairo_packed _tt_name { uint16_t format; uint16_t num_records; uint16_t strings_offset; @@ -182,13 +182,13 @@ typedef struct _tt_name { #define TT_WE_HAVE_AN_X_AND_Y_SCALE 0x0040 #define TT_WE_HAVE_A_TWO_BY_TWO 0x0080 -typedef struct _tt_composite_glyph { +typedef struct cairo_packed _tt_composite_glyph { uint16_t flags; uint16_t index; uint16_t args[6]; /* 1 to 6 arguments depending on value of flags */ } tt_composite_glyph_t; -typedef struct _tt_glyph_data { +typedef struct cairo_packed _tt_glyph_data { int16_t num_contours; int8_t data[8]; tt_composite_glyph_t glyph; -- 1.7.2.2