Allow enabling/disabling hinting through console.

This commit is contained in:
Aaron van Geffen 2017-10-13 18:07:02 +02:00 committed by Marijn van der Werf
parent d4c5218ba2
commit 5e7f9c4762
3 changed files with 19 additions and 2 deletions

View File

@ -60,7 +60,6 @@ static TTF_Font * ttf_open_font(const utf8 * fontPath, sint32 ptSize);
static void ttf_close_font(TTF_Font * font);
static uint32 ttf_surface_cache_hash(TTF_Font * font, const utf8 * text);
static void ttf_surface_cache_dispose(ttf_cache_entry * entry);
static void ttf_surface_cache_dispose_all();
static void ttf_getwidth_cache_dispose_all();
static bool ttf_get_size(TTF_Font * font, const utf8 * text, sint32 * width, sint32 * height);
static TTFSurface * ttf_render(TTF_Font * font, const utf8 * text);
@ -144,7 +143,7 @@ static void ttf_surface_cache_dispose(ttf_cache_entry *entry)
}
}
static void ttf_surface_cache_dispose_all()
void ttf_surface_cache_dispose_all()
{
for (sint32 i = 0; i < TTF_SURFACE_CACHE_SIZE; i++) {
ttf_surface_cache_dispose(&_ttfSurfaceCache[i]);

View File

@ -44,6 +44,7 @@ extern "C" {
TTFFontDescriptor * ttf_get_font_from_sprite_base(uint16 spriteBase);
TTFSurface * ttf_surface_cache_get_or_add(TTF_Font * font, const utf8 * text);
void ttf_surface_cache_dispose_all();
uint32 ttf_getwidth_cache_get_or_add(TTF_Font * font, const utf8 * text);
bool ttf_provides_glyph(const TTF_Font * font, codepoint_t codepoint);
void ttf_free_surface(TTFSurface * surface);

View File

@ -45,6 +45,10 @@
#include "console.h"
#include "viewport.h"
#ifndef NO_TTF
#include "../drawing/ttf.h"
#endif
#define CONSOLE_BUFFER_SIZE 8192
#define CONSOLE_BUFFER_2_SIZE 256
#define CONSOLE_HISTORY_SIZE 64
@ -833,6 +837,11 @@ static sint32 cc_get(const utf8 **argv, sint32 argc)
else if (strcmp(argv[0], "cheat_disable_support_limits") == 0) {
console_printf("cheat_disable_support_limits %d", gCheatsDisableSupportLimits);
}
#ifndef NO_TTF
else if (strcmp(argv[0], "enable_hinting") == 0) {
console_printf("enable_hinting %d", gConfigFonts.enable_hinting);
}
#endif
else {
console_writeline_warning("Invalid variable.");
}
@ -1069,6 +1078,14 @@ static sint32 cc_set(const utf8 **argv, sint32 argc)
}
console_execute_silent("get cheat_disable_support_limits");
}
#ifndef NO_TTF
else if (strcmp(argv[0], "enable_hinting") == 0 && invalidArguments(&invalidArgs, int_valid[0])) {
gConfigFonts.enable_hinting = (int_val[0] != 0);
config_save_default();
console_execute_silent("get enable_hinting");
ttf_surface_cache_dispose_all();
}
#endif
else if (invalidArgs) {
console_writeline_error("Invalid arguments.");
}