summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc56
1 files changed, 47 insertions, 9 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc
index c0ce89df3b5..72d3c583618 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc
@@ -36,9 +36,10 @@
#include "hb-ot-head-table.hh"
#include "hb-ot-hhea-table.hh"
#include "hb-ot-hmtx-table.hh"
+#include "hb-ot-kern-table.hh"
#include "hb-ot-os2-table.hh"
-#include "hb-ot-var-hvar-table.hh"
#include "hb-ot-post-table.hh"
+#include "hb-ot-var-hvar-table.hh"
struct hb_ot_face_metrics_accelerator_t
@@ -304,25 +305,24 @@ struct hb_ot_face_cbdt_accelerator_t
struct hb_ot_face_post_accelerator_t
{
hb_blob_t *post_blob;
- unsigned int post_len;
- const OT::post *post;
+ OT::post::accelerator_t accel;
inline void init (hb_face_t *face)
{
- this->post_blob = OT::Sanitizer<OT::post>::sanitize (face->reference_table (HB_OT_TAG_post));
- this->post = OT::Sanitizer<OT::post>::lock_instance (this->post_blob);
- this->post_len = hb_blob_get_length (this->post_blob);
+ hb_blob_t *blob = this->post_blob = OT::Sanitizer<OT::post>::sanitize (face->reference_table (HB_OT_TAG_post));
+ accel.init (OT::Sanitizer<OT::post>::lock_instance (blob), hb_blob_get_length (blob));
}
inline void fini (void)
{
+ accel.fini ();
hb_blob_destroy (this->post_blob);
}
inline bool get_glyph_name (hb_codepoint_t glyph,
char *name, unsigned int size) const
{
- return this->post->get_glyph_name (glyph, name, size, this->post_len);
+ return this->accel.get_glyph_name (glyph, name, size);
}
inline bool get_glyph_from_name (const char *name, int len,
@@ -331,10 +331,31 @@ struct hb_ot_face_post_accelerator_t
if (unlikely (!len))
return false;
- return this->post->get_glyph_from_name (name, len, glyph, this->post_len);
+ return this->accel.get_glyph_from_name (name, len, glyph);
}
};
+struct hb_ot_face_kern_accelerator_t
+{
+ hb_blob_t *kern_blob;
+ OT::kern::accelerator_t accel;
+
+ inline void init (hb_face_t *face)
+ {
+ hb_blob_t *blob = this->kern_blob = OT::Sanitizer<OT::kern>::sanitize (face->reference_table (HB_OT_TAG_kern));
+ accel.init (OT::Sanitizer<OT::kern>::lock_instance (blob), hb_blob_get_length (blob));
+ }
+
+ inline void fini (void)
+ {
+ accel.fini ();
+ hb_blob_destroy (this->kern_blob);
+ }
+
+ inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ { return accel.get_h_kerning (left, right); }
+};
+
typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj,
hb_codepoint_t codepoint,
hb_codepoint_t *glyph);
@@ -471,6 +492,7 @@ struct hb_ot_font_t
OT::hb_lazy_loader_t<hb_ot_face_glyf_accelerator_t> glyf;
OT::hb_lazy_loader_t<hb_ot_face_cbdt_accelerator_t> cbdt;
OT::hb_lazy_loader_t<hb_ot_face_post_accelerator_t> post;
+ OT::hb_lazy_loader_t<hb_ot_face_kern_accelerator_t> kern;
};
@@ -489,6 +511,7 @@ _hb_ot_font_create (hb_face_t *face)
ot_font->glyf.init (face);
ot_font->cbdt.init (face);
ot_font->post.init (face);
+ ot_font->kern.init (face);
return ot_font;
}
@@ -504,6 +527,7 @@ _hb_ot_font_destroy (void *data)
ot_font->glyf.fini ();
ot_font->cbdt.fini ();
ot_font->post.fini ();
+ ot_font->kern.fini ();
free (ot_font);
}
@@ -553,6 +577,17 @@ hb_ot_get_glyph_v_advance (hb_font_t *font,
return font->em_scale_y (-(int) ot_font->v_metrics.get_advance (glyph, font));
}
+static hb_position_t
+hb_ot_get_glyph_h_kerning (hb_font_t *font,
+ void *font_data,
+ hb_codepoint_t left_glyph,
+ hb_codepoint_t right_glyph,
+ void *user_data HB_UNUSED)
+{
+ const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
+ return font->em_scale_x (ot_font->kern->get_h_kerning (left_glyph, right_glyph));
+}
+
static hb_bool_t
hb_ot_get_glyph_extents (hb_font_t *font HB_UNUSED,
void *font_data,
@@ -628,6 +663,7 @@ static hb_font_funcs_t *static_ot_funcs = nullptr;
static
void free_static_ot_funcs (void)
{
+ hb_object_undo_inert (static_ot_funcs);
hb_font_funcs_destroy (static_ot_funcs);
}
#endif
@@ -650,7 +686,7 @@ retry:
hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ot_get_glyph_v_advance, nullptr, nullptr);
//hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ot_get_glyph_h_origin, nullptr, nullptr);
//hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, nullptr, nullptr);
- //hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ot_get_glyph_h_kerning, nullptr, nullptr); TODO
+ hb_font_funcs_set_glyph_h_kerning_func (funcs, hb_ot_get_glyph_h_kerning, nullptr, nullptr);
//hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ot_get_glyph_v_kerning, nullptr, nullptr);
hb_font_funcs_set_glyph_extents_func (funcs, hb_ot_get_glyph_extents, nullptr, nullptr);
//hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ot_get_glyph_contour_point, nullptr, nullptr); TODO
@@ -658,8 +694,10 @@ retry:
hb_font_funcs_set_glyph_from_name_func (funcs, hb_ot_get_glyph_from_name, nullptr, nullptr);
hb_font_funcs_make_immutable (funcs);
+ hb_object_make_inert (funcs);
if (!hb_atomic_ptr_cmpexch (&static_ot_funcs, nullptr, funcs)) {
+ hb_object_undo_inert (funcs);
hb_font_funcs_destroy (funcs);
goto retry;
}