Blender
V2.93
source
blender
blenfont
intern
blf_internal_types.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU General Public License
4
* as published by the Free Software Foundation; either version 2
5
* of the License, or (at your option) any later version.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software Foundation,
14
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
*
16
* The Original Code is Copyright (C) 2008 Blender Foundation.
17
* All rights reserved.
18
*/
19
24
#pragma once
25
26
#include "
GPU_texture.h
"
27
#include "
GPU_vertex_buffer.h
"
28
29
#define BLF_BATCH_DRAW_LEN_MAX 2048
/* in glyph */
30
31
typedef
struct
BatchBLF
{
32
struct
FontBLF
*
font
;
/* can only batch glyph from the same font */
33
struct
GPUBatch
*
batch
;
34
struct
GPUVertBuf
*
verts
;
35
struct
GPUVertBufRaw
pos_step, col_step, offset_step,
glyph_size_step
;
36
unsigned
int
pos_loc
,
col_loc
,
offset_loc
,
glyph_size_loc
;
37
unsigned
int
glyph_len
;
38
float
ofs
[2];
/* copy of font->pos */
39
float
mat
[4][4];
/* previous call modelmatrix. */
40
bool
enabled
,
active
,
simple_shader
;
41
struct
GlyphCacheBLF
*
glyph_cache
;
42
}
BatchBLF
;
43
44
extern
BatchBLF
g_batch
;
45
46
typedef
struct
KerningCacheBLF
{
47
struct
KerningCacheBLF
*
next
, *
prev
;
48
49
/* kerning mode. */
50
FT_UInt
mode
;
51
52
/* only cache a ascii glyph pairs. Only store the x
53
* offset we are interested in, instead of the full FT_Vector. */
54
int
table
[0x80][0x80];
55
}
KerningCacheBLF
;
56
57
typedef
struct
GlyphCacheBLF
{
58
struct
GlyphCacheBLF
*
next
;
59
struct
GlyphCacheBLF
*
prev
;
60
61
/* font size. */
62
unsigned
int
size
;
63
64
/* and dpi. */
65
unsigned
int
dpi
;
66
67
bool
bold
;
68
bool
italic
;
69
70
/* and the glyphs. */
71
ListBase
bucket
[257];
72
73
/* fast ascii lookup */
74
struct
GlyphBLF
*
glyph_ascii_table
[256];
75
76
/* texture array, to draw the glyphs. */
77
GPUTexture
*
texture
;
78
char
*
bitmap_result
;
79
int
bitmap_len
;
80
int
bitmap_len_landed
;
81
int
bitmap_len_alloc
;
82
83
/* and the bigger glyph in the font. */
84
int
glyph_width_max
;
85
int
glyph_height_max
;
86
87
/* number of glyphs in the font. */
88
int
glyphs_len_max
;
89
90
/* number of glyphs not yet loaded (decreases every glyph loaded). */
91
int
glyphs_len_free
;
92
93
/* ascender and descender value. */
94
float
ascender
;
95
float
descender
;
96
}
GlyphCacheBLF
;
97
98
typedef
struct
GlyphBLF
{
99
struct
GlyphBLF
*
next
;
100
struct
GlyphBLF
*
prev
;
101
102
/* and the character, as UTF8 */
103
unsigned
int
c
;
104
105
/* freetype2 index, to speed-up the search. */
106
FT_UInt
idx
;
107
108
/* glyph box. */
109
rctf
box
;
110
111
/* advance size. */
112
float
advance
;
113
/* avoid conversion to int while drawing */
114
int
advance_i
;
115
116
/* position inside the texture where this glyph is store. */
117
int
offset
;
118
119
/* Bitmap data, from freetype. Take care that this
120
* can be NULL.
121
*/
122
unsigned
char
*
bitmap
;
123
124
/* Glyph width and height. */
125
int
dims
[2];
126
int
pitch
;
127
133
int
pos
[2];
134
135
struct
GlyphCacheBLF
*
glyph_cache
;
136
}
GlyphBLF
;
137
138
typedef
struct
FontBufInfoBLF
{
139
/* for draw to buffer, always set this to NULL after finish! */
140
float
*
fbuf
;
141
142
/* the same but unsigned char */
143
unsigned
char
*
cbuf
;
144
146
int
dims
[2];
147
148
/* number of channels. */
149
int
ch
;
150
151
/* display device used for color management */
152
struct
ColorManagedDisplay
*
display
;
153
154
/* and the color, the alphas is get from the glyph!
155
* color is srgb space */
156
float
col_init
[4];
157
/* cached conversion from 'col_init' */
158
unsigned
char
col_char
[4];
159
float
col_float
[4];
160
161
}
FontBufInfoBLF
;
162
163
typedef
struct
FontBLF
{
164
/* font name. */
165
char
*
name
;
166
167
/* # of times this font was loaded */
168
unsigned
int
reference_count
;
169
170
/* filename or NULL. */
171
char
*
filename
;
172
173
/* aspect ratio or scale. */
174
float
aspect
[3];
175
176
/* initial position for draw the text. */
177
float
pos
[3];
178
179
/* angle in radians. */
180
float
angle
;
181
182
#if 0
/* BLF_BLUR_ENABLE */
183
/* blur: 3 or 5 large kernel */
184
int
blur;
185
#endif
186
187
/* shadow level. */
188
int
shadow
;
189
190
/* and shadow offset. */
191
int
shadow_x
;
192
int
shadow_y
;
193
194
/* shadow color. */
195
unsigned
char
shadow_color
[4];
196
197
/* main text color. */
198
unsigned
char
color
[4];
199
200
/* Multiplied this matrix with the current one before
201
* draw the text! see blf_draw__start.
202
*/
203
float
m
[16];
204
205
/* clipping rectangle. */
206
rctf
clip_rec
;
207
208
/* the width to wrap the text, see BLF_WORD_WRAP */
209
int
wrap_width
;
210
211
/* font dpi (default 72). */
212
unsigned
int
dpi
;
213
214
/* font size. */
215
unsigned
int
size
;
216
217
/* max texture size. */
218
int
tex_size_max
;
219
220
/* font options. */
221
int
flags
;
222
223
/* List of glyph caches (GlyphCacheBLF) for this font for size, dpi, bold, italic.
224
* Use blf_glyph_cache_acquire(font) and blf_glyph_cache_release(font) to access cache!
225
*/
226
ListBase
cache
;
227
228
/* list of kerning cache for this font. */
229
ListBase
kerning_caches
;
230
231
/* current kerning cache for this font and kerning mode. */
232
KerningCacheBLF
*
kerning_cache
;
233
234
/* freetype2 lib handle. */
235
FT_Library
ft_lib
;
236
237
/* Mutex lock for library */
238
SpinLock
*
ft_lib_mutex
;
239
240
/* freetype2 face. */
241
FT_Face
face
;
242
243
/* freetype kerning */
244
FT_UInt
kerning_mode
;
245
246
/* data for buffer usage (drawing into a texture buffer) */
247
FontBufInfoBLF
buf_info
;
248
249
/* Mutex lock for glyph cache. */
250
SpinLock
*
glyph_cache_mutex
;
251
}
FontBLF
;
252
253
typedef
struct
DirBLF
{
254
struct
DirBLF
*
next
;
255
struct
DirBLF
*
prev
;
256
257
/* full path where search fonts. */
258
char
*
path
;
259
}
DirBLF
;
SpinLock
pthread_spinlock_t SpinLock
Definition:
BLI_threads.h:111
GPUBatch
GPUBatch
Definition:
GPU_batch.h:93
GPU_texture.h
GPUTexture
struct GPUTexture GPUTexture
Definition:
GPU_texture.h:33
GPU_vertex_buffer.h
GPUVertBuf
struct GPUVertBuf GPUVertBuf
Definition:
GPU_vertex_buffer.h:65
g_batch
BatchBLF g_batch
Definition:
blf_font.c:67
FontBufInfoBLF
struct FontBufInfoBLF FontBufInfoBLF
GlyphBLF
struct GlyphBLF GlyphBLF
DirBLF
struct DirBLF DirBLF
BatchBLF
struct BatchBLF BatchBLF
KerningCacheBLF
struct KerningCacheBLF KerningCacheBLF
FontBLF
struct FontBLF FontBLF
GlyphCacheBLF
struct GlyphCacheBLF GlyphCacheBLF
BatchBLF
Definition:
blf_internal_types.h:31
BatchBLF::pos_loc
unsigned int pos_loc
Definition:
blf_internal_types.h:36
BatchBLF::batch
struct GPUBatch * batch
Definition:
blf_internal_types.h:33
BatchBLF::col_loc
unsigned int col_loc
Definition:
blf_internal_types.h:36
BatchBLF::simple_shader
bool simple_shader
Definition:
blf_internal_types.h:40
BatchBLF::offset_loc
unsigned int offset_loc
Definition:
blf_internal_types.h:36
BatchBLF::verts
struct GPUVertBuf * verts
Definition:
blf_internal_types.h:34
BatchBLF::font
struct FontBLF * font
Definition:
blf_internal_types.h:32
BatchBLF::mat
float mat[4][4]
Definition:
blf_internal_types.h:39
BatchBLF::enabled
bool enabled
Definition:
blf_internal_types.h:40
BatchBLF::glyph_size_step
struct GPUVertBufRaw pos_step col_step offset_step glyph_size_step
Definition:
blf_internal_types.h:35
BatchBLF::glyph_cache
struct GlyphCacheBLF * glyph_cache
Definition:
blf_internal_types.h:41
BatchBLF::active
bool active
Definition:
blf_internal_types.h:40
BatchBLF::ofs
float ofs[2]
Definition:
blf_internal_types.h:38
BatchBLF::glyph_len
unsigned int glyph_len
Definition:
blf_internal_types.h:37
BatchBLF::glyph_size_loc
unsigned int glyph_size_loc
Definition:
blf_internal_types.h:36
ColorManagedDisplay
Definition:
IMB_colormanagement_intern.h:63
DirBLF
Definition:
blf_internal_types.h:253
DirBLF::next
struct DirBLF * next
Definition:
blf_internal_types.h:254
DirBLF::prev
struct DirBLF * prev
Definition:
blf_internal_types.h:255
DirBLF::path
char * path
Definition:
blf_internal_types.h:258
FontBLF
Definition:
blf_internal_types.h:163
FontBLF::kerning_mode
FT_UInt kerning_mode
Definition:
blf_internal_types.h:244
FontBLF::kerning_cache
KerningCacheBLF * kerning_cache
Definition:
blf_internal_types.h:232
FontBLF::dpi
unsigned int dpi
Definition:
blf_internal_types.h:212
FontBLF::glyph_cache_mutex
SpinLock * glyph_cache_mutex
Definition:
blf_internal_types.h:250
FontBLF::flags
int flags
Definition:
blf_internal_types.h:221
FontBLF::shadow
int shadow
Definition:
blf_internal_types.h:188
FontBLF::tex_size_max
int tex_size_max
Definition:
blf_internal_types.h:218
FontBLF::color
unsigned char color[4]
Definition:
blf_internal_types.h:198
FontBLF::kerning_caches
ListBase kerning_caches
Definition:
blf_internal_types.h:229
FontBLF::name
char * name
Definition:
blf_internal_types.h:165
FontBLF::size
unsigned int size
Definition:
blf_internal_types.h:215
FontBLF::filename
char * filename
Definition:
blf_internal_types.h:171
FontBLF::aspect
float aspect[3]
Definition:
blf_internal_types.h:174
FontBLF::pos
float pos[3]
Definition:
blf_internal_types.h:177
FontBLF::wrap_width
int wrap_width
Definition:
blf_internal_types.h:209
FontBLF::ft_lib_mutex
SpinLock * ft_lib_mutex
Definition:
blf_internal_types.h:238
FontBLF::shadow_x
int shadow_x
Definition:
blf_internal_types.h:191
FontBLF::reference_count
unsigned int reference_count
Definition:
blf_internal_types.h:168
FontBLF::ft_lib
FT_Library ft_lib
Definition:
blf_internal_types.h:235
FontBLF::cache
ListBase cache
Definition:
blf_internal_types.h:226
FontBLF::buf_info
FontBufInfoBLF buf_info
Definition:
blf_internal_types.h:247
FontBLF::m
float m[16]
Definition:
blf_internal_types.h:203
FontBLF::clip_rec
rctf clip_rec
Definition:
blf_internal_types.h:206
FontBLF::angle
float angle
Definition:
blf_internal_types.h:180
FontBLF::face
FT_Face face
Definition:
blf_internal_types.h:241
FontBLF::shadow_color
unsigned char shadow_color[4]
Definition:
blf_internal_types.h:195
FontBLF::shadow_y
int shadow_y
Definition:
blf_internal_types.h:192
FontBufInfoBLF
Definition:
blf_internal_types.h:138
FontBufInfoBLF::dims
int dims[2]
Definition:
blf_internal_types.h:146
FontBufInfoBLF::ch
int ch
Definition:
blf_internal_types.h:149
FontBufInfoBLF::fbuf
float * fbuf
Definition:
blf_internal_types.h:140
FontBufInfoBLF::col_char
unsigned char col_char[4]
Definition:
blf_internal_types.h:158
FontBufInfoBLF::col_float
float col_float[4]
Definition:
blf_internal_types.h:159
FontBufInfoBLF::col_init
float col_init[4]
Definition:
blf_internal_types.h:156
FontBufInfoBLF::cbuf
unsigned char * cbuf
Definition:
blf_internal_types.h:143
FontBufInfoBLF::display
struct ColorManagedDisplay * display
Definition:
blf_internal_types.h:152
GPUVertBufRaw
Definition:
GPU_vertex_buffer.h:106
GlyphBLF
Definition:
blf_internal_types.h:98
GlyphBLF::advance_i
int advance_i
Definition:
blf_internal_types.h:114
GlyphBLF::pitch
int pitch
Definition:
blf_internal_types.h:126
GlyphBLF::offset
int offset
Definition:
blf_internal_types.h:117
GlyphBLF::bitmap
unsigned char * bitmap
Definition:
blf_internal_types.h:122
GlyphBLF::c
unsigned int c
Definition:
blf_internal_types.h:103
GlyphBLF::pos
int pos[2]
Definition:
blf_internal_types.h:133
GlyphBLF::glyph_cache
struct GlyphCacheBLF * glyph_cache
Definition:
blf_internal_types.h:135
GlyphBLF::idx
FT_UInt idx
Definition:
blf_internal_types.h:106
GlyphBLF::box
rctf box
Definition:
blf_internal_types.h:109
GlyphBLF::dims
int dims[2]
Definition:
blf_internal_types.h:125
GlyphBLF::prev
struct GlyphBLF * prev
Definition:
blf_internal_types.h:100
GlyphBLF::advance
float advance
Definition:
blf_internal_types.h:112
GlyphBLF::next
struct GlyphBLF * next
Definition:
blf_internal_types.h:99
GlyphCacheBLF
Definition:
blf_internal_types.h:57
GlyphCacheBLF::bold
bool bold
Definition:
blf_internal_types.h:67
GlyphCacheBLF::glyph_width_max
int glyph_width_max
Definition:
blf_internal_types.h:84
GlyphCacheBLF::glyph_ascii_table
struct GlyphBLF * glyph_ascii_table[256]
Definition:
blf_internal_types.h:74
GlyphCacheBLF::bitmap_len
int bitmap_len
Definition:
blf_internal_types.h:79
GlyphCacheBLF::size
unsigned int size
Definition:
blf_internal_types.h:62
GlyphCacheBLF::glyphs_len_max
int glyphs_len_max
Definition:
blf_internal_types.h:88
GlyphCacheBLF::glyphs_len_free
int glyphs_len_free
Definition:
blf_internal_types.h:91
GlyphCacheBLF::bitmap_len_landed
int bitmap_len_landed
Definition:
blf_internal_types.h:80
GlyphCacheBLF::dpi
unsigned int dpi
Definition:
blf_internal_types.h:65
GlyphCacheBLF::bitmap_result
char * bitmap_result
Definition:
blf_internal_types.h:78
GlyphCacheBLF::texture
GPUTexture * texture
Definition:
blf_internal_types.h:77
GlyphCacheBLF::ascender
float ascender
Definition:
blf_internal_types.h:94
GlyphCacheBLF::glyph_height_max
int glyph_height_max
Definition:
blf_internal_types.h:85
GlyphCacheBLF::next
struct GlyphCacheBLF * next
Definition:
blf_internal_types.h:58
GlyphCacheBLF::bucket
ListBase bucket[257]
Definition:
blf_internal_types.h:71
GlyphCacheBLF::italic
bool italic
Definition:
blf_internal_types.h:68
GlyphCacheBLF::bitmap_len_alloc
int bitmap_len_alloc
Definition:
blf_internal_types.h:81
GlyphCacheBLF::prev
struct GlyphCacheBLF * prev
Definition:
blf_internal_types.h:59
GlyphCacheBLF::descender
float descender
Definition:
blf_internal_types.h:95
KerningCacheBLF
Definition:
blf_internal_types.h:46
KerningCacheBLF::next
struct KerningCacheBLF * next
Definition:
blf_internal_types.h:47
KerningCacheBLF::mode
FT_UInt mode
Definition:
blf_internal_types.h:50
KerningCacheBLF::table
int table[0x80][0x80]
Definition:
blf_internal_types.h:54
KerningCacheBLF::prev
struct KerningCacheBLF * prev
Definition:
blf_internal_types.h:47
ListBase
Definition:
DNA_listBase.h:46
rctf
Definition:
DNA_vec_types.h:84
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1