Glyph 0xFFFF is a valid glyph.
Assert that the hb_codepoint_t passed to skhb_glyph_extents is in range using SkTo, which is obviously correct (and consistently used elsewhere) instead of the incorrect '< 0xFFFF' since 0xFFFF is a valid glyph id. While doing so, rename the hb_codepoint_t parameters which are actually glyph ids to reflect that they are glyphs and not codepoints (HarfBuzz uses hb_codepoint_t for both). Change-Id: I0bf2b7f12183dfb8254856b12168b8bee867c430 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/265769 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
2055827845
commit
32b45b32b7
@ -150,14 +150,14 @@ unsigned skhb_nominal_glyphs(hb_font_t *hb_font, void *font_data,
|
|||||||
|
|
||||||
hb_position_t skhb_glyph_h_advance(hb_font_t* hb_font,
|
hb_position_t skhb_glyph_h_advance(hb_font_t* hb_font,
|
||||||
void* font_data,
|
void* font_data,
|
||||||
hb_codepoint_t codepoint,
|
hb_codepoint_t hbGlyph,
|
||||||
void* user_data) {
|
void* user_data) {
|
||||||
SkFont& font = *reinterpret_cast<SkFont*>(font_data);
|
SkFont& font = *reinterpret_cast<SkFont*>(font_data);
|
||||||
|
|
||||||
SkScalar advance;
|
SkScalar advance;
|
||||||
SkGlyphID glyph = SkTo<SkGlyphID>(codepoint);
|
SkGlyphID skGlyph = SkTo<SkGlyphID>(hbGlyph);
|
||||||
|
|
||||||
font.getWidths(&glyph, 1, &advance);
|
font.getWidths(&skGlyph, 1, &advance);
|
||||||
if (!font.isSubpixel()) {
|
if (!font.isSubpixel()) {
|
||||||
advance = SkScalarRoundToInt(advance);
|
advance = SkScalarRoundToInt(advance);
|
||||||
}
|
}
|
||||||
@ -205,18 +205,16 @@ void skhb_glyph_h_advances(hb_font_t* hb_font,
|
|||||||
// Unicode mark classes. Above, below, centered or left or right, etc.
|
// Unicode mark classes. Above, below, centered or left or right, etc.
|
||||||
hb_bool_t skhb_glyph_extents(hb_font_t* hb_font,
|
hb_bool_t skhb_glyph_extents(hb_font_t* hb_font,
|
||||||
void* font_data,
|
void* font_data,
|
||||||
hb_codepoint_t codepoint,
|
hb_codepoint_t hbGlyph,
|
||||||
hb_glyph_extents_t* extents,
|
hb_glyph_extents_t* extents,
|
||||||
void* user_data) {
|
void* user_data) {
|
||||||
SkFont& font = *reinterpret_cast<SkFont*>(font_data);
|
SkFont& font = *reinterpret_cast<SkFont*>(font_data);
|
||||||
|
|
||||||
SkASSERT(codepoint < 0xFFFFu);
|
|
||||||
SkASSERT(extents);
|
SkASSERT(extents);
|
||||||
|
|
||||||
SkRect sk_bounds;
|
SkRect sk_bounds;
|
||||||
SkGlyphID glyph = codepoint;
|
SkGlyphID skGlyph = SkTo<SkGlyphID>(hbGlyph);
|
||||||
|
|
||||||
font.getWidths(&glyph, 1, nullptr, &sk_bounds);
|
font.getWidths(&skGlyph, 1, nullptr, &sk_bounds);
|
||||||
if (!font.isSubpixel()) {
|
if (!font.isSubpixel()) {
|
||||||
sk_bounds.set(sk_bounds.roundOut());
|
sk_bounds.set(sk_bounds.roundOut());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user