Blender  V2.93
blf_internal.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) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 struct FontBLF;
27 struct GlyphBLF;
28 struct GlyphCacheBLF;
29 struct ResultBLF;
30 struct rctf;
31 struct rcti;
32 
33 void blf_batch_draw_begin(struct FontBLF *font);
34 void blf_batch_draw(void);
35 
36 unsigned int blf_next_p2(unsigned int x);
37 unsigned int blf_hash(unsigned int val);
38 
39 char *blf_dir_search(const char *file);
40 char *blf_dir_metrics_search(const char *filename);
41 /* int blf_dir_split(const char *str, char *file, int *size); */ /* UNUSED */
42 
43 int blf_font_init(void);
44 void blf_font_exit(void);
45 
46 bool blf_font_id_is_valid(int fontid);
47 
48 void blf_draw_buffer__start(struct FontBLF *font);
49 void blf_draw_buffer__end(void);
50 
51 struct FontBLF *blf_font_new(const char *name, const char *filename);
52 struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size);
53 void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size);
54 
55 void blf_font_size(struct FontBLF *font, unsigned int size, unsigned int dpi);
56 void blf_font_draw(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info);
57 void blf_font_draw__wrap(struct FontBLF *font,
58  const char *str,
59  size_t len,
60  struct ResultBLF *r_info);
61 void blf_font_draw_ascii(struct FontBLF *font,
62  const char *str,
63  size_t len,
64  struct ResultBLF *r_info);
65 int blf_font_draw_mono(struct FontBLF *font, const char *str, size_t len, int cwidth);
66 void blf_font_draw_buffer(struct FontBLF *font,
67  const char *str,
68  size_t len,
69  struct ResultBLF *r_info);
70 void blf_font_draw_buffer__wrap(struct FontBLF *font,
71  const char *str,
72  size_t len,
73  struct ResultBLF *r_info);
75  struct FontBLF *font, const char *str, size_t len, float width, float *r_width);
77  struct FontBLF *font, const char *str, size_t len, float width, float *r_width);
78 void blf_font_boundbox(struct FontBLF *font,
79  const char *str,
80  size_t len,
81  struct rctf *r_box,
82  struct ResultBLF *r_info);
83 void blf_font_boundbox__wrap(struct FontBLF *font,
84  const char *str,
85  size_t len,
86  struct rctf *r_box,
87  struct ResultBLF *r_info);
88 void blf_font_width_and_height(struct FontBLF *font,
89  const char *str,
90  size_t len,
91  float *r_width,
92  float *r_height,
93  struct ResultBLF *r_info);
94 float blf_font_width(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info);
95 float blf_font_height(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info);
96 float blf_font_fixed_width(struct FontBLF *font);
97 int blf_font_height_max(struct FontBLF *font);
98 int blf_font_width_max(struct FontBLF *font);
99 float blf_font_descender(struct FontBLF *font);
100 float blf_font_ascender(struct FontBLF *font);
101 
103  const char *str,
104  size_t len,
105  bool (*user_fn)(const char *str,
106  const size_t str_step_ofs,
107  const struct rcti *glyph_step_bounds,
108  const int glyph_advance_x,
109  const struct rctf *glyph_bounds,
110  const int glyph_bearing[2],
111  void *user_data),
112  void *user_data,
113  struct ResultBLF *r_info);
114 
115 int blf_font_count_missing_chars(struct FontBLF *font,
116  const char *str,
117  const size_t len,
118  int *r_tot_chars);
119 
120 void blf_font_free(struct FontBLF *font);
121 
122 struct KerningCacheBLF *blf_kerning_cache_find(struct FontBLF *font);
123 struct KerningCacheBLF *blf_kerning_cache_new(struct FontBLF *font, struct GlyphCacheBLF *gc);
124 void blf_kerning_cache_clear(struct FontBLF *font);
125 
126 struct GlyphCacheBLF *blf_glyph_cache_find(struct FontBLF *font,
127  unsigned int size,
128  unsigned int dpi);
129 struct GlyphCacheBLF *blf_glyph_cache_new(struct FontBLF *font);
130 struct GlyphCacheBLF *blf_glyph_cache_acquire(struct FontBLF *font);
131 void blf_glyph_cache_release(struct FontBLF *font);
132 void blf_glyph_cache_clear(struct FontBLF *font);
133 void blf_glyph_cache_free(struct GlyphCacheBLF *gc);
134 
135 struct GlyphBLF *blf_glyph_search(struct GlyphCacheBLF *gc, unsigned int c);
136 struct GlyphBLF *blf_glyph_add(struct FontBLF *font,
137  struct GlyphCacheBLF *gc,
138  unsigned int index,
139  unsigned int c);
140 
141 void blf_glyph_free(struct GlyphBLF *g);
142 void blf_glyph_render(
143  struct FontBLF *font, struct GlyphCacheBLF *gc, struct GlyphBLF *g, float x, float y);
144 
145 #ifdef WIN32
146 /* blf_font_win32_compat.c */
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
_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
_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
int blf_font_draw_mono(struct FontBLF *font, const char *str, size_t len, int cwidth)
Definition: blf_font.c:518
struct GlyphBLF * blf_glyph_add(struct FontBLF *font, struct GlyphCacheBLF *gc, unsigned int index, unsigned int c)
Definition: blf_glyph.c:238
void blf_draw_buffer__start(struct FontBLF *font)
Definition: blf.c:880
void blf_font_draw_ascii(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
Definition: blf_font.c:512
void blf_batch_draw(void)
Definition: blf_font.c:217
void blf_glyph_cache_free(struct GlyphCacheBLF *gc)
Definition: blf_glyph.c:205
struct GlyphCacheBLF * blf_glyph_cache_acquire(struct FontBLF *font)
Definition: blf_glyph.c:174
float blf_font_height(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
Definition: blf_font.c:1133
struct FontBLF * blf_font_new(const char *name, const char *filename)
Definition: blf_font.c:1351
void blf_font_exit(void)
Definition: blf_font.c:269
void blf_glyph_free(struct GlyphBLF *g)
Definition: blf_glyph.c:392
struct GlyphBLF * blf_glyph_search(struct GlyphCacheBLF *gc, unsigned int c)
Definition: blf_glyph.c:222
int blf_font_height_max(struct FontBLF *font)
Definition: blf_font.c:1423
struct FontBLF * blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size)
Definition: blf_font.c:1397
void blf_glyph_cache_clear(struct FontBLF *font)
Definition: blf_glyph.c:192
void blf_font_draw_buffer__wrap(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
Definition: blf_font.c:1073
void blf_font_boundbox__wrap(struct FontBLF *font, const char *str, size_t len, struct rctf *r_box, struct ResultBLF *r_info)
Definition: blf_font.c:1052
size_t blf_font_width_to_rstrlen(struct FontBLF *font, const char *str, size_t len, float width, float *r_width)
Definition: blf_font.c:773
void blf_glyph_cache_release(struct FontBLF *font)
Definition: blf_glyph.c:187
bool blf_font_id_is_valid(int fontid)
Definition: blf.c:116
struct KerningCacheBLF * blf_kerning_cache_find(struct FontBLF *font)
Definition: blf_glyph.c:58
void blf_batch_draw_begin(struct FontBLF *font)
Definition: blf_font.c:117
struct KerningCacheBLF * blf_kerning_cache_new(struct FontBLF *font, struct GlyphCacheBLF *gc)
Definition: blf_glyph.c:73
int blf_font_count_missing_chars(struct FontBLF *font, const char *str, const size_t len, int *r_tot_chars)
Definition: blf_font.c:1254
void blf_font_draw__wrap(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
Definition: blf_font.c:1037
struct GlyphCacheBLF * blf_glyph_cache_new(struct FontBLF *font)
Definition: blf_glyph.c:132
void blf_kerning_cache_clear(struct FontBLF *font)
Definition: blf_glyph.c:110
float blf_font_ascender(struct FontBLF *font)
Definition: blf_font.c:1459
struct GlyphCacheBLF * blf_glyph_cache_find(struct FontBLF *font, unsigned int size, unsigned int dpi)
Definition: blf_glyph.c:116
unsigned int blf_next_p2(unsigned int x)
Definition: blf_util.c:34
char * blf_dir_search(const char *file)
Definition: blf_dir.c:128
void blf_font_draw(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
Definition: blf_font.c:461
size_t blf_font_width_to_strlen(struct FontBLF *font, const char *str, size_t len, float width, float *r_width)
Definition: blf_font.c:737
void blf_font_free(struct FontBLF *font)
Definition: blf_font.c:1279
void blf_font_width_and_height(struct FontBLF *font, const char *str, size_t len, float *r_width, float *r_height, struct ResultBLF *r_info)
Definition: blf_font.c:1083
float blf_font_width(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
Definition: blf_font.c:1112
int blf_font_init(void)
Definition: blf_font.c:261
int blf_font_width_max(struct FontBLF *font)
Definition: blf_font.c:1435
char * blf_dir_metrics_search(const char *filename)
Definition: blf_dir.c:158
float blf_font_fixed_width(struct FontBLF *font)
Definition: blf_font.c:1154
float blf_font_descender(struct FontBLF *font)
Definition: blf_font.c:1447
void blf_font_boundbox_foreach_glyph(struct FontBLF *font, const char *str, size_t len, bool(*user_fn)(const char *str, const size_t str_step_ofs, const struct rcti *glyph_step_bounds, const int glyph_advance_x, const struct rctf *glyph_bounds, const int glyph_bearing[2], void *user_data), void *user_data, struct ResultBLF *r_info)
void blf_glyph_render(struct FontBLF *font, struct GlyphCacheBLF *gc, struct GlyphBLF *g, float x, float y)
Definition: blf_glyph.c:482
void blf_font_draw_buffer(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info)
Definition: blf_font.c:705
void blf_draw_buffer__end(void)
Definition: blf.c:894
unsigned int blf_hash(unsigned int val)
Definition: blf_util.c:46
void blf_font_size(struct FontBLF *font, unsigned int size, unsigned int dpi)
Definition: blf_font.c:277
void blf_font_boundbox(struct FontBLF *font, const char *str, size_t len, struct rctf *r_box, struct ResultBLF *r_info)
Definition: blf_font.c:900
void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size)
Definition: blf_font.c:1387
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
FILE * file
void * user_data
#define str(s)
static FT_Library library
Definition: freetypefont.c:51
static unsigned c
Definition: RandGen.cpp:97
unsigned int dpi
unsigned int dpi
uint len