diff options
Diffstat (limited to 'source/blender/editors/interface/interface_style.c')
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 7be089fdf32..2e4106b3c04 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -153,10 +153,16 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str, height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */ yofs= floor( 0.5f*(rect->ymax - rect->ymin - height)); - if(fs->align==UI_STYLE_TEXT_CENTER) + if(fs->align==UI_STYLE_TEXT_CENTER) { xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str))); - else if(fs->align==UI_STYLE_TEXT_RIGHT) + /* don't center text if it chops off the start of the text, 2 gives some margin */ + if(xofs < 2) { + xofs= 2; + } + } + else if(fs->align==UI_STYLE_TEXT_RIGHT) { xofs= rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1; + } /* clip is very strict, so we give it some space */ BLF_clipping(fs->uifont_id, rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4); |