diff options
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 3 | ||||
-rw-r--r-- | source/blender/blenfont/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/blenfont/SConscript | 2 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 5 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 23 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 2 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_internal.h | 4 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_internal_types.h | 4 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_lang.c | 4 |
9 files changed, 26 insertions, 22 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 0732e02b5fc..ce10951d6ff 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -33,6 +33,7 @@ #define __BLF_API_H__ struct rctf; +struct ColorManagedDisplay; int BLF_init(int points, int dpi); void BLF_exit(void); @@ -151,7 +152,7 @@ void BLF_shadow_offset(int fontid, int x, int y); * * BLF_buffer(NULL, NULL, 0, 0, 0, FALSE); */ -void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management); +void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display); /* Set the color to be used for text. */ void BLF_buffer_col(int fontid, float r, float g, float b, float a); diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index ebf9ff4db39..da60710a137 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -27,6 +27,7 @@ set(INC ../blenlib ../editors/include ../makesdna + ../imbuf ../../../intern/guardedalloc ) diff --git a/source/blender/blenfont/SConscript b/source/blender/blenfont/SConscript index c46960d2311..d3c7b1c2fcc 100644 --- a/source/blender/blenfont/SConscript +++ b/source/blender/blenfont/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('intern/*.c') -incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../editors/include' +incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../imbuf ../editors/include' incs += ' #/extern/glew/include' incs += ' ' + env['BF_FREETYPE_INC'] incs += ' ' + env['BF_GETTEXT_INC'] diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index d4739b37f93..92fcb576e7d 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -50,7 +50,6 @@ #include "blf_internal_types.h" #include "blf_internal.h" - /* Max number of font in memory. * Take care that now every font have a glyph cache per size/dpi, * so we don't need load the same font with different size, just @@ -746,7 +745,7 @@ void BLF_shadow_offset(int fontid, int x, int y) } } -void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, int do_color_management) +void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch, struct ColorManagedDisplay *display) { FontBLF *font = BLF_get(fontid); @@ -756,7 +755,7 @@ void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int font->buf_info.w = w; font->buf_info.h = h; font->buf_info.ch = nch; - font->buf_info.do_color_management = do_color_management; + font->buf_info.display = display; } } diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index ab43804db8e..1900efa2dbc 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -53,6 +53,8 @@ #include "BIF_gl.h" #include "BLF_api.h" +#include "IMB_colormanagement.h" + #include "blf_internal_types.h" #include "blf_internal.h" @@ -159,7 +161,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font) } \ } (void)0 -void blf_font_draw(FontBLF *font, const char *str, unsigned int len) +void blf_font_draw(FontBLF *font, const char *str, size_t len) { unsigned int c; GlyphBLF *g, *g_prev = NULL; @@ -172,7 +174,7 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len) blf_font_ensure_ascii_table(font); - while (str[i] && i < len) { + while ((i < len) && str[i]) { BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); if (c == BLI_UTF8_ERR) @@ -191,7 +193,7 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len) } /* faster version of blf_font_draw, ascii only for view dimensions */ -void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len) +void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len) { unsigned char c; GlyphBLF *g, *g_prev = NULL; @@ -245,11 +247,12 @@ void blf_font_buffer(FontBLF *font, const char *str) blf_font_ensure_ascii_table(font); /* another buffer specific call for color conversion */ - if (buf_info->do_color_management) { - srgb_to_linearrgb_v4(b_col_float, buf_info->col); + if (buf_info->display) { + copy_v4_v4(b_col_float, buf_info->col); + IMB_colormanagement_display_to_scene_linear_v3(b_col_float, buf_info->display); } else { - copy_v4_v4(b_col_float, buf_info->col); + srgb_to_linearrgb_v4(b_col_float, buf_info->col); } while (str[i]) { @@ -427,8 +430,8 @@ void blf_font_width_and_height(FontBLF *font, const char *str, float *width, flo } blf_font_boundbox(font, str, &box); - *width = (BLI_RCT_SIZE_X(&box) * xa); - *height = (BLI_RCT_SIZE_Y(&box) * ya); + *width = (BLI_rctf_size_x(&box) * xa); + *height = (BLI_rctf_size_y(&box) * ya); } float blf_font_width(FontBLF *font, const char *str) @@ -442,7 +445,7 @@ float blf_font_width(FontBLF *font, const char *str) xa = 1.0f; blf_font_boundbox(font, str, &box); - return BLI_RCT_SIZE_X(&box) * xa; + return BLI_rctf_size_x(&box) * xa; } float blf_font_height(FontBLF *font, const char *str) @@ -456,7 +459,7 @@ float blf_font_height(FontBLF *font, const char *str) ya = 1.0f; blf_font_boundbox(font, str, &box); - return BLI_RCT_SIZE_Y(&box) * ya; + return BLI_rctf_size_y(&box) * ya; } float blf_font_fixed_width(FontBLF *font) diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 63225651e5b..91ecded88be 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -415,7 +415,7 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) g->uv[1][1] = ((float)(g->yoff + g->height)) / ((float)gc->p2_height); /* update the x offset for the next glyph. */ - gc->x_offs += (int)(BLI_RCT_SIZE_X(&g->box) + gc->pad); + gc->x_offs += (int)(BLI_rctf_size_x(&g->box) + gc->pad); gc->rem_glyphs--; g->build_tex = 1; diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index ba66fce8374..65a54783978 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -51,8 +51,8 @@ struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size); void blf_font_size(struct FontBLF *font, int size, int dpi); -void blf_font_draw(struct FontBLF *font, const char *str, unsigned int len); -void blf_font_draw_ascii(struct FontBLF *font, const char *str, unsigned int len); +void blf_font_draw(struct FontBLF *font, const char *str, size_t len); +void blf_font_draw_ascii(struct FontBLF *font, const char *str, size_t len); void blf_font_buffer(struct FontBLF *font, const char *str); void blf_font_boundbox(struct FontBLF *font, const char *str, struct rctf *box); void blf_font_width_and_height(struct FontBLF *font, const char *str, float *width, float *height); diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 4c617da7583..1acc3dad4cf 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -145,8 +145,8 @@ typedef struct FontBufInfoBLF { /* number of channels. */ int ch; - /* is the float buffer linear */ - int do_color_management; + /* display device used for color management */ + struct ColorManagedDisplay *display; /* and the color, the alphas is get from the glyph! * color is srgb space */ diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 2b7e225d709..d0b77222114 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -129,7 +129,7 @@ void BLF_lang_init(void) } /* get LANG/LANGUAGE environment variable */ -static void get_language_variable(const char *varname, char *var, int maxlen) +static void get_language_variable(const char *varname, char *var, const size_t maxlen) { char *env = getenv(varname); @@ -149,7 +149,7 @@ static void get_language_variable(const char *varname, char *var, int maxlen) /* get language to be used based on locale(which might be empty when using default language) and * LANG environment variable */ -static void get_language(const char *locale, const char *lang, char *language, int maxlen) +static void get_language(const char *locale, const char *lang, char *language, const size_t maxlen) { if (locale[0]) { BLI_strncpy(language, locale, maxlen); |