[HarfBuzz] HarfBuzz rewrite

Simon Hausmann simon.hausmann at trolltech.com
Wed Jan 3 06:16:49 PST 2007

On Wednesday 03 January 2007 10:41, Behdad Esfahbod wrote:
> On Wed, 2007-01-03 at 03:02 -0500, Lars Knoll wrote:
> > This is a little problematic, as the compiler is free to add paddings
> > inside
> > the structs (actually it's dependent on the ABI you have on the OS).
> > It
> > should work fine on x86, but you might run into problems on risk
> > architectures. gcc has a workaround for this (the packed attribute).
> > This is
> > something we'll need to look into for other compilers (which we
> > support with
> > Qt).
> Thanks Lars.  I already faced such problems as padding and alignment and
> have solved some, and have plans to solve the rest.  The neat thing is,
> it's a single place (the DEFINE_INT_TYPE macro) you need to tweak for
> that.  You can use an array of chars for example, etc etc.  I'll get to
> that when the rest is done.

Lars and I just had a look at it and we're afraid that it may not be possible
to get the padding/alignment working portably for all compilers :-(

Maybe it'd be easier to just have (initially generate) little wrapper classes
with member functions. For example:

struct OpenTypeFontFace
    enum Offsets {
        Tag_Offset = 0,
        SFntVersion_Offset = 4,
        NumTables_Offset = 8,
        SearchRange_Offset = 12,
    OpenTypeFontFace(const char *_data) : data(_data) {}

    uint32 tag() const { return fromBE32<uint32>(data + Tag_Offset); }
    uint32 sfntVersion() const { return fromBE32<uint32>(data + SFntVersion_Offset); }
    uint32 numTables() const { return fromBE32<uint32>(data + NumTables_Offset); }

    const char *data;

That keeps the code using it still very readable/maintainable and should work
nicely for all platforms.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20070103/830534d3/attachment.pgp>

More information about the HarfBuzz mailing list