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_table_loader_t<OT::kern> kern;
};
ot_font->glyf.init (face);
ot_font->cbdt.init (face);
ot_font->post.init (face);
+ ot_font->kern.init (face);
return ot_font;
}
ot_font->glyf.fini ();
ot_font->cbdt.fini ();
ot_font->post.fini ();
+ ot_font->kern.fini ();
free (ot_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,
struct KernSubTableFormat2
{
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ {
+ /* XXX */
+ return 0;
+ }
+
inline unsigned int get_size (void) const
{
/* XXX */
struct KernSubTable
{
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int format) const
+ {
+ switch (format) {
+ case 0: return u.format0.get_kerning (left, right);
+ case 2: return u.format2.get_kerning (left, right);
+ default:return 0;
+ }
+ }
+
inline unsigned int get_size (unsigned int format) const
{
switch (format) {
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
inline const T* thiz (void) const { return static_cast<const T *> (this); }
+ inline bool is_horizontal (void) const
+ { return (thiz()->coverage & T::COVERAGE_CHECK_FLAGS) == T::COVERAGE_CHECK_HORIZONTAL; }
+
+ inline bool is_override (void) const
+ { return bool (thiz()->coverage & T::COVERAGE_OVERRIDE_FLAG); }
+
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ { return thiz()->subtable.get_kerning (left, right, thiz()->format); }
+
+ inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ { return is_horizontal () ? get_kerning (left, right) : 0; }
+
inline unsigned int get_size (void) const { return thiz()->length; }
inline bool sanitize (hb_sanitize_context_t *c) const
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
inline const T* thiz (void) const { return static_cast<const T *> (this); }
+ inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ {
+ int v = 0;
+ const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (thiz()->data);
+ unsigned int count = thiz()->nTables;
+ for (unsigned int i = 0; i < count; i++)
+ {
+ if (st->is_override ())
+ v = 0;
+ v += st->get_h_kerning (left, right);
+ st = &StructAfter<typename T::SubTableWrapper> (*st);
+ }
+ return v;
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
{
friend struct KernSubTableWrapper<SubTableWrapper>;
+ enum coverage_flags_t {
+ COVERAGE_DIRECTION_FLAG = 0x01u,
+ COVERAGE_MINIMUM_FLAG = 0x02u,
+ COVERAGE_CROSSSTREAM_FLAG = 0x04u,
+ COVERAGE_OVERRIDE_FLAG = 0x08u,
+
+ COVERAGE_VARIATION_FLAG = 0x00u, /* Not supported. */
+
+ COVERAGE_CHECK_FLAGS = 0x07u,
+ COVERAGE_CHECK_HORIZONTAL = 0x01u
+ };
+
protected:
USHORT versionZ; /* Unused. */
USHORT length; /* Length of the subtable (including this header). */
{
friend struct KernSubTableWrapper<SubTableWrapper>;
+ enum coverage_flags_t {
+ COVERAGE_DIRECTION_FLAG = 0x80u,
+ COVERAGE_CROSSSTREAM_FLAG = 0x40u,
+ COVERAGE_VARIATION_FLAG = 0x20u,
+
+ COVERAGE_OVERRIDE_FLAG = 0x00u, /* Not supported. */
+
+ COVERAGE_CHECK_FLAGS = 0xE0u,
+ COVERAGE_CHECK_HORIZONTAL = 0x00u
+ };
+
protected:
ULONG length; /* Length of the subtable (including this header). */
BYTE coverage; /* Coverage bits. */
{
static const hb_tag_t tableTag = HB_OT_TAG_kern;
- private:
+ inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
+ {
+ switch (u.major) {
+ case 0: return u.ot.get_h_kerning (left, right);
+ case 1: return u.aat.get_h_kerning (left, right);
+ default:return 0;
+ }
+ }
+
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);