summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2010-05-27 16:05:00 +0200
committerLars Knoll <lars.knoll@nokia.com>2010-05-27 16:05:00 +0200
commit85ad0ddd092522b4cff251f324128662f100991f (patch)
treeb96471829b1be4b805b320a27cf49fb396d3a69a
parent30f0e6c3d0aa67ab9ff95c60903fe28c4df80fbc (diff)
use unsigned char instead of unsigned in the bitfield.
This saves significant memory, as the HB_CharAttributes and HB_GlyphAttributes structures are not 4 byte aligned anymore, by aligned to 1 resp. 2 bytes. The change is not compliant with ISO C, but accepted by almost all compilers.
-rw-r--r--src/harfbuzz-shaper.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/harfbuzz-shaper.h b/src/harfbuzz-shaper.h
index f7c7714..470e27b 100644
--- a/src/harfbuzz-shaper.h
+++ b/src/harfbuzz-shaper.h
@@ -34,6 +34,18 @@
HB_BEGIN_HEADER
+/*
+ using anything else than signed or unsigned for bitfields in C is non standard,
+ but accepted by almost all compilers. And it gives a significant reduction in
+ memory consumption as HB_CharAttributes and HB_GlyphAttributes will not have
+ a 4 byte alignment
+*/
+#ifdef __xlC__
+typedef unsigned hb_bitfield;
+#else
+typedef hb_uint8 hb_bitfield;
+#endif
+
typedef enum {
HB_Script_Common,
HB_Script_Greek,
@@ -123,12 +135,12 @@ typedef enum {
typedef struct {
- /*HB_LineBreakType*/ unsigned lineBreakType :2;
- /*HB_Bool*/ unsigned whiteSpace :1; /* A unicode whitespace character, except NBSP, ZWNBSP */
- /*HB_Bool*/ unsigned charStop :1; /* Valid cursor position (for left/right arrow) */
- /*HB_Bool*/ unsigned wordBoundary :1;
- /*HB_Bool*/ unsigned sentenceBoundary :1;
- unsigned unused :2;
+ /*HB_LineBreakType*/ hb_bitfield lineBreakType :2;
+ /*HB_Bool*/ hb_bitfield whiteSpace :1; /* A unicode whitespace character, except NBSP, ZWNBSP */
+ /*HB_Bool*/ hb_bitfield charStop :1; /* Valid cursor position (for left/right arrow) */
+ /*HB_Bool*/ hb_bitfield wordBoundary :1;
+ /*HB_Bool*/ hb_bitfield sentenceBoundary :1;
+ hb_bitfield unused :2;
} HB_CharAttributes;
void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
@@ -181,12 +193,12 @@ typedef enum {
* it like that. If this is a problem please tell Trolltech :)
*/
typedef struct {
- unsigned justification :4; /* Justification class */
- unsigned clusterStart :1; /* First glyph of representation of cluster */
- unsigned mark :1; /* needs to be positioned around base char */
- unsigned zeroWidth :1; /* ZWJ, ZWNJ etc, with no width */
- unsigned dontPrint :1;
- unsigned combiningClass :8;
+ hb_bitfield justification :4; /* Justification class */
+ hb_bitfield clusterStart :1; /* First glyph of representation of cluster */
+ hb_bitfield mark :1; /* needs to be positioned around base char */
+ hb_bitfield zeroWidth :1; /* ZWJ, ZWNJ etc, with no width */
+ hb_bitfield dontPrint :1;
+ hb_bitfield combiningClass :8;
} HB_GlyphAttributes;
typedef struct HB_FaceRec_ {