[cairo-commit] cairo/src cairo_font.c,1.17,1.18 cairo_ft_font.c,1.14,1.15 cairo_gstate.c,1.37,1.38 cairoint.h,1.46,1.47
Carl Worth
commit at pdx.freedesktop.org
Tue Dec 16 06:50:39 PST 2003
Committed by: cworth
Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv12569/src
Modified Files:
cairo_font.c cairo_ft_font.c cairo_gstate.c cairoint.h
Log Message:
* src/cairoint.h: Change cairo_font_backend_t to use a void * for
the abstract font. Put create, copy, and destroy as the first
functions in the list. Fix text_path and glyph_path so that the
path to be returned is the last argument. Add x,y arguments to
text_path.
* src/cairo_gstate.c (_cairo_gstate_text_path): Compute x,y now
needed by cairo_font_text_path.
(_cairo_gstate_glyph_path): Track change in
cairo_font_text/glyph_path (path argument is now last).
* src/cairo_ft_font.c: Switch to new macro-based mechanism for
including freetype headers.
(cairo_ft_font_face):
(cairo_ft_font_pattern): Minor cleanup.
(_cairo_ft_font_copy):
(_cairo_ft_font_destroy):
(_utf8_to_glyphs):
(_cairo_ft_font_font_extents):
(_cairo_ft_font_glyph_extents):
(_cairo_ft_font_text_extents):
(_cairo_ft_font_show_glyphs):
(_cairo_ft_font_show_text): Track changes to cairo_font_backend_t
interface.
* src/cairo_font.c (_cairo_font_text_path):
(_cairo_font_glyph_path): Track changes to cairo_font_backend_t
interface.
Index: cairo_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_font.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** cairo_font.c 15 Dec 2003 22:20:56 -0000 1.17
--- cairo_font.c 16 Dec 2003 14:50:37 -0000 1.18
***************
*** 134,151 ****
cairo_status_t
_cairo_font_text_path (cairo_font_t *font,
! cairo_path_t *path,
! const unsigned char *utf8)
{
! return font->backend->text_path(font, path, utf8);
}
cairo_status_t
_cairo_font_glyph_path (cairo_font_t *font,
- cairo_path_t *path,
cairo_glyph_t *glyphs,
! int num_glyphs)
{
! return font->backend->glyph_path(font, path,
! glyphs, num_glyphs);
}
--- 134,152 ----
cairo_status_t
_cairo_font_text_path (cairo_font_t *font,
! double x,
! double y,
! const unsigned char *utf8,
! cairo_path_t *path)
{
! return font->backend->text_path(font, x, y, utf8, path);
}
cairo_status_t
_cairo_font_glyph_path (cairo_font_t *font,
cairo_glyph_t *glyphs,
! int num_glyphs,
! cairo_path_t *path)
{
! return font->backend->glyph_path(font, glyphs, num_glyphs, path);
}
Index: cairo_ft_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_ft_font.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** cairo_ft_font.c 16 Dec 2003 03:00:15 -0000 1.14
--- cairo_ft_font.c 16 Dec 2003 14:50:37 -0000 1.15
***************
*** 26,30 ****
#include <fontconfig/fontconfig.h>
#include <fontconfig/fcfreetype.h>
! #include <freetype/freetype.h>
typedef struct {
--- 26,33 ----
#include <fontconfig/fontconfig.h>
#include <fontconfig/fcfreetype.h>
!
! #include <ft2build.h>
! #include FT_FREETYPE_H
! #include FT_OUTLINE_H
typedef struct {
***************
*** 40,44 ****
} cairo_ft_font_t;
-
#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0))
#define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0)
--- 43,46 ----
***************
*** 100,122 ****
FT_Face
! cairo_ft_font_face (cairo_font_t *font)
{
if (font == NULL)
return NULL;
! return ((cairo_ft_font_t *) font)->face;
}
FcPattern *
! cairo_ft_font_pattern (cairo_font_t *font)
{
if (font == NULL)
return NULL;
! return ((cairo_ft_font_t *) font)->pattern;
}
-
-
/* implement the backend interface */
--- 102,126 ----
FT_Face
! cairo_ft_font_face (cairo_font_t *abstract_font)
{
+ cairo_ft_font_t *font = (cairo_ft_font_t *) abstract_font;
+
if (font == NULL)
return NULL;
! return font->face;
}
FcPattern *
! cairo_ft_font_pattern (cairo_font_t *abstract_font)
{
+ cairo_ft_font_t *font = (cairo_ft_font_t *) abstract_font;
+
if (font == NULL)
return NULL;
! return font->pattern;
}
/* implement the backend interface */
***************
*** 190,232 ****
}
-
static cairo_font_t *
! _cairo_ft_font_copy (cairo_font_t *font)
{
! cairo_ft_font_t * ft_font_new = NULL;
! cairo_ft_font_t * ft_font = NULL;
! ft_font = (cairo_ft_font_t *)font;
! ft_font_new = (cairo_ft_font_t *)cairo_ft_font_create_for_ft_face (ft_font->face);
! if (ft_font_new == NULL)
return NULL;
! if (ft_font_new != NULL && ft_font->pattern != NULL)
! ft_font_new->pattern = FcPatternDuplicate (ft_font->pattern);
! return (cairo_font_t *)ft_font_new;
}
static void
! _cairo_ft_font_destroy (cairo_font_t *font)
{
! cairo_ft_font_t * ft_font = NULL;
if (font == NULL)
return;
! ft_font = (cairo_ft_font_t *)font;
!
! if (ft_font->face != NULL && ft_font->owns_face)
! FT_Done_Face (ft_font->face);
! if (ft_font->pattern != NULL)
! FcPatternDestroy (ft_font->pattern);
! if (ft_font->ft_library && ft_font->owns_ft_library)
! FT_Done_FreeType (ft_font->ft_library);
! free (ft_font);
}
--- 194,234 ----
}
static cairo_font_t *
! _cairo_ft_font_copy (void *abstract_font)
{
! cairo_ft_font_t * font_new = NULL;
! cairo_ft_font_t * font = abstract_font;
! if (font->base.backend != &cairo_ft_font_backend)
! return NULL;
! font_new = (cairo_ft_font_t *) cairo_ft_font_create_for_ft_face (font->face);
! if (font_new == NULL)
return NULL;
! if (font_new != NULL && font->pattern != NULL)
! font_new->pattern = FcPatternDuplicate (font->pattern);
! return (cairo_font_t *) font_new;
}
static void
! _cairo_ft_font_destroy (void *abstract_font)
{
! cairo_ft_font_t * font = abstract_font;
if (font == NULL)
return;
! if (font->face != NULL && font->owns_face)
! FT_Done_Face (font->face);
! if (font->pattern != NULL)
! FcPatternDestroy (font->pattern);
! if (font->ft_library && font->owns_ft_library)
! FT_Done_FreeType (font->ft_library);
! free (font);
}
***************
*** 302,324 ****
}
-
static int
! _utf8_to_glyphs (cairo_font_t *font,
! const unsigned char *utf8,
! double x0,
! double y0,
! cairo_glyph_t **glyphs,
! size_t *nglyphs)
{
! cairo_ft_font_t *ft;
double x = 0., y = 0.;
size_t i;
FT_ULong *ucs4 = NULL;
- if (font == NULL)
- return 0;
-
- ft = (cairo_ft_font_t *)font;
-
_utf8_to_ucs4 (utf8, &ucs4, nglyphs);
--- 304,320 ----
}
static int
! _utf8_to_glyphs (cairo_ft_font_t *font,
! const unsigned char *utf8,
! double x0,
! double y0,
! cairo_glyph_t **glyphs,
! size_t *nglyphs)
{
! FT_Face face = font->face;
double x = 0., y = 0.;
size_t i;
FT_ULong *ucs4 = NULL;
_utf8_to_ucs4 (utf8, &ucs4, nglyphs);
***************
*** 333,348 ****
}
! _install_font_matrix (&font->matrix, ft->face);
for (i = 0; i < *nglyphs; i++)
{
! (*glyphs)[i].index = FT_Get_Char_Index (ft->face, ucs4[i]);
(*glyphs)[i].x = x0 + x;
(*glyphs)[i].y = y0 + y;
! FT_Load_Glyph (ft->face, (*glyphs)[i].index, FT_LOAD_DEFAULT);
! x += DOUBLE_FROM_26_6 (ft->face->glyph->advance.x);
! y -= DOUBLE_FROM_26_6 (ft->face->glyph->advance.y);
}
--- 329,344 ----
}
! _install_font_matrix (&font->base.matrix, face);
for (i = 0; i < *nglyphs; i++)
{
! (*glyphs)[i].index = FT_Get_Char_Index (face, ucs4[i]);
(*glyphs)[i].x = x0 + x;
(*glyphs)[i].y = y0 + y;
! FT_Load_Glyph (face, (*glyphs)[i].index, FT_LOAD_DEFAULT);
! x += DOUBLE_FROM_26_6 (face->glyph->advance.x);
! y -= DOUBLE_FROM_26_6 (face->glyph->advance.y);
}
***************
*** 352,364 ****
static cairo_status_t
! _cairo_ft_font_font_extents (cairo_font_t *font,
! cairo_font_extents_t *extents)
{
! FT_Face face;
double scale_x, scale_y;
! face = ((cairo_ft_font_t *)font)->face;
double upm = face->units_per_EM;
! _cairo_matrix_compute_scale_factors (&font->matrix, &scale_x, &scale_y);
extents->ascent = face->ascender / upm * scale_y;
--- 348,361 ----
static cairo_status_t
! _cairo_ft_font_font_extents (void *abstract_font,
! cairo_font_extents_t *extents)
{
! cairo_ft_font_t *font = abstract_font;
! FT_Face face = font->face;
double scale_x, scale_y;
!
double upm = face->units_per_EM;
! _cairo_matrix_compute_scale_factors (&font->base.matrix, &scale_x, &scale_y);
extents->ascent = face->ascender / upm * scale_y;
***************
*** 372,386 ****
static cairo_status_t
! _cairo_ft_font_glyph_extents (cairo_font_t *font,
! cairo_glyph_t *glyphs,
! int num_glyphs,
! cairo_text_extents_t *extents)
{
int i;
cairo_point_double_t origin;
cairo_point_double_t glyph_min, glyph_max;
cairo_point_double_t total_min, total_max;
FT_Error error;
! FT_Face face = ((cairo_ft_font_t *)font)->face;
FT_GlyphSlot glyph = face->glyph;
FT_Glyph_Metrics *metrics = &glyph->metrics;
--- 369,384 ----
static cairo_status_t
! _cairo_ft_font_glyph_extents (void *abstract_font,
! cairo_glyph_t *glyphs,
! int num_glyphs,
! cairo_text_extents_t *extents)
{
int i;
+ cairo_ft_font_t *font = abstract_font;
cairo_point_double_t origin;
cairo_point_double_t glyph_min, glyph_max;
cairo_point_double_t total_min, total_max;
FT_Error error;
! FT_Face face = font->face;
FT_GlyphSlot glyph = face->glyph;
FT_Glyph_Metrics *metrics = &glyph->metrics;
***************
*** 401,405 ****
origin.y = glyphs[0].y;
! _install_font_matrix (&font->matrix, face);
for (i = 0; i < num_glyphs; i++)
--- 399,403 ----
origin.y = glyphs[0].y;
! _install_font_matrix (&font->base.matrix, face);
for (i = 0; i < num_glyphs; i++)
***************
*** 448,455 ****
static cairo_status_t
! _cairo_ft_font_text_extents (cairo_font_t *font,
! const unsigned char *utf8,
! cairo_text_extents_t *extents)
{
cairo_glyph_t *glyphs;
size_t nglyphs;
--- 446,454 ----
static cairo_status_t
! _cairo_ft_font_text_extents (void *abstract_font,
! const unsigned char *utf8,
! cairo_text_extents_t *extents)
{
+ cairo_ft_font_t *font = abstract_font;
cairo_glyph_t *glyphs;
size_t nglyphs;
***************
*** 464,472 ****
return status;
}
-
-
static cairo_status_t
! _cairo_ft_font_show_glyphs (cairo_font_t *font,
cairo_operator_t operator,
cairo_surface_t *source,
--- 463,469 ----
return status;
}
static cairo_status_t
! _cairo_ft_font_show_glyphs (void *abstract_font,
cairo_operator_t operator,
cairo_surface_t *source,
***************
*** 475,478 ****
--- 472,476 ----
int num_glyphs)
{
+ cairo_ft_font_t *font = abstract_font;
cairo_status_t status;
int i;
***************
*** 492,496 ****
ft = (cairo_ft_font_t *)font;
glyphslot = ft->face->glyph;
! _install_font_matrix (&font->matrix, ft->face);
for (i = 0; i < num_glyphs; i++)
--- 490,494 ----
ft = (cairo_ft_font_t *)font;
glyphslot = ft->face->glyph;
! _install_font_matrix (&font->base.matrix, ft->face);
for (i = 0; i < num_glyphs; i++)
***************
*** 567,571 ****
static cairo_status_t
! _cairo_ft_font_show_text (cairo_font_t *font,
cairo_operator_t operator,
cairo_surface_t *source,
--- 565,569 ----
static cairo_status_t
! _cairo_ft_font_show_text (void *abstract_font,
cairo_operator_t operator,
cairo_surface_t *source,
***************
*** 575,578 ****
--- 573,577 ----
const unsigned char *utf8)
{
+ cairo_ft_font_t *font = abstract_font;
cairo_glyph_t *glyphs;
int num_glyphs;
***************
*** 609,623 ****
static cairo_status_t
! _cairo_ft_font_text_path (cairo_font_t *font,
! cairo_path_t *path,
const unsigned char *utf8)
{
cairo_glyph_t *glyphs;
size_t nglyphs;
! if (_utf8_to_glyphs (font, utf8, 0, 0, &glyphs, &nglyphs))
{
cairo_status_t res;
! res = _cairo_ft_font_glyph_path (font, path, glyphs, nglyphs);
free (glyphs);
return res;
--- 608,625 ----
static cairo_status_t
! _cairo_ft_font_text_path (void *abstract_font,
! cairo_path_t *path,
! double x,
! double y,
const unsigned char *utf8)
{
+ cairo_ft_font_t *font = abstract_font;
cairo_glyph_t *glyphs;
size_t nglyphs;
! if (_utf8_to_glyphs (font, utf8, x, y, &glyphs, &nglyphs))
{
cairo_status_t res;
! res = _cairo_ft_font_glyph_path (font, glyphs, nglyphs, path);
free (glyphs);
return res;
***************
*** 652,655 ****
--- 654,660 ----
const struct cairo_font_backend cairo_ft_font_backend = {
+ _cairo_ft_font_create,
+ _cairo_ft_font_copy,
+ _cairo_ft_font_destroy,
_cairo_ft_font_font_extents,
_cairo_ft_font_text_extents,
***************
*** 659,664 ****
_cairo_ft_font_text_path,
_cairo_ft_font_glyph_path,
- _cairo_ft_font_create,
- _cairo_ft_font_copy,
- _cairo_ft_font_destroy
};
--- 664,666 ----
Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** cairo_gstate.c 16 Dec 2003 03:00:15 -0000 1.37
--- cairo_gstate.c 16 Dec 2003 14:50:37 -0000 1.38
***************
*** 1798,1802 ****
--- 1798,1821 ----
{
cairo_status_t status;
+ cairo_matrix_t user_to_source;
cairo_matrix_t saved_font_matrix;
+ double x, y;
+
+ status = setup_text_rendering_context (gstate, &user_to_source);
+ if (status)
+ return status;
+
+ /* XXX: I believe this is correct, but it would be much more clear
+ to have some explicit current_point accesor functions, (one for
+ user- and one for device-space). */
+
+ if (gstate->has_current_point) {
+ x = gstate->current_point.x;
+ y = gstate->current_point.y;
+ } else {
+ x = 0;
+ y = 0;
+ cairo_matrix_transform_point (&gstate->ctm, &x, &y);
+ }
cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
***************
*** 1804,1811 ****
status = _cairo_font_text_path (gstate->font,
! &gstate->path,
! utf8);
cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
return status;
}
--- 1823,1833 ----
status = _cairo_font_text_path (gstate->font,
! x, y,
! utf8,
! &gstate->path);
cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
+ restore_text_rendering_context (gstate, &user_to_source);
+
return status;
}
***************
*** 1838,1843 ****
status = _cairo_font_glyph_path (gstate->font,
! &gstate->path,
! transformed_glyphs, num_glyphs);
cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
--- 1860,1865 ----
status = _cairo_font_glyph_path (gstate->font,
! transformed_glyphs, num_glyphs,
! &gstate->path);
cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** cairoint.h 16 Dec 2003 02:26:51 -0000 1.46
--- cairoint.h 16 Dec 2003 14:50:37 -0000 1.47
***************
*** 251,299 ****
typedef struct cairo_font_backend {
! cairo_status_t (*font_extents) (cairo_font_t *font,
! cairo_font_extents_t *extents);
! cairo_status_t (*text_extents) (cairo_font_t *font,
! const unsigned char *utf8,
! cairo_text_extents_t *extents);
! cairo_status_t (*glyph_extents) (cairo_font_t *font,
! cairo_glyph_t *glyphs,
! int num_glyphs,
! cairo_text_extents_t *extents);
! cairo_status_t (*show_text) (cairo_font_t *font,
! cairo_operator_t operator,
! cairo_surface_t *source,
! cairo_surface_t *surface,
! double x,
! double y,
! const unsigned char *utf8);
! cairo_status_t (*show_glyphs) (cairo_font_t *font,
! cairo_operator_t operator,
! cairo_surface_t *source,
! cairo_surface_t *surface,
! const cairo_glyph_t *glyphs,
! int num_glyphs);
! cairo_status_t (*text_path) (cairo_font_t *font,
! cairo_path_t *path,
! const unsigned char *utf8);
!
! cairo_status_t (*glyph_path) (cairo_font_t *font,
! cairo_path_t *path,
! cairo_glyph_t *glyphs,
! int num_glyphs);
! cairo_font_t *(*create) (const char *family,
! cairo_font_slant_t slant,
! cairo_font_weight_t weight);
!
! cairo_font_t *(*copy) (cairo_font_t *other);
- void (*destroy) (cairo_font_t *font);
-
} cairo_font_backend_t;
--- 251,300 ----
typedef struct cairo_font_backend {
+ cairo_font_t *(*create) (const char *family,
+ cairo_font_slant_t slant,
+ cairo_font_weight_t weight);
+
+ cairo_font_t *(*copy) (void *font);
! void (*destroy) (void *font);
!
! cairo_status_t (*font_extents) (void *font,
! cairo_font_extents_t *extents);
! cairo_status_t (*text_extents) (void *font,
! const unsigned char *utf8,
! cairo_text_extents_t *extents);
! cairo_status_t (*glyph_extents) (void *font,
! cairo_glyph_t *glyphs,
! int num_glyphs,
! cairo_text_extents_t *extents);
! cairo_status_t (*show_text) (void *font,
! cairo_operator_t operator,
! cairo_surface_t *source,
! cairo_surface_t *surface,
! double x,
! double y,
! const unsigned char *utf8);
! cairo_status_t (*show_glyphs) (void *font,
! cairo_operator_t operator,
! cairo_surface_t *source,
! cairo_surface_t *surface,
! const cairo_glyph_t *glyphs,
! int num_glyphs);
! cairo_status_t (*text_path) (void *font,
! double x,
! double y,
! const unsigned char *utf8,
! cairo_path_t *path);
! cairo_status_t (*glyph_path) (void *font,
! cairo_glyph_t *glyphs,
! int num_glyphs,
! cairo_path_t *path);
} cairo_font_backend_t;
***************
*** 886,898 ****
extern cairo_int_status_t __internal_linkage
_cairo_font_text_path (cairo_font_t *font,
! cairo_path_t *path,
! const unsigned char *utf8);
extern cairo_int_status_t __internal_linkage
_cairo_font_glyph_path (cairo_font_t *font,
- cairo_path_t *path,
cairo_glyph_t *glyphs,
! int num_glyphs);
!
/* cairo_hull.c */
--- 887,900 ----
extern cairo_int_status_t __internal_linkage
_cairo_font_text_path (cairo_font_t *font,
! double x,
! double y,
! const unsigned char *utf8,
! cairo_path_t *path);
extern cairo_int_status_t __internal_linkage
_cairo_font_glyph_path (cairo_font_t *font,
cairo_glyph_t *glyphs,
! int num_glyphs,
! cairo_path_t *path);
/* cairo_hull.c */
More information about the cairo-commit
mailing list