[cbdt] Implement strike selection logic
This commit is contained in:
parent
98bddbc8ef
commit
5eb251aab0
|
@ -345,13 +345,28 @@ struct CBLC
|
||||||
protected:
|
protected:
|
||||||
const BitmapSizeTable &choose_strike (hb_font_t *font) const
|
const BitmapSizeTable &choose_strike (hb_font_t *font) const
|
||||||
{
|
{
|
||||||
/* TODO: Make it possible to select strike. */
|
unsigned count = sizeTables.len;
|
||||||
|
if (unlikely (!count))
|
||||||
|
return Null(BitmapSizeTable);
|
||||||
|
|
||||||
unsigned int count = sizeTables.len;
|
unsigned int requested_ppem = MAX (font->x_ppem, font->y_ppem);
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
if (!requested_ppem)
|
||||||
return sizeTables[i];
|
requested_ppem = 1<<30; /* Choose largest strike. */
|
||||||
|
unsigned int best_i = 0;
|
||||||
|
unsigned int best_ppem = MAX (sizeTables[0].ppemX, sizeTables[0].ppemY);
|
||||||
|
|
||||||
return Null(BitmapSizeTable);
|
for (unsigned int i = 1; i < count; i++)
|
||||||
|
{
|
||||||
|
unsigned int ppem = MAX (sizeTables[i].ppemX, sizeTables[i].ppemY);
|
||||||
|
if ((requested_ppem <= ppem && ppem < best_ppem) ||
|
||||||
|
(requested_ppem > best_ppem && ppem > best_ppem))
|
||||||
|
{
|
||||||
|
best_i = i;
|
||||||
|
best_ppem = ppem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sizeTables[best_i];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue