1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/*
* Copyright © 2002 University of Southern California
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of the
* University of Southern California not be used in advertising or
* publicity pertaining to distribution of the software without
* specific, written prior permission. The University of Southern
* California makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express
* or implied warranty.
*
* THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
* SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Carl D. Worth <cworth@isi.edu>
*/
#include "cairoint.h"
cairo_font_t *
_cairo_font_create (char *family,
cairo_font_slant_t slant,
cairo_font_weight_t weight)
{
const struct cairo_font_backend *backend = CAIRO_FONT_BACKEND_DEFAULT;
return backend->create (family, slant, weight);
}
cairo_status_t
_cairo_font_init (cairo_font_t *font,
const struct cairo_font_backend *backend)
{
cairo_matrix_set_identity (&font->matrix);
font->refcount = 1;
font->backend = backend;
return CAIRO_STATUS_SUCCESS;
}
cairo_font_t *
_cairo_font_copy (cairo_font_t *font)
{
cairo_font_t *newfont = NULL;
char *tmp = NULL;
if (font == NULL || font->backend->copy == NULL)
return NULL;
newfont = font->backend->copy (font);
if (newfont == NULL) {
free (tmp);
return NULL;
}
newfont->refcount = 1;
cairo_matrix_copy(&newfont->matrix, &font->matrix);
newfont->backend = font->backend;
return newfont;
}
cairo_status_t
_cairo_font_scale (cairo_font_t *font, double scale)
{
return cairo_matrix_scale (&font->matrix, scale, scale);
}
cairo_status_t
_cairo_font_transform (cairo_font_t *font, cairo_matrix_t *matrix)
{
return cairo_matrix_multiply (&font->matrix, matrix, &font->matrix);
}
cairo_status_t
_cairo_font_text_extents (cairo_font_t *font,
const unsigned char *utf8,
cairo_text_extents_t *extents)
{
return font->backend->text_extents(font, utf8, extents);
}
cairo_status_t
_cairo_font_glyph_extents (cairo_font_t *font,
cairo_glyph_t *glyphs,
int num_glyphs,
cairo_text_extents_t *extents)
{
return font->backend->glyph_extents(font, glyphs, num_glyphs, extents);
}
cairo_status_t
_cairo_font_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)
{
return font->backend->show_text(font, operator, source,
surface, x, y, utf8);
}
cairo_status_t
_cairo_font_show_glyphs (cairo_font_t *font,
cairo_operator_t operator,
cairo_surface_t *source,
cairo_surface_t *surface,
double x,
double y,
cairo_glyph_t *glyphs,
int num_glyphs)
{
return font->backend->show_glyphs(font, operator, source,
surface, x, y, glyphs, num_glyphs);
}
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);
}
cairo_status_t
_cairo_font_font_extents (cairo_font_t *font,
cairo_font_extents_t *extents)
{
return font->backend->font_extents(font, extents);
}
/* public font interface follows */
void
cairo_font_reference (cairo_font_t *font)
{
font->refcount++;
}
void
cairo_font_destroy (cairo_font_t *font)
{
if (--(font->refcount) > 0)
return;
if (font->backend->destroy)
font->backend->destroy (font);
}
void
cairo_font_set_transform (cairo_font_t *font,
cairo_matrix_t *matrix)
{
cairo_matrix_copy (&(font->matrix), matrix);
}
void
cairo_font_current_transform (cairo_font_t *font,
cairo_matrix_t *matrix)
{
cairo_matrix_copy (matrix, &(font->matrix));
}
|