#include "hb.hh"
+#ifndef HB_NO_OT_FONT
+
#include "hb-ot.h"
#include "hb-font.hh"
#include "hb-ot-cff1-table.hh"
#include "hb-ot-cff2-table.hh"
#include "hb-ot-hmtx-table.hh"
-#include "hb-ot-kern-table.hh"
#include "hb-ot-os2-table.hh"
#include "hb-ot-post-table.hh"
#include "hb-ot-stat-table.hh" // Just so we compile it; unused otherwise.
*x = font->get_glyph_h_advance (glyph) / 2;
+#ifndef HB_NO_OT_FONT_CFF
const OT::VORG &VORG = *ot_face->VORG;
if (VORG.has_data ())
{
*y = font->em_scale_y (VORG.get_y_origin (glyph));
return true;
}
+#endif
hb_glyph_extents_t extents = {0};
- if (ot_face->glyf->get_extents (glyph, &extents))
+ if (ot_face->glyf->get_extents (font, glyph, &extents))
{
const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
- hb_position_t tsb = vmtx.get_side_bearing (glyph);
- *y = font->em_scale_y (extents.y_bearing + tsb);
+ hb_position_t tsb = vmtx.get_side_bearing (font, glyph);
+ *y = extents.y_bearing + font->em_scale_y (tsb);
return true;
}
void *user_data HB_UNUSED)
{
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
- bool ret = ot_face->sbix->get_extents (font, glyph, extents);
- if (!ret)
- ret = ot_face->glyf->get_extents (glyph, extents);
- if (!ret)
- ret = ot_face->cff1->get_extents (glyph, extents);
- if (!ret)
- ret = ot_face->cff2->get_extents (font, glyph, extents);
- if (!ret)
- ret = ot_face->CBDT->get_extents (font, glyph, extents);
+ bool ret = false;
+
+#if !defined(HB_NO_OT_FONT_BITMAP) && !defined(HB_NO_COLOR)
+ if (!ret) ret = ot_face->sbix->get_extents (font, glyph, extents);
+#endif
+ if (!ret) ret = ot_face->glyf->get_extents (font, glyph, extents);
+#ifndef HB_NO_OT_FONT_CFF
+ if (!ret) ret = ot_face->cff1->get_extents (font, glyph, extents);
+ if (!ret) ret = ot_face->cff2->get_extents (font, glyph, extents);
+#endif
+#if !defined(HB_NO_OT_FONT_BITMAP) && !defined(HB_NO_COLOR)
+ if (!ret) ret = ot_face->CBDT->get_extents (font, glyph, extents);
+#endif
+
// 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);
- extents->width = font->em_scale_x (extents->width);
- extents->height = font->em_scale_y (extents->height);
return ret;
}
+#ifndef HB_NO_OT_FONT_GLYPH_NAMES
static hb_bool_t
hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED,
- void *font_data,
- hb_codepoint_t glyph,
- char *name, unsigned int size,
- void *user_data HB_UNUSED)
+ void *font_data,
+ hb_codepoint_t glyph,
+ char *name, unsigned int size,
+ void *user_data HB_UNUSED)
{
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->post->get_glyph_name (glyph, name, size);
}
-
static hb_bool_t
hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED,
- void *font_data,
- const char *name, int len,
- hb_codepoint_t *glyph,
- void *user_data HB_UNUSED)
+ void *font_data,
+ const char *name, int len,
+ hb_codepoint_t *glyph,
+ void *user_data HB_UNUSED)
{
const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
return ot_face->post->get_glyph_from_name (name, len, glyph);
}
+#endif
static hb_bool_t
hb_ot_get_font_h_extents (hb_font_t *font,
- void *font_data,
+ void *font_data HB_UNUSED,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
- const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
- const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx;
- metrics->ascender = font->em_scale_y (hmtx.ascender);
- metrics->descender = font->em_scale_y (hmtx.descender);
- metrics->line_gap = font->em_scale_y (hmtx.line_gap);
- // TODO Hook up variations.
- return hmtx.has_font_extents;
+ return _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER, &metrics->ascender) &&
+ _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_HORIZONTAL_DESCENDER, &metrics->descender) &&
+ _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_HORIZONTAL_LINE_GAP, &metrics->line_gap);
}
static hb_bool_t
hb_ot_get_font_v_extents (hb_font_t *font,
- void *font_data,
+ void *font_data HB_UNUSED,
hb_font_extents_t *metrics,
void *user_data HB_UNUSED)
{
- const hb_ot_face_t *ot_face = (const hb_ot_face_t *) font_data;
- const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx;
- metrics->ascender = font->em_scale_x (vmtx.ascender);
- metrics->descender = font->em_scale_x (vmtx.descender);
- metrics->line_gap = font->em_scale_x (vmtx.line_gap);
- // TODO Hook up variations.
- return vmtx.has_font_extents;
+ return _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_VERTICAL_ASCENDER, &metrics->ascender) &&
+ _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_VERTICAL_DESCENDER, &metrics->descender) &&
+ _hb_ot_metrics_get_position_common (font, HB_OT_METRICS_TAG_VERTICAL_LINE_GAP, &metrics->line_gap);
}
#if HB_USE_ATEXIT
hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, 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);
+#ifndef HB_NO_OT_FONT_GLYPH_NAMES
hb_font_funcs_set_glyph_name_func (funcs, hb_ot_get_glyph_name, nullptr, nullptr);
hb_font_funcs_set_glyph_from_name_func (funcs, hb_ot_get_glyph_from_name, nullptr, nullptr);
+#endif
hb_font_funcs_make_immutable (funcs);
&font->face->table,
nullptr);
}
+
+#ifndef HB_NO_VAR
+int
+_glyf_get_side_bearing_var (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical)
+{
+ return font->face->table.glyf->get_side_bearing_var (font, glyph, is_vertical);
+}
+
+unsigned
+_glyf_get_advance_var (hb_font_t *font, hb_codepoint_t glyph, bool is_vertical)
+{
+ return font->face->table.glyf->get_advance_var (font, glyph, is_vertical);
+}
+#endif
+
+
+#endif