[sbix] Clean up
This commit is contained in:
parent
218fa7166e
commit
fb0f3e3767
|
@ -34,33 +34,43 @@ namespace OT {
|
||||||
|
|
||||||
struct SBIXGlyph
|
struct SBIXGlyph
|
||||||
{
|
{
|
||||||
friend struct sbix;
|
HBINT16 xOffset; /* The horizontal (x-axis) offset from the left
|
||||||
|
* edge of the graphic to the glyph’s origin.
|
||||||
protected:
|
* That is, the x-coordinate of the point on the
|
||||||
HBINT16 originOffsetX;
|
* baseline at the left edge of the glyph. */
|
||||||
HBINT16 originOffsetY;
|
HBINT16 yOffset; /* The vertical (y-axis) offset from the bottom
|
||||||
unsigned char tag[4];
|
* edge of the graphic to the glyph’s origin.
|
||||||
HBUINT8 data[VAR];
|
* That is, the y-coordinate of the point on the
|
||||||
|
* baseline at the left edge of the glyph. */
|
||||||
|
Tag graphicType; /* Indicates the format of the embedded graphic
|
||||||
|
* data: one of 'jpg ', 'png ' or 'tiff', or the
|
||||||
|
* special format 'dupe'. */
|
||||||
|
HBUINT8 data[VAR]; /* The actual embedded graphic data. The total
|
||||||
|
* length is inferred from sequential entries in
|
||||||
|
* the glyphDataOffsets array and the fixed size
|
||||||
|
* (8 bytes) of the preceding fields. */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_STATIC (9);
|
DEFINE_SIZE_ARRAY (8, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImageTable
|
struct SBIXStrike
|
||||||
{
|
{
|
||||||
friend struct sbix;
|
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
return_trace (c->check_struct (this) &&
|
return_trace (c->check_struct (this) &&
|
||||||
c->check_array (imageOffsetsZ, sizeof (HBUINT32), c->num_glyphs) &&
|
c->check_array (imageOffsetsZ,
|
||||||
c->check_range (this, imageOffsetsZ[c->num_glyphs]));
|
sizeof (HBUINT32),
|
||||||
|
1 + c->num_glyphs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HBUINT16 ppem; /* The PPEM size for which this strike was designed. */
|
||||||
|
HBUINT16 resolution; /* The device pixel density (in PPI) for which this
|
||||||
|
* strike was designed. (E.g., 96 PPI, 192 PPI.) */
|
||||||
protected:
|
protected:
|
||||||
HBUINT16 ppem;
|
|
||||||
HBUINT16 resolution;
|
|
||||||
LOffsetTo<SBIXGlyph> imageOffsetsZ[VAR]; // VAR=maxp.numGlyphs + 1
|
LOffsetTo<SBIXGlyph> imageOffsetsZ[VAR]; // VAR=maxp.numGlyphs + 1
|
||||||
|
/* Offset from the beginning of the strike data header
|
||||||
|
* to bitmap data for an individual glyph ID. */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_STATIC (8);
|
DEFINE_SIZE_STATIC (8);
|
||||||
};
|
};
|
||||||
|
@ -87,40 +97,34 @@ struct sbix
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
if (!(c->check_struct (this) && imageTables.sanitize (c, this)))
|
return_trace (c->check_struct (this) && strikes.sanitize (c, this));
|
||||||
return_trace (false);
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < imageTables.len; ++i)
|
|
||||||
if (!(imageTables[i].sanitize (c, this)))
|
|
||||||
return_trace (false);
|
|
||||||
|
|
||||||
// dump (c->num_glyphs, 8);
|
|
||||||
|
|
||||||
return_trace (true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// inline void dump (unsigned int num_glyphs, unsigned int group) const
|
// inline void dump (unsigned int num_glyphs, unsigned int group) const
|
||||||
// {
|
// {
|
||||||
// const ImageTable &imageTable = imageTables[group](this);
|
// const SBIXStrike &strike = strikes[group](this);
|
||||||
// for (unsigned int i = 0; i < num_glyphs; ++i)
|
// for (unsigned int i = 0; i < num_glyphs; ++i)
|
||||||
// if (imageTable.imageOffsetsZ[i + 1] - imageTable.imageOffsetsZ[i] > 0)
|
// if (strike.imageOffsetsZ[i + 1] - strike.imageOffsetsZ[i] > 0)
|
||||||
// {
|
// {
|
||||||
// const SBIXGlyph &sbixGlyph = imageTable.imageOffsetsZ[i]((const void *) &imageTable);
|
// const SBIXGlyph &sbixGlyph = strike.imageOffsetsZ[i]((const void *) &strike);
|
||||||
// char outName[255];
|
// char outName[255];
|
||||||
// sprintf (outName, "out/%d-%d.png", group, i);
|
// sprintf (outName, "out/%d-%d.png", group, i);
|
||||||
// FILE *f = fopen (outName, "wb");
|
// FILE *f = fopen (outName, "wb");
|
||||||
// fwrite (sbixGlyph.data, 1,
|
// fwrite (sbixGlyph.data, 1,
|
||||||
// imageTable.imageOffsetsZ[i + 1] - imageTable.imageOffsetsZ[i] - 8, f);
|
// strike.imageOffsetsZ[i + 1] - strike.imageOffsetsZ[i] - 8, f);
|
||||||
// fclose (f);
|
// fclose (f);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HBUINT16 version;
|
HBUINT16 version; /* Table version number — set to 1 */
|
||||||
HBUINT16 flags;
|
HBUINT16 flags; /* Bit 0: Set to 1. Bit 1: Draw outlines.
|
||||||
ArrayOf<LOffsetTo<ImageTable>, HBUINT32> imageTables;
|
* Bits 2 to 15: reserved (set to 0). */
|
||||||
|
ArrayOf<LOffsetTo<SBIXStrike>, HBUINT32>
|
||||||
|
strikes; /* Offsets from the beginning of the 'sbix'
|
||||||
|
* table to data for each individual bitmap strike. */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (8, imageTables);
|
DEFINE_SIZE_ARRAY (8, strikes);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace OT */
|
} /* namespace OT */
|
||||||
|
|
Loading…
Reference in New Issue