1 |
/* Pango |
2 |
* pangoopengl.h: OpenGL/Freetype2 backend |
3 |
* |
4 |
* Copyright (C) 1999 Red Hat Software |
5 |
* Copyright (C) 2000 Tor Lillqvist |
6 |
* Copyright (C) 2006 Marc Lehmann <pcg@goof.com> |
7 |
* |
8 |
* This file is free software; you can redistribute it and/or |
9 |
* modify it under the terms of the GNU Library General Public |
10 |
* License as published by the Free Software Foundation; either |
11 |
* version 2 of the License, or (at your option) any later version. |
12 |
* |
13 |
* This file is distributed in the hope that it will be useful, |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 |
* Library General Public License for more details. |
17 |
* |
18 |
* You should have received a copy of the GNU Library General Public |
19 |
* License along with this library; if not, write to the |
20 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 |
* Boston, MA 02111-1307, USA. |
22 |
*/ |
23 |
|
24 |
#ifndef PANGOOPENGL_H__ |
25 |
#define PANGOOPENGL_H__ |
26 |
|
27 |
#include <glib-object.h> |
28 |
|
29 |
#include <fontconfig/fontconfig.h> |
30 |
|
31 |
#include <pango/pango-layout.h> |
32 |
#include <pango/pangofc-font.h> |
33 |
|
34 |
G_BEGIN_DECLS |
35 |
|
36 |
#define PANGO_TYPE_OPENGL_FONT_MAP (pango_opengl_font_map_get_type ()) |
37 |
#define PANGO_OPENGL_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_OPENGL_FONT_MAP, PangoOpenGLFontMap)) |
38 |
#define PANGO_OPENGL_IS_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_OPENGL_FONT_MAP)) |
39 |
|
40 |
typedef struct _PangoOpenGLFontMap PangoOpenGLFontMap; |
41 |
typedef struct _PangoOpenGLFont PangoOpenGLFont; |
42 |
typedef struct _PangoOpenGLGlyphInfo PangoOpenGLGlyphInfo; |
43 |
typedef struct _PangoOpenGLRenderer PangoOpenGLRenderer; |
44 |
typedef struct _PangoOpenGLFontMapClass PangoOpenGLFontMapClass; |
45 |
|
46 |
typedef void (*PangoOpenGLSubstituteFunc) (FcPattern *pattern, gpointer data); |
47 |
|
48 |
#define FLAG_INVERSE 1 |
49 |
#define FLAG_OUTLINE 2 // not yet implemented |
50 |
|
51 |
/* Calls for applications */ |
52 |
|
53 |
void |
54 |
pango_opengl_render_layout_subpixel (PangoLayout *layout, |
55 |
rc_t *rc, |
56 |
int x, int y, |
57 |
float r, float g, float b, float a, |
58 |
int flags); |
59 |
|
60 |
void |
61 |
pango_opengl_render_layout (PangoLayout *layout, |
62 |
rc_t *rc, |
63 |
int x, int y, |
64 |
float r, float g, float b, float a, |
65 |
int flags); |
66 |
|
67 |
GType pango_opengl_font_map_get_type (void); |
68 |
|
69 |
PangoFontMap *pango_opengl_font_map_new (void); |
70 |
void pango_opengl_font_map_set_default_substitute (PangoOpenGLFontMap *fontmap, |
71 |
PangoOpenGLSubstituteFunc func, |
72 |
gpointer data, |
73 |
GDestroyNotify notify); |
74 |
void pango_opengl_font_map_substitute_changed (PangoOpenGLFontMap *fontmap); |
75 |
PangoContext *pango_opengl_font_map_create_context (PangoOpenGLFontMap *fontmap); |
76 |
|
77 |
struct _PangoOpenGLFont |
78 |
{ |
79 |
PangoFcFont font; |
80 |
|
81 |
FT_Face face; |
82 |
int load_flags; |
83 |
|
84 |
int size; |
85 |
|
86 |
GSList *metrics_by_lang; |
87 |
|
88 |
GHashTable *glyph_info; |
89 |
GDestroyNotify glyph_cache_destroy; |
90 |
}; |
91 |
|
92 |
struct _PangoOpenGLGlyphInfo |
93 |
{ |
94 |
PangoRectangle logical_rect; |
95 |
PangoRectangle ink_rect; |
96 |
void *cached_glyph; |
97 |
}; |
98 |
|
99 |
#define PANGO_TYPE_OPENGL_FONT (pango_opengl_font_get_type ()) |
100 |
#define PANGO_OPENGL_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_OPENGL_FONT, PangoOpenGLFont)) |
101 |
#define PANGO_OPENGL_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_OPENGL_FONT)) |
102 |
|
103 |
#define PANGO_SCALE_26_6 (PANGO_SCALE / (1<<6)) |
104 |
#define PANGO_PIXELS_26_6(d) \ |
105 |
(((d) >= 0) ? \ |
106 |
((d) + PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6 : \ |
107 |
((d) - PANGO_SCALE_26_6 / 2) / PANGO_SCALE_26_6) |
108 |
#define PANGO_UNITS_26_6(d) (PANGO_SCALE_26_6 * (d)) |
109 |
|
110 |
GType pango_opengl_font_get_type (void); |
111 |
|
112 |
PangoOpenGLFont *_pango_opengl_font_new (PangoOpenGLFontMap *fontmap, FcPattern *pattern); |
113 |
FT_Library _pango_opengl_font_map_get_library (PangoFontMap *fontmap); |
114 |
|
115 |
void *_pango_opengl_font_get_cache_glyph_data (PangoFont *font, int glyph_index); |
116 |
void _pango_opengl_font_set_cache_glyph_data (PangoFont *font, int glyph_index, void *cached_glyph); |
117 |
void _pango_opengl_font_set_glyph_cache_destroy (PangoFont *font, GDestroyNotify destroy_notify); |
118 |
|
119 |
#define PANGO_TYPE_OPENGL_RENDERER (pango_opengl_renderer_get_type()) |
120 |
#define PANGO_OPENGL_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_OPENGL_RENDERER, PangoOpenGLRenderer)) |
121 |
#define PANGO_IS_OPENGL_RENDERER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_OPENGL_RENDERER)) |
122 |
|
123 |
GType pango_opengl_renderer_get_type (void); |
124 |
|
125 |
PangoRenderer *_pango_opengl_font_map_get_renderer (PangoOpenGLFontMap *fontmap); |
126 |
|
127 |
// ERROR/TODO: this is not public. this means we have to reimplement |
128 |
// not just all of pangoft2, but all of pangofc. Whats the point |
129 |
// of adding 3 layers of abstractions if you can't extend it in any way? |
130 |
void pango_fc_font_get_raw_extents (PangoFcFont *font, FT_Int32 load_flags, PangoGlyph glyph, PangoRectangle *ink_rect, PangoRectangle *logical_rect); |
131 |
|
132 |
G_END_DECLS |
133 |
|
134 |
#endif |