shadows for fonts

This commit is contained in:
Michał Janiszewski 2016-01-07 15:06:09 +01:00
parent 73b0e403c4
commit 2d82bf344e
1 changed files with 35 additions and 12 deletions

View File

@ -1042,15 +1042,37 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo *dpi, const utf8 *text, te
int srcScanSkip = surface->pitch - width; int srcScanSkip = surface->pitch - width;
int dstScanSkip = dpi->width + dpi->pitch - width; int dstScanSkip = dpi->width + dpi->pitch - width;
uint8 *dst_orig = dst;
uint8 *src_orig = src;
// Draw shadow/outline
if (info->flags & TEXT_DRAW_FLAG_OUTLINE) {
for (int yy = 0; yy < height - 0; yy++) {
for (int xx = 0; xx < width - 0; xx++) {
if (*src != 0) {
*(dst + 1) = info->palette[3]; // right
*(dst - 1) = info->palette[3]; // left
*(dst - width - dstScanSkip) = info->palette[3]; // top
*(dst + width + dstScanSkip) = info->palette[3]; // bottom
}
src++;
dst++;
}
// Skip any remaining bits
src += srcScanSkip;
dst += dstScanSkip;
}
}
{
dst = dst_orig;
src = src_orig;
for (int yy = 0; yy < height; yy++) { for (int yy = 0; yy < height; yy++) {
for (int xx = 0; xx < width; xx++) { for (int xx = 0; xx < width; xx++) {
if (*src != 0) { if (*src != 0) {
*dst = colour;
if (info->flags & TEXT_DRAW_FLAG_INSET) { if (info->flags & TEXT_DRAW_FLAG_INSET) {
*(dst + width + dstScanSkip + 1) = info->palette[3]; *(dst + width + dstScanSkip + 1) = info->palette[3];
} else if (info->flags & TEXT_DRAW_FLAG_OUTLINE) {
*(dst + width + dstScanSkip + 1) = info->palette[3];
} }
*dst = colour;
} }
src++; src++;
dst++; dst++;
@ -1058,6 +1080,7 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo *dpi, const utf8 *text, te
src += srcScanSkip; src += srcScanSkip;
dst += dstScanSkip; dst += dstScanSkip;
} }
}
if (SDL_MUSTLOCK(surface)) { if (SDL_MUSTLOCK(surface)) {
SDL_UnlockSurface(surface); SDL_UnlockSurface(surface);