- cmap14 support in get_glyph callback
- Use size_t in sanitize?
- Buffer error handling?
+- Better define HB_INTERNAL
hb-ot:
- Fix ot query APIs
hb_bool_t immutable;
- hb_font_get_glyph_func_t glyph_func;
- hb_font_get_contour_point_func_t contour_point_func;
- hb_font_get_glyph_metrics_func_t glyph_metrics_func;
- hb_font_get_kerning_func_t kerning_func;
+ hb_font_get_glyph_func_t get_glyph;
+ hb_font_get_contour_point_func_t get_contour_point;
+ hb_font_get_glyph_metrics_func_t get_glyph_metrics;
+ hb_font_get_kerning_func_t get_kerning;
};
HB_INTERNAL hb_font_funcs_t
#include "hb-ot-layout-private.h"
+#include <string.h>
+
+
/*
* hb_font_funcs_t
*/
+static hb_codepoint_t
+hb_font_get_glyph_nil (hb_font_t *font, hb_face_t *face, const void *user_data,
+ hb_codepoint_t unicode, hb_codepoint_t variant_selector)
+{ return unicode; }
+
+static hb_bool_t
+hb_font_get_contour_point_nil (hb_font_t *font, hb_face_t *face, const void *user_data,
+ unsigned int point_index,
+ hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y)
+{ return false; }
+
+static void
+hb_font_get_glyph_metrics_nil (hb_font_t *font, hb_face_t *face, const void *user_data,
+ hb_codepoint_t glyph, hb_glyph_metrics_t *metrics)
+{ memset (metrics, 0, sizeof (*metrics)); }
+
+static hb_position_t
+hb_font_get_kerning_nil (hb_font_t *font, hb_face_t *face, const void *user_data,
+ hb_codepoint_t first_glyph, hb_codepoint_t second_glyph)
+{ return 0; }
+
hb_font_funcs_t _hb_font_funcs_nil = {
HB_REFERENCE_COUNT_INVALID, /* ref_count */
TRUE, /* immutable */
- NULL, /* glyph_func */
- NULL, /* contour_point_func */
- NULL, /* glyph_metrics_func */
- NULL /* kerning_func */
+ hb_font_get_glyph_nil,
+ hb_font_get_contour_point_nil,
+ hb_font_get_glyph_metrics_nil,
+ hb_font_get_kerning_nil
};
hb_font_funcs_t *
}
+void
+hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
+ hb_font_get_glyph_func_t glyph_func)
+{
+ if (ffuncs->immutable)
+ return;
+
+ ffuncs->get_glyph = glyph_func ? glyph_func : hb_font_get_glyph_nil;
+}
+
+void
+hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
+ hb_font_get_contour_point_func_t contour_point_func)
+{
+ if (ffuncs->immutable)
+ return;
+
+ ffuncs->get_contour_point = contour_point_func ? contour_point_func : hb_font_get_contour_point_nil;
+}
+
+void
+hb_font_funcs_set_glyph_metrics_func (hb_font_funcs_t *ffuncs,
+ hb_font_get_glyph_metrics_func_t glyph_metrics_func)
+{
+ if (ffuncs->immutable)
+ return;
+
+ ffuncs->get_glyph_metrics = glyph_metrics_func ? glyph_metrics_func : hb_font_get_glyph_metrics_nil;
+}
+
+void
+hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
+ hb_font_get_kerning_func_t kerning_func)
+{
+ if (ffuncs->immutable)
+ return;
+
+ ffuncs->get_kerning = kerning_func ? kerning_func : hb_font_get_kerning_nil;
+}
+
/*
* hb_face_t
/* funcs */
-typedef struct _hb_glyph_metrics_t hb_glyph_metrics_t;
-struct _hb_glyph_metrics_t
+typedef struct _hb_glyph_metrics_t
{
+ hb_position_t x_pos;
+ hb_position_t y_pos;
hb_position_t x_advance;
hb_position_t y_advance;
- hb_position_t x_offset;
- hb_position_t y_offset;
hb_position_t width;
hb_position_t height;
-};
+} hb_glyph_metrics_t;
typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
hb_codepoint_t unicode, hb_codepoint_t variant_selector);
inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
- /* TODO Contour */
+ /* TODO Contour
+ * NOTE only adjust directions with nonzero ppem */
*x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate);
*y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate);
}
if (buffer->direction == HB_DIRECTION_RTL)
{
POSITION (buffer->in_pos)->x_advance = entry_x - gpi->anchor_x;
- POSITION (buffer->in_pos)->new_advance = TRUE;
+ POSITION (buffer->in_pos)->new_advance = true;
}
else
{
POSITION (last_pos)->x_advance = gpi->anchor_x - entry_x;
- POSITION (last_pos)->new_advance = TRUE;
+ POSITION (last_pos)->new_advance = true;
}
if (lookup_flag & LookupFlag::RightToLeft)
}
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
- is_mark = FALSE;
+ is_mark = false;
if (HB_LIKELY (IN_GLYPH (j) != component[i]))
return false;
ASSERT_STATIC (sizeof (_type) == (_size) + VAR * sizeof (_var_type1) + VAR * sizeof (_var_type2))
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
-#define _HB_BOOLEAN_EXPR(expr) \
- __extension__ ({ \
- int _cairo_boolean_var_; \
- if (expr) \
- _cairo_boolean_var_ = 1; \
- else \
- _cairo_boolean_var_ = 0; \
- _cairo_boolean_var_; \
-})
+#define _HB_BOOLEAN_EXPR(expr) \
+ __extension__ ({ \
+ int _hb_boolean_var_; \
+ if (expr) \
+ _hb_boolean_var_ = 1; \
+ else \
+ _hb_boolean_var_ = 0; \
+ _hb_boolean_var_; \
+ })
#define HB_LIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1))
#define HB_UNLIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0))
#else