[ot-color] Apply Behdad reviews
This commit is contained in:
parent
8ef0d2ef92
commit
3d4c1f6a41
|
@ -459,8 +459,8 @@ hb_color_get_blue
|
||||||
hb_color_get_green
|
hb_color_get_green
|
||||||
hb_color_get_red
|
hb_color_get_red
|
||||||
hb_ot_color_glyph_get_layers
|
hb_ot_color_glyph_get_layers
|
||||||
hb_ot_color_glyph_reference_blob_png
|
hb_ot_color_glyph_reference_png
|
||||||
hb_ot_color_glyph_reference_blob_svg
|
hb_ot_color_glyph_reference_svg
|
||||||
hb_ot_color_has_layers
|
hb_ot_color_has_layers
|
||||||
hb_ot_color_has_palettes
|
hb_ot_color_has_palettes
|
||||||
hb_ot_color_has_png
|
hb_ot_color_has_png
|
||||||
|
|
|
@ -505,15 +505,14 @@ struct CBDT
|
||||||
}
|
}
|
||||||
|
|
||||||
inline hb_blob_t* reference_blob_for_glyph (hb_codepoint_t glyph_id,
|
inline hb_blob_t* reference_blob_for_glyph (hb_codepoint_t glyph_id,
|
||||||
unsigned int requested_x_ppem,
|
unsigned int x_ppem,
|
||||||
unsigned int requested_y_ppem) const
|
unsigned int y_ppem) const
|
||||||
{
|
{
|
||||||
if (!cblc)
|
if (!cblc)
|
||||||
return hb_blob_get_empty (); // Not a color bitmap font.
|
return hb_blob_get_empty (); // Not a color bitmap font.
|
||||||
|
|
||||||
if (requested_x_ppem == 0) requested_x_ppem = upem;
|
if (x_ppem == 0) x_ppem = upem;
|
||||||
if (requested_y_ppem == 0) requested_y_ppem = upem;
|
if (y_ppem == 0) y_ppem = upem;
|
||||||
unsigned int x_ppem = requested_x_ppem, y_ppem = requested_y_ppem;
|
|
||||||
|
|
||||||
const void *base;
|
const void *base;
|
||||||
const IndexSubtableRecord *subtable_record = this->cblc->find_table (glyph_id, &x_ppem, &y_ppem, &base);
|
const IndexSubtableRecord *subtable_record = this->cblc->find_table (glyph_id, &x_ppem, &y_ppem, &base);
|
||||||
|
@ -527,8 +526,6 @@ struct CBDT
|
||||||
switch (image_format)
|
switch (image_format)
|
||||||
{
|
{
|
||||||
case 17: {
|
case 17: {
|
||||||
// if (strike_x_ppem) *strike_x_ppem = x_ppem;
|
|
||||||
// if (strike_x_ppem) *strike_y_ppem = y_ppem;
|
|
||||||
const GlyphBitmapDataFormat17& glyphFormat17 =
|
const GlyphBitmapDataFormat17& glyphFormat17 =
|
||||||
StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
|
StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
|
||||||
return hb_blob_create_sub_blob (cbdt_blob,
|
return hb_blob_create_sub_blob (cbdt_blob,
|
||||||
|
@ -536,8 +533,6 @@ struct CBDT
|
||||||
glyphFormat17.data.len);
|
glyphFormat17.data.len);
|
||||||
}
|
}
|
||||||
case 18: {
|
case 18: {
|
||||||
// if (strike_x_ppem) *strike_x_ppem = x_ppem;
|
|
||||||
// if (strike_x_ppem) *strike_y_ppem = y_ppem;
|
|
||||||
const GlyphBitmapDataFormat18& glyphFormat18 =
|
const GlyphBitmapDataFormat18& glyphFormat18 =
|
||||||
StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
|
StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
|
||||||
return hb_blob_create_sub_blob (cbdt_blob,
|
return hb_blob_create_sub_blob (cbdt_blob,
|
||||||
|
@ -545,8 +540,6 @@ struct CBDT
|
||||||
glyphFormat18.data.len);
|
glyphFormat18.data.len);
|
||||||
}
|
}
|
||||||
case 19: {
|
case 19: {
|
||||||
// if (strike_x_ppem) *strike_x_ppem = x_ppem;
|
|
||||||
// if (strike_x_ppem) *strike_y_ppem = y_ppem;
|
|
||||||
const GlyphBitmapDataFormat19& glyphFormat19 =
|
const GlyphBitmapDataFormat19& glyphFormat19 =
|
||||||
StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset);
|
StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset);
|
||||||
return hb_blob_create_sub_blob (cbdt_blob,
|
return hb_blob_create_sub_blob (cbdt_blob,
|
||||||
|
|
|
@ -84,7 +84,7 @@ struct SBIXStrike
|
||||||
hb_blob_t *sbix_blob,
|
hb_blob_t *sbix_blob,
|
||||||
unsigned int sbix_len,
|
unsigned int sbix_len,
|
||||||
unsigned int strike_offset,
|
unsigned int strike_offset,
|
||||||
hb_tag_t requested_file_type,
|
hb_tag_t file_type,
|
||||||
unsigned int num_glyphs) const
|
unsigned int num_glyphs) const
|
||||||
{
|
{
|
||||||
if (imageOffsetsZ[glyph_id + 1] - imageOffsetsZ[glyph_id] == 0)
|
if (imageOffsetsZ[glyph_id + 1] - imageOffsetsZ[glyph_id] == 0)
|
||||||
|
@ -106,10 +106,8 @@ struct SBIXStrike
|
||||||
return hb_blob_get_empty ();
|
return hb_blob_get_empty ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unlikely (requested_file_type != glyph->graphicType))
|
if (unlikely (file_type != glyph->graphicType))
|
||||||
return hb_blob_get_empty ();
|
return hb_blob_get_empty ();
|
||||||
// if (x_offset) *x_offset = glyph->xOffset;
|
|
||||||
// if (y_offset) *y_offset = glyph->yOffset;
|
|
||||||
unsigned int offset = strike_offset + SBIXGlyph::min_size;
|
unsigned int offset = strike_offset + SBIXGlyph::min_size;
|
||||||
offset += imageOffsetsZ[glyph_id];
|
offset += imageOffsetsZ[glyph_id];
|
||||||
return hb_blob_create_sub_blob (sbix_blob, offset, blob_size (glyph_id));
|
return hb_blob_create_sub_blob (sbix_blob, offset, blob_size (glyph_id));
|
||||||
|
|
|
@ -268,7 +268,7 @@ hb_ot_color_has_svg (hb_face_t *face)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_ot_color_glyph_reference_blob_svg:
|
* hb_ot_color_glyph_reference_svg:
|
||||||
* @face: a font face.
|
* @face: a font face.
|
||||||
* @glyph: a svg glyph index.
|
* @glyph: a svg glyph index.
|
||||||
*
|
*
|
||||||
|
@ -277,7 +277,7 @@ hb_ot_color_has_svg (hb_face_t *face)
|
||||||
* Since: REPLACEME
|
* Since: REPLACEME
|
||||||
*/
|
*/
|
||||||
hb_blob_t *
|
hb_blob_t *
|
||||||
hb_ot_color_glyph_reference_blob_svg (hb_face_t *face, hb_codepoint_t glyph)
|
hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph)
|
||||||
{
|
{
|
||||||
return _get_svg (face).reference_blob_for_glyph (glyph);
|
return _get_svg (face).reference_blob_for_glyph (glyph);
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ hb_ot_color_has_png (hb_face_t *face)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_ot_color_glyph_reference_blob_png:
|
* hb_ot_color_glyph_reference_png:
|
||||||
* @font: a font object, not face. upem should be set on
|
* @font: a font object, not face. upem should be set on
|
||||||
* that font object if one wants to get optimal png blob, otherwise
|
* that font object if one wants to get optimal png blob, otherwise
|
||||||
* return the biggest one
|
* return the biggest one
|
||||||
|
@ -313,7 +313,7 @@ hb_ot_color_has_png (hb_face_t *face)
|
||||||
* Since: REPLACEME
|
* Since: REPLACEME
|
||||||
*/
|
*/
|
||||||
hb_blob_t *
|
hb_blob_t *
|
||||||
hb_ot_color_glyph_reference_blob_png (hb_font_t *font, hb_codepoint_t glyph)
|
hb_ot_color_glyph_reference_png (hb_font_t *font, hb_codepoint_t glyph)
|
||||||
{
|
{
|
||||||
hb_blob_t *blob = hb_blob_get_empty ();
|
hb_blob_t *blob = hb_blob_get_empty ();
|
||||||
/* don't run cbdt first if aat is set */
|
/* don't run cbdt first if aat is set */
|
||||||
|
|
|
@ -119,7 +119,7 @@ HB_EXTERN hb_bool_t
|
||||||
hb_ot_color_has_svg (hb_face_t *face);
|
hb_ot_color_has_svg (hb_face_t *face);
|
||||||
|
|
||||||
HB_EXTERN hb_blob_t *
|
HB_EXTERN hb_blob_t *
|
||||||
hb_ot_color_glyph_reference_blob_svg (hb_face_t *face, hb_codepoint_t glyph);
|
hb_ot_color_glyph_reference_svg (hb_face_t *face, hb_codepoint_t glyph);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PNG: CBDT or sbix
|
* PNG: CBDT or sbix
|
||||||
|
@ -129,7 +129,7 @@ HB_EXTERN hb_bool_t
|
||||||
hb_ot_color_has_png (hb_face_t *face);
|
hb_ot_color_has_png (hb_face_t *face);
|
||||||
|
|
||||||
HB_EXTERN hb_blob_t *
|
HB_EXTERN hb_blob_t *
|
||||||
hb_ot_color_glyph_reference_blob_png (hb_font_t *font, hb_codepoint_t glyph);
|
hb_ot_color_glyph_reference_png (hb_font_t *font, hb_codepoint_t glyph);
|
||||||
|
|
||||||
|
|
||||||
HB_END_DECLS
|
HB_END_DECLS
|
||||||
|
|
|
@ -385,10 +385,10 @@ test_hb_ot_color_svg (void)
|
||||||
{
|
{
|
||||||
hb_blob_t *blob;
|
hb_blob_t *blob;
|
||||||
|
|
||||||
blob = hb_ot_color_glyph_reference_blob_svg (svg, 0);
|
blob = hb_ot_color_glyph_reference_svg (svg, 0);
|
||||||
g_assert (hb_blob_get_length (blob) == 0);
|
g_assert (hb_blob_get_length (blob) == 0);
|
||||||
|
|
||||||
blob = hb_ot_color_glyph_reference_blob_svg (svg, 1);
|
blob = hb_ot_color_glyph_reference_svg (svg, 1);
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
const char *data = hb_blob_get_data (blob, &length);
|
const char *data = hb_blob_get_data (blob, &length);
|
||||||
g_assert_cmpuint (length, ==, 146);
|
g_assert_cmpuint (length, ==, 146);
|
||||||
|
@ -396,7 +396,7 @@ test_hb_ot_color_svg (void)
|
||||||
g_assert (strncmp (data + 140, "</svg>", 5) == 0);
|
g_assert (strncmp (data + 140, "</svg>", 5) == 0);
|
||||||
hb_blob_destroy (blob);
|
hb_blob_destroy (blob);
|
||||||
|
|
||||||
blob = hb_ot_color_glyph_reference_blob_svg (empty, 0);
|
blob = hb_ot_color_glyph_reference_svg (empty, 0);
|
||||||
g_assert (hb_blob_get_length (blob) == 0);
|
g_assert (hb_blob_get_length (blob) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,10 +411,10 @@ test_hb_ot_color_png (void)
|
||||||
/* sbix */
|
/* sbix */
|
||||||
hb_font_t *sbix_font;
|
hb_font_t *sbix_font;
|
||||||
sbix_font = hb_font_create (sbix);
|
sbix_font = hb_font_create (sbix);
|
||||||
blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 0);
|
blob = hb_ot_color_glyph_reference_png (sbix_font, 0);
|
||||||
g_assert (hb_blob_get_length (blob) == 0);
|
g_assert (hb_blob_get_length (blob) == 0);
|
||||||
|
|
||||||
blob = hb_ot_color_glyph_reference_blob_png (sbix_font, 1);
|
blob = hb_ot_color_glyph_reference_png (sbix_font, 1);
|
||||||
data = hb_blob_get_data (blob, &length);
|
data = hb_blob_get_data (blob, &length);
|
||||||
g_assert_cmpuint (length, ==, 224);
|
g_assert_cmpuint (length, ==, 224);
|
||||||
g_assert (strncmp (data + 1, "PNG", 3) == 0);
|
g_assert (strncmp (data + 1, "PNG", 3) == 0);
|
||||||
|
@ -424,10 +424,10 @@ test_hb_ot_color_png (void)
|
||||||
/* cbdt */
|
/* cbdt */
|
||||||
hb_font_t *cbdt_font;
|
hb_font_t *cbdt_font;
|
||||||
cbdt_font = hb_font_create (cbdt);
|
cbdt_font = hb_font_create (cbdt);
|
||||||
blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 0);
|
blob = hb_ot_color_glyph_reference_png (cbdt_font, 0);
|
||||||
g_assert (hb_blob_get_length (blob) == 0);
|
g_assert (hb_blob_get_length (blob) == 0);
|
||||||
|
|
||||||
blob = hb_ot_color_glyph_reference_blob_png (cbdt_font, 1);
|
blob = hb_ot_color_glyph_reference_png (cbdt_font, 1);
|
||||||
data = hb_blob_get_data (blob, &length);
|
data = hb_blob_get_data (blob, &length);
|
||||||
g_assert_cmpuint (length, ==, 88);
|
g_assert_cmpuint (length, ==, 88);
|
||||||
g_assert (strncmp (data + 1, "PNG", 3) == 0);
|
g_assert (strncmp (data + 1, "PNG", 3) == 0);
|
||||||
|
|
Loading…
Reference in New Issue