From 2d82bf344e0275b9b56b1609ef1ee45d4ca9f694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 7 Jan 2016 15:06:09 +0100 Subject: [PATCH] shadows for fonts --- src/drawing/string.c | 47 +++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/src/drawing/string.c b/src/drawing/string.c index 7cfaf346df..ed1ee5edbd 100644 --- a/src/drawing/string.c +++ b/src/drawing/string.c @@ -1042,21 +1042,44 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo *dpi, const utf8 *text, te int srcScanSkip = surface->pitch - width; int dstScanSkip = dpi->width + dpi->pitch - width; - for (int yy = 0; yy < height; yy++) { - for (int xx = 0; xx < width; xx++) { - if (*src != 0) { - *dst = colour; - if (info->flags & TEXT_DRAW_FLAG_INSET) { - *(dst + width + dstScanSkip + 1) = info->palette[3]; - } else if (info->flags & TEXT_DRAW_FLAG_OUTLINE) { - *(dst + width + dstScanSkip + 1) = info->palette[3]; + 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++; } - 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 xx = 0; xx < width; xx++) { + if (*src != 0) { + if (info->flags & TEXT_DRAW_FLAG_INSET) { + *(dst + width + dstScanSkip + 1) = info->palette[3]; + } + *dst = colour; + } + src++; + dst++; + } + src += srcScanSkip; + dst += dstScanSkip; } - src += srcScanSkip; - dst += dstScanSkip; } if (SDL_MUSTLOCK(surface)) {