Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenfont/intern/blf_glyph.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| static void blf_glyph_calc_rect(rcti *rect, GlyphBLF *g, const int x, const int y) | static void blf_glyph_calc_rect(rcti *rect, GlyphBLF *g, const int x, const int y) | ||||
| { | { | ||||
| rect->xmin = x + g->pos[0]; | rect->xmin = x + g->pos[0]; | ||||
| rect->xmax = rect->xmin + g->dims[0]; | rect->xmax = rect->xmin + g->dims[0]; | ||||
| rect->ymin = y + g->pos[1]; | rect->ymin = y + g->pos[1]; | ||||
| rect->ymax = rect->ymin - g->dims[1]; | rect->ymax = rect->ymin - g->dims[1]; | ||||
| } | } | ||||
| static void blf_glyph_calc_rect_test(rcti *rect, GlyphBLF *g, const int x, const int y) | |||||
| { | |||||
| /* Intentionally check with `g->advance`, because this is the | |||||
| * width used by BLF_width. This allows that the text slightly | |||||
| * overlaps the clipping border to achieve better alignment. */ | |||||
| rect->xmin = x; | |||||
| rect->xmax = rect->xmin + MIN2(ft_pix_to_int(g->advance_x), g->dims[0]); | |||||
| rect->ymin = y; | |||||
| rect->ymax = rect->ymin - g->dims[1]; | |||||
| } | |||||
| static void blf_glyph_calc_rect_shadow( | static void blf_glyph_calc_rect_shadow( | ||||
| rcti *rect, GlyphBLF *g, const int x, const int y, FontBLF *font) | rcti *rect, GlyphBLF *g, const int x, const int y, FontBLF *font) | ||||
| { | { | ||||
| blf_glyph_calc_rect(rect, g, x + font->shadow_x, y + font->shadow_y); | blf_glyph_calc_rect(rect, g, x + font->shadow_x, y + font->shadow_y); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
| memcpy(&gc->bitmap_result[gc->bitmap_len], g->bitmap, (size_t)buff_size); | memcpy(&gc->bitmap_result[gc->bitmap_len], g->bitmap, (size_t)buff_size); | ||||
| gc->bitmap_len = bitmap_len; | gc->bitmap_len = bitmap_len; | ||||
| g->glyph_cache = gc; | g->glyph_cache = gc; | ||||
| } | } | ||||
| if (font->flags & BLF_CLIPPING) { | if (font->flags & BLF_CLIPPING) { | ||||
| rcti rect_test; | rcti rect_test; | ||||
| blf_glyph_calc_rect_test(&rect_test, g, x, y); | rect_test.xmin = x + font->pos[0] + g->pos[0] + 1; | ||||
| BLI_rcti_translate(&rect_test, font->pos[0], font->pos[1]); | rect_test.xmax = rect_test.xmin + g->dims[0] - 2; | ||||
| rect_test.ymin = y + font->pos[1]; | |||||
| rect_test.ymax = rect_test.ymin + g->pos[1]; | |||||
| if (!BLI_rcti_inside_rcti(&font->clip_rec, &rect_test)) { | if (!BLI_rcti_inside_rcti(&font->clip_rec, &rect_test)) { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| if (g_batch.glyph_cache != g->glyph_cache) { | if (g_batch.glyph_cache != g->glyph_cache) { | ||||
| blf_batch_draw(); | blf_batch_draw(); | ||||
| g_batch.glyph_cache = g->glyph_cache; | g_batch.glyph_cache = g->glyph_cache; | ||||
| ▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines | |||||