mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
topti: improve text positioning
* Specify a line height for the default fx-CG 50 font so that the height returned by dsize() is correctly 9, not 11. * Adjust vertical and horizontal alignment in dtext_opt() and dprint_opt() by a full pixel (DTEXT_BOTTOM, DTEXT_RIGHT) and half a pixel (DTEXT_MIDDLE, DTEXT_CENTER) to make sure that the specified position is within rendered text (as in DTEXT_LEFT and TEXT_TOP) and to improve centering of strings with odd width or odd height, for which there is only one valid position.
This commit is contained in:
parent
e63ff8351b
commit
3a15340335
3 changed files with 9 additions and 9 deletions
|
@ -123,7 +123,7 @@ $(call src2obj,../src/font8x9.png): ../src/font8x9.png
|
|||
$(call cmd_m,fxconv,font8x9.png) fxconv -f $< -o $@ \
|
||||
--cg --toolchain=$(CONFIG.TOOLCHAIN) name:gint_font8x9 \
|
||||
charset:print grid.size:8x11 grid.padding:1 grid.border:0 \
|
||||
proportional:true
|
||||
proportional:true height:9
|
||||
|
||||
# Version symbol. ld generates a .stack section for unknown reasons; I remove
|
||||
# it in the linker script.
|
||||
|
|
|
@ -114,10 +114,10 @@ void dtext_opt(int x, int y, int fg, int bg, int halign, int valign,
|
|||
int w, h;
|
||||
dsize(str, topti_font, &w, &h);
|
||||
|
||||
if(halign == DTEXT_RIGHT) x -= w;
|
||||
if(halign == DTEXT_CENTER) x -= ((w+1) >> 1);
|
||||
if(valign == DTEXT_BOTTOM) y -= h;
|
||||
if(valign == DTEXT_MIDDLE) y -= ((h+1) >> 1);
|
||||
if(halign == DTEXT_RIGHT) x -= w - 1;
|
||||
if(halign == DTEXT_CENTER) x -= (w >> 1);
|
||||
if(valign == DTEXT_BOTTOM) y -= h - 1;
|
||||
if(valign == DTEXT_MIDDLE) y -= (h >> 1);
|
||||
}
|
||||
|
||||
topti_render(x, y, str, topti_font, fg, bg);
|
||||
|
|
|
@ -186,10 +186,10 @@ void dtext_opt(int x, int y, int fg, int bg, int halign, int valign,
|
|||
int w, h;
|
||||
dsize(str, topti_font, &w, &h);
|
||||
|
||||
if(halign == DTEXT_RIGHT) x -= w;
|
||||
if(halign == DTEXT_CENTER) x -= ((w+1) >> 1);
|
||||
if(valign == DTEXT_BOTTOM) y -= h;
|
||||
if(valign == DTEXT_MIDDLE) y -= ((h+1) >> 1);
|
||||
if(halign == DTEXT_RIGHT) x -= w - 1;
|
||||
if(halign == DTEXT_CENTER) x -= (w >> 1);
|
||||
if(valign == DTEXT_BOTTOM) y -= h - 1;
|
||||
if(valign == DTEXT_MIDDLE) y -= (h >> 1);
|
||||
}
|
||||
|
||||
topti_render(x, y, str, topti_font, topti_asm_text[fg],
|
||||
|
|
Loading…
Reference in a new issue