summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2018-09-11 04:13:36 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2018-09-11 04:13:36 +0000
commit683672628fe7bb6a6c5e71735942eb1b5fcae0a6 (patch)
treeb01fc67059d533445d1bc8826f03c5055af389c2 /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc
parentc9d2cebb0c8eac1a2f3f6aac9031c9957cf956aa (diff)
harfbuzz 1.9.0
git-svn-id: svn://tug.org/texlive/trunk@48641 c570f23f-e606-0410-a88d-b1316a301751
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.cc133
1 files changed, 38 insertions, 95 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 9da8fc7d497..a4c5584fbd9 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
@@ -24,84 +24,22 @@
* Google Author(s): Behdad Esfahbod, Roozbeh Pournader
*/
-#include "hb-private.hh"
+#include "hb.hh"
#include "hb-ot.h"
-#include "hb-font-private.hh"
-#include "hb-machinery-private.hh"
+#include "hb-font.hh"
+#include "hb-machinery.hh"
+#include "hb-ot-face.hh"
#include "hb-ot-cmap-table.hh"
-#include "hb-ot-glyf-table.hh"
#include "hb-ot-hmtx-table.hh"
#include "hb-ot-kern-table.hh"
#include "hb-ot-post-table.hh"
-
+#include "hb-ot-glyf-table.hh"
#include "hb-ot-color-cbdt-table.hh"
-struct hb_ot_font_t
-{
- inline void init (hb_face_t *face)
- {
- cmap.init (face);
- h_metrics.init (face);
- v_metrics.init (face, h_metrics.ascender - h_metrics.descender); /* TODO Can we do this lazily? */
-
- this->face = face;
- glyf.init ();
- cbdt.init ();
- post.init ();
- kern.init ();
- }
- inline void fini (void)
- {
- cmap.fini ();
- h_metrics.fini ();
- v_metrics.fini ();
-
- glyf.fini ();
- cbdt.fini ();
- post.fini ();
- kern.fini ();
- }
-
- OT::cmap::accelerator_t cmap;
- OT::hmtx::accelerator_t h_metrics;
- OT::vmtx::accelerator_t v_metrics;
-
- hb_face_t *face; /* MUST be JUST before the lazy loaders. */
- hb_face_lazy_loader_t<1, OT::glyf::accelerator_t> glyf;
- hb_face_lazy_loader_t<2, OT::CBDT::accelerator_t> cbdt;
- hb_face_lazy_loader_t<3, OT::post::accelerator_t> post;
- hb_face_lazy_loader_t<4, OT::kern::accelerator_t> kern;
-};
-
-
-static hb_ot_font_t *
-_hb_ot_font_create (hb_face_t *face)
-{
- hb_ot_font_t *ot_font = (hb_ot_font_t *) calloc (1, sizeof (hb_ot_font_t));
-
- if (unlikely (!ot_font))
- return nullptr;
-
- ot_font->init (face);
-
- return ot_font;
-}
-
-static void
-_hb_ot_font_destroy (void *data)
-{
- hb_ot_font_t *ot_font = (hb_ot_font_t *) data;
-
- ot_font->fini ();
-
- free (ot_font);
-}
-
-
static hb_bool_t
hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED,
void *font_data,
@@ -110,8 +48,8 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
- return ot_font->cmap.get_nominal_glyph (unicode, glyph);
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
+ return ot_font->cmap.get_relaxed()->get_nominal_glyph (unicode, glyph);
}
static hb_bool_t
@@ -122,8 +60,8 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
- return ot_font->cmap.get_variation_glyph (unicode, variation_selector, glyph);
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
+ return ot_font->cmap.get_relaxed ()->get_variation_glyph (unicode, variation_selector, glyph);
}
static hb_position_t
@@ -132,8 +70,8 @@ hb_ot_get_glyph_h_advance (hb_font_t *font,
hb_codepoint_t 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->h_metrics.get_advance (glyph, font));
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
+ return font->em_scale_x (ot_font->hmtx.get_relaxed ()->get_advance (glyph, font));
}
static hb_position_t
@@ -142,8 +80,8 @@ hb_ot_get_glyph_v_advance (hb_font_t *font,
hb_codepoint_t glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
- return font->em_scale_y (-(int) ot_font->v_metrics.get_advance (glyph, font));
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
+ return font->em_scale_y (-(int) ot_font->vmtx.get_relaxed ()->get_advance (glyph, font));
}
static hb_position_t
@@ -153,7 +91,7 @@ hb_ot_get_glyph_h_kerning (hb_font_t *font,
hb_codepoint_t right_glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return font->em_scale_x (ot_font->kern->get_h_kerning (left_glyph, right_glyph));
}
@@ -164,10 +102,10 @@ hb_ot_get_glyph_extents (hb_font_t *font,
hb_glyph_extents_t *extents,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
bool ret = ot_font->glyf->get_extents (glyph, extents);
if (!ret)
- ret = ot_font->cbdt->get_extents (glyph, extents);
+ ret = ot_font->CBDT->get_extents (glyph, extents);
// TODO Hook up side-bearings variations.
extents->x_bearing = font->em_scale_x (extents->x_bearing);
extents->y_bearing = font->em_scale_y (extents->y_bearing);
@@ -183,7 +121,7 @@ hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED,
char *name, unsigned int size,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return ot_font->post->get_glyph_name (glyph, name, size);
}
@@ -194,7 +132,7 @@ hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
return ot_font->post->get_glyph_from_name (name, len, glyph);
}
@@ -204,12 +142,12 @@ hb_ot_get_font_h_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
- metrics->ascender = font->em_scale_y (ot_font->h_metrics.ascender);
- metrics->descender = font->em_scale_y (ot_font->h_metrics.descender);
- metrics->line_gap = font->em_scale_y (ot_font->h_metrics.line_gap);
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
+ metrics->ascender = font->em_scale_y (ot_font->hmtx.get_relaxed ()->ascender);
+ metrics->descender = font->em_scale_y (ot_font->hmtx.get_relaxed ()->descender);
+ metrics->line_gap = font->em_scale_y (ot_font->hmtx.get_relaxed ()->line_gap);
// TODO Hook up variations.
- return ot_font->h_metrics.has_font_extents;
+ return ot_font->hmtx.get_relaxed ()->has_font_extents;
}
static hb_bool_t
@@ -218,16 +156,17 @@ hb_ot_get_font_v_extents (hb_font_t *font,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
- const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data;
- metrics->ascender = font->em_scale_x (ot_font->v_metrics.ascender);
- metrics->descender = font->em_scale_x (ot_font->v_metrics.descender);
- metrics->line_gap = font->em_scale_x (ot_font->v_metrics.line_gap);
+ const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data;
+ metrics->ascender = font->em_scale_x (ot_font->vmtx.get_relaxed ()->ascender);
+ metrics->descender = font->em_scale_x (ot_font->vmtx.get_relaxed ()->descender);
+ metrics->line_gap = font->em_scale_x (ot_font->vmtx.get_relaxed ()->line_gap);
// TODO Hook up variations.
- return ot_font->v_metrics.has_font_extents;
+ return ot_font->vmtx.get_relaxed ()->has_font_extents;
}
-
+#ifdef HB_USE_ATEXIT
static void free_static_ot_funcs (void);
+#endif
static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot_font_funcs_lazy_loader_t>
{
@@ -283,12 +222,16 @@ _hb_ot_get_font_funcs (void)
void
hb_ot_font_set_funcs (hb_font_t *font)
{
- hb_ot_font_t *ot_font = _hb_ot_font_create (font->face);
- if (unlikely (!ot_font))
- return;
+ if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return;
+ hb_ot_face_data_t *ot_font = hb_ot_face_data (font->face);
+
+ /* Load them lazies. We access them with get_relaxed() for performance. */
+ ot_font->cmap.get ();
+ ot_font->hmtx.get ();
+ ot_font->vmtx.get ();
hb_font_set_funcs (font,
_hb_ot_get_font_funcs (),
ot_font,
- _hb_ot_font_destroy);
+ nullptr);
}