mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
(svn r23009) -Change: Improve appearance of antialiased text with shadow.
This commit is contained in:
parent
ca1df3ddab
commit
8a41530585
@ -1045,7 +1045,7 @@ const Sprite *GetGlyph(FontSize size, WChar key)
|
||||
sprite.y_offs = _ascender[size] - slot->bitmap_top;
|
||||
|
||||
/* Draw shadow for medium size */
|
||||
if (size == FS_NORMAL) {
|
||||
if (size == FS_NORMAL && !aa) {
|
||||
for (y = 0; y < slot->bitmap.rows; y++) {
|
||||
for (x = 0; x < slot->bitmap.width; x++) {
|
||||
if (aa ? (slot->bitmap.buffer[x + y * slot->bitmap.pitch] > 0) : HasBit(slot->bitmap.buffer[(x / 8) + y * slot->bitmap.pitch], 7 - (x % 8))) {
|
||||
@ -1074,6 +1074,12 @@ const Sprite *GetGlyph(FontSize size, WChar key)
|
||||
}
|
||||
|
||||
|
||||
bool GetDrawGlyphShadow()
|
||||
{
|
||||
return GetFontFace(FS_NORMAL) != NULL && GetFontAAState(FS_NORMAL);
|
||||
}
|
||||
|
||||
|
||||
uint GetGlyphWidth(FontSize size, WChar key)
|
||||
{
|
||||
FT_Face face = GetFontFace(size);
|
||||
|
@ -45,6 +45,7 @@ void InitFreeType();
|
||||
void UninitFreeType();
|
||||
const Sprite *GetGlyph(FontSize size, uint32 key);
|
||||
uint GetGlyphWidth(FontSize size, uint32 key);
|
||||
bool GetDrawGlyphShadow();
|
||||
|
||||
typedef bool (SetFallbackFontCallback)(const char **);
|
||||
/**
|
||||
@ -82,6 +83,11 @@ static inline uint GetGlyphWidth(FontSize size, uint32 key)
|
||||
return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + (size != FS_NORMAL) : 0;
|
||||
}
|
||||
|
||||
static inline bool GetDrawGlyphShadow()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* WITH_FREETYPE */
|
||||
|
||||
#endif /* FONTCACHE_H */
|
||||
|
@ -1057,6 +1057,7 @@ void DrawCharCentered(WChar c, int x, int y, TextColour colour)
|
||||
static int ReallyDoDrawString(const UChar *string, int x, int y, DrawStringParams ¶ms, bool parse_string_also_when_clipped)
|
||||
{
|
||||
DrawPixelInfo *dpi = _cur_dpi;
|
||||
bool draw_shadow = GetDrawGlyphShadow();
|
||||
UChar c;
|
||||
int xo = x;
|
||||
|
||||
@ -1087,7 +1088,13 @@ skip_cont:;
|
||||
if (IsPrintable(c) && !IsTextDirectionChar(c)) {
|
||||
if (x >= dpi->left + dpi->width) goto skip_char;
|
||||
if (x + _max_char_width >= dpi->left) {
|
||||
GfxMainBlitter(GetGlyph(params.fontsize, c), x, y, BM_COLOUR_REMAP);
|
||||
const Sprite *glyph = GetGlyph(params.fontsize, c);
|
||||
if (draw_shadow && params.fontsize == FS_NORMAL && params.cur_colour != TC_BLACK && !(c >= SCC_SPRITE_START && c <= SCC_SPRITE_END)) {
|
||||
SetColourRemap(TC_BLACK);
|
||||
GfxMainBlitter(glyph, x + 1, y + 1, BM_COLOUR_REMAP);
|
||||
SetColourRemap(params.cur_colour);
|
||||
}
|
||||
GfxMainBlitter(glyph, x, y, BM_COLOUR_REMAP);
|
||||
}
|
||||
x += GetCharacterWidth(params.fontsize, c);
|
||||
} else if (c == '\n') { // newline = {}
|
||||
|
Loading…
Reference in New Issue
Block a user