Blender V5.3
blf_glyph.cc File Reference
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ft2build.h>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.hh"
#include "BLI_math_color_c.hh"
#include "BLI_math_geom_c.hh"
#include "BLI_rect.hh"
#include "BLF_api.hh"
#include "GPU_capabilities.hh"
#include "blf_internal.hh"
#include "blf_internal_types.hh"
#include "BLI_string_utf8.hh"
#include "nanosvgrast.h"
#include "svg_icons.h"
#include "BLI_strict_flags.hh"

Go to the source code of this file.

Classes

struct  blender::UnicodeBlock

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define BLF_GAMMA_CORRECT_GLYPHS

Functions

Internal Utilities
static FT_Fixed blender::to_16dot16 (const double val)
static float blender::from_16dot16 (const FT_Fixed value)
Glyph Cache
static GlyphCacheBLF * blender::blf_glyph_cache_find (const FontBLF *font)
static GlyphCacheBLF * blender::blf_glyph_cache_new (FontBLF *font)
GlyphCacheBLF * blender::blf_glyph_cache_acquire (FontBLF *font)
void blender::blf_glyph_cache_release (FontBLF *font)
void blender::blf_glyph_cache_clear (FontBLF *font)
static GlyphBLF * blender::blf_glyph_cache_find_glyph (const GlyphCacheBLF *gc, const uint charcode, const uint8_t subpixel)
static uchar blender::blf_glyph_gamma (const uchar c)
static GlyphBLF * blender::blf_glyph_cache_add_glyph (GlyphCacheBLF *gc, const FT_GlyphSlot glyph, const uint charcode, const FT_UInt glyph_index, const uint8_t subpixel)
static GlyphBLF * blender::blf_glyph_cache_add_blank (GlyphCacheBLF *gc, const uint charcode)
static GlyphBLF * blender::blf_glyph_cache_add_svg (GlyphCacheBLF *gc, const uint charcode, const bool color, FunctionRef< void(std::string &)> edit_source_cb=nullptr)
Glyph Load
static FT_GlyphSlot blender::blf_glyph_load (FontBLF *font, const FT_UInt glyph_index, const bool outline_only)
Glyph Render
static bool blender::blf_glyph_render_bitmap (FontBLF *font, FT_GlyphSlot glyph)
Variations (Multiple Masters) support
static const FT_Var_Axis * blender::blf_var_axis_by_tag (const FT_MM_Var *variations, const uint32_t tag, int *r_axis_index)
static FT_Fixed blender::blf_factor_to_coordinate (const FT_Var_Axis *axis, const float factor)
static bool blender::blf_glyph_set_variation_normalized (const FontBLF *font, FT_Fixed coords[], const uint32_t tag, const float factor)
static bool blender::blf_glyph_set_variation_float (const FontBLF *font, FT_Fixed coords[], uint32_t tag, float *value)
static float blender::blf_glyph_set_variation_weight (const FontBLF *font, FT_Fixed coords[], float current_weight, float target_weight)
static float blender::blf_glyph_set_variation_slant (const FontBLF *font, FT_Fixed coords[], float current_degrees, float target_degrees)
static float blender::blf_glyph_set_variation_width (const FontBLF *font, FT_Fixed coords[], float current_width, float target_width)
static float blender::blf_glyph_set_variation_spacing (const FontBLF *font, FT_Fixed coords[], float current_spacing, float target_spacing)
static bool blender::blf_glyph_set_variation_optical_size (const FontBLF *font, FT_Fixed coords[], const float points)
Glyph Transformations
static bool blender::blf_glyph_transform_weight (FT_GlyphSlot glyph, float width, bool monospaced)
static bool blender::blf_glyph_transform_slant (FT_GlyphSlot glyph, float degrees)
static bool blender::blf_glyph_transform_width (FT_GlyphSlot glyph, float factor)
static bool blender::blf_glyph_transform_spacing (FT_GlyphSlot glyph, float factor)
static bool blender::blf_glyph_transform_monospace (FT_GlyphSlot glyph, int width)
Glyph Access (Ensure/Free)
static FT_GlyphSlot blender::blf_glyph_render (FontBLF *settings_font, FontBLF *glyph_font, FT_UInt glyph_index, uint charcode, uint8_t subpixel, int fixed_width, bool outline_only)
FT_GlyphSlot blender::blf_glyph_render_outline (FontBLF *settings_font, FontBLF *glyph_font, FT_UInt glyph_index, uint charcode, int fixed_width)
GlyphBLF * blender::blf_glyph_ensure (FontBLF *font, GlyphCacheBLF *gc, const uint charcode, uint8_t subpixel)
GlyphBLF * blender::blf_glyph_ensure_icon (GlyphCacheBLF *gc, const uint icon_id, bool color, FunctionRef< void(std::string &)> edit_source_cb)
GlyphBLF * blender::blf_glyph_ensure_subpixel (FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int32_t pen_x)
Glyph Bounds Calculation
static void blender::blf_glyph_calc_rect (const GlyphBLF *g, const int x, const int y, rcti *r_rect)
static void blender::blf_glyph_calc_rect_test (const GlyphBLF *g, const int x, const int y, rcti *r_rect)
static void blender::blf_glyph_calc_rect_shadow (const GlyphBLF *g, const int x, const int y, const FontBLF *font, rcti *r_rect)
Glyph Drawing
static void blender::blf_texture_draw (const GlyphBLF *g, const uchar color[4], const FontShadowType shadow, const int x1, const int y1, const int x2, const int y2)
void blender::blf_glyph_draw (FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, const int x, const int y)

Glyph Unicode Block Lookup

This table can be used to find a coverage bit based on a charcode. Later we can get default language and script from codepoint.

static const UnicodeBlock blender::unicode_blocks []
static const UnicodeBlock * blender::blf_charcode_to_unicode_block (const uint charcode)
static int blender::blf_charcode_to_coverage_bit (const uint charcode)
static bool blender::blf_font_has_coverage_bit (const FontBLF *font, const int coverage_bit)
FT_UInt blender::blf_glyph_index_from_charcode (FontBLF **font, const uint charcode)

Detailed Description

Glyph rendering, texturing and caching. Wraps Freetype and OpenGL functions.

Definition in file blf_glyph.cc.

Macro Definition Documentation

◆ BLF_GAMMA_CORRECT_GLYPHS

#define BLF_GAMMA_CORRECT_GLYPHS

Convert glyph coverage amounts to lightness values. Uses a LUT that perceptually improves anti-aliasing and results in text that looks a bit fuller and slightly brighter. This should be reconsidered in some - or all - cases when we transform the entire UI.

Definition at line 57 of file blf_glyph.cc.