COLRv1: use ClipBoxes for extents
This is a first step; ultimatively, we should compute the extents is ClipBoxes are missing.
This commit is contained in:
parent
d36a0f8c42
commit
7a748ad4ac
|
@ -928,6 +928,24 @@ struct ClipBox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get_extents (hb_glyph_extents_t *extents) const
|
||||||
|
{
|
||||||
|
switch (u.format) {
|
||||||
|
case 1:
|
||||||
|
extents->x_bearing = u.format1.xMin;
|
||||||
|
extents->y_bearing = u.format1.yMax;
|
||||||
|
extents->width = u.format1.xMax - u.format1.xMin;
|
||||||
|
extents->height = u.format1.yMin - u.format1.yMax;
|
||||||
|
return true;
|
||||||
|
case 2:
|
||||||
|
// TODO
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
// This shouldn't happen
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
union {
|
union {
|
||||||
HBUINT8 format; /* Format identifier */
|
HBUINT8 format; /* Format identifier */
|
||||||
|
@ -953,6 +971,11 @@ struct ClipRecord
|
||||||
return_trace (c->check_struct (this) && clipBox.sanitize (c, base));
|
return_trace (c->check_struct (this) && clipBox.sanitize (c, base));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get_extents (hb_glyph_extents_t *extents, const void *base) const
|
||||||
|
{
|
||||||
|
return (base+clipBox).get_extents (extents);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HBUINT16 startGlyphID; // first gid clip applies to
|
HBUINT16 startGlyphID; // first gid clip applies to
|
||||||
HBUINT16 endGlyphID; // last gid clip applies to, inclusive
|
HBUINT16 endGlyphID; // last gid clip applies to, inclusive
|
||||||
|
@ -1052,6 +1075,17 @@ struct ClipList
|
||||||
return_trace (c->check_struct (this) && clips.sanitize (c, this));
|
return_trace (c->check_struct (this) && clips.sanitize (c, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
get_extents (hb_codepoint_t gid, hb_glyph_extents_t *extents) const
|
||||||
|
{
|
||||||
|
for (const ClipRecord& record : clips.iter ())
|
||||||
|
{
|
||||||
|
if (record.startGlyphID <= gid && gid <= record.endGlyphID)
|
||||||
|
return record.get_extents (extents, this);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
HBUINT8 format; // Set to 1.
|
HBUINT8 format; // Set to 1.
|
||||||
SortedArray32Of<ClipRecord> clips; // Clip records, sorted by startGlyphID
|
SortedArray32Of<ClipRecord> clips; // Clip records, sorted by startGlyphID
|
||||||
public:
|
public:
|
||||||
|
@ -1513,6 +1547,21 @@ struct COLR
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
|
||||||
|
{
|
||||||
|
if ((this+clipList).get_extents (glyph, extents))
|
||||||
|
{
|
||||||
|
extents->x_bearing = font->em_scale_x (extents->x_bearing);
|
||||||
|
extents->y_bearing = font->em_scale_x (extents->y_bearing);
|
||||||
|
extents->width = font->em_scale_x (extents->width);
|
||||||
|
extents->height = font->em_scale_x (extents->height);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HBUINT16 version; /* Table version number (starts at 0). */
|
HBUINT16 version; /* Table version number (starts at 0). */
|
||||||
HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */
|
HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "hb-ot-vorg-table.hh"
|
#include "hb-ot-vorg-table.hh"
|
||||||
#include "hb-ot-color-cbdt-table.hh"
|
#include "hb-ot-color-cbdt-table.hh"
|
||||||
#include "hb-ot-color-sbix-table.hh"
|
#include "hb-ot-color-sbix-table.hh"
|
||||||
|
#include "hb-ot-color-colr-table.hh"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,6 +350,9 @@ hb_ot_get_glyph_extents (hb_font_t *font,
|
||||||
#if !defined(HB_NO_OT_FONT_BITMAP) && !defined(HB_NO_COLOR)
|
#if !defined(HB_NO_OT_FONT_BITMAP) && !defined(HB_NO_COLOR)
|
||||||
if (ot_face->sbix->get_extents (font, glyph, extents)) return true;
|
if (ot_face->sbix->get_extents (font, glyph, extents)) return true;
|
||||||
if (ot_face->CBDT->get_extents (font, glyph, extents)) return true;
|
if (ot_face->CBDT->get_extents (font, glyph, extents)) return true;
|
||||||
|
#endif
|
||||||
|
#if !defined(HB_NO_COLOR)
|
||||||
|
if (ot_face->COLR->get_extents (font, glyph, extents)) return true;
|
||||||
#endif
|
#endif
|
||||||
if (ot_face->glyf->get_extents (font, glyph, extents)) return true;
|
if (ot_face->glyf->get_extents (font, glyph, extents)) return true;
|
||||||
#ifndef HB_NO_OT_FONT_CFF
|
#ifndef HB_NO_OT_FONT_CFF
|
||||||
|
|
Loading…
Reference in New Issue