[instancer] update head table flagbit: allXMinIsLsb

This commit is contained in:
Qunxin Liu 2023-01-25 11:01:08 -08:00 committed by Behdad Esfahbod
parent 2c49eba044
commit d15551c6f3
4 changed files with 15 additions and 1 deletions

View File

@ -104,6 +104,9 @@ struct Glyph
if (hori_aw < 0) hori_aw = 0; if (hori_aw < 0) hori_aw = 0;
int lsb = roundf (xMin - leftSideX); int lsb = roundf (xMin - leftSideX);
plan->hmtx_map.set (new_gid, hb_pair ((unsigned) hori_aw, lsb)); plan->hmtx_map.set (new_gid, hb_pair ((unsigned) hori_aw, lsb));
//flag value should be computed using non-empty glyphs
if (type != EMPTY && lsb != xMin)
plan->head_maxp_info.allXMinIsLsb = false;
signed vert_aw = roundf (topSideY - bottomSideY); signed vert_aw = roundf (topSideY - bottomSideY);
if (vert_aw < 0) vert_aw = 0; if (vert_aw < 0) vert_aw = 0;

View File

@ -50,6 +50,13 @@ _add_head_and_set_loca_version (hb_subset_plan_t *plan, bool use_short_loca)
head_prime->xMax = plan->head_maxp_info.xMax; head_prime->xMax = plan->head_maxp_info.xMax;
head_prime->yMin = plan->head_maxp_info.yMin; head_prime->yMin = plan->head_maxp_info.yMin;
head_prime->yMax = plan->head_maxp_info.yMax; head_prime->yMax = plan->head_maxp_info.yMax;
unsigned orig_flag = head_prime->flags;
if (plan->head_maxp_info.allXMinIsLsb)
orig_flag |= 1 << 1;
else
orig_flag &= ~(1 << 1);
head_prime->flags = orig_flag;
} }
bool success = plan->add_table (HB_OT_TAG_head, head_prime_blob); bool success = plan->add_table (HB_OT_TAG_head, head_prime_blob);

View File

@ -97,6 +97,7 @@ struct head
* entire font as HBUINT32, then store * entire font as HBUINT32, then store
* 0xB1B0AFBAu - sum. */ * 0xB1B0AFBAu - sum. */
HBUINT32 magicNumber; /* Set to 0x5F0F3CF5u. */ HBUINT32 magicNumber; /* Set to 0x5F0F3CF5u. */
public:
HBUINT16 flags; /* Bit 0: Baseline for font at y=0; HBUINT16 flags; /* Bit 0: Baseline for font at y=0;
* Bit 1: Left sidebearing point at x=0; * Bit 1: Left sidebearing point at x=0;
* Bit 2: Instructions may depend on point size; * Bit 2: Instructions may depend on point size;
@ -141,6 +142,7 @@ struct head
* encoded in the cmap subtables represent proper * encoded in the cmap subtables represent proper
* support for those code points. * support for those code points.
* Bit 15: Reserved, set to 0. */ * Bit 15: Reserved, set to 0. */
protected:
HBUINT16 unitsPerEm; /* Valid range is from 16 to 16384. This value HBUINT16 unitsPerEm; /* Valid range is from 16 to 16384. This value
* should be a power of 2 for fonts that have * should be a power of 2 for fonts that have
* TrueType outlines. */ * TrueType outlines. */

View File

@ -49,7 +49,8 @@ struct head_maxp_info_t
maxCompositePoints (0), maxCompositePoints (0),
maxCompositeContours (0), maxCompositeContours (0),
maxComponentElements (0), maxComponentElements (0),
maxComponentDepth (0) {} maxComponentDepth (0),
allXMinIsLsb (true) {}
int xMin; int xMin;
int xMax; int xMax;
@ -61,6 +62,7 @@ struct head_maxp_info_t
unsigned maxCompositeContours; unsigned maxCompositeContours;
unsigned maxComponentElements; unsigned maxComponentElements;
unsigned maxComponentDepth; unsigned maxComponentDepth;
bool allXMinIsLsb;
}; };
typedef struct head_maxp_info_t head_maxp_info_t; typedef struct head_maxp_info_t head_maxp_info_t;