- added monospacing support to Screen.DrawText and its native counterparts.

This commit is contained in:
Christoph Oelckers 2019-04-13 12:17:38 +02:00
commit d73f8faafa
7 changed files with 61 additions and 35 deletions

View file

@ -296,6 +296,11 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double
cx = x;
cy = y;
if (parms.monospace == EMonospacing::CellCenter)
cx += parms.spacing / 2;
else if (parms.monospace == EMonospacing::CellRight)
cx += parms.spacing;
auto currentcolor = normalcolor;
while (ch - string < parms.maxstrlen)
@ -334,9 +339,24 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double
parms.destwidth = parms.cellx;
parms.destheight = parms.celly;
}
if (parms.monospace == EMonospacing::CellLeft)
parms.left = 0;
else if (parms.monospace == EMonospacing::CellCenter)
parms.left = w / 2.;
else if (parms.monospace == EMonospacing::CellRight)
parms.left = w;
DrawTextureParms(pic, parms);
}
cx += (w + kerning) * parms.scalex;
if (parms.monospace == EMonospacing::Off)
{
cx += (w + kerning + parms.spacing) * parms.scalex;
}
else
{
cx += (parms.spacing) * parms.scalex;
}
}
}