mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-25 07:44:38 +01:00
Improve NO_TTF build
This commit is contained in:
@@ -357,10 +357,10 @@ void shorten_path(utf8 *buffer, size_t bufferSize, const utf8 *path, int availab
|
||||
#ifndef NO_TTF
|
||||
SDL_Surface *ttf_surface_cache_get_or_add(TTF_Font *font, const utf8 *text);
|
||||
TTFFontDescriptor *ttf_get_font_from_sprite_base(uint16 spriteBase);
|
||||
#endif // NO_TTF
|
||||
|
||||
bool ttf_initialise();
|
||||
void ttf_dispose();
|
||||
#endif // NO_TTF
|
||||
|
||||
// scrolling text
|
||||
void scrolling_text_initialise_bitmaps();
|
||||
|
||||
@@ -194,9 +194,9 @@ bool font_supports_string_sprite(const utf8 *text)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef NO_TTF
|
||||
bool font_supports_string_ttf(const utf8 *text, int fontSize)
|
||||
{
|
||||
#ifndef NO_TTF
|
||||
const utf8 *src = text;
|
||||
const TTF_Font *font = gCurrentTTFFontSet->size[fontSize].font;
|
||||
if (font == NULL) {
|
||||
@@ -211,18 +211,16 @@ bool font_supports_string_ttf(const utf8 *text, int fontSize)
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif // NO_TTF
|
||||
}
|
||||
|
||||
bool font_supports_string(const utf8 *text, int fontSize)
|
||||
{
|
||||
#ifndef NO_TTF
|
||||
if (gUseTrueTypeFont) {
|
||||
return font_supports_string_ttf(text, fontSize);
|
||||
} else {
|
||||
#endif // NO_TTF
|
||||
return font_supports_string_sprite(text);
|
||||
#ifndef NO_TTF
|
||||
}
|
||||
#endif // NO_TTF
|
||||
}
|
||||
|
||||
@@ -68,9 +68,7 @@ int font_get_size_from_sprite_base(uint16 spriteBase);
|
||||
int font_get_line_height(int fontSpriteBase);
|
||||
int font_get_line_height_small(int fontSpriteBase);
|
||||
bool font_supports_string_sprite(const utf8 *text);
|
||||
#ifndef NO_TTF
|
||||
bool font_supports_string_ttf(const utf8 *text, int fontSize);
|
||||
#endif // NO_TTF
|
||||
bool font_supports_string(const utf8 *text, int fontSize);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1447,15 +1447,11 @@ int scrolling_text_setup(rct_string_id stringId, uint16 scroll, uint16 scrolling
|
||||
const sint16* scrollingModePositions = _scrollPositions[scrollingMode];
|
||||
|
||||
memset(scrollText->bitmap, 0, 320 * 8);
|
||||
#ifndef NO_TTF
|
||||
if (gUseTrueTypeFont) {
|
||||
scrolling_text_set_bitmap_for_ttf(scrollString, scroll, scrollText->bitmap, scrollingModePositions);
|
||||
} else {
|
||||
#endif // NO_TTF
|
||||
scrolling_text_set_bitmap_for_sprite(scrollString, scroll, scrollText->bitmap, scrollingModePositions);
|
||||
#ifndef NO_TTF
|
||||
}
|
||||
#endif // NO_TTF
|
||||
|
||||
uint32 imageId = SPR_SCROLLING_TEXT_START + scrollIndex;
|
||||
drawing_engine_invalidate_image(imageId);
|
||||
@@ -1511,9 +1507,9 @@ void scrolling_text_set_bitmap_for_sprite(utf8 *text, int scroll, uint8 *bitmap,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NO_TTF
|
||||
void scrolling_text_set_bitmap_for_ttf(utf8 *text, int scroll, uint8 *bitmap, const sint16 *scrollPositionOffsets)
|
||||
{
|
||||
#ifndef NO_TTF
|
||||
TTFFontDescriptor *fontDesc = ttf_get_font_from_sprite_base(FONT_SPRITE_BASE_TINY);
|
||||
if (fontDesc->font == NULL) {
|
||||
scrolling_text_set_bitmap_for_sprite(text, scroll, bitmap, scrollPositionOffsets);
|
||||
@@ -1588,5 +1584,5 @@ void scrolling_text_set_bitmap_for_ttf(utf8 *text, int scroll, uint8 *bitmap, co
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface);
|
||||
}
|
||||
#endif // NO_TTF
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ enum {
|
||||
TEXT_DRAW_FLAG_DARK = 1 << 2,
|
||||
TEXT_DRAW_FLAG_EXTRA_DARK = 1 << 3,
|
||||
TEXT_DRAW_FLAG_Y_OFFSET_EFFECT = 1 << 29,
|
||||
#ifndef NO_TTF
|
||||
TEXT_DRAW_FLAG_TTF = 1 << 30,
|
||||
#endif // NO_TTF
|
||||
TEXT_DRAW_FLAG_NO_DRAW = 1u << 31
|
||||
};
|
||||
|
||||
@@ -895,6 +897,13 @@ TTFFontDescriptor *ttf_get_font_from_sprite_base(uint16 spriteBase)
|
||||
{
|
||||
return &gCurrentTTFFontSet->size[font_get_size_from_sprite_base(spriteBase)];
|
||||
}
|
||||
#else
|
||||
bool ttf_initialise()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void ttf_dispose() {}
|
||||
#endif // NO_TTF
|
||||
|
||||
typedef struct text_draw_info {
|
||||
@@ -1169,7 +1178,11 @@ static const utf8 *ttf_process_glyph_run(rct_drawpixelinfo *dpi, const utf8 *tex
|
||||
const utf8 *lastCh;
|
||||
int codepoint;
|
||||
|
||||
#ifndef NO_TTF
|
||||
bool isTTF = info->flags & TEXT_DRAW_FLAG_TTF;
|
||||
#else
|
||||
bool isTTF = false;
|
||||
#endif // NO_TTF
|
||||
while (!utf8_is_format_code(codepoint = utf8_get_next(ch, &lastCh))) {
|
||||
if (isTTF && utf8_should_use_sprite_for_codepoint(codepoint)) {
|
||||
break;
|
||||
@@ -1194,7 +1207,11 @@ static void ttf_process_string(rct_drawpixelinfo *dpi, const utf8 *text, text_dr
|
||||
const utf8 *nextCh;
|
||||
int codepoint;
|
||||
|
||||
#ifndef NO_TTF
|
||||
bool isTTF = info->flags & TEXT_DRAW_FLAG_TTF;
|
||||
#else
|
||||
bool isTTF = false;
|
||||
#endif // NO_TTF
|
||||
|
||||
while ((codepoint = utf8_get_next(ch, &nextCh)) != 0) {
|
||||
if (utf8_is_format_code(codepoint)) {
|
||||
@@ -1329,9 +1346,11 @@ void gfx_draw_string_with_y_offsets(rct_drawpixelinfo *dpi, const utf8 *text, in
|
||||
|
||||
info.flags |= TEXT_DRAW_FLAG_Y_OFFSET_EFFECT;
|
||||
|
||||
#ifndef NO_TTF
|
||||
if (!forceSpriteFont && gUseTrueTypeFont) {
|
||||
info.flags |= TEXT_DRAW_FLAG_TTF;
|
||||
}
|
||||
#endif // NO_TTF
|
||||
|
||||
memcpy(info.palette, text_palette, sizeof(info.palette));
|
||||
ttf_process_initial_colour(colour, &info);
|
||||
|
||||
@@ -96,11 +96,11 @@ const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT] = {
|
||||
|
||||
static void LoadSpriteFont()
|
||||
{
|
||||
#ifndef NO_TTF
|
||||
ttf_dispose();
|
||||
gUseTrueTypeFont = false;
|
||||
#ifndef NO_TTF
|
||||
gCurrentTTFFontSet = nullptr;
|
||||
#endif
|
||||
#endif // NO_TTF
|
||||
}
|
||||
|
||||
#ifndef NO_TTF
|
||||
|
||||
@@ -53,7 +53,7 @@ typedef struct language_descriptor {
|
||||
#ifndef NO_TTF
|
||||
TTFFontSetDescriptor *font;
|
||||
#else
|
||||
void * font;
|
||||
void * font;
|
||||
#endif // NO_TTF
|
||||
uint8 rct2_original_id;
|
||||
} language_descriptor;
|
||||
|
||||
Reference in New Issue
Block a user