[API] Make hb_font_create() take a face and reference it

This commit is contained in:
Behdad Esfahbod 2011-05-02 20:46:32 -04:00
parent cec6611c5c
commit 72657e4ce7
15 changed files with 70 additions and 79 deletions

View File

@ -83,6 +83,8 @@ struct _hb_face_t {
struct _hb_font_t { struct _hb_font_t {
hb_object_header_t header; hb_object_header_t header;
hb_face_t *face;
unsigned int x_scale; unsigned int x_scale;
unsigned int y_scale; unsigned int y_scale;

View File

@ -43,7 +43,6 @@ HB_BEGIN_DECLS
static hb_codepoint_t static hb_codepoint_t
hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data HB_UNUSED, const void *user_data HB_UNUSED,
hb_codepoint_t unicode HB_UNUSED, hb_codepoint_t unicode HB_UNUSED,
hb_codepoint_t variation_selector HB_UNUSED) hb_codepoint_t variation_selector HB_UNUSED)
@ -51,7 +50,6 @@ hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
static void static void
hb_font_get_glyph_advance_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_advance_nil (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data HB_UNUSED, const void *user_data HB_UNUSED,
hb_codepoint_t glyph HB_UNUSED, hb_codepoint_t glyph HB_UNUSED,
hb_position_t *x_advance HB_UNUSED, hb_position_t *x_advance HB_UNUSED,
@ -60,7 +58,6 @@ hb_font_get_glyph_advance_nil (hb_font_t *font HB_UNUSED,
static void static void
hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED, hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data HB_UNUSED, const void *user_data HB_UNUSED,
hb_codepoint_t glyph HB_UNUSED, hb_codepoint_t glyph HB_UNUSED,
hb_glyph_extents_t *extents HB_UNUSED) hb_glyph_extents_t *extents HB_UNUSED)
@ -68,7 +65,6 @@ hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
static hb_bool_t static hb_bool_t
hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED, hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data HB_UNUSED, const void *user_data HB_UNUSED,
unsigned int point_index HB_UNUSED, unsigned int point_index HB_UNUSED,
hb_codepoint_t glyph HB_UNUSED, hb_codepoint_t glyph HB_UNUSED,
@ -78,7 +74,6 @@ hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED,
static hb_position_t static hb_position_t
hb_font_get_kerning_nil (hb_font_t *font HB_UNUSED, hb_font_get_kerning_nil (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data HB_UNUSED, const void *user_data HB_UNUSED,
hb_codepoint_t first_glyph HB_UNUSED, hb_codepoint_t first_glyph HB_UNUSED,
hb_codepoint_t second_glyph HB_UNUSED) hb_codepoint_t second_glyph HB_UNUSED)
@ -241,48 +236,48 @@ hb_font_funcs_get_kerning_func (hb_font_funcs_t *ffuncs)
hb_codepoint_t hb_codepoint_t
hb_font_get_glyph (hb_font_t *font, hb_face_t *face, hb_font_get_glyph (hb_font_t *font,
hb_codepoint_t unicode, hb_codepoint_t variation_selector) hb_codepoint_t unicode, hb_codepoint_t variation_selector)
{ {
return font->klass->v.get_glyph (font, face, font->user_data, return font->klass->v.get_glyph (font, font->user_data,
unicode, variation_selector); unicode, variation_selector);
} }
void void
hb_font_get_glyph_advance (hb_font_t *font, hb_face_t *face, hb_font_get_glyph_advance (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance) hb_position_t *x_advance, hb_position_t *y_advance)
{ {
*x_advance = *y_advance = 0; *x_advance = *y_advance = 0;
return font->klass->v.get_glyph_advance (font, face, font->user_data, return font->klass->v.get_glyph_advance (font, font->user_data,
glyph, x_advance, y_advance); glyph, x_advance, y_advance);
} }
void void
hb_font_get_glyph_extents (hb_font_t *font, hb_face_t *face, hb_font_get_glyph_extents (hb_font_t *font,
hb_codepoint_t glyph, hb_glyph_extents_t *extents) hb_codepoint_t glyph, hb_glyph_extents_t *extents)
{ {
memset (extents, 0, sizeof (*extents)); memset (extents, 0, sizeof (*extents));
return font->klass->v.get_glyph_extents (font, face, font->user_data, return font->klass->v.get_glyph_extents (font, font->user_data,
glyph, extents); glyph, extents);
} }
hb_bool_t hb_bool_t
hb_font_get_contour_point (hb_font_t *font, hb_face_t *face, hb_font_get_contour_point (hb_font_t *font,
unsigned int point_index, unsigned int point_index,
hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y) hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y)
{ {
*x = 0; *y = 0; *x = 0; *y = 0;
return font->klass->v.get_contour_point (font, face, font->user_data, return font->klass->v.get_contour_point (font, font->user_data,
point_index, point_index,
glyph, x, y); glyph, x, y);
} }
hb_position_t hb_position_t
hb_font_get_kerning (hb_font_t *font, hb_face_t *face, hb_font_get_kerning (hb_font_t *font,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph) hb_codepoint_t first_glyph, hb_codepoint_t second_glyph)
{ {
return font->klass->v.get_kerning (font, face, font->user_data, return font->klass->v.get_kerning (font, font->user_data,
first_glyph, second_glyph); first_glyph, second_glyph);
} }
@ -462,6 +457,8 @@ hb_face_get_upem (hb_face_t *face)
static hb_font_t _hb_font_nil = { static hb_font_t _hb_font_nil = {
HB_OBJECT_HEADER_STATIC, HB_OBJECT_HEADER_STATIC,
&_hb_face_nil,
0, /* x_scale */ 0, /* x_scale */
0, /* y_scale */ 0, /* y_scale */
@ -474,13 +471,18 @@ static hb_font_t _hb_font_nil = {
}; };
hb_font_t * hb_font_t *
hb_font_create (void) hb_font_create (hb_face_t *face)
{ {
hb_font_t *font; hb_font_t *font;
if (unlikely (!face))
face = &_hb_face_nil;
if (unlikely (hb_object_is_inert (face)))
return &_hb_font_nil;
if (!(font = hb_object_create<hb_font_t> ())) if (!(font = hb_object_create<hb_font_t> ()))
return &_hb_font_nil; return &_hb_font_nil;
font->face = hb_face_reference (face);
font->klass = &_hb_font_funcs_nil; font->klass = &_hb_font_funcs_nil;
return font; return font;
@ -497,6 +499,7 @@ hb_font_destroy (hb_font_t *font)
{ {
if (!hb_object_destroy (font)) return; if (!hb_object_destroy (font)) return;
hb_face_destroy (font->face);
hb_font_funcs_destroy (font->klass); hb_font_funcs_destroy (font->klass);
if (font->destroy) if (font->destroy)
font->destroy (font->user_data); font->destroy (font->user_data);
@ -521,6 +524,13 @@ hb_font_get_user_data (hb_font_t *font,
} }
hb_face_t *
hb_font_get_face (hb_font_t *font)
{
return font->face;
}
void void
hb_font_set_funcs (hb_font_t *font, hb_font_set_funcs (hb_font_t *font,
hb_font_funcs_t *klass, hb_font_funcs_t *klass,

View File

@ -121,18 +121,18 @@ typedef struct _hb_glyph_extents_t
hb_position_t height; hb_position_t height;
} hb_glyph_extents_t; } hb_glyph_extents_t;
typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, const void *user_data,
hb_codepoint_t unicode, hb_codepoint_t variation_selector); hb_codepoint_t unicode, hb_codepoint_t variation_selector);
typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, const void *user_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance); hb_position_t *x_advance, hb_position_t *y_advance);
typedef void (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, typedef void (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, const void *user_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_glyph_extents_t *extents); hb_glyph_extents_t *extents);
typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, const void *user_data,
unsigned int point_index, hb_codepoint_t glyph, unsigned int point_index, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y); hb_position_t *x, hb_position_t *y);
typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, const void *user_data,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph); hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
@ -176,26 +176,26 @@ hb_font_funcs_get_kerning_func (hb_font_funcs_t *ffuncs);
hb_codepoint_t hb_codepoint_t
hb_font_get_glyph (hb_font_t *font, hb_face_t *face, hb_font_get_glyph (hb_font_t *font,
hb_codepoint_t unicode, hb_codepoint_t variation_selector); hb_codepoint_t unicode, hb_codepoint_t variation_selector);
void void
hb_font_get_glyph_advance (hb_font_t *font, hb_face_t *face, hb_font_get_glyph_advance (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance); hb_position_t *x_advance, hb_position_t *y_advance);
void void
hb_font_get_glyph_extents (hb_font_t *font, hb_face_t *face, hb_font_get_glyph_extents (hb_font_t *font,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_glyph_extents_t *extents); hb_glyph_extents_t *extents);
hb_bool_t hb_bool_t
hb_font_get_contour_point (hb_font_t *font, hb_face_t *face, hb_font_get_contour_point (hb_font_t *font,
unsigned int point_index, hb_codepoint_t glyph, unsigned int point_index, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y); hb_position_t *x, hb_position_t *y);
hb_position_t hb_position_t
hb_font_get_kerning (hb_font_t *font, hb_face_t *face, hb_font_get_kerning (hb_font_t *font,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph); hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
@ -206,7 +206,7 @@ hb_font_get_kerning (hb_font_t *font, hb_face_t *face,
/* Fonts are very light-weight objects */ /* Fonts are very light-weight objects */
hb_font_t * hb_font_t *
hb_font_create (void); hb_font_create (hb_face_t *face);
hb_font_t * hb_font_t *
hb_font_reference (hb_font_t *font); hb_font_reference (hb_font_t *font);
@ -226,6 +226,10 @@ hb_font_get_user_data (hb_font_t *font,
hb_user_data_key_t *key); hb_user_data_key_t *key);
hb_face_t *
hb_font_get_face (hb_font_t *font);
void void
hb_font_set_funcs (hb_font_t *font, hb_font_set_funcs (hb_font_t *font,
hb_font_funcs_t *klass, hb_font_funcs_t *klass,

View File

@ -38,7 +38,6 @@ HB_BEGIN_DECLS
static hb_codepoint_t static hb_codepoint_t
hb_ft_get_glyph (hb_font_t *font HB_UNUSED, hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data, const void *user_data,
hb_codepoint_t unicode, hb_codepoint_t unicode,
hb_codepoint_t variation_selector) hb_codepoint_t variation_selector)
@ -58,7 +57,6 @@ hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
static void static void
hb_ft_get_glyph_advance (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_advance (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data, const void *user_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *x_advance,
@ -78,7 +76,6 @@ hb_ft_get_glyph_advance (hb_font_t *font HB_UNUSED,
static void static void
hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED, hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data, const void *user_data,
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_glyph_extents_t *extents) hb_glyph_extents_t *extents)
@ -100,7 +97,6 @@ hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED,
static hb_bool_t static hb_bool_t
hb_ft_get_contour_point (hb_font_t *font HB_UNUSED, hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data, const void *user_data,
unsigned int point_index, unsigned int point_index,
hb_codepoint_t glyph, hb_codepoint_t glyph,
@ -129,7 +125,6 @@ hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
static hb_position_t static hb_position_t
hb_ft_get_kerning (hb_font_t *font HB_UNUSED, hb_ft_get_kerning (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data, const void *user_data,
hb_codepoint_t first_glyph, hb_codepoint_t first_glyph,
hb_codepoint_t second_glyph) hb_codepoint_t second_glyph)
@ -244,7 +239,7 @@ hb_ft_font_create (FT_Face ft_face,
{ {
hb_font_t *font; hb_font_t *font;
font = hb_font_create (); font = hb_font_create (hb_ft_face_create_cached (ft_face));
hb_font_set_funcs (font, hb_font_set_funcs (font,
hb_ft_get_font_funcs (), hb_ft_get_font_funcs (),
ft_face, destroy); ft_face, destroy);

View File

@ -121,7 +121,7 @@ struct CaretValueFormat2
inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t direction, hb_codepoint_t glyph_id) const inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t direction, hb_codepoint_t glyph_id) const
{ {
hb_position_t x, y; hb_position_t x, y;
if (hb_font_get_contour_point (c->font, c->face, caretValuePoint, glyph_id, &x, &y)) if (hb_font_get_contour_point (c->font, caretValuePoint, glyph_id, &x, &y))
return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
else else
return 0; return 0;

View File

@ -243,7 +243,7 @@ struct AnchorFormat2
hb_bool_t ret = false; hb_bool_t ret = false;
if (x_ppem || y_ppem) if (x_ppem || y_ppem)
ret = hb_font_get_contour_point (layout->font, layout->face, anchorPoint, glyph_id, &cx, &cy); ret = hb_font_get_contour_point (layout->font, anchorPoint, glyph_id, &cx, &cy);
*x = x_ppem && ret ? cx : layout->scale_x (xCoordinate); *x = x_ppem && ret ? cx : layout->scale_x (xCoordinate);
*y = y_ppem && ret ? cy : layout->scale_y (yCoordinate); *y = y_ppem && ret ? cy : layout->scale_y (yCoordinate);
} }

View File

@ -193,7 +193,6 @@ hb_ot_layout_get_attach_points (hb_face_t *face,
unsigned int unsigned int
hb_ot_layout_get_ligature_carets (hb_font_t *font, hb_ot_layout_get_ligature_carets (hb_font_t *font,
hb_face_t *face,
hb_direction_t direction, hb_direction_t direction,
hb_codepoint_t glyph, hb_codepoint_t glyph,
unsigned int start_offset, unsigned int start_offset,
@ -202,8 +201,8 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font,
{ {
hb_ot_layout_context_t c; hb_ot_layout_context_t c;
c.font = font; c.font = font;
c.face = face; c.face = font->face;
return _get_gdef (face).get_lig_carets (&c, direction, glyph, start_offset, caret_count, caret_array); return _get_gdef (c.face).get_lig_carets (&c, direction, glyph, start_offset, caret_count, caret_array);
} }
/* /*
@ -470,15 +469,14 @@ hb_ot_layout_position_start (hb_buffer_t *buffer)
hb_bool_t hb_bool_t
hb_ot_layout_position_lookup (hb_font_t *font, hb_ot_layout_position_lookup (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
hb_mask_t mask) hb_mask_t mask)
{ {
hb_ot_layout_context_t c; hb_ot_layout_context_t c;
c.font = font; c.font = font;
c.face = face; c.face = font->face;
return _get_gpos (face).position_lookup (&c, buffer, lookup_index, mask); return _get_gpos (c.face).position_lookup (&c, buffer, lookup_index, mask);
} }
void void

View File

@ -59,7 +59,6 @@ hb_ot_layout_get_attach_points (hb_face_t *face,
/* Ligature caret positions */ /* Ligature caret positions */
unsigned int unsigned int
hb_ot_layout_get_ligature_carets (hb_font_t *font, hb_ot_layout_get_ligature_carets (hb_font_t *font,
hb_face_t *face,
hb_direction_t direction, hb_direction_t direction,
hb_codepoint_t glyph, hb_codepoint_t glyph,
unsigned int start_offset, unsigned int start_offset,
@ -185,7 +184,6 @@ hb_ot_layout_position_start (hb_buffer_t *buffer);
hb_bool_t hb_bool_t
hb_ot_layout_position_lookup (hb_font_t *font, hb_ot_layout_position_lookup (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
hb_mask_t mask); hb_mask_t mask);

View File

@ -121,7 +121,7 @@ struct hb_ot_map_t {
inline void position (hb_font_t *font, hb_face_t *face, hb_buffer_t *buffer) const { inline void position (hb_font_t *font, hb_face_t *face, hb_buffer_t *buffer) const {
for (unsigned int i = 0; i < lookup_count[1]; i++) for (unsigned int i = 0; i < lookup_count[1]; i++)
hb_ot_layout_position_lookup (font, face, buffer, lookup_maps[1][i].index, lookup_maps[1][i].mask); hb_ot_layout_position_lookup (font, buffer, lookup_maps[1][i].index, lookup_maps[1][i].mask);
} }
private: private:

View File

@ -29,6 +29,8 @@
#include "hb-ot-shape-private.hh" #include "hb-ot-shape-private.hh"
#include "hb-ot-shape-complex-private.hh" #include "hb-ot-shape-complex-private.hh"
#include "hb-font-private.hh"
HB_BEGIN_DECLS HB_BEGIN_DECLS
@ -209,7 +211,6 @@ hb_mirror_chars (hb_ot_shape_context_t *c)
static void static void
hb_map_glyphs (hb_font_t *font, hb_map_glyphs (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer) hb_buffer_t *buffer)
{ {
if (unlikely (!buffer->len)) if (unlikely (!buffer->len))
@ -219,21 +220,21 @@ hb_map_glyphs (hb_font_t *font,
unsigned int count = buffer->len - 1; unsigned int count = buffer->len - 1;
for (buffer->i = 0; buffer->i < count;) { for (buffer->i = 0; buffer->i < count;) {
if (unlikely (is_variation_selector (buffer->info[buffer->i + 1].codepoint))) { if (unlikely (is_variation_selector (buffer->info[buffer->i + 1].codepoint))) {
buffer->replace_glyph (hb_font_get_glyph (font, face, buffer->info[buffer->i].codepoint, buffer->info[buffer->i + 1].codepoint)); buffer->replace_glyph (hb_font_get_glyph (font, buffer->info[buffer->i].codepoint, buffer->info[buffer->i + 1].codepoint));
buffer->i++; buffer->i++;
} else { } else {
buffer->replace_glyph (hb_font_get_glyph (font, face, buffer->info[buffer->i].codepoint, 0)); buffer->replace_glyph (hb_font_get_glyph (font, buffer->info[buffer->i].codepoint, 0));
} }
} }
if (likely (buffer->i < buffer->len)) if (likely (buffer->i < buffer->len))
buffer->replace_glyph (hb_font_get_glyph (font, face, buffer->info[buffer->i].codepoint, 0)); buffer->replace_glyph (hb_font_get_glyph (font, buffer->info[buffer->i].codepoint, 0));
buffer->swap (); buffer->swap ();
} }
static void static void
hb_substitute_default (hb_ot_shape_context_t *c) hb_substitute_default (hb_ot_shape_context_t *c)
{ {
hb_map_glyphs (c->font, c->face, c->buffer); hb_map_glyphs (c->font, c->buffer);
} }
static void static void
@ -252,7 +253,7 @@ hb_position_default (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len; unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++) { for (unsigned int i = 0; i < count; i++) {
hb_font_get_glyph_advance (c->font, c->face, c->buffer->info[i].codepoint, hb_font_get_glyph_advance (c->font, c->buffer->info[i].codepoint,
&c->buffer->pos[i].x_advance, &c->buffer->pos[i].x_advance,
&c->buffer->pos[i].y_advance); &c->buffer->pos[i].y_advance);
} }
@ -271,7 +272,7 @@ hb_truetype_kern (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len; unsigned int count = c->buffer->len;
for (unsigned int i = 1; i < count; i++) { for (unsigned int i = 1; i < count; i++) {
hb_position_t kern, kern1, kern2; hb_position_t kern, kern1, kern2;
kern = hb_font_get_kerning (c->font, c->face, c->buffer->info[i - 1].codepoint, c->buffer->info[i].codepoint); kern = hb_font_get_kerning (c->font, c->buffer->info[i - 1].codepoint, c->buffer->info[i].codepoint);
kern1 = kern >> 1; kern1 = kern >> 1;
kern2 = kern - kern1; kern2 = kern - kern1;
c->buffer->pos[i - 1].x_advance += kern1; c->buffer->pos[i - 1].x_advance += kern1;
@ -355,26 +356,24 @@ hb_ot_shape_plan_internal (hb_ot_shape_plan_t *plan,
void void
hb_ot_shape_execute (hb_ot_shape_plan_t *plan, hb_ot_shape_execute (hb_ot_shape_plan_t *plan,
hb_font_t *font, hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
const hb_feature_t *user_features, const hb_feature_t *user_features,
unsigned int num_user_features) unsigned int num_user_features)
{ {
hb_ot_shape_context_t c = {plan, font, face, buffer, user_features, num_user_features}; hb_ot_shape_context_t c = {plan, font, font->face, buffer, user_features, num_user_features};
hb_ot_shape_execute_internal (&c); hb_ot_shape_execute_internal (&c);
} }
void void
hb_ot_shape (hb_font_t *font, hb_ot_shape (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
const hb_feature_t *features, const hb_feature_t *features,
unsigned int num_features) unsigned int num_features)
{ {
hb_ot_shape_plan_t plan; hb_ot_shape_plan_t plan;
hb_ot_shape_plan_internal (&plan, face, &buffer->props, features, num_features); hb_ot_shape_plan_internal (&plan, font->face, &buffer->props, features, num_features);
hb_ot_shape_execute (&plan, font, face, buffer, features, num_features); hb_ot_shape_execute (&plan, font, buffer, features, num_features);
} }

View File

@ -35,7 +35,6 @@ HB_BEGIN_DECLS
void void
hb_ot_shape (hb_font_t *font, hb_ot_shape (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
const hb_feature_t *features, const hb_feature_t *features,
unsigned int num_features); unsigned int num_features);

View File

@ -41,29 +41,15 @@ HB_BEGIN_DECLS
static void static void
hb_shape_internal (hb_font_t *font, hb_shape_internal (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
const hb_feature_t *features, const hb_feature_t *features,
unsigned int num_features) unsigned int num_features)
{ {
#if 0 && defined(HAVE_GRAPHITE) hb_ot_shape (font, buffer, features, num_features);
hb_blob_t *silf_blob;
silf_blob = hb_face_reference_table (face, HB_GRAPHITE_TAG_Silf);
if (hb_blob_get_length(silf_blob))
{
hb_graphite_shape(font, face, buffer, features, num_features);
hb_blob_destroy(silf_blob);
return;
}
hb_blob_destroy(silf_blob);
#endif
hb_ot_shape (font, face, buffer, features, num_features);
} }
void void
hb_shape (hb_font_t *font, hb_shape (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
const hb_feature_t *features, const hb_feature_t *features,
unsigned int num_features) unsigned int num_features)
@ -98,7 +84,7 @@ hb_shape (hb_font_t *font,
//buffer->props.language = hb_language_get_default (); //buffer->props.language = hb_language_get_default ();
} }
hb_shape_internal (font, face, buffer, features, num_features); hb_shape_internal (font, buffer, features, num_features);
buffer->props = orig_props; buffer->props = orig_props;
} }

View File

@ -43,7 +43,6 @@ typedef struct _hb_feature_t {
void void
hb_shape (hb_font_t *font, hb_shape (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
const hb_feature_t *features, const hb_feature_t *features,
unsigned int num_features); unsigned int num_features);

View File

@ -344,7 +344,6 @@ _hb_cr_text_glyphs (cairo_t *cr,
{ {
cairo_scaled_font_t *scaled_font = cairo_get_scaled_font (cr); cairo_scaled_font_t *scaled_font = cairo_get_scaled_font (cr);
FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font); FT_Face ft_face = cairo_ft_scaled_font_lock_face (scaled_font);
hb_face_t *hb_face = hb_ft_face_create_cached (ft_face);
hb_font_t *hb_font = hb_ft_font_create (ft_face, NULL); hb_font_t *hb_font = hb_ft_font_create (ft_face, NULL);
hb_buffer_t *hb_buffer; hb_buffer_t *hb_buffer;
cairo_glyph_t *cairo_glyphs; cairo_glyph_t *cairo_glyphs;
@ -366,7 +365,7 @@ _hb_cr_text_glyphs (cairo_t *cr,
len = strlen (text); len = strlen (text);
hb_buffer_add_utf8 (hb_buffer, text, len, 0, len); hb_buffer_add_utf8 (hb_buffer, text, len, 0, len);
hb_shape (hb_font, hb_face, hb_buffer, features, num_features); hb_shape (hb_font, hb_buffer, features, num_features);
num_glyphs = hb_buffer_get_length (hb_buffer); num_glyphs = hb_buffer_get_length (hb_buffer);
hb_glyph = hb_buffer_get_glyph_infos (hb_buffer, NULL); hb_glyph = hb_buffer_get_glyph_infos (hb_buffer, NULL);
@ -386,7 +385,6 @@ _hb_cr_text_glyphs (cairo_t *cr,
cairo_glyphs[i].x = x * (1./64); cairo_glyphs[i].x = x * (1./64);
hb_buffer_destroy (hb_buffer); hb_buffer_destroy (hb_buffer);
hb_font_destroy (hb_font); hb_font_destroy (hb_font);
hb_face_destroy (hb_face);
cairo_ft_scaled_font_unlock_face (scaled_font); cairo_ft_scaled_font_unlock_face (scaled_font);
if (pnum_glyphs) if (pnum_glyphs)

View File

@ -74,12 +74,15 @@ create_face_inert (void)
static void * static void *
create_font (void) create_font (void)
{ {
return hb_font_create (); hb_face_t *face = (hb_face_t *) create_face ();
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
return font;
} }
static void * static void *
create_font_inert (void) create_font_inert (void)
{ {
return NULL; return hb_font_create (create_face_inert ());
} }
static void * static void *