らんだむな記憶

blogというものを体験してみようか!的なー

32bitアライメント

The OpenType Font File

Font Tables

The TrueType rasterizer has a much easier time traversing tables if they are padded so that each table begins on a 4-byte boundary. Also, the algorithm for calculating table checksums assumes that tables are 32-bit aligned. For this reason, all tables must be 32-bit aligned and padded with zeroes.

さりげなくこんなこと書いてあるなぁ。
そして以下のような。うーむ。うーん、そうか。

Calculating Checksums

Table checksums are the unsigned sum of the uint32 units of a given table. In C, the following function can be used to determine a checksum:

uint32
CalcTableChecksum(uint32 *Table, uint32 Length)
{
    uint32 Sum = 0L;
    uint32 *Endptr = Table+((Length+3) & ~3) / sizeof(uint32);
    while (Table < EndPtr)
        Sum += *Table++;
    return Sum;
}