Fix #10660: Sprite Font scale affected by viewport zoom level limits. (#10668)

(cherry picked from commit db573c8742)

# Conflicts:
#	src/fontcache/spritefontcache.cpp
#	src/gfx.cpp
#	src/spritecache.cpp
This commit is contained in:
Jonathan G Rennison
2023-04-17 21:09:25 +01:00
parent 7da25820ea
commit de5b114a83
6 changed files with 50 additions and 18 deletions

View File

@@ -568,14 +568,14 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
return (void*)GetRawSprite(SPR_IMG_QUERY, ST_NORMAL, allocator, encoder);
}
if (sprite->type == ST_FONT && ZOOM_LVL_GUI != ZOOM_LVL_NORMAL) {
if (sprite->type == ST_FONT && _font_zoom != ZOOM_LVL_NORMAL) {
/* Make ZOOM_LVL_NORMAL be ZOOM_LVL_GUI */
sprite[ZOOM_LVL_NORMAL].width = sprite[ZOOM_LVL_GUI].width;
sprite[ZOOM_LVL_NORMAL].height = sprite[ZOOM_LVL_GUI].height;
sprite[ZOOM_LVL_NORMAL].x_offs = sprite[ZOOM_LVL_GUI].x_offs;
sprite[ZOOM_LVL_NORMAL].y_offs = sprite[ZOOM_LVL_GUI].y_offs;
sprite[ZOOM_LVL_NORMAL].data = sprite[ZOOM_LVL_GUI].data;
sprite[ZOOM_LVL_NORMAL].colours = sprite[ZOOM_LVL_GUI].colours;
sprite[ZOOM_LVL_NORMAL].width = sprite[_font_zoom].width;
sprite[ZOOM_LVL_NORMAL].height = sprite[_font_zoom].height;
sprite[ZOOM_LVL_NORMAL].x_offs = sprite[_font_zoom].x_offs;
sprite[ZOOM_LVL_NORMAL].y_offs = sprite[_font_zoom].y_offs;
sprite[ZOOM_LVL_NORMAL].data = sprite[_font_zoom].data;
sprite[ZOOM_LVL_NORMAL].colours = sprite[_font_zoom].colours;
}
return encoder->Encode(sprite, allocator);
@@ -1084,4 +1084,17 @@ void GfxClearSpriteCache()
VideoDriver::GetInstance()->ClearSystemSprites();
}
/**
* Remove all encoded font sprites from the sprite cache without
* discarding sprite location information.
*/
void GfxClearFontSpriteCache()
{
/* Clear sprite ptr for all cached font items */
for (uint i = 0; i != _spritecache.size(); i++) {
SpriteCache *sc = GetSpriteCache(i);
if (sc->GetType() == ST_FONT && sc->GetPtr() != nullptr) DeleteEntryFromSpriteCache(i);
}
}
/* static */ ReusableBuffer<SpriteLoader::CommonPixel> SpriteLoader::Sprite::buffer[ZOOM_LVL_COUNT];