glyf: Implement paint_glyph

This commit is contained in:
Matthias Clasen 2022-12-16 23:32:15 -05:00 committed by Behdad Esfahbod
parent 0b33b35eb0
commit 2edd771cf5
1 changed files with 22 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include "SubsetGlyph.hh" #include "SubsetGlyph.hh"
#include "loca.hh" #include "loca.hh"
#include "path-builder.hh" #include "path-builder.hh"
#include "hb-paint.hh"
namespace OT { namespace OT {
@ -332,6 +333,27 @@ struct glyf_accelerator_t
return glyph_for_gid (gid).get_extents_without_var_scaled (font, *this, extents); return glyph_for_gid (gid).get_extents_without_var_scaled (font, *this, extents);
} }
bool paint_glyph (hb_font_t *font, hb_codepoint_t gid, hb_paint_funcs_t *funcs, void *data) const
{
int xscale, yscale;
unsigned int upem;
hb_font_get_scale (font, &xscale, &yscale);
upem = hb_face_get_upem (hb_font_get_face (font));
funcs->push_transform (data, xscale/(float)upem, 0,
0, yscale/(float)upem,
0, 0);
funcs->push_clip_glyph (data, gid);
funcs->color (data, 0xffff, 1.);
funcs->pop_clip (data);
funcs->pop_transform (data);
return false;
}
const glyf_impl::Glyph const glyf_impl::Glyph
glyph_for_gid (hb_codepoint_t gid, bool needs_padding_removal = false) const glyph_for_gid (hb_codepoint_t gid, bool needs_padding_removal = false) const
{ {