mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 09:58:12 +02:00
Bump version to 0.1.17 for new functions: cairo_text_extents, cairo_glyph_extents, cairo_text_path, cairo_glyph_path.
Re-enable cairo_text_path and cairo_glyph_path. Add missing transformation. Initial implementation of glyph_path.
This commit is contained in:
parent
bf40046a4e
commit
fb93261e37
9 changed files with 236 additions and 37 deletions
19
ChangeLog
19
ChangeLog
|
|
@ -1,3 +1,22 @@
|
|||
2003-12-16 Carl Worth <cworth@isi.edu>
|
||||
|
||||
* configure.in: Bump version to 0.1.17 for new functions:
|
||||
cairo_text_extents, cairo_glyph_extents, cairo_text_path,
|
||||
cairo_glyph_path.
|
||||
|
||||
* src/cairo.h:
|
||||
* src/cairo.c (cairo_text_path):
|
||||
(cairo_glyph_path): Re-enable cairo_text_path and cairo_glyph_path.
|
||||
|
||||
* src/cairo_gstate.c (_cairo_gstate_glyph_path): Add missing
|
||||
transformation.
|
||||
|
||||
* src/cairo_ft_font.c (_move_to):
|
||||
(_line_to):
|
||||
(_conic_to):
|
||||
(_cubic_to):
|
||||
(_cairo_ft_font_glyph_path): Initial implementation of glyph_path.
|
||||
|
||||
2003-12-16 Carl Worth <cworth@isi.edu>
|
||||
|
||||
* src/cairoint.h: Move all current_point state fields from
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ AC_INIT(src/cairo.h)
|
|||
dnl ===========================================================================
|
||||
|
||||
# Package version number, (as distinct from shared library version)
|
||||
CAIRO_VERSION=0.1.16
|
||||
CAIRO_VERSION=0.1.17
|
||||
|
||||
# libtool shared library version
|
||||
|
||||
|
|
|
|||
|
|
@ -589,21 +589,112 @@ _cairo_ft_font_show_text (void *abstract_font,
|
|||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
static int
|
||||
_move_to (FT_Vector *to, void *closure)
|
||||
{
|
||||
cairo_path_t *path = closure;
|
||||
|
||||
_cairo_path_close_path (path);
|
||||
_cairo_path_move_to (path,
|
||||
DOUBLE_FROM_26_6(to->x),
|
||||
DOUBLE_FROM_26_6(to->y));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_line_to (FT_Vector *to, void *closure)
|
||||
{
|
||||
cairo_path_t *path = closure;
|
||||
|
||||
_cairo_path_line_to (path,
|
||||
DOUBLE_FROM_26_6(to->x),
|
||||
DOUBLE_FROM_26_6(to->y));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_conic_to (FT_Vector *control, FT_Vector *to, void *closure)
|
||||
{
|
||||
cairo_path_t *path = closure;
|
||||
|
||||
double x1, y1;
|
||||
double x2 = DOUBLE_FROM_26_6(control->x);
|
||||
double y2 = DOUBLE_FROM_26_6(control->y);
|
||||
double x3 = DOUBLE_FROM_26_6(to->x);
|
||||
double y3 = DOUBLE_FROM_26_6(to->y);
|
||||
|
||||
_cairo_path_current_point (path, &x1, &y1);
|
||||
|
||||
_cairo_path_curve_to (path,
|
||||
x1 + 2.0/3.0 * (x2 - x1), y1 + 2.0/3.0 * (y2 - y1),
|
||||
x3 + 2.0/3.0 * (x2 - x3), y3 + 2.0/3.0 * (y2 - y3),
|
||||
x3, y3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_cubic_to (FT_Vector *control1, FT_Vector *control2, FT_Vector *to, void *closure)
|
||||
{
|
||||
cairo_path_t *path = closure;
|
||||
|
||||
_cairo_path_curve_to (path,
|
||||
DOUBLE_FROM_26_6(control1->x), DOUBLE_FROM_26_6(control1->y),
|
||||
DOUBLE_FROM_26_6(control2->x), DOUBLE_FROM_26_6(control2->y),
|
||||
DOUBLE_FROM_26_6(to->x), DOUBLE_FROM_26_6(to->y));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_ft_font_glyph_path (void *font,
|
||||
_cairo_ft_font_glyph_path (void *abstract_font,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_path_t *path)
|
||||
{
|
||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
cairo_ft_font_t *ft;
|
||||
int i;
|
||||
cairo_ft_font_t *font = abstract_font;
|
||||
FT_GlyphSlot glyph;
|
||||
FT_Error error;
|
||||
FT_Outline_Funcs outline_funcs = {
|
||||
_move_to,
|
||||
_line_to,
|
||||
_conic_to,
|
||||
_cubic_to,
|
||||
0, /* shift */
|
||||
0, /* delta */
|
||||
};
|
||||
|
||||
glyph = font->face->glyph;
|
||||
_install_font_matrix (&font->base.matrix, font->face);
|
||||
|
||||
for (i = 0; i < num_glyphs; i++)
|
||||
{
|
||||
FT_Matrix invert_y = {
|
||||
DOUBLE_TO_16_16 (1.0), 0,
|
||||
0, DOUBLE_TO_16_16 (-1.0),
|
||||
};
|
||||
|
||||
error = FT_Load_Glyph (font->face, glyphs[i].index, FT_LOAD_DEFAULT);
|
||||
/* XXX: What to do in this error case? */
|
||||
if (error)
|
||||
continue;
|
||||
/* XXX: Do we want to support bitmap fonts here? */
|
||||
if (glyph->format == ft_glyph_format_bitmap)
|
||||
continue;
|
||||
|
||||
/* Font glyphs have an inverted Y axis compared to cairo. */
|
||||
FT_Outline_Transform (&glyph->outline, &invert_y);
|
||||
FT_Outline_Translate (&glyph->outline,
|
||||
DOUBLE_TO_26_6(glyphs[i].x),
|
||||
DOUBLE_TO_26_6(glyphs[i].y));
|
||||
FT_Outline_Decompose (&glyph->outline, &outline_funcs, path);
|
||||
}
|
||||
_cairo_path_close_path (path);
|
||||
|
||||
ft = (cairo_ft_font_t *)font;
|
||||
|
||||
/* XXX: lift code from xft to do this */
|
||||
|
||||
return status;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
|
|
@ -628,7 +719,6 @@ _cairo_ft_font_text_path (void *abstract_font,
|
|||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
cairo_font_t *
|
||||
cairo_ft_font_create_for_ft_face (FT_Face face)
|
||||
{
|
||||
|
|
@ -651,7 +741,6 @@ cairo_ft_font_create_for_ft_face (FT_Face face)
|
|||
return (cairo_font_t *) f;
|
||||
}
|
||||
|
||||
|
||||
const struct cairo_font_backend cairo_ft_font_backend = {
|
||||
_cairo_ft_font_create,
|
||||
_cairo_ft_font_copy,
|
||||
|
|
|
|||
|
|
@ -1646,7 +1646,7 @@ _cairo_gstate_show_text (cairo_gstate_t *gstate,
|
|||
cairo_matrix_transform_point (&gstate->ctm, &x, &y);
|
||||
}
|
||||
|
||||
status = setup_text_rendering_context(gstate, &user_to_source);
|
||||
status = setup_text_rendering_context (gstate, &user_to_source);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
|
|
@ -1744,13 +1744,14 @@ _cairo_gstate_text_path (cairo_gstate_t *gstate,
|
|||
|
||||
|
||||
cairo_status_t
|
||||
_cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
||||
_cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs)
|
||||
{
|
||||
cairo_status_t status;
|
||||
int i;
|
||||
cairo_glyph_t *transformed_glyphs = NULL;
|
||||
cairo_matrix_t user_to_source;
|
||||
cairo_matrix_t saved_font_matrix;
|
||||
|
||||
transformed_glyphs = malloc (num_glyphs * sizeof(cairo_glyph_t));
|
||||
|
|
@ -1765,6 +1766,10 @@ _cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
|||
&(transformed_glyphs[i].y));
|
||||
}
|
||||
|
||||
status = setup_text_rendering_context (gstate, &user_to_source);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
|
||||
cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
|
||||
|
||||
|
|
@ -1773,6 +1778,7 @@ _cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
|||
&gstate->path);
|
||||
|
||||
cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
|
||||
restore_text_rendering_context (gstate, &user_to_source);
|
||||
|
||||
free (transformed_glyphs);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -706,7 +706,6 @@ cairo_transform_font (cairo_t *cr, cairo_matrix_t *matrix)
|
|||
cr->status = _cairo_gstate_transform_font (cr->gstate, matrix);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cairo_text_extents (cairo_t *cr,
|
||||
const unsigned char *utf8,
|
||||
|
|
@ -749,7 +748,6 @@ cairo_show_glyphs (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs)
|
|||
cr->status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, num_glyphs);
|
||||
}
|
||||
|
||||
/* XXX: NYI
|
||||
void
|
||||
cairo_text_path (cairo_t *cr, const unsigned char *utf8)
|
||||
{
|
||||
|
|
@ -767,7 +765,6 @@ cairo_glyph_path (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs)
|
|||
|
||||
cr->status = _cairo_gstate_glyph_path (cr->gstate, glyphs, num_glyphs);
|
||||
}
|
||||
*/
|
||||
|
||||
void
|
||||
cairo_show_surface (cairo_t *cr,
|
||||
|
|
|
|||
|
|
@ -418,17 +418,12 @@ cairo_glyph_extents (cairo_t *ct,
|
|||
int num_glyphs,
|
||||
cairo_text_extents_t *extents);
|
||||
|
||||
/* XXX: NYI
|
||||
|
||||
extern void __external_linkage
|
||||
cairo_text_path (cairo_t *ct, const unsigned char *utf8);
|
||||
|
||||
extern void __external_linkage
|
||||
cairo_glyph_path (cairo_t *ct, cairo_glyph_t *glyphs, int num_glyphs);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* Portable interface to general font features. */
|
||||
|
||||
extern void __external_linkage
|
||||
|
|
@ -467,10 +462,9 @@ cairo_ft_font_face (cairo_font_t *ft_font);
|
|||
extern FcPattern * __external_linkage
|
||||
cairo_ft_font_pattern (cairo_font_t *ft_font);
|
||||
|
||||
|
||||
|
||||
/* Image functions */
|
||||
|
||||
/* XXX: Eliminate width/height here */
|
||||
extern void __external_linkage
|
||||
cairo_show_surface (cairo_t *cr,
|
||||
cairo_surface_t *surface,
|
||||
|
|
|
|||
|
|
@ -589,21 +589,112 @@ _cairo_ft_font_show_text (void *abstract_font,
|
|||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
static int
|
||||
_move_to (FT_Vector *to, void *closure)
|
||||
{
|
||||
cairo_path_t *path = closure;
|
||||
|
||||
_cairo_path_close_path (path);
|
||||
_cairo_path_move_to (path,
|
||||
DOUBLE_FROM_26_6(to->x),
|
||||
DOUBLE_FROM_26_6(to->y));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_line_to (FT_Vector *to, void *closure)
|
||||
{
|
||||
cairo_path_t *path = closure;
|
||||
|
||||
_cairo_path_line_to (path,
|
||||
DOUBLE_FROM_26_6(to->x),
|
||||
DOUBLE_FROM_26_6(to->y));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_conic_to (FT_Vector *control, FT_Vector *to, void *closure)
|
||||
{
|
||||
cairo_path_t *path = closure;
|
||||
|
||||
double x1, y1;
|
||||
double x2 = DOUBLE_FROM_26_6(control->x);
|
||||
double y2 = DOUBLE_FROM_26_6(control->y);
|
||||
double x3 = DOUBLE_FROM_26_6(to->x);
|
||||
double y3 = DOUBLE_FROM_26_6(to->y);
|
||||
|
||||
_cairo_path_current_point (path, &x1, &y1);
|
||||
|
||||
_cairo_path_curve_to (path,
|
||||
x1 + 2.0/3.0 * (x2 - x1), y1 + 2.0/3.0 * (y2 - y1),
|
||||
x3 + 2.0/3.0 * (x2 - x3), y3 + 2.0/3.0 * (y2 - y3),
|
||||
x3, y3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_cubic_to (FT_Vector *control1, FT_Vector *control2, FT_Vector *to, void *closure)
|
||||
{
|
||||
cairo_path_t *path = closure;
|
||||
|
||||
_cairo_path_curve_to (path,
|
||||
DOUBLE_FROM_26_6(control1->x), DOUBLE_FROM_26_6(control1->y),
|
||||
DOUBLE_FROM_26_6(control2->x), DOUBLE_FROM_26_6(control2->y),
|
||||
DOUBLE_FROM_26_6(to->x), DOUBLE_FROM_26_6(to->y));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_ft_font_glyph_path (void *font,
|
||||
_cairo_ft_font_glyph_path (void *abstract_font,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_path_t *path)
|
||||
{
|
||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
cairo_ft_font_t *ft;
|
||||
int i;
|
||||
cairo_ft_font_t *font = abstract_font;
|
||||
FT_GlyphSlot glyph;
|
||||
FT_Error error;
|
||||
FT_Outline_Funcs outline_funcs = {
|
||||
_move_to,
|
||||
_line_to,
|
||||
_conic_to,
|
||||
_cubic_to,
|
||||
0, /* shift */
|
||||
0, /* delta */
|
||||
};
|
||||
|
||||
glyph = font->face->glyph;
|
||||
_install_font_matrix (&font->base.matrix, font->face);
|
||||
|
||||
for (i = 0; i < num_glyphs; i++)
|
||||
{
|
||||
FT_Matrix invert_y = {
|
||||
DOUBLE_TO_16_16 (1.0), 0,
|
||||
0, DOUBLE_TO_16_16 (-1.0),
|
||||
};
|
||||
|
||||
error = FT_Load_Glyph (font->face, glyphs[i].index, FT_LOAD_DEFAULT);
|
||||
/* XXX: What to do in this error case? */
|
||||
if (error)
|
||||
continue;
|
||||
/* XXX: Do we want to support bitmap fonts here? */
|
||||
if (glyph->format == ft_glyph_format_bitmap)
|
||||
continue;
|
||||
|
||||
/* Font glyphs have an inverted Y axis compared to cairo. */
|
||||
FT_Outline_Transform (&glyph->outline, &invert_y);
|
||||
FT_Outline_Translate (&glyph->outline,
|
||||
DOUBLE_TO_26_6(glyphs[i].x),
|
||||
DOUBLE_TO_26_6(glyphs[i].y));
|
||||
FT_Outline_Decompose (&glyph->outline, &outline_funcs, path);
|
||||
}
|
||||
_cairo_path_close_path (path);
|
||||
|
||||
ft = (cairo_ft_font_t *)font;
|
||||
|
||||
/* XXX: lift code from xft to do this */
|
||||
|
||||
return status;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
|
|
@ -628,7 +719,6 @@ _cairo_ft_font_text_path (void *abstract_font,
|
|||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
cairo_font_t *
|
||||
cairo_ft_font_create_for_ft_face (FT_Face face)
|
||||
{
|
||||
|
|
@ -651,7 +741,6 @@ cairo_ft_font_create_for_ft_face (FT_Face face)
|
|||
return (cairo_font_t *) f;
|
||||
}
|
||||
|
||||
|
||||
const struct cairo_font_backend cairo_ft_font_backend = {
|
||||
_cairo_ft_font_create,
|
||||
_cairo_ft_font_copy,
|
||||
|
|
|
|||
|
|
@ -1646,7 +1646,7 @@ _cairo_gstate_show_text (cairo_gstate_t *gstate,
|
|||
cairo_matrix_transform_point (&gstate->ctm, &x, &y);
|
||||
}
|
||||
|
||||
status = setup_text_rendering_context(gstate, &user_to_source);
|
||||
status = setup_text_rendering_context (gstate, &user_to_source);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
|
|
@ -1744,13 +1744,14 @@ _cairo_gstate_text_path (cairo_gstate_t *gstate,
|
|||
|
||||
|
||||
cairo_status_t
|
||||
_cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
||||
_cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs)
|
||||
{
|
||||
cairo_status_t status;
|
||||
int i;
|
||||
cairo_glyph_t *transformed_glyphs = NULL;
|
||||
cairo_matrix_t user_to_source;
|
||||
cairo_matrix_t saved_font_matrix;
|
||||
|
||||
transformed_glyphs = malloc (num_glyphs * sizeof(cairo_glyph_t));
|
||||
|
|
@ -1765,6 +1766,10 @@ _cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
|||
&(transformed_glyphs[i].y));
|
||||
}
|
||||
|
||||
status = setup_text_rendering_context (gstate, &user_to_source);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
|
||||
cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
|
||||
|
||||
|
|
@ -1773,6 +1778,7 @@ _cairo_gstate_glyph_path (cairo_gstate_t *gstate,
|
|||
&gstate->path);
|
||||
|
||||
cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
|
||||
restore_text_rendering_context (gstate, &user_to_source);
|
||||
|
||||
free (transformed_glyphs);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ typedef struct cairo_font_backend {
|
|||
cairo_font_t *(*copy) (void *font);
|
||||
|
||||
void (*destroy) (void *font);
|
||||
|
||||
|
||||
cairo_status_t (*font_extents) (void *font,
|
||||
cairo_font_extents_t *extents);
|
||||
|
||||
|
|
@ -299,7 +299,6 @@ typedef struct cairo_font_backend {
|
|||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_path_t *path);
|
||||
|
||||
} cairo_font_backend_t;
|
||||
|
||||
/* concrete font backends */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue