Blender V4.3
blf_internal_types.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include <mutex>
12
13#include "BLF_api.hh"
14
15#include "BLI_map.hh"
16#include "BLI_vector.hh"
17
18#include "GPU_texture.hh"
19#include "GPU_vertex_buffer.hh"
20
22struct FontBLF;
23namespace blender::gpu {
24class Batch;
25class VertBuf;
26} // namespace blender::gpu
27struct GPUVertBufRaw;
28
29#include FT_MULTIPLE_MASTERS_H /* Variable font support. */
30
32#define BLF_VARIATIONS_MAX 16
33
34#define MAKE_DVAR_TAG(a, b, c, d) \
35 ((uint32_t(a) << 24u) | (uint32_t(b) << 16u) | (uint32_t(c) << 8u) | (uint32_t(d)))
36
37#define BLF_VARIATION_AXIS_WEIGHT MAKE_DVAR_TAG('w', 'g', 'h', 't') /* 'wght' weight axis. */
38#define BLF_VARIATION_AXIS_SLANT MAKE_DVAR_TAG('s', 'l', 'n', 't') /* 'slnt' slant axis. */
39#define BLF_VARIATION_AXIS_WIDTH MAKE_DVAR_TAG('w', 'd', 't', 'h') /* 'wdth' width axis. */
40#define BLF_VARIATION_AXIS_SPACING MAKE_DVAR_TAG('s', 'p', 'a', 'c') /* 'spac' spacing axis. */
41#define BLF_VARIATION_AXIS_OPTSIZE MAKE_DVAR_TAG('o', 'p', 's', 'z') /* 'opsz' optical size. */
42
43/* -------------------------------------------------------------------- */
55
56/* Macros copied from `include/freetype/internal/ftobjs.h`. */
57
58#define FT_PIX_FLOOR(x) ((x) & ~63)
59#define FT_PIX_ROUND(x) FT_PIX_FLOOR((x) + 32)
60#define FT_PIX_CEIL(x) ((x) + 63)
61
63{
64 return int(v >> 6);
65}
66
68{
69 return int(v >> 6); /* No need for explicit floor as the bits are removed when shifting. */
70}
71
73{
74 return int(FT_PIX_CEIL(v) >> 6);
75}
76
78{
79 return v * 64;
80}
81
83{
84 return lroundf(v * 64.0f);
85}
86
89#define BLF_BATCH_DRAW_LEN_MAX 2048 /* in glyph */
90
92#define KERNING_CACHE_TABLE_SIZE 128
93
95#define KERNING_ENTRY_UNSET INT_MAX
96
112
113extern BatchBLF g_batch;
114
122
126 friend bool operator==(const GlyphCacheKey &a, const GlyphCacheKey &b)
127 {
128 return a.charcode == b.charcode && a.subpixel == b.subpixel;
129 }
131 {
133 }
134};
135
163
209
212 float *fbuf;
213
215 unsigned char *cbuf;
216
218 int dims[2];
219
222
224 float col_init[4];
226 unsigned char col_char[4];
227 float col_float[4];
228};
229
295
296struct FontBLF {
298 char *filepath;
299
301 void *mem;
302 size_t mem_size;
304 char *mem_name;
305
312
314 unsigned int reference_count;
315
317 float aspect[3];
318
320 int pos[3];
321
323 float angle;
324
327
331
333 unsigned char shadow_color[4];
334
336 unsigned char color[4];
337
340
343
345 float size;
346
348 FT_MM_Var *variations;
349
351 int char_weight; /* 100 - 900, 400 = normal. */
352 float char_slant; /* Slant in clockwise degrees. 0.0 = upright. */
353 float char_width; /* Factor of normal character width. 1.0 = normal. */
354 float char_spacing; /* Factor of normal character spacing. 0.0 = normal. */
355
358
360 int flags;
361
367
370
372 FT_Library ft_lib;
373
375 FT_Face face;
376
378 FT_Size ft_size;
379
381 FT_Long face_flags;
382
385
388
391};
FontShadowType
Definition BLF_api.hh:33
unsigned int uint
#define FT_PIX_CEIL(x)
BatchBLF g_batch
Definition blf_font.cc:59
ft_pix ft_pix_from_float(float v)
int32_t ft_pix
ft_pix ft_pix_from_int(int v)
#define KERNING_CACHE_TABLE_SIZE
int ft_pix_to_int_floor(ft_pix v)
int ft_pix_to_int_ceil(ft_pix v)
int ft_pix_to_int(ft_pix v)
ATTR_WARN_UNUSED_RESULT const BMVert * v
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
uint64_t get_default_hash(const T &v)
Definition BLI_hash.hh:219
signed int int32_t
Definition stdint.h:77
unsigned char uint8_t
Definition stdint.h:78
unsigned __int64 uint64_t
Definition stdint.h:90
unsigned int pos_loc
unsigned int glyph_flags_loc
blender::gpu::Batch * batch
unsigned int col_loc
unsigned int offset_loc
float mat[4][4]
GlyphCacheBLF * glyph_cache
unsigned int glyph_len
GPUVertBufRaw pos_step
GPUVertBufRaw offset_step
unsigned int glyph_size_loc
GPUVertBufRaw glyph_flags_step
GPUVertBufRaw col_step
GPUVertBufRaw glyph_size_step
blender::gpu::VertBuf * verts
KerningCacheBLF * kerning_cache
uint unicode_ranges[4]
blender::Vector< std::unique_ptr< GlyphCacheBLF > > cache
std::mutex glyph_cache_mutex
FT_MM_Var * variations
FontMetrics metrics
unsigned int reference_count
FT_Library ft_lib
FontBufInfoBLF buf_info
FontShadowType shadow
unsigned char shadow_color[4]
ColorManagedDisplay * display
unsigned char col_char[4]
unsigned char * cbuf
GlyphCacheBLF * glyph_cache
unsigned char * bitmap
unsigned int c
blender::Map< GlyphCacheKey, std::unique_ptr< GlyphBLF > > glyphs
uint64_t hash() const
friend bool operator==(const GlyphCacheKey &a, const GlyphCacheKey &b)
int ascii_table[KERNING_CACHE_TABLE_SIZE][KERNING_CACHE_TABLE_SIZE]