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 <ideasman42@gmail.com>2020-05-03 10:55:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-05-03 11:01:20 +0300
commitccaab7268572f1640411309463009b3a3453b247 (patch)
tree300cebf59fa9457b25ad0f3abe9c836363126743 /source/blender/blenfont/intern/blf_font.c
parent5366eb89c6eb4057edfdf16eb42f31d34f6a0ba4 (diff)
BLF: use 'int' for internal glyph x,y bearing
These were stored as float but were originally cast from an int and were often cast back to int. Also use int pairs for dimensions values.
Diffstat (limited to 'source/blender/blenfont/intern/blf_font.c')
-rw-r--r--source/blender/blenfont/intern/blf_font.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 0eee887efa6..e5e03418073 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -613,28 +613,28 @@ static void blf_font_draw_buffer_ex(FontBLF *font,
BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x);
}
- chx = pen_x + ((int)g->pos_x);
- chy = pen_y_basis + g->height;
+ chx = pen_x + ((int)g->pos[0]);
+ chy = pen_y_basis + g->dims[1];
if (g->pitch < 0) {
- pen_y = pen_y_basis + (g->height - (int)g->pos_y);
+ pen_y = pen_y_basis + (g->dims[1] - g->pos[1]);
}
else {
- pen_y = pen_y_basis - (g->height - (int)g->pos_y);
+ pen_y = pen_y_basis - (g->dims[1] - g->pos[1]);
}
- if ((chx + g->width) >= 0 && chx < buf_info->w && (pen_y + g->height) >= 0 &&
- pen_y < buf_info->h) {
+ if ((chx + g->dims[0]) >= 0 && chx < buf_info->dims[0] && (pen_y + g->dims[1]) >= 0 &&
+ pen_y < buf_info->dims[1]) {
/* don't draw beyond the buffer bounds */
- int width_clip = g->width;
- int height_clip = g->height;
- int yb_start = g->pitch < 0 ? 0 : g->height - 1;
+ int width_clip = g->dims[0];
+ int height_clip = g->dims[1];
+ int yb_start = g->pitch < 0 ? 0 : g->dims[1] - 1;
- if (width_clip + chx > buf_info->w) {
- width_clip -= chx + width_clip - buf_info->w;
+ if (width_clip + chx > buf_info->dims[0]) {
+ width_clip -= chx + width_clip - buf_info->dims[0];
}
- if (height_clip + pen_y > buf_info->h) {
- height_clip -= pen_y + height_clip - buf_info->h;
+ if (height_clip + pen_y > buf_info->dims[1]) {
+ height_clip -= pen_y + height_clip - buf_info->dims[1];
}
/* drawing below the image? */
@@ -652,7 +652,7 @@ static void blf_font_draw_buffer_ex(FontBLF *font,
if (a_byte) {
const float a = (a_byte / 255.0f) * b_col_float[3];
const size_t buf_ofs = (((size_t)(chx + x) +
- ((size_t)(pen_y + y) * (size_t)buf_info->w)) *
+ ((size_t)(pen_y + y) * (size_t)buf_info->dims[0])) *
(size_t)buf_info->ch);
float *fbuf = buf_info->fbuf + buf_ofs;
@@ -689,7 +689,7 @@ static void blf_font_draw_buffer_ex(FontBLF *font,
if (a_byte) {
const float a = (a_byte / 255.0f) * b_col_float[3];
const size_t buf_ofs = (((size_t)(chx + x) +
- ((size_t)(pen_y + y) * (size_t)buf_info->w)) *
+ ((size_t)(pen_y + y) * (size_t)buf_info->dims[0])) *
(size_t)buf_info->ch);
unsigned char *cbuf = buf_info->cbuf + buf_ofs;
@@ -1246,13 +1246,13 @@ static void blf_font_boundbox_foreach_glyph_ex(FontBLF *font,
}
gbox.xmin = pen_x;
- gbox.xmax = gbox.xmin + MIN2(g->advance_i, g->width);
+ gbox.xmax = gbox.xmin + MIN2(g->advance_i, g->dims[0]);
gbox.ymin = pen_y;
- gbox.ymax = gbox.ymin - g->height;
+ gbox.ymax = gbox.ymin - g->dims[1];
pen_x += g->advance_i;
- if (user_fn(str, i_curr, &gbox, g->advance_i, &g->box, &g->pos_x, user_data) == false) {
+ if (user_fn(str, i_curr, &gbox, g->advance_i, &g->box, g->pos, user_data) == false) {
break;
}
@@ -1365,8 +1365,8 @@ static void blf_font_fill(FontBLF *font)
font->buf_info.fbuf = NULL;
font->buf_info.cbuf = NULL;
- font->buf_info.w = 0;
- font->buf_info.h = 0;
+ font->buf_info.dims[0] = 0;
+ font->buf_info.dims[1] = 0;
font->buf_info.ch = 0;
font->buf_info.col_init[0] = 0;
font->buf_info.col_init[1] = 0;