Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-04-13 05:45:41 +0300
committerCampbell Barton <campbell@blender.org>2022-04-13 06:06:29 +0300
commit21ae323dbf28b4e0049e68153fe1a310ccf5ebef (patch)
tree184d0ff206289632094a71f574d6c8270c872a3c /source/blender/blenfont/intern
parentae43872ad572eb3e6ad1ebfd02921fc2403059bc (diff)
Cleanup: avoid redundant float/int conversions in BLF
Internally many offsets for BLF were integers but exposed as floats, since these are used in pixel-space, many callers were converging them back to integers. Simplify logic by using ints.
Diffstat (limited to 'source/blender/blenfont/intern')
-rw-r--r--source/blender/blenfont/intern/blf.c36
-rw-r--r--source/blender/blenfont/intern/blf_font.c85
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c75
-rw-r--r--source/blender/blenfont/intern/blf_internal.h14
-rw-r--r--source/blender/blenfont/intern/blf_internal_types.h6
-rw-r--r--source/blender/blenfont/intern/blf_thumbs.c4
6 files changed, 111 insertions, 109 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 2b5a2cdf606..a944ab332bd 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -342,9 +342,9 @@ void BLF_position(int fontid, float x, float y, float z)
}
}
- font->pos[0] = x;
- font->pos[1] = y;
- font->pos[2] = z;
+ font->pos[0] = round_fl_to_int(x);
+ font->pos[1] = round_fl_to_int(y);
+ font->pos[2] = round_fl_to_int(z);
}
}
@@ -488,7 +488,7 @@ static void blf_draw_gl__start(FontBLF *font)
GPU_matrix_mul(font->m);
}
- GPU_matrix_translate_3fv(font->pos);
+ GPU_matrix_translate_3f(font->pos[0], font->pos[1], font->pos[2]);
if (font->flags & BLF_ASPECT) {
GPU_matrix_scale_3fv(font->aspect);
@@ -589,9 +589,10 @@ size_t BLF_width_to_strlen(
if (font) {
const float xa = (font->flags & BLF_ASPECT) ? font->aspect[0] : 1.0f;
size_t ret;
- ret = blf_font_width_to_strlen(font, str, str_len, width / xa, r_width);
+ int width_result;
+ ret = blf_font_width_to_strlen(font, str, str_len, width / xa, &width_result);
if (r_width) {
- *r_width *= xa;
+ *r_width = (float)width_result * xa;
}
return ret;
}
@@ -610,9 +611,10 @@ size_t BLF_width_to_rstrlen(
if (font) {
const float xa = (font->flags & BLF_ASPECT) ? font->aspect[0] : 1.0f;
size_t ret;
- ret = blf_font_width_to_rstrlen(font, str, str_len, width / xa, r_width);
+ int width_result;
+ ret = blf_font_width_to_rstrlen(font, str, str_len, width / xa, &width_result);
if (r_width) {
- *r_width *= xa;
+ *r_width = (float)width_result * xa;
}
return ret;
}
@@ -624,7 +626,7 @@ size_t BLF_width_to_rstrlen(
}
void BLF_boundbox_ex(
- int fontid, const char *str, const size_t str_len, rctf *r_box, struct ResultBLF *r_info)
+ int fontid, const char *str, const size_t str_len, rcti *r_box, struct ResultBLF *r_info)
{
FontBLF *font = blf_get(fontid);
@@ -640,7 +642,7 @@ void BLF_boundbox_ex(
}
}
-void BLF_boundbox(int fontid, const char *str, const size_t str_len, rctf *r_box)
+void BLF_boundbox(int fontid, const char *str, const size_t str_len, rcti *r_box)
{
BLF_boundbox_ex(fontid, str, str_len, r_box, NULL);
}
@@ -716,7 +718,7 @@ int BLF_height_max(int fontid)
return 0;
}
-float BLF_width_max(int fontid)
+int BLF_width_max(int fontid)
{
FontBLF *font = blf_get(fontid);
@@ -724,10 +726,10 @@ float BLF_width_max(int fontid)
return blf_font_width_max(font);
}
- return 0.0f;
+ return 0;
}
-float BLF_descender(int fontid)
+int BLF_descender(int fontid)
{
FontBLF *font = blf_get(fontid);
@@ -735,10 +737,10 @@ float BLF_descender(int fontid)
return blf_font_descender(font);
}
- return 0.0f;
+ return 0;
}
-float BLF_ascender(int fontid)
+int BLF_ascender(int fontid)
{
FontBLF *font = blf_get(fontid);
@@ -758,7 +760,7 @@ void BLF_rotation(int fontid, float angle)
}
}
-void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax)
+void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
{
FontBLF *font = blf_get(fontid);
@@ -889,7 +891,7 @@ void BLF_state_print(int fontid)
printf(" name: '%s'\n", font->name);
printf(" size: %f\n", font->size);
printf(" dpi: %u\n", font->dpi);
- printf(" pos: %.6f %.6f %.6f\n", UNPACK3(font->pos));
+ printf(" pos: %d %d %d\n", UNPACK3(font->pos));
printf(" aspect: (%d) %.6f %.6f %.6f\n",
(font->flags & BLF_ROTATION) != 0,
UNPACK3(font->aspect));
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index e5d7cb05408..16d4c46589d 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -138,12 +138,12 @@ void blf_batch_draw_begin(FontBLF *font)
if (simple_shader) {
/* Offset is applied to each glyph. */
- g_batch.ofs[0] = floorf(font->pos[0]);
- g_batch.ofs[1] = floorf(font->pos[1]);
+ g_batch.ofs[0] = font->pos[0];
+ g_batch.ofs[1] = font->pos[1];
}
else {
/* Offset is baked in modelview mat. */
- zero_v2(g_batch.ofs);
+ zero_v2_int(g_batch.ofs);
}
if (g_batch.active) {
@@ -425,8 +425,8 @@ static void blf_font_draw_buffer_ex(FontBLF *font,
ft_pix pen_y)
{
GlyphBLF *g, *g_prev = NULL;
- ft_pix pen_x = ft_pix_from_float(font->pos[0]);
- ft_pix pen_y_basis = ft_pix_from_float(font->pos[1]) + pen_y;
+ ft_pix pen_x = ft_pix_from_int(font->pos[0]);
+ ft_pix pen_y_basis = ft_pix_from_int(font->pos[1]) + pen_y;
size_t i = 0;
/* buffer specific vars */
@@ -586,7 +586,7 @@ static bool blf_font_width_to_strlen_glyph_process(
}
size_t blf_font_width_to_strlen(
- FontBLF *font, const char *str, const size_t str_len, float width, float *r_width)
+ FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
{
GlyphBLF *g, *g_prev;
ft_pix pen_x;
@@ -606,7 +606,7 @@ size_t blf_font_width_to_strlen(
}
if (r_width) {
- *r_width = (float)ft_pix_to_int(width_new);
+ *r_width = ft_pix_to_int(width_new);
}
blf_glyph_cache_release(font);
@@ -614,7 +614,7 @@ size_t blf_font_width_to_strlen(
}
size_t blf_font_width_to_rstrlen(
- FontBLF *font, const char *str, const size_t str_len, float width, float *r_width)
+ FontBLF *font, const char *str, const size_t str_len, int width, int *r_width)
{
GlyphBLF *g, *g_prev;
ft_pix pen_x, width_new;
@@ -622,7 +622,6 @@ size_t blf_font_width_to_rstrlen(
const char *s, *s_prev;
GlyphCacheBLF *gc = blf_glyph_cache_acquire(font);
- const int width_i = (int)width;
i = BLI_strnlen(str, str_len);
s = BLI_str_find_prev_char_utf8(&str[i], str);
@@ -643,13 +642,13 @@ size_t blf_font_width_to_rstrlen(
BLI_assert(i_tmp == i);
}
- if (blf_font_width_to_strlen_glyph_process(font, g_prev, g, &pen_x, width_i)) {
+ if (blf_font_width_to_strlen_glyph_process(font, g_prev, g, &pen_x, width)) {
break;
}
}
if (r_width) {
- *r_width = (float)ft_pix_to_int(width_new);
+ *r_width = ft_pix_to_int(width_new);
}
blf_glyph_cache_release(font);
@@ -666,7 +665,7 @@ static void blf_font_boundbox_ex(FontBLF *font,
GlyphCacheBLF *gc,
const char *str,
const size_t str_len,
- rctf *box,
+ rcti *box,
struct ResultBLF *r_info,
ft_pix pen_y)
{
@@ -718,10 +717,10 @@ static void blf_font_boundbox_ex(FontBLF *font,
box_ymax = 0;
}
- box->xmin = (float)ft_pix_to_int_floor(box_xmin);
- box->xmax = (float)ft_pix_to_int_ceil(box_xmax);
- box->ymin = (float)ft_pix_to_int_floor(box_ymin);
- box->ymax = (float)ft_pix_to_int_ceil(box_ymax);
+ box->xmin = ft_pix_to_int_floor(box_xmin);
+ box->xmax = ft_pix_to_int_ceil(box_xmax);
+ box->ymin = ft_pix_to_int_floor(box_ymin);
+ box->ymax = ft_pix_to_int_ceil(box_ymax);
if (r_info) {
r_info->lines = 1;
@@ -729,7 +728,7 @@ static void blf_font_boundbox_ex(FontBLF *font,
}
}
void blf_font_boundbox(
- FontBLF *font, const char *str, const size_t str_len, rctf *r_box, struct ResultBLF *r_info)
+ FontBLF *font, const char *str, const size_t str_len, rcti *r_box, struct ResultBLF *r_info)
{
GlyphCacheBLF *gc = blf_glyph_cache_acquire(font);
blf_font_boundbox_ex(font, gc, str, str_len, r_box, r_info, 0);
@@ -744,7 +743,7 @@ void blf_font_width_and_height(FontBLF *font,
struct ResultBLF *r_info)
{
float xa, ya;
- rctf box;
+ rcti box;
if (font->flags & BLF_ASPECT) {
xa = font->aspect[0];
@@ -761,8 +760,8 @@ void blf_font_width_and_height(FontBLF *font,
else {
blf_font_boundbox(font, str, str_len, &box, r_info);
}
- *r_width = (BLI_rctf_size_x(&box) * xa);
- *r_height = (BLI_rctf_size_y(&box) * ya);
+ *r_width = ((float)BLI_rcti_size_x(&box) * xa);
+ *r_height = ((float)BLI_rcti_size_y(&box) * ya);
}
float blf_font_width(FontBLF *font,
@@ -771,7 +770,7 @@ float blf_font_width(FontBLF *font,
struct ResultBLF *r_info)
{
float xa;
- rctf box;
+ rcti box;
if (font->flags & BLF_ASPECT) {
xa = font->aspect[0];
@@ -786,7 +785,7 @@ float blf_font_width(FontBLF *font,
else {
blf_font_boundbox(font, str, str_len, &box, r_info);
}
- return BLI_rctf_size_x(&box) * xa;
+ return (float)BLI_rcti_size_x(&box) * xa;
}
float blf_font_height(FontBLF *font,
@@ -795,7 +794,7 @@ float blf_font_height(FontBLF *font,
struct ResultBLF *r_info)
{
float ya;
- rctf box;
+ rcti box;
if (font->flags & BLF_ASPECT) {
ya = font->aspect[1];
@@ -810,7 +809,7 @@ float blf_font_height(FontBLF *font,
else {
blf_font_boundbox(font, str, str_len, &box, r_info);
}
- return BLI_rctf_size_y(&box) * ya;
+ return (float)BLI_rcti_size_y(&box) * ya;
}
float blf_font_fixed_width(FontBLF *font)
@@ -858,11 +857,11 @@ static void blf_font_boundbox_foreach_glyph_ex(FontBLF *font,
pen_x = pen_x_next;
- rctf box_px;
- box_px.xmin = (float)ft_pix_to_int_floor(g->box_xmin);
- box_px.xmax = (float)ft_pix_to_int_ceil(g->box_xmax);
- box_px.ymin = (float)ft_pix_to_int_floor(g->box_ymin);
- box_px.ymax = (float)ft_pix_to_int_ceil(g->box_ymax);
+ rcti box_px;
+ box_px.xmin = ft_pix_to_int_floor(g->box_xmin);
+ box_px.xmax = ft_pix_to_int_ceil(g->box_xmax);
+ box_px.ymin = ft_pix_to_int_floor(g->box_ymin);
+ box_px.ymax = ft_pix_to_int_ceil(g->box_ymax);
if (user_fn(str, i_curr, &gbox_px, advance_x_px, &box_px, g->pos, user_data) == false) {
break;
@@ -1026,19 +1025,19 @@ static void blf_font_boundbox_wrap_cb(FontBLF *font,
ft_pix pen_y,
void *userdata)
{
- rctf *box = userdata;
- rctf box_single;
+ rcti *box = userdata;
+ rcti box_single;
blf_font_boundbox_ex(font, gc, str, str_len, &box_single, NULL, pen_y);
- BLI_rctf_union(box, &box_single);
+ BLI_rcti_union(box, &box_single);
}
void blf_font_boundbox__wrap(
- FontBLF *font, const char *str, const size_t str_len, rctf *box, struct ResultBLF *r_info)
+ FontBLF *font, const char *str, const size_t str_len, rcti *box, struct ResultBLF *r_info)
{
- box->xmin = 32000.0f;
- box->xmax = -32000.0f;
- box->ymin = 32000.0f;
- box->ymax = -32000.0f;
+ box->xmin = 32000;
+ box->xmax = -32000;
+ box->ymin = 32000;
+ box->ymax = -32000;
blf_font_wrap_apply(font, str, str_len, r_info, blf_font_boundbox_wrap_cb, box);
}
@@ -1141,14 +1140,14 @@ int blf_font_width_max(FontBLF *font)
return ft_pix_to_int(blf_font_width_max_ft_pix(font));
}
-float blf_font_descender(FontBLF *font)
+int blf_font_descender(FontBLF *font)
{
- return ((float)font->face->size->metrics.descender) / 64.0f;
+ return ft_pix_to_int((ft_pix)font->face->size->metrics.descender);
}
-float blf_font_ascender(FontBLF *font)
+int blf_font_ascender(FontBLF *font)
{
- return ((float)font->face->size->metrics.ascender) / 64.0f;
+ return ft_pix_to_int((ft_pix)font->face->size->metrics.ascender);
}
char *blf_display_name(FontBLF *font)
@@ -1197,8 +1196,8 @@ static void blf_font_fill(FontBLF *font)
font->aspect[0] = 1.0f;
font->aspect[1] = 1.0f;
font->aspect[2] = 1.0f;
- font->pos[0] = 0.0f;
- font->pos[1] = 0.0f;
+ font->pos[0] = 0;
+ font->pos[1] = 0;
font->angle = 0.0f;
for (int i = 0; i < 16; i++) {
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 497c797fd36..2694b179a11 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -491,28 +491,29 @@ void blf_glyph_free(GlyphBLF *g)
/** \name Glyph Bounds Calculation
* \{ */
-static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
+static void blf_glyph_calc_rect(rcti *rect, GlyphBLF *g, const int x, const int y)
{
- rect->xmin = floorf(x + (float)g->pos[0]);
- rect->xmax = rect->xmin + (float)g->dims[0];
- rect->ymin = floorf(y + (float)g->pos[1]);
- rect->ymax = rect->ymin - (float)g->dims[1];
+ rect->xmin = x + g->pos[0];
+ rect->xmax = rect->xmin + g->dims[0];
+ rect->ymin = y + g->pos[1];
+ rect->ymax = rect->ymin - g->dims[1];
}
-static void blf_glyph_calc_rect_test(rctf *rect, GlyphBLF *g, float x, float y)
+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 = floorf(x);
- rect->xmax = rect->xmin + MIN2((float)ft_pix_to_int(g->advance_x), (float)g->dims[0]);
- rect->ymin = floorf(y);
- rect->ymax = rect->ymin - (float)g->dims[1];
+ 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(rctf *rect, GlyphBLF *g, float x, float y, FontBLF *font)
+static void blf_glyph_calc_rect_shadow(
+ rcti *rect, GlyphBLF *g, const int x, const int y, FontBLF *font)
{
- blf_glyph_calc_rect(rect, g, x + (float)font->shadow_x, y + (float)font->shadow_y);
+ blf_glyph_calc_rect(rect, g, x + font->shadow_x, y + font->shadow_y);
}
/** \} */
@@ -524,18 +525,18 @@ static void blf_glyph_calc_rect_shadow(rctf *rect, GlyphBLF *g, float x, float y
static void blf_texture_draw(const unsigned char color[4],
const int glyph_size[2],
const int offset,
- float x1,
- float y1,
- float x2,
- float y2)
+ const int x1,
+ const int y1,
+ const int x2,
+ const int y2)
{
/* Only one vertex per glyph, geometry shader expand it into a quad. */
/* TODO: Get rid of Geom Shader because it's not optimal AT ALL for the GPU. */
copy_v4_fl4(GPU_vertbuf_raw_step(&g_batch.pos_step),
- x1 + g_batch.ofs[0],
- y1 + g_batch.ofs[1],
- x2 + g_batch.ofs[0],
- y2 + g_batch.ofs[1]);
+ (float)(x1 + g_batch.ofs[0]),
+ (float)(y1 + g_batch.ofs[1]),
+ (float)(x2 + g_batch.ofs[0]),
+ (float)(y2 + g_batch.ofs[1]));
copy_v4_v4_uchar(GPU_vertbuf_raw_step(&g_batch.col_step), color);
copy_v2_v2_int(GPU_vertbuf_raw_step(&g_batch.glyph_size_step), glyph_size);
*((int *)GPU_vertbuf_raw_step(&g_batch.offset_step)) = offset;
@@ -550,10 +551,10 @@ static void blf_texture_draw(const unsigned char color[4],
static void blf_texture5_draw(const unsigned char color_in[4],
const int glyph_size[2],
const int offset,
- float x1,
- float y1,
- float x2,
- float y2)
+ const int x1,
+ const int y1,
+ const int x2,
+ const int y2)
{
int glyph_size_flag[2];
/* flag the x and y component signs for 5x5 blurring */
@@ -566,10 +567,10 @@ static void blf_texture5_draw(const unsigned char color_in[4],
static void blf_texture3_draw(const unsigned char color_in[4],
const int glyph_size[2],
const int offset,
- float x1,
- float y1,
- float x2,
- float y2)
+ const int x1,
+ const int y1,
+ const int x2,
+ const int y2)
{
int glyph_size_flag[2];
/* flag the x component sign for 3x3 blurring */
@@ -579,7 +580,7 @@ static void blf_texture3_draw(const unsigned char color_in[4],
blf_texture_draw(color_in, glyph_size_flag, offset, x1, y1, x2, y2);
}
-void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int x, int y)
+void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, const int x, const int y)
{
if ((!g->dims[0]) || (!g->dims[1])) {
return;
@@ -618,11 +619,11 @@ void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int x, int y)
}
if (font->flags & BLF_CLIPPING) {
- rctf rect_test;
- blf_glyph_calc_rect_test(&rect_test, g, (float)x, (float)y);
- BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
+ rcti rect_test;
+ blf_glyph_calc_rect_test(&rect_test, g, x, y);
+ BLI_rcti_translate(&rect_test, font->pos[0], font->pos[1]);
- if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
+ if (!BLI_rcti_inside_rcti(&font->clip_rec, &rect_test)) {
return;
}
}
@@ -633,8 +634,8 @@ void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int x, int y)
}
if (font->flags & BLF_SHADOW) {
- rctf rect_ofs;
- blf_glyph_calc_rect_shadow(&rect_ofs, g, (float)x, (float)y, font);
+ rcti rect_ofs;
+ blf_glyph_calc_rect_shadow(&rect_ofs, g, x, y, font);
if (font->shadow == 0) {
blf_texture_draw(font->shadow_color,
@@ -665,8 +666,8 @@ void blf_glyph_draw(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int x, int y)
}
}
- rctf rect;
- blf_glyph_calc_rect(&rect, g, (float)x, (float)y);
+ rcti rect;
+ blf_glyph_calc_rect(&rect, g, x, y);
#if BLF_BLUR_ENABLE
switch (font->blur) {
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index c38b1654d8e..7754f960043 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -67,18 +67,18 @@ void blf_font_draw_buffer__wrap(struct FontBLF *font,
size_t str_len,
struct ResultBLF *r_info);
size_t blf_font_width_to_strlen(
- struct FontBLF *font, const char *str, size_t str_len, float width, float *r_width);
+ struct FontBLF *font, const char *str, size_t str_len, int width, int *r_width);
size_t blf_font_width_to_rstrlen(
- struct FontBLF *font, const char *str, size_t str_len, float width, float *r_width);
+ struct FontBLF *font, const char *str, size_t str_len, int width, int *r_width);
void blf_font_boundbox(struct FontBLF *font,
const char *str,
size_t str_len,
- struct rctf *r_box,
+ struct rcti *r_box,
struct ResultBLF *r_info);
void blf_font_boundbox__wrap(struct FontBLF *font,
const char *str,
size_t str_len,
- struct rctf *r_box,
+ struct rcti *r_box,
struct ResultBLF *r_info);
void blf_font_width_and_height(struct FontBLF *font,
const char *str,
@@ -97,8 +97,8 @@ float blf_font_height(struct FontBLF *font,
float blf_font_fixed_width(struct FontBLF *font);
int blf_font_height_max(struct FontBLF *font);
int blf_font_width_max(struct FontBLF *font);
-float blf_font_descender(struct FontBLF *font);
-float blf_font_ascender(struct FontBLF *font);
+int blf_font_descender(struct FontBLF *font);
+int blf_font_ascender(struct FontBLF *font);
char *blf_display_name(struct FontBLF *font);
@@ -109,7 +109,7 @@ void blf_font_boundbox_foreach_glyph(struct FontBLF *font,
size_t str_step_ofs,
const struct rcti *glyph_step_bounds,
int glyph_advance_x,
- const struct rctf *glyph_bounds,
+ const struct rcti *glyph_bounds,
const int glyph_bearing[2],
void *user_data),
void *user_data,
diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h
index 34fa82629b4..79388752969 100644
--- a/source/blender/blenfont/intern/blf_internal_types.h
+++ b/source/blender/blenfont/intern/blf_internal_types.h
@@ -101,7 +101,7 @@ typedef struct BatchBLF {
struct GPUVertBufRaw pos_step, col_step, offset_step, glyph_size_step;
unsigned int pos_loc, col_loc, offset_loc, glyph_size_loc;
unsigned int glyph_len;
- float ofs[2]; /* copy of font->pos */
+ int ofs[2]; /* copy of font->pos */
float mat[4][4]; /* previous call modelmatrix. */
bool enabled, active, simple_shader;
struct GlyphCacheBLF *glyph_cache;
@@ -231,7 +231,7 @@ typedef struct FontBLF {
float aspect[3];
/* initial position for draw the text. */
- float pos[3];
+ int pos[3];
/* angle in radians. */
float angle;
@@ -260,7 +260,7 @@ typedef struct FontBLF {
float m[16];
/* clipping rectangle. */
- rctf clip_rec;
+ rcti clip_rec;
/* the width to wrap the text, see BLF_WORD_WRAP */
int wrap_width;
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c
index 0e265fb7553..a75072f854f 100644
--- a/source/blender/blenfont/intern/blf_thumbs.c
+++ b/source/blender/blenfont/intern/blf_thumbs.c
@@ -64,7 +64,7 @@ void BLF_thumb_preview(const char *filepath,
/* Always create the image with a white font,
* the caller can theme how it likes */
memcpy(font->buf_info.col_init, font_color, sizeof(font->buf_info.col_init));
- font->pos[1] = (float)h;
+ font->pos[1] = h;
font_size_curr = font_size;
@@ -84,7 +84,7 @@ void BLF_thumb_preview(const char *filepath,
font_size_curr -= (font_size_curr / font_shrink);
font_shrink += 1;
- font->pos[1] -= blf_font_ascender(font) * 1.1f;
+ font->pos[1] -= (int)((float)blf_font_ascender(font) * 1.1f);
/* We fallback to default english strings in case not enough chars are available in current
* font for given translated string (useful in non-latin i18n context, like Chinese,