summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/harfbuzz-ng/src/hb-ot-cff2-table.cc
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-03-23 07:45:57 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-04-06 12:55:18 +0100
commit70af64433f491ee28e8b4ff19ebf413d45960155 (patch)
tree46dd5971011d619377ed233469f33c33f303d79e /src/3rdparty/harfbuzz-ng/src/hb-ot-cff2-table.cc
parent29450dfa283bc08f1999ac6dfc5c4956cc9af044 (diff)
Update to Harfbuzz 2.8.0
This updates Harfbuzz to the latest version and also adds an import script to help with this work in the future. Task-number: QTBUG-90217 Pick-to: 6.1 Change-Id: I23eae7b7bbbd5001df9873e4784a0c4213de5508 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-ot-cff2-table.cc')
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-ot-cff2-table.cc73
1 files changed, 71 insertions, 2 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-ot-cff2-table.cc b/src/3rdparty/harfbuzz-ng/src/hb-ot-cff2-table.cc
index a2242b76fb..879b7cdb23 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-ot-cff2-table.cc
+++ b/src/3rdparty/harfbuzz-ng/src/hb-ot-cff2-table.cc
@@ -30,6 +30,7 @@
#include "hb-ot-cff2-table.hh"
#include "hb-cff2-interp-cs.hh"
+#include "hb-draw.hh"
using namespace CFF;
@@ -126,7 +127,7 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
else
{
extents->x_bearing = font->em_scalef_x (param.min_x.to_real ());
- extents->width = font->em_scalef_x (param.max_x.to_real () - param.min_x.to_real ());
+ extents->width = font->em_scalef_x (param.max_x.to_real ()) - extents->x_bearing;
}
if (param.min_y >= param.max_y)
{
@@ -136,11 +137,79 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
else
{
extents->y_bearing = font->em_scalef_y (param.max_y.to_real ());
- extents->height = font->em_scalef_y (param.min_y.to_real () - param.max_y.to_real ());
+ extents->height = font->em_scalef_y (param.min_y.to_real ()) - extents->y_bearing;
}
return true;
}
+#ifdef HB_EXPERIMENTAL_API
+struct cff2_path_param_t
+{
+ cff2_path_param_t (hb_font_t *font_, draw_helper_t &draw_helper_)
+ {
+ draw_helper = &draw_helper_;
+ font = font_;
+ }
+
+ void move_to (const point_t &p)
+ { draw_helper->move_to (font->em_scalef_x (p.x.to_real ()), font->em_scalef_y (p.y.to_real ())); }
+
+ void line_to (const point_t &p)
+ { draw_helper->line_to (font->em_scalef_x (p.x.to_real ()), font->em_scalef_y (p.y.to_real ())); }
+
+ void cubic_to (const point_t &p1, const point_t &p2, const point_t &p3)
+ {
+ draw_helper->cubic_to (font->em_scalef_x (p1.x.to_real ()), font->em_scalef_y (p1.y.to_real ()),
+ font->em_scalef_x (p2.x.to_real ()), font->em_scalef_y (p2.y.to_real ()),
+ font->em_scalef_x (p3.x.to_real ()), font->em_scalef_y (p3.y.to_real ()));
+ }
+
+ protected:
+ draw_helper_t *draw_helper;
+ hb_font_t *font;
+};
+
+struct cff2_path_procs_path_t : path_procs_t<cff2_path_procs_path_t, cff2_cs_interp_env_t, cff2_path_param_t>
+{
+ static void moveto (cff2_cs_interp_env_t &env, cff2_path_param_t& param, const point_t &pt)
+ {
+ param.move_to (pt);
+ env.moveto (pt);
+ }
+
+ static void line (cff2_cs_interp_env_t &env, cff2_path_param_t& param, const point_t &pt1)
+ {
+ param.line_to (pt1);
+ env.moveto (pt1);
+ }
+
+ static void curve (cff2_cs_interp_env_t &env, cff2_path_param_t& param, const point_t &pt1, const point_t &pt2, const point_t &pt3)
+ {
+ param.cubic_to (pt1, pt2, pt3);
+ env.moveto (pt3);
+ }
+};
+
+struct cff2_cs_opset_path_t : cff2_cs_opset_t<cff2_cs_opset_path_t, cff2_path_param_t, cff2_path_procs_path_t> {};
+
+bool OT::cff2::accelerator_t::get_path (hb_font_t *font, hb_codepoint_t glyph, draw_helper_t &draw_helper) const
+{
+#ifdef HB_NO_OT_FONT_CFF
+ /* XXX Remove check when this code moves to .hh file. */
+ return true;
+#endif
+
+ if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false;
+
+ unsigned int fd = fdSelect->get_fd (glyph);
+ cff2_cs_interpreter_t<cff2_cs_opset_path_t, cff2_path_param_t> interp;
+ const byte_str_t str = (*charStrings)[glyph];
+ interp.env.init (str, *this, fd, font->coords, font->num_coords);
+ cff2_path_param_t param (font, draw_helper);
+ if (unlikely (!interp.interpret (param))) return false;
+ return true;
+}
+#endif
#endif