提交 502f4cba 编写于 作者: B Behdad Esfahbod

Divide get_metrics into get_advance and get_extents

Graphite module not updated.
Bump version to 0.3.
上级 ec6c0e54
AC_PREREQ(2.59)
AC_INIT(harfbuzz, 0.2, [http://bugs.freedesktop.org/enter_bug.cgi?product=harfbuzz])
AC_INIT(harfbuzz, 0.3, [http://bugs.freedesktop.org/enter_bug.cgi?product=harfbuzz])
AC_CONFIG_SRCDIR([harfbuzz.pc.in])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.9.6 gnu dist-bzip2 no-dist-gzip -Wall no-define])
......
......@@ -45,8 +45,9 @@ struct _hb_font_funcs_t {
struct {
hb_font_get_glyph_func_t get_glyph;
hb_font_get_glyph_advance_func_t get_glyph_advance;
hb_font_get_glyph_extents_func_t get_glyph_extents;
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;
} v;
};
......
......@@ -49,24 +49,33 @@ hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
hb_codepoint_t variation_selector HB_UNUSED)
{ return 0; }
static hb_bool_t
hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED,
static void
hb_font_get_glyph_advance_nil (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data HB_UNUSED,
unsigned int point_index HB_UNUSED,
hb_codepoint_t glyph HB_UNUSED,
hb_position_t *x HB_UNUSED,
hb_position_t *y HB_UNUSED)
{ return false; }
hb_position_t *x_advance HB_UNUSED,
hb_position_t *y_advance HB_UNUSED)
{ }
static void
hb_font_get_glyph_metrics_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,
hb_codepoint_t glyph HB_UNUSED,
hb_glyph_metrics_t *metrics HB_UNUSED)
hb_glyph_extents_t *extents HB_UNUSED)
{ }
static hb_bool_t
hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data HB_UNUSED,
unsigned int point_index HB_UNUSED,
hb_codepoint_t glyph HB_UNUSED,
hb_position_t *x HB_UNUSED,
hb_position_t *y HB_UNUSED)
{ return false; }
static hb_position_t
hb_font_get_kerning_nil (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
......@@ -80,8 +89,9 @@ hb_font_funcs_t _hb_font_funcs_nil = {
TRUE, /* immutable */
{
hb_font_get_glyph_nil,
hb_font_get_glyph_advance_nil,
hb_font_get_glyph_extents_nil,
hb_font_get_contour_point_nil,
hb_font_get_glyph_metrics_nil,
hb_font_get_kerning_nil
}
};
......@@ -159,23 +169,33 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
}
void
hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
hb_font_get_contour_point_func_t contour_point_func)
hb_font_funcs_set_glyph_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_advance_func_t glyph_advance_func)
{
if (ffuncs->immutable)
return;
ffuncs->v.get_contour_point = contour_point_func ? contour_point_func : hb_font_get_contour_point_nil;
ffuncs->v.get_glyph_advance = glyph_advance_func ? glyph_advance_func : hb_font_get_glyph_advance_nil;
}
void
hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_extents_func_t glyph_extents_func)
{
if (ffuncs->immutable)
return;
ffuncs->v.get_glyph_extents = glyph_extents_func ? glyph_extents_func : hb_font_get_glyph_extents_nil;
}
void
hb_font_funcs_set_glyph_metrics_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_metrics_func_t glyph_metrics_func)
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->v.get_glyph_metrics = glyph_metrics_func ? glyph_metrics_func : hb_font_get_glyph_metrics_nil;
ffuncs->v.get_contour_point = contour_point_func ? contour_point_func : hb_font_get_contour_point_nil;
}
void
......@@ -195,16 +215,22 @@ hb_font_funcs_get_glyph_func (hb_font_funcs_t *ffuncs)
return ffuncs->v.get_glyph;
}
hb_font_get_contour_point_func_t
hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs)
hb_font_get_glyph_advance_func_t
hb_font_funcs_get_glyph_advance_func (hb_font_funcs_t *ffuncs)
{
return ffuncs->v.get_contour_point;
return ffuncs->v.get_glyph_advance;
}
hb_font_get_glyph_extents_func_t
hb_font_funcs_get_glyph_extents_func (hb_font_funcs_t *ffuncs)
{
return ffuncs->v.get_glyph_extents;
}
hb_font_get_glyph_metrics_func_t
hb_font_funcs_get_glyph_metrics_func (hb_font_funcs_t *ffuncs)
hb_font_get_contour_point_func_t
hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs)
{
return ffuncs->v.get_glyph_metrics;
return ffuncs->v.get_contour_point;
}
hb_font_get_kerning_func_t
......@@ -223,6 +249,25 @@ hb_font_get_glyph (hb_font_t *font, hb_face_t *face,
unicode, variation_selector);
}
void
hb_font_get_glyph_advance (hb_font_t *font, hb_face_t *face,
hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance)
{
*x_advance = *y_advance = 0;
return font->klass->v.get_glyph_advance (font, face, font->user_data,
glyph, x_advance, y_advance);
}
void
hb_font_get_glyph_extents (hb_font_t *font, hb_face_t *face,
hb_codepoint_t glyph, hb_glyph_extents_t *extents)
{
memset (extents, 0, sizeof (*extents));
return font->klass->v.get_glyph_extents (font, face, font->user_data,
glyph, extents);
}
hb_bool_t
hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
unsigned int point_index,
......@@ -234,15 +279,6 @@ hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
glyph, x, y);
}
void
hb_font_get_glyph_metrics (hb_font_t *font, hb_face_t *face,
hb_codepoint_t glyph, hb_glyph_metrics_t *metrics)
{
memset (metrics, 0, sizeof (*metrics));
return font->klass->v.get_glyph_metrics (font, face, font->user_data,
glyph, metrics);
}
hb_position_t
hb_font_get_kerning (hb_font_t *font, hb_face_t *face,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph)
......
......@@ -111,23 +111,25 @@ hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
/* funcs */
typedef struct _hb_glyph_metrics_t
typedef struct _hb_glyph_extents_t
{
hb_position_t x_advance;
hb_position_t y_advance;
hb_position_t x_offset;
hb_position_t y_offset;
hb_position_t x_bearing;
hb_position_t y_bearing;
hb_position_t width;
hb_position_t height;
} hb_glyph_metrics_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,
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,
hb_codepoint_t glyph,
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,
hb_codepoint_t glyph,
hb_glyph_extents_t *metrics);
typedef hb_bool_t (*hb_font_get_contour_point_func_t) (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);
typedef void (*hb_font_get_glyph_metrics_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
hb_codepoint_t glyph, hb_glyph_metrics_t *metrics);
unsigned int point_index, hb_codepoint_t glyph,
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,
hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
......@@ -137,12 +139,16 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_func_t glyph_func);
void
hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
hb_font_get_contour_point_func_t contour_point_func);
hb_font_funcs_set_glyph_advance_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_advance_func_t glyph_advance_func);
void
hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_extents_func_t glyph_extents_func);
void
hb_font_funcs_set_glyph_metrics_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_metrics_func_t glyph_metrics_func);
hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
hb_font_get_contour_point_func_t contour_point_func);
void
hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
......@@ -154,12 +160,15 @@ hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_func_t
hb_font_funcs_get_glyph_func (hb_font_funcs_t *ffuncs);
hb_font_get_glyph_advance_func_t
hb_font_funcs_get_glyph_advance_func (hb_font_funcs_t *ffuncs);
hb_font_get_glyph_extents_func_t
hb_font_funcs_get_glyph_extents_func (hb_font_funcs_t *ffuncs);
hb_font_get_contour_point_func_t
hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs);
hb_font_get_glyph_metrics_func_t
hb_font_funcs_get_glyph_metrics_func (hb_font_funcs_t *ffuncs);
hb_font_get_kerning_func_t
hb_font_funcs_get_kerning_func (hb_font_funcs_t *ffuncs);
......@@ -168,14 +177,20 @@ hb_codepoint_t
hb_font_get_glyph (hb_font_t *font, hb_face_t *face,
hb_codepoint_t unicode, hb_codepoint_t variation_selector);
hb_bool_t
hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
unsigned int point_index,
hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y);
void
hb_font_get_glyph_advance (hb_font_t *font, hb_face_t *face,
hb_codepoint_t glyph,
hb_position_t *x_advance, hb_position_t *y_advance);
void
hb_font_get_glyph_metrics (hb_font_t *font, hb_face_t *face,
hb_codepoint_t glyph, hb_glyph_metrics_t *metrics);
hb_font_get_glyph_extents (hb_font_t *font, hb_face_t *face,
hb_codepoint_t glyph,
hb_glyph_extents_t *metrics);
hb_bool_t
hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
unsigned int point_index, hb_codepoint_t glyph,
hb_position_t *x, hb_position_t *y);
hb_position_t
hb_font_get_kerning (hb_font_t *font, hb_face_t *face,
......
......@@ -56,6 +56,48 @@ hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
return FT_Get_Char_Index (ft_face, unicode);
}
static void
hb_ft_get_glyph_advance (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data,
hb_codepoint_t glyph,
hb_position_t *x_advance,
hb_position_t *y_advance)
{
FT_Face ft_face = (FT_Face) user_data;
int load_flags = FT_LOAD_DEFAULT;
/* TODO: load_flags, embolden, etc */
if (likely (!FT_Load_Glyph (ft_face, glyph, load_flags)))
{
*x_advance = ft_face->glyph->advance.x;
*y_advance = ft_face->glyph->advance.y;
}
}
static void
hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data,
hb_codepoint_t glyph,
hb_glyph_extents_t *extents)
{
FT_Face ft_face = (FT_Face) user_data;
int load_flags = FT_LOAD_DEFAULT;
/* TODO: load_flags, embolden, etc */
if (likely (!FT_Load_Glyph (ft_face, glyph, load_flags)))
{
/* XXX: A few negations should be in order here, not sure. */
extents->x_bearing = ft_face->glyph->metrics.horiBearingX;
extents->y_bearing = ft_face->glyph->metrics.horiBearingY;
extents->width = ft_face->glyph->metrics.width;
extents->height = ft_face->glyph->metrics.height;
}
}
static hb_bool_t
hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
......@@ -85,33 +127,6 @@ hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
return TRUE;
}
static void
hb_ft_get_glyph_metrics (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
const void *user_data,
hb_codepoint_t glyph,
hb_glyph_metrics_t *metrics)
{
FT_Face ft_face = (FT_Face) user_data;
int load_flags = FT_LOAD_DEFAULT;
/* TODO: load_flags, embolden, etc */
metrics->x_advance = metrics->y_advance = 0;
metrics->x_offset = metrics->y_offset = 0;
metrics->width = metrics->height = 0;
if (likely (!FT_Load_Glyph (ft_face, glyph, load_flags)))
{
/* TODO: A few negations should be in order here, not sure. */
metrics->x_advance = ft_face->glyph->advance.x;
metrics->y_advance = ft_face->glyph->advance.y;
metrics->x_offset = ft_face->glyph->metrics.horiBearingX;
metrics->y_offset = ft_face->glyph->metrics.horiBearingY;
metrics->width = ft_face->glyph->metrics.width;
metrics->height = ft_face->glyph->metrics.height;
}
}
static hb_position_t
hb_ft_get_kerning (hb_font_t *font HB_UNUSED,
hb_face_t *face HB_UNUSED,
......@@ -134,8 +149,9 @@ static hb_font_funcs_t ft_ffuncs = {
TRUE, /* immutable */
{
hb_ft_get_glyph,
hb_ft_get_glyph_advance,
hb_ft_get_glyph_extents,
hb_ft_get_contour_point,
hb_ft_get_glyph_metrics,
hb_ft_get_kerning
}
};
......
......@@ -233,10 +233,9 @@ hb_position_default (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++) {
hb_glyph_metrics_t metrics;
hb_font_get_glyph_metrics (c->font, c->face, c->buffer->info[i].codepoint, &metrics);
c->buffer->pos[i].x_advance = metrics.x_advance;
c->buffer->pos[i].y_advance = metrics.y_advance;
hb_font_get_glyph_advance (c->font, c->face, c->buffer->info[i].codepoint,
&c->buffer->pos[i].x_advance,
&c->buffer->pos[i].y_advance);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册