[paint] Use tags for image formats
This fits better with the rest of the HarfBuzz API.
This commit is contained in:
parent
4c728e952b
commit
0a2f3673b9
|
@ -947,7 +947,7 @@ struct CBDT
|
||||||
if (unlikely (!get_extents (font, glyph, &extents)))
|
if (unlikely (!get_extents (font, glyph, &extents)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
funcs->image (data, blob, "image/png", &extents);
|
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents);
|
||||||
|
|
||||||
hb_blob_destroy (blob);
|
hb_blob_destroy (blob);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -248,7 +248,7 @@ struct sbix
|
||||||
if (!get_extents (font, glyph, &extents))
|
if (!get_extents (font, glyph, &extents))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
funcs->image (data, blob, "image/png", &extents);
|
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_PNG, &extents);
|
||||||
|
|
||||||
hb_blob_destroy (blob);
|
hb_blob_destroy (blob);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -103,7 +103,7 @@ struct SVG
|
||||||
if (blob == hb_blob_get_empty ())
|
if (blob == hb_blob_get_empty ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
funcs->image (data, blob, "image/svg+xml", nullptr);
|
funcs->image (data, blob, HB_PAINT_IMAGE_FORMAT_SVG, nullptr);
|
||||||
|
|
||||||
hb_blob_destroy (blob);
|
hb_blob_destroy (blob);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -71,7 +71,7 @@ hb_paint_color_nil (hb_paint_funcs_t *funcs, void *paint_data,
|
||||||
static void
|
static void
|
||||||
hb_paint_image_nil (hb_paint_funcs_t *funcs, void *paint_data,
|
hb_paint_image_nil (hb_paint_funcs_t *funcs, void *paint_data,
|
||||||
hb_blob_t *image,
|
hb_blob_t *image,
|
||||||
const char *mimetype,
|
hb_tag_t format,
|
||||||
hb_glyph_extents_t *extents,
|
hb_glyph_extents_t *extents,
|
||||||
void *user_data) {}
|
void *user_data) {}
|
||||||
|
|
||||||
|
@ -347,10 +347,10 @@ hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
|
||||||
void
|
void
|
||||||
hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
|
hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
|
||||||
hb_blob_t *image,
|
hb_blob_t *image,
|
||||||
const char *mimetype,
|
hb_tag_t format,
|
||||||
hb_glyph_extents_t *extents)
|
hb_glyph_extents_t *extents)
|
||||||
{
|
{
|
||||||
funcs->image (paint_data, image, mimetype, extents);
|
funcs->image (paint_data, image, format, extents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -222,12 +222,26 @@ typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
|
||||||
float alpha,
|
float alpha,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HB_PAINT_IMAGE_FORMAT_PNG:
|
||||||
|
*
|
||||||
|
* Tag identifying png images in #hb_paint_image_func_t callbacks.
|
||||||
|
*/
|
||||||
|
#define HB_PAINT_IMAGE_FORMAT_PNG HB_TAG('p','n','g',' ')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HB_PAINT_IMAGE_FORMAT_SVG:
|
||||||
|
*
|
||||||
|
* Tag identifying svg images in #hb_paint_image_func_t callbacks.
|
||||||
|
*/
|
||||||
|
#define HB_PAINT_IMAGE_FORMAT_SVG HB_TAG('s','v','g',' ')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_paint_image_func_t:
|
* hb_paint_image_func_t:
|
||||||
* @funcs: paint functions object
|
* @funcs: paint functions object
|
||||||
* @paint_data: The data accompanying the paint functions
|
* @paint_data: The data accompanying the paint functions
|
||||||
* @image: the image data
|
* @image: the image data
|
||||||
* @mimetype: the mime type for the image data
|
* @format: the image format as a tag
|
||||||
* @extents: (nullable): glyph extents
|
* @extents: (nullable): glyph extents
|
||||||
* @user_data: user data passed to the hb_font_paint_glyph() call
|
* @user_data: user data passed to the hb_font_paint_glyph() call
|
||||||
*
|
*
|
||||||
|
@ -235,17 +249,19 @@ typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
|
||||||
* glyph image.
|
* glyph image.
|
||||||
*
|
*
|
||||||
* This method is intended for glyphs with image blobs in the CBDT,
|
* This method is intended for glyphs with image blobs in the CBDT,
|
||||||
* sbix or SVG tables. The @mimetype identifies the kind of data
|
* sbix or SVG tables. The @format identifies the kind of data that
|
||||||
* that is contained in @image. Possible values include "image/png"
|
* is contained in @image. Possible values include #HB_PAINT_IMAGE_FORMAT_PNG
|
||||||
* and "image/svg+xml". The glyph extents are provided if available,
|
* and HB_PAINT_IMAGE_FORMAT_SVG.
|
||||||
* and should be used to position the image.
|
*
|
||||||
|
* The glyph extents are provided if available, and should be used
|
||||||
|
* to position the image.
|
||||||
*
|
*
|
||||||
* Since: REPLACEME
|
* Since: REPLACEME
|
||||||
*/
|
*/
|
||||||
typedef void (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs,
|
typedef void (*hb_paint_image_func_t) (hb_paint_funcs_t *funcs,
|
||||||
void *paint_data,
|
void *paint_data,
|
||||||
hb_blob_t *image,
|
hb_blob_t *image,
|
||||||
const char *mimetype,
|
hb_tag_t format,
|
||||||
hb_glyph_extents_t *extents,
|
hb_glyph_extents_t *extents,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
|
@ -693,7 +709,7 @@ hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
|
||||||
HB_EXTERN void
|
HB_EXTERN void
|
||||||
hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
|
hb_paint_image (hb_paint_funcs_t *funcs, void *paint_data,
|
||||||
hb_blob_t *image,
|
hb_blob_t *image,
|
||||||
const char *mimetype,
|
hb_tag_t format,
|
||||||
hb_glyph_extents_t *extents);
|
hb_glyph_extents_t *extents);
|
||||||
|
|
||||||
HB_EXTERN void
|
HB_EXTERN void
|
||||||
|
|
|
@ -97,10 +97,10 @@ struct hb_paint_funcs_t
|
||||||
!user_data ? nullptr : user_data->color); }
|
!user_data ? nullptr : user_data->color); }
|
||||||
void image (void *paint_data,
|
void image (void *paint_data,
|
||||||
hb_blob_t *image,
|
hb_blob_t *image,
|
||||||
const char *mimetype,
|
hb_tag_t format,
|
||||||
hb_glyph_extents_t *extents)
|
hb_glyph_extents_t *extents)
|
||||||
{ func.image (this, paint_data,
|
{ func.image (this, paint_data,
|
||||||
image, mimetype, extents,
|
image, format, extents,
|
||||||
!user_data ? nullptr : user_data->image); }
|
!user_data ? nullptr : user_data->image); }
|
||||||
void linear_gradient (void *paint_data,
|
void linear_gradient (void *paint_data,
|
||||||
hb_color_line_t *color_line,
|
hb_color_line_t *color_line,
|
||||||
|
|
|
@ -325,7 +325,7 @@ static void
|
||||||
paint_image (hb_paint_funcs_t *funcs,
|
paint_image (hb_paint_funcs_t *funcs,
|
||||||
void *paint_data,
|
void *paint_data,
|
||||||
hb_blob_t *blob,
|
hb_blob_t *blob,
|
||||||
const char *mimetype,
|
hb_tag_t format,
|
||||||
hb_glyph_extents_t *extents,
|
hb_glyph_extents_t *extents,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
|
@ -335,7 +335,7 @@ paint_image (hb_paint_funcs_t *funcs,
|
||||||
cairo_pattern_t *pattern;
|
cairo_pattern_t *pattern;
|
||||||
cairo_matrix_t m;
|
cairo_matrix_t m;
|
||||||
|
|
||||||
if (strcmp (mimetype, "image/png") != 0)
|
if (format != HB_PAINT_IMAGE_FORMAT_PNG)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
r.blob = blob;
|
r.blob = blob;
|
||||||
|
|
Loading…
Reference in New Issue