Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenfont/intern/blf_glyph.c
| Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) | ||||
| gc->char_weight = font->char_weight; | gc->char_weight = font->char_weight; | ||||
| gc->char_slant = font->char_slant; | gc->char_slant = font->char_slant; | ||||
| gc->char_width = font->char_width; | gc->char_width = font->char_width; | ||||
| gc->char_spacing = font->char_spacing; | gc->char_spacing = font->char_spacing; | ||||
| memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); | memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); | ||||
| memset(gc->bucket, 0, sizeof(gc->bucket)); | memset(gc->bucket, 0, sizeof(gc->bucket)); | ||||
| blf_ensure_size(font); | |||||
| /* Determine ideal fixed-width size for monospaced output. */ | /* Determine ideal fixed-width size for monospaced output. */ | ||||
| FT_UInt gindex = blf_get_char_index(font, U'0'); | FT_UInt gindex = blf_get_char_index(font, U'0'); | ||||
| if (gindex && font->face) { | if (gindex && font->face) { | ||||
| FT_Fixed advance = 0; | FT_Fixed advance = 0; | ||||
| FT_Get_Advance(font->face, gindex, FT_LOAD_NO_HINTING, &advance); | FT_Get_Advance(font->face, gindex, FT_LOAD_NO_HINTING, &advance); | ||||
| /* Use CSS 'ch unit' width, advance of zero character. */ | /* Use CSS 'ch unit' width, advance of zero character. */ | ||||
| gc->fixed_width = (int)(advance >> 16); | gc->fixed_width = (int)(advance >> 16); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Font does not have a face or does not contain "0" so use CSS fallback of 1/2 of em. */ | /* Font does not have a face or does not contain "0" so use CSS fallback of 1/2 of em. */ | ||||
| blf_ensure_size(font); | |||||
| gc->fixed_width = (int)((font->ft_size->metrics.height / 2) >> 6); | gc->fixed_width = (int)((font->ft_size->metrics.height / 2) >> 6); | ||||
| } | } | ||||
| if (gc->fixed_width < 1) { | if (gc->fixed_width < 1) { | ||||
| gc->fixed_width = 1; | gc->fixed_width = 1; | ||||
| } | } | ||||
| BLI_addhead(&font->cache, gc); | BLI_addhead(&font->cache, gc); | ||||
| return gc; | return gc; | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||