-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgd_pango.h
176 lines (147 loc) · 4.74 KB
/
gd_pango.h
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
/*
+----------------------------------------------------------------------+
| GD-Pango |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2007 Pierre-Alain Joye |
+----------------------------------------------------------------------+
| This source file is subject to the New BSD license, That is bundled |
| with this package in the file LICENSE.NEWBSD, and is available |
| through the world-wide-web at |
| http://www.opensource.org/licenses/bsd-license.php |
| If you did not receive a copy of the new BSDlicense and are unable |
| to obtain it through the world-wide-web, please send a note to |
| pajoye@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Pierre-A. Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
/**
* @file
* @brief Header file of gd-pango
*
* @author Pierre-Alain Joye
* @date 2006/12/19
* $Id$
*/
#ifndef GD_PANGO_H
#define GD_PANGO_H
#ifdef __cplusplus
extern "C" {
#endif
#define GD_SUCCESS 1
#define GD_FAILURE -1
#define GD_PANGO_DEFAULT_FONT_FAMILY Vera
#define GD_PANGO_DEFAULT_FONT_SIZE 10
/* TODO: Use GD DPI instead */
#define GD_PANGO_DEFAULT_DPI 96
#define _MAKE_FONT_NAME(family, size) #family " " #size
#define GD_PANGO_MAKE_FONT_NAME(family, size) _MAKE_FONT_NAME(family, size)
#define gdPangoColorToRGBA7888(pc) \
gdTrueColorAlpha(pc.red >> 8, \
pc.green >> 8, \
pc.blue >> 8, \
0)
enum {
GD_PANGO_ERROR_FC_FT,
GD_PANGO_ERROR_FC_PAT,
GD_PANGO_ERROR_FORMAT,
};
/**
* Defines a bounding box. Note that the box includes all of the corners.
*/
typedef struct { /* bounding box */
gdPoint bottom_left;
gdPoint bottom_right;
gdPoint top_right;
gdPoint top_left;
} gdBBox;
/**
* Defines a colors set. The foreground and background can be
* defined using a integer value returned by gdTrueColor(r,g,b).
* For example, you can use when you create a gdPangoContext.
*/
typedef struct gdPangoColors { /* colors definition */
unsigned int fg; /*!< Foreground color */
unsigned int bg; /*!< Background color */
unsigned int alpha; /*!< General alpha component */
} gdPangoColors;
/**
* Defines a gd Pango context. Use gdPangoCreateContext to create a GD
* Context object. Different functions are provided to access its
* values, do not access it directly.
*/
typedef struct gdPangoContext { /* GD Pango Context */
PangoContext *context;
PangoFontMap *font_map;
PangoFontDescription *font_desc;
PangoMatrix *matrix;
PangoLayout *layout;
FT_Bitmap *ft2bmp;
gdPangoColors default_colors;
int min_width;
int min_height;
double angle;
} gdPangoContext;
extern int gdPangoInit(void);
extern int gdPangoIsInitialized(void);
extern gdPangoContext* gdPangoCreateContext(void);
extern void gdPangoFreeContext(gdPangoContext *context);
extern gdImagePtr gdPangoCreateSurfaceDraw(
gdPangoContext *context);
extern gdImagePtr gdPangoRenderTo(
gdPangoContext *context,
gdImagePtr surface,
int x, int y);
extern void gdPangoSetDpi(
gdPangoContext *context,
double dpi_x, double dpi_y);
extern void gdPangoSetMinimumSize(
gdPangoContext *context,
int width, int height);
extern void gdPangoSetDefaultColor(
gdPangoContext *context,
const gdPangoColors *colors);
extern int gdPangoGetLayoutWidth(
gdPangoContext *context);
extern int gdPangoGetLayoutHeight(
gdPangoContext *context);
extern void gdPangoSetMarkup(
gdPangoContext *context,
const char *markup,
const int length);
extern void gdPangoSetText(
gdPangoContext *context,
const char *markup,
int length);
extern void gdPangoSetBaseDirection(
gdPangoContext *context, PangoDirection pango_dir);
extern int gdPangoSetPangoFontDescriptionFromFile(
gdPangoContext *context, const char *fontlist, double ptsize, int *error);
#ifdef __FT2_BUILD_UNIX_H__
extern void gdPangoCopyFTBitmapToSurface(
const FT_Bitmap *bitmap,
gdImagePtr surface,
const gdPangoColors *colors,
gdRect *rect);
extern char *gdImageStringPangoFT(
gdImagePtr im,
gdBBox *bbox,
int fg,
char *fontlist,
double ptsize,
double angle,
int x,
int y,
char *string);
#endif /* __FT2_BUILD_UNIX_H__ */
#ifdef __PANGO_H__
extern PangoFontMap* gdPangoGetPangoFontMap(gdPangoContext *context);
extern PangoFontDescription* gdPangoGetPangoFontDescription(gdPangoContext *context);
extern PangoLayout* gdPangoGetPangoLayout(gdPangoContext *context);
extern PangoContext* gdPangoGetPangoContext(gdPangoContext *context);
#endif /* __PANGO_H__ */
#ifdef __cplusplus
}
#endif
#endif /* GD_PANGO_H */