[ot-color] Apply Behdad comment

This commit is contained in:
Ebrahim Byagowi 2018-10-28 20:09:40 +03:30 committed by Behdad Esfahbod
parent dbd419bede
commit 8ef0d2ef92
6 changed files with 24 additions and 50 deletions

View File

@ -70,7 +70,7 @@ sbix_dump (hb_face_t *face)
{
hb_blob_t *blob;
blob = sbix.reference_blob_for_glyph (glyph_id, 0, available_ppems[group],
HB_TAG('p','n','g',' '), NULL, NULL);
HB_TAG('p','n','g',' '));
if (hb_blob_get_length (blob) == 0) continue;
char output_path[255];

View File

@ -506,9 +506,7 @@ struct CBDT
inline hb_blob_t* reference_blob_for_glyph (hb_codepoint_t glyph_id,
unsigned int requested_x_ppem,
unsigned int requested_y_ppem,
unsigned int *strike_x_ppem,
unsigned int *strike_y_ppem) const
unsigned int requested_y_ppem) const
{
if (!cblc)
return hb_blob_get_empty (); // Not a color bitmap font.
@ -529,8 +527,8 @@ struct CBDT
switch (image_format)
{
case 17: {
if (strike_x_ppem) *strike_x_ppem = x_ppem;
if (strike_x_ppem) *strike_y_ppem = y_ppem;
// if (strike_x_ppem) *strike_x_ppem = x_ppem;
// if (strike_x_ppem) *strike_y_ppem = y_ppem;
const GlyphBitmapDataFormat17& glyphFormat17 =
StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
return hb_blob_create_sub_blob (cbdt_blob,
@ -538,8 +536,8 @@ struct CBDT
glyphFormat17.data.len);
}
case 18: {
if (strike_x_ppem) *strike_x_ppem = x_ppem;
if (strike_x_ppem) *strike_y_ppem = y_ppem;
// if (strike_x_ppem) *strike_x_ppem = x_ppem;
// if (strike_x_ppem) *strike_y_ppem = y_ppem;
const GlyphBitmapDataFormat18& glyphFormat18 =
StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
return hb_blob_create_sub_blob (cbdt_blob,
@ -547,8 +545,8 @@ struct CBDT
glyphFormat18.data.len);
}
case 19: {
if (strike_x_ppem) *strike_x_ppem = x_ppem;
if (strike_x_ppem) *strike_y_ppem = y_ppem;
// if (strike_x_ppem) *strike_x_ppem = x_ppem;
// if (strike_x_ppem) *strike_y_ppem = y_ppem;
const GlyphBitmapDataFormat19& glyphFormat19 =
StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset);
return hb_blob_create_sub_blob (cbdt_blob,

View File

@ -84,8 +84,6 @@ struct SBIXStrike
hb_blob_t *sbix_blob,
unsigned int sbix_len,
unsigned int strike_offset,
unsigned int *x_offset,
unsigned int *y_offset,
hb_tag_t requested_file_type,
unsigned int num_glyphs) const
{
@ -110,8 +108,8 @@ struct SBIXStrike
}
if (unlikely (requested_file_type != glyph->graphicType))
return hb_blob_get_empty ();
if (likely (x_offset)) *x_offset = glyph->xOffset;
if (likely (y_offset)) *y_offset = glyph->yOffset;
// if (x_offset) *x_offset = glyph->xOffset;
// if (y_offset) *y_offset = glyph->yOffset;
unsigned int offset = strike_offset + SBIXGlyph::min_size;
offset += imageOffsetsZ[glyph_id];
return hb_blob_create_sub_blob (sbix_blob, offset, blob_size (glyph_id));
@ -169,9 +167,7 @@ struct sbix
inline hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id,
unsigned int ptem HB_UNUSED,
unsigned int requested_ppem,
unsigned int requested_file_type,
unsigned int *available_x_ppem,
unsigned int *available_y_ppem) const
unsigned int requested_file_type) const
{
if (unlikely (sbix_len == 0 || sbix_table->strikes.len == 0))
return hb_blob_get_empty ();
@ -185,11 +181,9 @@ struct sbix
break;
const SBIXStrike &strike = sbix_table+sbix_table->strikes[group];
if (available_x_ppem) *available_x_ppem = strike.get_ppem ();
if (available_y_ppem) *available_y_ppem = strike.get_ppem ();
return strike.get_glyph_blob (glyph_id, sbix_blob, sbix_len,
sbix_table->strikes[group],
nullptr, nullptr, requested_file_type, num_glyphs);
requested_file_type, num_glyphs);
}
inline bool has_data () const

View File

