Blender  V2.93
blf_glyph.c
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) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19 
26 #include <math.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 
31 #include <ft2build.h>
32 
33 #include FT_FREETYPE_H
34 #include FT_GLYPH_H
35 #include FT_OUTLINE_H
36 #include FT_BITMAP_H
37 
38 #include "MEM_guardedalloc.h"
39 
40 #include "DNA_userdef_types.h"
41 #include "DNA_vec_types.h"
42 
43 #include "BLI_listbase.h"
44 #include "BLI_rect.h"
45 #include "BLI_threads.h"
46 
47 #include "BLF_api.h"
48 
49 #include "GPU_capabilities.h"
50 #include "GPU_immediate.h"
51 
52 #include "blf_internal.h"
53 #include "blf_internal_types.h"
54 
55 #include "BLI_math_vector.h"
56 #include "BLI_strict_flags.h"
57 
59 {
60  KerningCacheBLF *p;
61 
63  while (p) {
64  if (p->mode == font->kerning_mode) {
65  return p;
66  }
67  p = p->next;
68  }
69  return NULL;
70 }
71 
72 /* Create a new glyph cache for the current kerning mode. */
74 {
75  KerningCacheBLF *kc;
76 
77  kc = (KerningCacheBLF *)MEM_callocN(sizeof(KerningCacheBLF), "blf_kerning_cache_new");
78  kc->next = NULL;
79  kc->prev = NULL;
80  kc->mode = font->kerning_mode;
81 
82  unsigned int i, j;
83  for (i = 0; i < 0x80; i++) {
84  for (j = 0; j < 0x80; j++) {
85  GlyphBLF *g = blf_glyph_search(gc, i);
86  if (!g) {
87  FT_UInt glyph_index = FT_Get_Char_Index(font->face, i);
88  g = blf_glyph_add(font, gc, glyph_index, i);
89  }
90  /* Can fail on certain fonts */
91  GlyphBLF *g_prev = blf_glyph_search(gc, j);
92 
93  FT_Vector delta = {
94  .x = 0,
95  .y = 0,
96  };
97  if (g && g_prev && FT_Get_Kerning(font->face, g_prev->idx, g->idx, kc->mode, &delta) == 0) {
98  kc->table[i][j] = (int)delta.x >> 6;
99  }
100  else {
101  kc->table[i][j] = 0;
102  }
103  }
104  }
105 
106  BLI_addhead(&font->kerning_caches, kc);
107  return kc;
108 }
109 
111 {
112  font->kerning_cache = NULL;
114 }
115 
116 GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned int dpi)
117 {
118  GlyphCacheBLF *p;
119 
120  p = (GlyphCacheBLF *)font->cache.first;
121  while (p) {
122  if (p->size == size && p->dpi == dpi && (p->bold == ((font->flags & BLF_BOLD) != 0)) &&
123  (p->italic == ((font->flags & BLF_ITALIC) != 0))) {
124  return p;
125  }
126  p = p->next;
127  }
128  return NULL;
129 }
130 
131 /* Create a new glyph cache for the current size, dpi, bold, italic. */
133 {
134  GlyphCacheBLF *gc;
135 
136  gc = (GlyphCacheBLF *)MEM_callocN(sizeof(GlyphCacheBLF), "blf_glyph_cache_new");
137  gc->next = NULL;
138  gc->prev = NULL;
139  gc->size = font->size;
140  gc->dpi = font->dpi;
141  gc->bold = ((font->flags & BLF_BOLD) != 0);
142  gc->italic = ((font->flags & BLF_ITALIC) != 0);
143 
144  memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table));
145  memset(gc->bucket, 0, sizeof(gc->bucket));
146 
147  gc->glyphs_len_max = (int)font->face->num_glyphs;
148  gc->glyphs_len_free = (int)font->face->num_glyphs;
149  gc->ascender = ((float)font->face->size->metrics.ascender) / 64.0f;
150  gc->descender = ((float)font->face->size->metrics.descender) / 64.0f;
151 
152  if (FT_IS_SCALABLE(font->face)) {
153  gc->glyph_width_max = (int)((float)(font->face->bbox.xMax - font->face->bbox.xMin) *
154  (((float)font->face->size->metrics.x_ppem) /
155  ((float)font->face->units_per_EM)));
156 
157  gc->glyph_height_max = (int)((float)(font->face->bbox.yMax - font->face->bbox.yMin) *
158  (((float)font->face->size->metrics.y_ppem) /
159  ((float)font->face->units_per_EM)));
160  }
161  else {
162  gc->glyph_width_max = (int)(((float)font->face->size->metrics.max_advance) / 64.0f);
163  gc->glyph_height_max = (int)(((float)font->face->size->metrics.height) / 64.0f);
164  }
165 
166  /* can happen with size 1 fonts */
167  CLAMP_MIN(gc->glyph_width_max, 1);
168  CLAMP_MIN(gc->glyph_height_max, 1);
169 
170  BLI_addhead(&font->cache, gc);
171  return gc;
172 }
173 
175 {
177 
178  GlyphCacheBLF *gc = blf_glyph_cache_find(font, font->size, font->dpi);
179 
180  if (!gc) {
181  gc = blf_glyph_cache_new(font);
182  }
183 
184  return gc;
185 }
186 
188 {
190 }
191 
193 {
194  GlyphCacheBLF *gc;
195 
197 
198  while ((gc = BLI_pophead(&font->cache))) {
200  }
201 
203 }
204 
206 {
207  GlyphBLF *g;
208  for (uint i = 0; i < ARRAY_SIZE(gc->bucket); i++) {
209  while ((g = BLI_pophead(&gc->bucket[i]))) {
210  blf_glyph_free(g);
211  }
212  }
213  if (gc->texture) {
215  }
216  if (gc->bitmap_result) {
218  }
219  MEM_freeN(gc);
220 }
221 
223 {
224  GlyphBLF *p;
225  unsigned int key;
226 
227  key = blf_hash(c);
228  p = gc->bucket[key].first;
229  while (p) {
230  if (p->c == c) {
231  return p;
232  }
233  p = p->next;
234  }
235  return NULL;
236 }
237 
238 GlyphBLF *blf_glyph_add(FontBLF *font, GlyphCacheBLF *gc, unsigned int index, unsigned int c)
239 {
240  FT_GlyphSlot slot;
241  GlyphBLF *g;
242  FT_Error err;
243  FT_Bitmap bitmap, tempbitmap;
244  FT_BBox bbox;
245  unsigned int key;
246 
247  g = blf_glyph_search(gc, c);
248  if (g) {
249  return g;
250  }
251 
252  /* glyphs are dynamically created as needed by font rendering. this means that
253  * to make font rendering thread safe we have to do locking here. note that this
254  * must be a lock for the whole library and not just per font, because the font
255  * renderer uses a shared buffer internally */
257 
258  /* search again after locking */
259  g = blf_glyph_search(gc, c);
260  if (g) {
262  return g;
263  }
264 
265  int load_flags;
266  int render_mode;
267 
268  if (font->flags & BLF_MONOCHROME) {
269  load_flags = FT_LOAD_TARGET_MONO;
270  render_mode = FT_RENDER_MODE_MONO;
271  }
272  else {
273  load_flags = FT_LOAD_NO_BITMAP;
274  render_mode = FT_RENDER_MODE_NORMAL;
275  if (font->flags & BLF_HINTING_NONE) {
276  load_flags |= FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING;
277  }
278  else if (font->flags & BLF_HINTING_SLIGHT) {
279  load_flags |= FT_LOAD_TARGET_LIGHT;
280  }
281  else if (font->flags & BLF_HINTING_FULL) {
282  load_flags |= FT_LOAD_TARGET_NORMAL;
283  }
284  else {
285  /* Default, hinting disabled until FreeType has been upgraded
286  * to give good results on all platforms. */
287  load_flags |= FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING;
288  }
289  }
290 
291  err = FT_Load_Glyph(font->face, (FT_UInt)index, load_flags);
292 
293  /* Do not oblique a font that is designed to be italic! */
294  if (((font->flags & BLF_ITALIC) != 0) && !(font->face->style_flags & FT_STYLE_FLAG_ITALIC) &&
295  (font->face->glyph->format == FT_GLYPH_FORMAT_OUTLINE)) {
296  /* For (fake) italic: a shear transform with a 6 degree angle. */
297  FT_Matrix transform;
298  transform.xx = 0x10000L;
299  transform.yx = 0x00000L;
300  transform.xy = 0x03000L;
301  transform.yy = 0x10000L;
302  FT_Outline_Transform(&font->face->glyph->outline, &transform);
303  }
304 
305  /* Do not embolden an already bold font! */
306  if (((font->flags & BLF_BOLD) != 0) &&
307  !(font->face->style_flags & FT_STYLE_FLAG_BOLD) &
308  (font->face->glyph->format == FT_GLYPH_FORMAT_OUTLINE)) {
309  /* Strengthen the width more than the height. */
310  const FT_Pos extra_x = FT_MulFix(font->face->units_per_EM, font->face->size->metrics.x_scale) /
311  14;
312  const FT_Pos extra_y = FT_MulFix(font->face->units_per_EM, font->face->size->metrics.y_scale) /
313  28;
314  FT_Outline_EmboldenXY(&font->face->glyph->outline, extra_x, extra_y);
315  if ((font->face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) == 0) {
316  /* Need to increase advance, but not for fixed-width fonts. */
317  font->face->glyph->advance.x += (FT_Pos)(((float)extra_x) * 1.05f);
318  font->face->glyph->advance.y += extra_y;
319  }
320  else {
321  /* Widened fixed-pitch font gets a nudge left. */
322  FT_Outline_Translate(&font->face->glyph->outline, (extra_x / -2), 0);
323  }
324  }
325 
326  if (err) {
328  return NULL;
329  }
330 
331  /* get the glyph. */
332  slot = font->face->glyph;
333  err = FT_Render_Glyph(slot, render_mode);
334 
335  if (font->flags & BLF_MONOCHROME) {
336  /* Convert result from 1 bit per pixel to 8 bit per pixel */
337  /* Accum errors for later, fine if not interested beyond "ok vs any error" */
338  FT_Bitmap_New(&tempbitmap);
339 
340  /* Does Blender use Pitch 1 always? It works so far */
341  err += FT_Bitmap_Convert(font->ft_lib, &slot->bitmap, &tempbitmap, 1);
342  err += FT_Bitmap_Copy(font->ft_lib, &tempbitmap, &slot->bitmap);
343  err += FT_Bitmap_Done(font->ft_lib, &tempbitmap);
344  }
345 
346  if (err || slot->format != FT_GLYPH_FORMAT_BITMAP) {
348  return NULL;
349  }
350 
351  g = (GlyphBLF *)MEM_callocN(sizeof(GlyphBLF), "blf_glyph_add");
352  g->c = c;
353  g->idx = (FT_UInt)index;
354  bitmap = slot->bitmap;
355  g->dims[0] = (int)bitmap.width;
356  g->dims[1] = (int)bitmap.rows;
357 
358  const int buffer_size = g->dims[0] * g->dims[1];
359 
360  if (buffer_size != 0) {
361  if (font->flags & BLF_MONOCHROME) {
362  /* Font buffer uses only 0 or 1 values, Blender expects full 0..255 range */
363  for (int i = 0; i < buffer_size; i++) {
364  bitmap.buffer[i] = bitmap.buffer[i] ? 255 : 0;
365  }
366  }
367 
368  g->bitmap = MEM_mallocN((size_t)buffer_size, "glyph bitmap");
369  memcpy(g->bitmap, bitmap.buffer, (size_t)buffer_size);
370  }
371 
372  g->advance = ((float)slot->advance.x) / 64.0f;
373  g->advance_i = (int)g->advance;
374  g->pos[0] = slot->bitmap_left;
375  g->pos[1] = slot->bitmap_top;
376  g->pitch = slot->bitmap.pitch;
377 
378  FT_Outline_Get_CBox(&(slot->outline), &bbox);
379  g->box.xmin = ((float)bbox.xMin) / 64.0f;
380  g->box.xmax = ((float)bbox.xMax) / 64.0f;
381  g->box.ymin = ((float)bbox.yMin) / 64.0f;
382  g->box.ymax = ((float)bbox.yMax) / 64.0f;
383 
384  key = blf_hash(g->c);
385  BLI_addhead(&(gc->bucket[key]), g);
386 
388 
389  return g;
390 }
391 
393 {
394  if (g->bitmap) {
395  MEM_freeN(g->bitmap);
396  }
397  MEM_freeN(g);
398 }
399 
400 static void blf_texture_draw(const unsigned char color[4],
401  const int glyph_size[2],
402  const int offset,
403  float x1,
404  float y1,
405  float x2,
406  float y2)
407 {
408  /* Only one vertex per glyph, geometry shader expand it into a quad. */
409  /* TODO Get rid of Geom Shader because it's not optimal AT ALL for the GPU */
411  x1 + g_batch.ofs[0],
412  y1 + g_batch.ofs[1],
413  x2 + g_batch.ofs[0],
414  y2 + g_batch.ofs[1]);
415  copy_v4_v4_uchar(GPU_vertbuf_raw_step(&g_batch.col_step), color);
417  *((int *)GPU_vertbuf_raw_step(&g_batch.offset_step)) = offset;
418 
419  g_batch.glyph_len++;
420  /* Flush cache if it's full. */
422  blf_batch_draw();
423  }
424 }
425 
426 static void blf_texture5_draw(const unsigned char color_in[4],
427  const int glyph_size[2],
428  const int offset,
429  float x1,
430  float y1,
431  float x2,
432  float y2)
433 {
434  int glyph_size_flag[2];
435  /* flag the x and y component signs for 5x5 blurring */
436  glyph_size_flag[0] = -glyph_size[0];
437  glyph_size_flag[1] = -glyph_size[1];
438 
439  blf_texture_draw(color_in, glyph_size_flag, offset, x1, y1, x2, y2);
440 }
441 
442 static void blf_texture3_draw(const unsigned char color_in[4],
443  const int glyph_size[2],
444  const int offset,
445  float x1,
446  float y1,
447  float x2,
448  float y2)
449 {
450  int glyph_size_flag[2];
451  /* flag the x component sign for 3x3 blurring */
452  glyph_size_flag[0] = -glyph_size[0];
453  glyph_size_flag[1] = glyph_size[1];
454 
455  blf_texture_draw(color_in, glyph_size_flag, offset, x1, y1, x2, y2);
456 }
457 
458 static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
459 {
460  rect->xmin = floorf(x + (float)g->pos[0]);
461  rect->xmax = rect->xmin + (float)g->dims[0];
462  rect->ymin = floorf(y + (float)g->pos[1]);
463  rect->ymax = rect->ymin - (float)g->dims[1];
464 }
465 
466 static void blf_glyph_calc_rect_test(rctf *rect, GlyphBLF *g, float x, float y)
467 {
468  /* Intentionally check with g->advance, because this is the
469  * width used by BLF_width. This allows that the text slightly
470  * overlaps the clipping border to achieve better alignment. */
471  rect->xmin = floorf(x);
472  rect->xmax = rect->xmin + MIN2(g->advance, (float)g->dims[0]);
473  rect->ymin = floorf(y);
474  rect->ymax = rect->ymin - (float)g->dims[1];
475 }
476 
477 static void blf_glyph_calc_rect_shadow(rctf *rect, GlyphBLF *g, float x, float y, FontBLF *font)
478 {
479  blf_glyph_calc_rect(rect, g, x + (float)font->shadow_x, y + (float)font->shadow_y);
480 }
481 
482 void blf_glyph_render(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, float x, float y)
483 {
484  if ((!g->dims[0]) || (!g->dims[1])) {
485  return;
486  }
487 
488  if (g->glyph_cache == NULL) {
489  if (font->tex_size_max == -1) {
491  }
492 
493  g->offset = gc->bitmap_len;
494 
495  int buff_size = g->dims[0] * g->dims[1];
496  int bitmap_len = gc->bitmap_len + buff_size;
497 
498  if (bitmap_len > gc->bitmap_len_alloc) {
499  int w = font->tex_size_max;
500  int h = bitmap_len / w + 1;
501 
502  gc->bitmap_len_alloc = w * h;
504 
505  /* Keep in sync with the texture. */
506  if (gc->texture) {
508  }
509  gc->texture = GPU_texture_create_2d(__func__, w, h, 1, GPU_R8, NULL);
510 
511  gc->bitmap_len_landed = 0;
512  }
513 
514  memcpy(&gc->bitmap_result[gc->bitmap_len], g->bitmap, (size_t)buff_size);
515  gc->bitmap_len = bitmap_len;
516 
517  gc->glyphs_len_free--;
518  g->glyph_cache = gc;
519  }
520 
521  if (font->flags & BLF_CLIPPING) {
522  rctf rect_test;
523  blf_glyph_calc_rect_test(&rect_test, g, x, y);
524  BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
525 
526  if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
527  return;
528  }
529  }
530 
531  if (g_batch.glyph_cache != g->glyph_cache) {
532  blf_batch_draw();
534  }
535 
536  if (font->flags & BLF_SHADOW) {
537  rctf rect_ofs;
538  blf_glyph_calc_rect_shadow(&rect_ofs, g, x, y, font);
539 
540  if (font->shadow == 0) {
542  g->dims,
543  g->offset,
544  rect_ofs.xmin,
545  rect_ofs.ymin,
546  rect_ofs.xmax,
547  rect_ofs.ymax);
548  }
549  else if (font->shadow <= 4) {
551  g->dims,
552  g->offset,
553  rect_ofs.xmin,
554  rect_ofs.ymin,
555  rect_ofs.xmax,
556  rect_ofs.ymax);
557  }
558  else {
560  g->dims,
561  g->offset,
562  rect_ofs.xmin,
563  rect_ofs.ymin,
564  rect_ofs.xmax,
565  rect_ofs.ymax);
566  }
567  }
568 
569  rctf rect;
570  blf_glyph_calc_rect(&rect, g, x, y);
571 
572 #if BLF_BLUR_ENABLE
573  switch (font->blur) {
574  case 3:
576  font->color, g->dims, g->offset, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
577  break;
578  case 5:
580  font->color, g->dims, g->offset, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
581  break;
582  default:
584  font->color, g->dims, g->offset, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
585  }
586 #else
587  blf_texture_draw(font->color, g->dims, g->offset, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
588 #endif
589 }
typedef float(TangentPoint)[2]
#define BLF_CLIPPING
Definition: BLF_api.h:270
#define BLF_MONOCHROME
Definition: BLF_api.h:276
#define BLF_HINTING_NONE
Definition: BLF_api.h:277
#define BLF_BOLD
Definition: BLF_api.h:280
#define BLF_ITALIC
Definition: BLF_api.h:281
#define BLF_HINTING_FULL
Definition: BLF_api.h:279
#define BLF_HINTING_SLIGHT
Definition: BLF_api.h:278
#define BLF_SHADOW
Definition: BLF_api.h:271
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:257
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:87
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
void BLI_rctf_translate(struct rctf *rect, float x, float y)
Definition: rct.c:604
bool BLI_rctf_inside_rctf(const rctf *rct_a, const rctf *rct_b)
Definition: rct.c:221
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
unsigned int uint
Definition: BLI_sys_types.h:83
void BLI_spin_unlock(SpinLock *spin)
Definition: threads.cc:480
void BLI_spin_lock(SpinLock *spin)
Definition: threads.cc:461
#define ARRAY_SIZE(arr)
#define MIN2(a, b)
#define CLAMP_MIN(a, b)
int GPU_max_texture_size(void)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble y1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble x2
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:508
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:250
@ GPU_R8
Definition: GPU_texture.h:108
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
BatchBLF g_batch
Definition: blf_font.c:67
void blf_batch_draw(void)
Definition: blf_font.c:217
static void blf_texture5_draw(const unsigned char color_in[4], const int glyph_size[2], const int offset, float x1, float y1, float x2, float y2)
Definition: blf_glyph.c:426
GlyphBLF * blf_glyph_add(FontBLF *font, GlyphCacheBLF *gc, unsigned int index, unsigned int c)
Definition: blf_glyph.c:238
void blf_kerning_cache_clear(FontBLF *font)
Definition: blf_glyph.c:110
GlyphCacheBLF * blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned int dpi)
Definition: blf_glyph.c:116
void blf_glyph_cache_clear(FontBLF *font)
Definition: blf_glyph.c:192
KerningCacheBLF * blf_kerning_cache_new(FontBLF *font, GlyphCacheBLF *gc)
Definition: blf_glyph.c:73
void blf_glyph_cache_free(GlyphCacheBLF *gc)
Definition: blf_glyph.c:205
void blf_glyph_render(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, float x, float y)
Definition: blf_glyph.c:482
static void blf_texture_draw(const unsigned char color[4], const int glyph_size[2], const int offset, float x1, float y1, float x2, float y2)
Definition: blf_glyph.c:400
static void blf_glyph_calc_rect_test(rctf *rect, GlyphBLF *g, float x, float y)
Definition: blf_glyph.c:466
static void blf_texture3_draw(const unsigned char color_in[4], const int glyph_size[2], const int offset, float x1, float y1, float x2, float y2)
Definition: blf_glyph.c:442
static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
Definition: blf_glyph.c:458
void blf_glyph_cache_release(FontBLF *font)
Definition: blf_glyph.c:187
GlyphBLF * blf_glyph_search(GlyphCacheBLF *gc, unsigned int c)
Definition: blf_glyph.c:222
static void blf_glyph_calc_rect_shadow(rctf *rect, GlyphBLF *g, float x, float y, FontBLF *font)
Definition: blf_glyph.c:477
GlyphCacheBLF * blf_glyph_cache_acquire(FontBLF *font)
Definition: blf_glyph.c:174
void blf_glyph_free(GlyphBLF *g)
Definition: blf_glyph.c:392
GlyphCacheBLF * blf_glyph_cache_new(FontBLF *font)
Definition: blf_glyph.c:132
KerningCacheBLF * blf_kerning_cache_find(FontBLF *font)
Definition: blf_glyph.c:58
unsigned int blf_hash(unsigned int val)
Definition: blf_util.c:46
#define BLF_BATCH_DRAW_LEN_MAX
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
static FT_Error err
Definition: freetypefont.c:52
#define floorf(x)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
static unsigned c
Definition: RandGen.cpp:97
struct GPUVertBufRaw pos_step col_step offset_step glyph_size_step
struct GlyphCacheBLF * glyph_cache
float ofs[2]
unsigned int glyph_len
FT_UInt kerning_mode
KerningCacheBLF * kerning_cache
unsigned int dpi
SpinLock * glyph_cache_mutex
unsigned char color[4]
ListBase kerning_caches
unsigned int size
float pos[3]
SpinLock * ft_lib_mutex
FT_Library ft_lib
ListBase cache
unsigned char shadow_color[4]
unsigned char * bitmap
unsigned int c
struct GlyphCacheBLF * glyph_cache
struct GlyphBLF * next
struct GlyphBLF * glyph_ascii_table[256]
unsigned int size
unsigned int dpi
GPUTexture * texture
struct GlyphCacheBLF * next
ListBase bucket[257]
struct GlyphCacheBLF * prev
struct KerningCacheBLF * next
int table[0x80][0x80]
struct KerningCacheBLF * prev
void * first
Definition: DNA_listBase.h:47
float xmax
Definition: DNA_vec_types.h:85
float xmin
Definition: DNA_vec_types.h:85
float ymax
Definition: DNA_vec_types.h:86
float ymin
Definition: DNA_vec_types.h:86