Blender  V3.3
blf_internal.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 struct FontBLF;
11 struct GlyphBLF;
12 struct GlyphCacheBLF;
13 struct ResultBLF;
14 struct rctf;
15 struct rcti;
16 
17 /* Max number of fonts in memory. Take care that every font has a glyph cache per size/dpi,
18  * so we don't need load the same font with different size, just load one and call BLF_size. */
19 #define BLF_MAX_FONT 32
20 
21 extern struct FontBLF *global_font[BLF_MAX_FONT];
22 
23 void blf_batch_draw_begin(struct FontBLF *font);
24 void blf_batch_draw(void);
25 
26 unsigned int blf_next_p2(unsigned int x);
27 unsigned int blf_hash(unsigned int val);
28 
29 char *blf_dir_search(const char *file);
34 char *blf_dir_metrics_search(const char *filepath);
35 /* int blf_dir_split(const char *str, char *file, int *size); */ /* UNUSED */
36 
37 int blf_font_init(void);
38 void blf_font_exit(void);
39 
40 bool blf_font_id_is_valid(int fontid);
41 
42 void blf_draw_buffer__start(struct FontBLF *font);
43 void blf_draw_buffer__end(void);
44 
45 struct FontBLF *blf_font_new(const char *name, const char *filepath);
46 struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size);
47 void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size);
48 
52 bool blf_font_size(struct FontBLF *font, float size, unsigned int dpi);
53 
54 void blf_font_draw(struct FontBLF *font,
55  const char *str,
56  size_t str_len,
57  struct ResultBLF *r_info);
58 void blf_font_draw__wrap(struct FontBLF *font,
59  const char *str,
60  size_t str_len,
61  struct ResultBLF *r_info);
62 
66 int blf_font_draw_mono(struct FontBLF *font, const char *str, size_t str_len, int cwidth);
67 void blf_font_draw_buffer(struct FontBLF *font,
68  const char *str,
69  size_t str_len,
70  struct ResultBLF *r_info);
71 void blf_font_draw_buffer__wrap(struct FontBLF *font,
72  const char *str,
73  size_t str_len,
74  struct ResultBLF *r_info);
76  struct FontBLF *font, const char *str, size_t str_len, int width, int *r_width);
78  struct FontBLF *font, const char *str, size_t str_len, int width, int *r_width);
79 void blf_font_boundbox(struct FontBLF *font,
80  const char *str,
81  size_t str_len,
82  struct rcti *r_box,
83  struct ResultBLF *r_info);
84 void blf_font_boundbox__wrap(struct FontBLF *font,
85  const char *str,
86  size_t str_len,
87  struct rcti *r_box,
88  struct ResultBLF *r_info);
89 void blf_font_width_and_height(struct FontBLF *font,
90  const char *str,
91  size_t str_len,
92  float *r_width,
93  float *r_height,
94  struct ResultBLF *r_info);
95 float blf_font_width(struct FontBLF *font,
96  const char *str,
97  size_t str_len,
98  struct ResultBLF *r_info);
99 float blf_font_height(struct FontBLF *font,
100  const char *str,
101  size_t str_len,
102  struct ResultBLF *r_info);
103 float blf_font_fixed_width(struct FontBLF *font);
104 int blf_font_height_max(struct FontBLF *font);
105 int blf_font_width_max(struct FontBLF *font);
106 int blf_font_descender(struct FontBLF *font);
107 int blf_font_ascender(struct FontBLF *font);
108 
109 char *blf_display_name(struct FontBLF *font);
110 
112  const char *str,
113  size_t str_len,
114  bool (*user_fn)(const char *str,
115  size_t str_step_ofs,
116  const struct rcti *glyph_step_bounds,
117  int glyph_advance_x,
118  const struct rcti *glyph_bounds,
119  const int glyph_bearing[2],
120  void *user_data),
121  void *user_data,
122  struct ResultBLF *r_info);
123 
124 int blf_font_count_missing_chars(struct FontBLF *font,
125  const char *str,
126  size_t str_len,
127  int *r_tot_chars);
128 
129 void blf_font_free(struct FontBLF *font);
130 
131 struct GlyphCacheBLF *blf_glyph_cache_acquire(struct FontBLF *font);
132 void blf_glyph_cache_release(struct FontBLF *font);
133 void blf_glyph_cache_clear(struct FontBLF *font);
134 
138 struct GlyphBLF *blf_glyph_ensure(struct FontBLF *font, struct GlyphCacheBLF *gc, uint charcode);
139 
140 void blf_glyph_free(struct GlyphBLF *g);
141 void blf_glyph_draw(
142  struct FontBLF *font, struct GlyphCacheBLF *gc, struct GlyphBLF *g, int x, int y);
143 
144 #ifdef WIN32
145 /* blf_font_win32_compat.c */
146 
147 # ifdef FT_FREETYPE_H
148 extern FT_Error FT_New_Face__win32_compat(FT_Library library,
149  const char *pathname,
150  FT_Long face_index,
151  FT_Face *aface);
152 # endif
153 #endif
unsigned int uint
Definition: BLI_sys_types.h:67
_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
_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 width
void blf_font_draw_buffer(struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info)
Definition: blf_font.c:557
void blf_draw_buffer__start(struct FontBLF *font)
Definition: blf.c:845
char * blf_display_name(struct FontBLF *font)
Definition: blf_font.c:1158
void blf_font_draw(struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info)
Definition: blf_font.c:371
void blf_batch_draw(void)
Definition: blf_font.c:229
int blf_font_draw_mono(struct FontBLF *font, const char *str, size_t str_len, int cwidth)
Definition: blf_font.c:378
char * blf_dir_metrics_search(const char *filepath)
Definition: blf_dir.c:135
int blf_font_count_missing_chars(struct FontBLF *font, const char *str, size_t str_len, int *r_tot_chars)
Definition: blf_font.c:1074
struct GlyphCacheBLF * blf_glyph_cache_acquire(struct FontBLF *font)
Definition: blf_glyph.c:116
bool blf_font_size(struct FontBLF *font, float size, unsigned int dpi)
Definition: blf_font.c:1408
void blf_font_exit(void)
Definition: blf_font.c:1180
void blf_font_boundbox(struct FontBLF *font, const char *str, size_t str_len, struct rcti *r_box, struct ResultBLF *r_info)
Definition: blf_font.c:732
void blf_glyph_free(struct GlyphBLF *g)
Definition: blf_glyph.c:1005
int blf_font_descender(struct FontBLF *font)
Definition: blf_font.c:1148
int blf_font_height_max(struct FontBLF *font)
Definition: blf_font.c:1122
void blf_glyph_draw(struct FontBLF *font, struct GlyphCacheBLF *gc, struct GlyphBLF *g, int x, int y)
Definition: blf_glyph.c:1108
struct FontBLF * blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size)
Definition: blf_font.c:1339
void blf_glyph_cache_clear(struct FontBLF *font)
Definition: blf_glyph.c:151
float blf_font_width(struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info)
Definition: blf_font.c:769
int blf_font_ascender(struct FontBLF *font)
Definition: blf_font.c:1153
void blf_glyph_cache_release(struct FontBLF *font)
Definition: blf_glyph.c:129
struct FontBLF * blf_font_new(const char *name, const char *filepath)
Definition: blf_font.c:1247
void blf_font_draw_buffer__wrap(struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info)
Definition: blf_font.c:1060
bool blf_font_id_is_valid(int fontid)
Definition: blf.c:93
void blf_batch_draw_begin(struct FontBLF *font)
Definition: blf_font.c:129
void blf_font_boundbox__wrap(struct FontBLF *font, const char *str, size_t str_len, struct rcti *r_box, struct ResultBLF *r_info)
Definition: blf_font.c:1039
unsigned int blf_next_p2(unsigned int x)
Definition: blf_util.c:18
char * blf_dir_search(const char *file)
Definition: blf_dir.c:109
void blf_font_boundbox_foreach_glyph(struct FontBLF *font, const char *str, size_t str_len, bool(*user_fn)(const char *str, size_t str_step_ofs, const struct rcti *glyph_step_bounds, int glyph_advance_x, const struct rcti *glyph_bounds, const int glyph_bearing[2], void *user_data), void *user_data, struct ResultBLF *r_info)
void blf_font_width_and_height(struct FontBLF *font, const char *str, size_t str_len, float *r_width, float *r_height, struct ResultBLF *r_info)
Definition: blf_font.c:740
struct FontBLF * global_font[BLF_MAX_FONT]
Definition: blf.c:44
void blf_font_free(struct FontBLF *font)
Definition: blf_font.c:1380
float blf_font_height(struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info)
Definition: blf_font.c:793
#define BLF_MAX_FONT
Definition: blf_internal.h:19
size_t blf_font_width_to_strlen(struct FontBLF *font, const char *str, size_t str_len, int width, int *r_width)
Definition: blf_font.c:590
size_t blf_font_width_to_rstrlen(struct FontBLF *font, const char *str, size_t str_len, int width, int *r_width)
Definition: blf_font.c:618
int blf_font_init(void)
Definition: blf_font.c:1172
int blf_font_width_max(struct FontBLF *font)
Definition: blf_font.c:1143
void blf_font_draw__wrap(struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info)
Definition: blf_font.c:1017
float blf_font_fixed_width(struct FontBLF *font)
Definition: blf_font.c:817
void blf_draw_buffer__end(void)
Definition: blf.c:859
unsigned int blf_hash(unsigned int val)
Definition: blf_util.c:30
struct GlyphBLF * blf_glyph_ensure(struct FontBLF *font, struct GlyphCacheBLF *gc, uint charcode)
Definition: blf_glyph.c:976
void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size)
Definition: blf_font.c:1329
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
FILE * file
void * user_data
#define str(s)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
unsigned int dpi
static FT_Library library