@ -272,7 +272,7 @@ hb_ot_color_has_svg (hb_face_t *face)
* @face: a font face.
* @glyph: a svg glyph index.
*
* Returns: respective svg blob of the glyph, if available.
* Returns: (transfer full): respective svg blob of the glyph, if available.
*
* Since: REPLACEME
*/
@ -302,39 +302,31 @@ hb_ot_color_has_png (hb_face_t *face)
}
/**
* hb_ot_color_glyph_reference_blob_svg:
* hb_ot_color_glyph_reference_blob_png:
* @font: a font object, not face. upem should be set on
* that font object if one wants to get optimal png blob, otherwise
* return the biggest one
* @glyph: a glyph index.
* @strike_x_ppem: (out):
* @strike_y_ppem: (out):
*
* Returns: respective png blob of the glyph, if available.
* Returns: (transfer full): respective png blob of the glyph, if available.
*
* Since: REPLACEME
*/
hb_blob_t *
hb_ot_color_glyph_reference_blob_png (hb_font_t *font,
hb_codepoint_t glyph,
unsigned int *strike_x_ppem /* OUT */,
unsigned int *strike_y_ppem /* OUT */)
hb_ot_color_glyph_reference_blob_png (hb_font_t *font, hb_codepoint_t glyph)
{
hb_blob_t *blob = hb_blob_get_empty ();
/* don't run cbdt first if aat is set */
if (!hb_options ().aat && _get_cbdt (font->face).has_data ())
blob = _get_cbdt (font->face).reference_blob_for_glyph (glyph, font->x_ppem, font->y_ppem,
strike_x_ppem, strike_y_ppem);
blob = _get_cbdt (font->face).reference_blob_for_glyph (glyph, font->x_ppem, font->y_ppem);
if (_get_sbix (font->face).has_data () && !hb_blob_get_length (blob))
blob = _get_sbix (font->face).reference_blob_for_glyph (glyph, font->ptem,
MAX (font->x_ppem, font->y_ppem),
HB_TAG('p','n','g',' '),
strike_x_ppem, strike_y_ppem);
HB_TAG('p','n','g',' '));
if (hb_options ().aat && _get_cbdt (font->face).has_data () && !hb_blob_get_length (blob))
blob = _get_cbdt (font->face).reference_blob_for_glyph (glyph, font->x_ppem, font->y_ppem,
strike_x_ppem, strike_y_ppem);
blob = _get_cbdt (font->face).reference_blob_for_glyph (glyph, font->x_ppem, font->y_ppem);
return blob;
}

View File

@ -129,10 +129,7 @@ HB_EXTERN hb_bool_t
hb_ot_color_has_png (hb_face_t *face);
HB_EXTERN hb_blob_t *
hb_ot_color_glyph_reference_blob_png (hb_font_t *font,
hb_codepoint_t glyph,
unsigned int *strike_x_ppem,
unsigned int *strike_y_ppem);
hb_ot_color_glyph_reference_blob_png (hb_font_t *font, hb_codepoint_t glyph);
HB_END_DECLS

View File

@ -407,20 +407,16 @@ test_hb_ot_color_png (void)
hb_blob_t *blob;
unsigned int length;
const char *data;
unsigned int strike_x_ppem, strike_y_ppem;
/* sbix */
hb_font_t *sbix_font;
sbix_font = hb_font_create (sbix);
blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 0, NULL, NULL);
blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 0);
g_assert (hb_blob_get_length (blob) == 0);
blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 1,
&strike_x_ppem, &strike_y_ppem);
blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 1);
data = hb_blob_get_data (blob, &length);
g_assert_cmpuint (length, ==, 224);
g_assert_cmpuint (strike_x_ppem, ==, 300);
g_assert_cmpuint (strike_y_ppem, ==, 300);
g_assert (strncmp (data + 1, "PNG", 3) == 0);
hb_blob_destroy (blob);
hb_font_destroy (sbix_font);
@ -428,15 +424,12 @@ test_hb_ot_color_png (void)
/* cbdt */
hb_font_t *cbdt_font;
cbdt_font = hb_font_create (cbdt);
blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 0, NULL, NULL);
blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 0);
g_assert (hb_blob_get_length (blob) == 0);
blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 1,
&strike_x_ppem, &strike_y_ppem);
blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 1);
data = hb_blob_get_data (blob, &length);
g_assert_cmpuint (length, ==, 88);
g_assert_cmpuint (strike_x_ppem, ==, 80);
g_assert_cmpuint (strike_y_ppem, ==, 80);
g_assert (strncmp (data + 1, "PNG", 3) == 0);
hb_blob_destroy (blob);
hb_font_destroy (cbdt_font);