mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 06:21:16 +01:00
[COLRv1] Move paint boundedness check to font layer
This way it will apply to fontations and future implementations as well. But this slows down things apparently, specially if the font does use clipboxes. So I'm going to revert.
This commit is contained in:
1 parent
8aa88aa416
commit
c9a26fbf47
3 files changed
+16
-37
No files matched your search
@@ -2695,7 +2695,6 @@ struct COLR
|
||||
{
|
||||
// COLRv1 glyph
|
||||
|
||||
bool is_bounded = true;
|
||||
if (clip)
|
||||
{
|
||||
hb_glyph_extents_t extents;
|
||||
@@ -2710,30 +2709,12 @@ struct COLR
|
||||
extents.y_bearing);
|
||||
}
|
||||
else
|
||||
{
|
||||
clip = false;
|
||||
is_bounded = false;
|
||||
}
|
||||
|
||||
if (!is_bounded)
|
||||
{
|
||||
auto *bounded_funcs = hb_paint_bounded_get_funcs ();
|
||||
scratch.paint_bounded.clear ();
|
||||
|
||||
paint_glyph (font, glyph,
|
||||
bounded_funcs, &scratch.paint_bounded,
|
||||
palette_index, foreground,
|
||||
false,
|
||||
scratch);
|
||||
|
||||
is_bounded = scratch.paint_bounded.is_bounded ();
|
||||
}
|
||||
}
|
||||
|
||||
c.funcs->push_font_transform (c.data, font);
|
||||
|
||||
if (is_bounded)
|
||||
c.recurse (*paint);
|
||||
c.recurse (*paint);
|
||||
|
||||
c.funcs->pop_transform (c.data);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "hb-atomic.hh"
|
||||
#include "hb-shaper.hh"
|
||||
#include "hb-outline.hh"
|
||||
#include "hb-paint-bounded.hh"
|
||||
|
||||
|
||||
/*
|
||||
@@ -524,6 +525,19 @@ struct hb_font_t
|
||||
unsigned int palette,
|
||||
hb_color_t foreground)
|
||||
{
|
||||
/* COLRv1 spec says a glyph must not be painted if the paint graph
|
||||
* draws unbounded. Implement this here such that all font-funcs
|
||||
* benefit, since we have the code. */
|
||||
auto *bounded_funcs = hb_paint_bounded_get_funcs ();
|
||||
hb_paint_bounded_context_t bounded_data;
|
||||
klass->get.f.paint_glyph (this, user_data,
|
||||
glyph,
|
||||
bounded_funcs, &bounded_data,
|
||||
palette, foreground,
|
||||
!klass->user_data ? nullptr : klass->user_data->paint_glyph);
|
||||
if (!bounded_data.is_bounded ())
|
||||
return;
|
||||
|
||||
klass->get.f.paint_glyph (this, user_data,
|
||||
glyph,
|
||||
paint_funcs, paint_data,
|
||||
|
||||
+1
-17
@@ -28,7 +28,6 @@
|
||||
#include "hb.hh"
|
||||
|
||||
#include "hb-decycler.hh"
|
||||
#include "hb-paint-bounded.hh"
|
||||
|
||||
#include FT_COLOR_H
|
||||
|
||||
@@ -513,7 +512,6 @@ hb_ft_paint_glyph_colr (hb_font_t *font,
|
||||
node.visit (gid);
|
||||
|
||||
bool clip = false;
|
||||
bool is_bounded = false;
|
||||
FT_ClipBox clip_box;
|
||||
if (FT_Get_Color_Glyph_ClipBox (ft_face, gid, &clip_box))
|
||||
{
|
||||
@@ -527,25 +525,11 @@ hb_ft_paint_glyph_colr (hb_font_t *font,
|
||||
font->slant_xy * clip_box.top_right.y)),
|
||||
clip_box.top_right.y);
|
||||
clip = true;
|
||||
is_bounded = true;
|
||||
}
|
||||
if (!is_bounded)
|
||||
{
|
||||
auto *bounded_funcs = hb_paint_bounded_get_funcs ();
|
||||
hb_paint_bounded_context_t bounded_data;
|
||||
hb_ft_paint_context_t ce (ft_font, font,
|
||||
bounded_funcs, &bounded_data,
|
||||
palette_array, palette_index, foreground);
|
||||
hb_decycler_node_t node2 (ce.glyphs_decycler);
|
||||
node2.visit (gid);
|
||||
ce.recurse (paint);
|
||||
is_bounded = bounded_data.is_bounded ();
|
||||
}
|
||||
|
||||
c.funcs->push_font_transform (c.data, font);
|
||||
|
||||
if (is_bounded)
|
||||
c.recurse (paint);
|
||||
c.recurse (paint);
|
||||
|
||||
c.funcs->pop_transform (c.data);
|
||||
|
||||
|
||||
Reference in new issue
Block a user