Center any glyphs narrower than the cell (i.e. in proportional fonts).

This commit is contained in:
William McBrine
2018-11-25 02:44:33 -05:00
parent 4538ae6520
commit 65b24e74ea
2 changed files with 20 additions and 0 deletions

View File

@@ -203,12 +203,16 @@ void PDC_gotoyx(int row, int col)
pdc_font = TTF_RenderUNICODE_Blended(pdc_ttffont, chstr, pdc_color[foregr]);
if (pdc_font)
{
int center = pdc_fwidth > pdc_font->w ?
(pdc_fwidth - pdc_font->w) >> 1 : 0;
dest.h = src.h;
dest.w = src.w;
src.x = 0;
src.y = pdc_fheight - src.h;
SDL_FillRect(pdc_screen, &dest, pdc_mapped[backgr]);
dest.x += center;
SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
dest.x -= center;
SDL_FreeSurface(pdc_font);
pdc_font = NULL;
}
@@ -441,7 +445,13 @@ void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp)
}
if (pdc_font)
{
int center = pdc_fwidth > pdc_font->w ?
(pdc_fwidth - pdc_font->w) >> 1 : 0;
dest.x += center;
SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
dest.x -= center;
}
}
#else
src.x = (ch & 0xff) % 32 * pdc_fwidth;

View File

@@ -203,12 +203,16 @@ void PDC_gotoyx(int row, int col)
pdc_font = TTF_RenderUNICODE_Blended(pdc_ttffont, chstr, pdc_color[foregr]);
if (pdc_font)
{
int center = pdc_fwidth > pdc_font->w ?
(pdc_fwidth - pdc_font->w) >> 1 : 0;
dest.h = src.h;
dest.w = src.w;
src.x = 0;
src.y = pdc_fheight - src.h;
SDL_FillRect(pdc_screen, &dest, pdc_mapped[backgr]);
dest.x += center;
SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
dest.x -= center;
SDL_FreeSurface(pdc_font);
pdc_font = NULL;
}
@@ -441,7 +445,13 @@ void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp)
}
if (pdc_font)
{
int center = pdc_fwidth > pdc_font->w ?
(pdc_fwidth - pdc_font->w) >> 1 : 0;
dest.x += center;
SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
dest.x -= center;
}
}
#else
src.x = (ch & 0xff) % 32 * pdc_fwidth;