[cbdt] Implement strike selection logic

This commit is contained in:
Behdad Esfahbod 2018-10-28 23:16:13 -07:00
parent 98bddbc8ef
commit 5eb251aab0
1 changed files with 20 additions and 5 deletions

View File

@ -345,13 +345,28 @@ struct CBLC
protected:
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;
for (uint32_t i = 0; i < count; ++i)
return sizeTables[i];
unsigned int requested_ppem = MAX (font->x_ppem, font->y_ppem);
if (!requested_ppem)
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: