DEFINE_SIZE_STATIC(12);
};
+
/*
* Index Subtables.
*/
+
struct IndexSubtableHeader
{
inline bool sanitize (hb_sanitize_context_t *c) const
DEFINE_SIZE_STATIC(8);
};
-/*
- * Glyph Bitmap Data Formats.
- */
-
-struct GlyphBitmapDataFormat17
-{
- SmallGlyphMetrics glyphMetrics;
- ULONG dataLen;
- BYTE dataZ[VAR];
-
- DEFINE_SIZE_ARRAY(9, dataZ);
-};
-
struct IndexSubtableArray
{
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
struct BitmapSizeTable
{
+ friend struct CBLC;
+
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
vertical.sanitize (c));
}
+ const IndexSubtableRecord *find_table (hb_codepoint_t glyph, const void *base) const
+ {
+ return (base+indexSubtableArrayOffset).find_table (glyph, numberOfIndexSubtables);
+ }
+
+ protected:
OffsetTo<IndexSubtableArray, ULONG> indexSubtableArrayOffset;
ULONG indexTablesSize;
ULONG numberOfIndexSubtables;
BYTE bitDepth;
CHAR flags;
+public:
DEFINE_SIZE_STATIC(48);
};
+
+/*
+ * Glyph Bitmap Data Formats.
+ */
+
+struct GlyphBitmapDataFormat17
+{
+ SmallGlyphMetrics glyphMetrics;
+ ULONG dataLen;
+ BYTE dataZ[VAR];
+
+ DEFINE_SIZE_ARRAY(9, dataZ);
+};
+
+
/*
* CBLC -- Color Bitmap Location Table
*/
}
public:
- const BitmapSizeTable* find_table (hb_codepoint_t glyph) const
+ const IndexSubtableRecord *find_table (hb_codepoint_t glyph,
+ unsigned int *x_ppem, unsigned int *y_ppem) const
{
- // TODO: Make it possible to select strike.
+ /* TODO: Make it possible to select strike. */
+
+ const BitmapSizeTable *sizeTable = &Null(BitmapSizeTable);
unsigned int count = sizeTables.len;
- for (uint32_t i = 0; i < count; ++i) {
+ for (uint32_t i = 0; i < count; ++i)
+ {
unsigned int startGlyphIndex = sizeTables.array[i].startGlyphIndex;
unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex;
- if (startGlyphIndex <= glyph && glyph <= endGlyphIndex) {
- return &sizeTables[i];
+ if (startGlyphIndex <= glyph && glyph <= endGlyphIndex)
+ {
+ sizeTable = &sizeTables[i];
+ break;
}
}
- return NULL;
+
+ *x_ppem = sizeTable->ppemX;
+ *y_ppem = sizeTable->ppemY;
+
+ return sizeTable->find_table (glyph, this);
}
protected:
inline bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
{
+ unsigned int x_ppem = upem, y_ppem = upem; /* TODO Use font ppem if available. */
+
if (cblc == NULL) {
return false; // Not a color bitmap font.
}
- const OT::BitmapSizeTable* sizeTable = this->cblc->find_table(glyph);
- if (sizeTable == NULL) {
- return false;
- }
-
- const OT::IndexSubtableArray& subtables = this->cblc + sizeTable->indexSubtableArrayOffset;
- const OT::IndexSubtableRecord *subtable_record = subtables.find_table (glyph, sizeTable->numberOfIndexSubtables);
+ const OT::IndexSubtableRecord *subtable_record = this->cblc->find_table(glyph, &x_ppem, &y_ppem);
if (subtable_record == NULL) {
return false;
}
}
/* Convert to the font units. */
- extents->x_bearing *= upem / (float)(sizeTable->ppemX);
- extents->y_bearing *= upem / (float)(sizeTable->ppemY);
- extents->width *= upem / (float)(sizeTable->ppemX);
- extents->height *= upem / (float)(sizeTable->ppemY);
+ extents->x_bearing *= upem / (float) x_ppem;
+ extents->y_bearing *= upem / (float) y_ppem;
+ extents->width *= upem / (float) x_ppem;
+ extents->height *= upem / (float) y_ppem;
return true;
}