From 3b541a9a4c0423178d68a1c34ab85efa9d97fc3b Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 11 Sep 2023 11:55:37 +0200 Subject: Add font specific scale config --- example-config.json | 9 ++++++++- include/Config.hpp | 13 +++++++++++-- src/Body.cpp | 10 +++++----- src/Config.cpp | 9 +++++++++ src/Entry.cpp | 6 +++--- src/ImageViewer.cpp | 8 ++++---- src/QuickMedia.cpp | 40 ++++++++++++++++++++-------------------- src/SearchBar.cpp | 4 ++-- src/Tabs.cpp | 2 +- src/Text.cpp | 33 +++++++++++++++++++-------------- 10 files changed, 82 insertions(+), 52 deletions(-) diff --git a/example-config.json b/example-config.json index 40e640b..a8f3aa0 100644 --- a/example-config.json +++ b/example-config.json @@ -107,7 +107,14 @@ "latin_bold": "", "latin_monospace": "", "cjk": "", - "symbols": "" + "symbols": "", + "scale": { + "latin": 1.0, + "latin_bold": 1.0, + "latin_monospace": 1.0, + "cjk": 1.0, + "symbols": 1.0 + } }, "mangadex": { "allow_hentai": false diff --git a/include/Config.hpp b/include/Config.hpp index 306b535..44cde39 100644 --- a/include/Config.hpp +++ b/include/Config.hpp @@ -68,19 +68,28 @@ namespace QuickMedia { std::string file_directory; }; + struct FontScaleConfig { + float latin = 1.0f; + float latin_bold = 1.0f; + float latin_monospace = 1.0f; + float cjk = 1.0f; + float symbols = 1.0f; + }; + struct FontConfig { std::string latin; std::string latin_bold; std::string latin_monospace; std::string cjk; std::string symbols; + FontScaleConfig scale; }; struct MangadexConfig { bool allow_hentai = false; }; - struct FileManager { + struct FileManagerConfig { bool grid_view = true; }; @@ -102,7 +111,7 @@ namespace QuickMedia { DownloadConfig download; FontConfig font; MangadexConfig mangadex; - FileManager file_manager; + FileManagerConfig file_manager; bool use_system_fonts = false; bool use_system_mpv_config = false; bool enable_shaders = true; diff --git a/src/Body.cpp b/src/Body.cpp index 2700288..54a3b5f 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -34,8 +34,8 @@ struct BodySpacing { }; namespace QuickMedia { - static const int card_width = 250.0f * get_config().scale * get_config().font_scale; - static const int card_height = 350.0f * get_config().scale * get_config().font_scale; + static const int card_width = 250.0f * get_config().scale; + static const int card_height = 350.0f * get_config().scale; static const int min_column_spacing = 5 * get_config().scale * get_config().spacing_scale; static const int card_padding_x = 15 * get_config().scale * get_config().spacing_scale; @@ -99,7 +99,7 @@ namespace QuickMedia { selected_item(0), prev_selected_item(0), loading_icon(&loading_icon_texture), - progress_text("", *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().body.progress_font_size * get_config().scale * get_config().font_scale)), + progress_text("", *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().body.progress_font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin)), embedded_item_load_text("", *FontLoader::get_font(FontLoader::FontType::LATIN, body_spacing[body_theme].embedded_item_font_size)), num_visible_items(0), top_cut_off(false), @@ -1474,9 +1474,9 @@ namespace QuickMedia { const float image_padding_x = !draw_thumbnails ? 0.0f : body_spacing[body_theme].image_padding_x; const float text_max_width = size.x - text_offset_x - image_padding_x; - const float text_offset_y = std::floor(6.0f * get_config().scale * get_config().font_scale); + const float text_offset_y = std::floor(6.0f * get_config().scale * get_config().font_scale * get_config().font.scale.latin); - const float timestamp_text_y = std::floor(item_pos.y + padding_y - text_offset_y - std::floor(4.0f * get_config().scale * get_config().font_scale)); + const float timestamp_text_y = std::floor(item_pos.y + padding_y - text_offset_y - std::floor(4.0f * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); if(item->author_text && !merge_with_previous) { item->author_text->set_position(vec2f_floor(item_pos.x + text_offset_x, item_pos.y + padding_y - text_offset_y)); item->author_text->draw(window); diff --git a/src/Config.cpp b/src/Config.cpp index 4f8d4d1..474e6a9 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -302,6 +302,15 @@ namespace QuickMedia { get_json_value_path(font_json, "latin_monospace", config->font.latin_monospace); get_json_value_path(font_json, "cjk", config->font.cjk); get_json_value_path(font_json, "symbols", config->font.symbols); + + const Json::Value &font_scale_json = font_json["scale"]; + if(font_scale_json.isObject()) { + get_json_value(font_scale_json, "latin", config->font.scale.latin); + get_json_value(font_scale_json, "latin_bold", config->font.scale.latin_bold); + get_json_value(font_scale_json, "latin_monospace", config->font.scale.latin_monospace); + get_json_value(font_scale_json, "cjk", config->font.scale.cjk); + get_json_value(font_scale_json, "symbols", config->font.scale.symbols); + } } const Json::Value &mangadex_json = json_root["mangadex"]; diff --git a/src/Entry.cpp b/src/Entry.cpp index 7e664c3..5416724 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -13,8 +13,8 @@ namespace QuickMedia { return (int)v; } - static const float background_margin_horizontal = 5.0f + floor(get_config().input.font_size * get_config().scale * get_config().font_scale * 0.6f); - static const float background_margin_vertical = 2.0f + floor(get_config().input.font_size * get_config().scale * get_config().font_scale * 0.25f); + static const float background_margin_horizontal = 5.0f + floor(get_config().input.font_size * get_config().scale * 0.6f); + static const float background_margin_vertical = 2.0f + floor(get_config().input.font_size * get_config().scale * 0.25f); Entry::Entry(const std::string &placeholder_text, mgl::Shader *rounded_rectangle_shader) : on_submit_callback(nullptr), @@ -22,7 +22,7 @@ namespace QuickMedia { text("", false, floor(get_config().input.font_size * get_config().scale * get_config().font_scale), 0.0f), width(0.0f), background(mgl::vec2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().shade_color, rounded_rectangle_shader), - placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().input.font_size * get_config().scale * get_config().font_scale)), + placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().input.font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin)), mouse_left_inside(false) { text.setEditable(true); diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp index e8bc71d..fb9912c 100644 --- a/src/ImageViewer.cpp +++ b/src/ImageViewer.cpp @@ -14,7 +14,7 @@ #include namespace QuickMedia { - static const int page_text_character_size = 14 * get_config().scale * get_config().font_scale; + static const int page_text_character_size = 14 * get_config().scale * get_config().font_scale * get_config().font.scale.latin; static mgl::vec2d get_no_image_size_scaled(mgl::vec2d window_size, bool fit_image_to_window) { mgl::vec2d no_image_page_size(720.0, 1280.0); @@ -108,7 +108,7 @@ namespace QuickMedia { if(page == -1 || page == num_pages) { // TODO: Dont show if first/last chapter - mgl::Text text(page == -1 ? "Scroll up to go to the previous chapter" : "Scroll down to go to the next chapter", *FontLoader::get_font(FontLoader::FontType::LATIN, 30 * get_config().scale * get_config().font_scale)); + mgl::Text text(page == -1 ? "Scroll up to go to the previous chapter" : "Scroll down to go to the next chapter", *FontLoader::get_font(FontLoader::FontType::LATIN, 30 * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); auto text_bounds = text.get_bounds(); text.set_color(get_theme().text_color); mgl::vec2d render_pos_text(floor(window_size.x * 0.5 - text_bounds.size.x * 0.5), image_size.y * 0.5 - text_bounds.size.y * 0.5 + scroll + offset_y); @@ -160,7 +160,7 @@ namespace QuickMedia { msg = "Failed to load image for page " + page_str; } - mgl::Text error_message(std::move(msg), *FontLoader::get_font(FontLoader::FontType::LATIN, 30 * get_config().scale * get_config().font_scale)); + mgl::Text error_message(std::move(msg), *FontLoader::get_font(FontLoader::FontType::LATIN, 30 * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); auto text_bounds = error_message.get_bounds(); error_message.set_color(get_theme().text_color); mgl::vec2d render_pos_text(floor(window_size.x * 0.5 - text_bounds.size.x * 0.5), image_size.y * 0.5 - text_bounds.size.y * 0.5 + scroll + offset_y); @@ -179,7 +179,7 @@ namespace QuickMedia { } else { std::string page_str = std::to_string(1 + page); - mgl::Text error_message("Downloading page " + page_str, *FontLoader::get_font(FontLoader::FontType::LATIN, 30 * get_config().scale * get_config().font_scale)); + mgl::Text error_message("Downloading page " + page_str, *FontLoader::get_font(FontLoader::FontType::LATIN, 30 * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); auto text_bounds = error_message.get_bounds(); error_message.set_color(get_theme().text_color); mgl::vec2d render_pos_text(floor(window_size.x * 0.5 - text_bounds.size.x * 0.5), image_size.y * 0.5 - text_bounds.size.y * 0.5 + scroll + offset_y); diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 79684ed..279cb28 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -2067,7 +2067,7 @@ namespace QuickMedia { } if(!tabs[selected_tab].page->is_ready()) { - mgl::Text loading_text("Loading...", *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().body.loading_text_font_size * get_config().scale * get_config().font_scale)); + mgl::Text loading_text("Loading...", *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().body.loading_text_font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); loading_text.set_color(get_theme().text_color); auto text_bounds = loading_text.get_bounds(); loading_text.set_position(mgl::vec2f( @@ -2154,7 +2154,7 @@ namespace QuickMedia { std::vector tab_associated_data; for(size_t i = 0; i < tabs.size(); ++i) { TabAssociatedData data; - data.search_result_text = mgl::Text("", *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().body.loading_text_font_size * get_config().scale * get_config().font_scale)); + data.search_result_text = mgl::Text("", *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().body.loading_text_font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); data.search_result_text.set_color(get_theme().text_color); data.card_view = tabs[i].body ? tabs[i].body->card_view : false; tab_associated_data.push_back(std::move(data)); @@ -4233,7 +4233,7 @@ namespace QuickMedia { mgl::Texture image_texture; mgl::Sprite image; - mgl::Text error_message("", *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().body.loading_text_font_size * get_config().scale * get_config().font_scale)); + mgl::Text error_message("", *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().body.loading_text_font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); error_message.set_color(get_theme().text_color); bool download_in_progress = false; @@ -4270,7 +4270,7 @@ namespace QuickMedia { bool error = !error_message.get_string().empty(); bool redraw = true; - const int chapter_text_character_size = 14 * get_config().scale * get_config().font_scale; + const int chapter_text_character_size = 14 * get_config().scale * get_config().font_scale * get_config().font.scale.latin; mgl::Text chapter_text(images_page->manga_name + " | " + images_page->get_chapter_name() + " | Page " + std::to_string(image_index + 1) + "/" + std::to_string(num_manga_pages), *FontLoader::get_font(FontLoader::FontType::LATIN, chapter_text_character_size)); if(image_index == num_manga_pages) chapter_text.set_string(images_page->manga_name + " | " + images_page->get_chapter_name() + " | End"); @@ -4627,7 +4627,7 @@ namespace QuickMedia { std::string captcha_post_id; std::string captcha_solution; std::string comment_to_post; - const int captcha_solution_text_height = 18 * get_config().scale * get_config().font_scale; + const int captcha_solution_text_height = 18 * get_config().scale * get_config().font_scale * get_config().font.scale.latin_bold; mgl::Text captcha_solution_text("", *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, captcha_solution_text_height)); captcha_solution_text.set_color(get_theme().text_color); int solved_captcha_ttl = 0; @@ -5270,7 +5270,7 @@ namespace QuickMedia { time_left_bg.set_color(mgl::Color(0, 0, 0, 100)); window.draw(time_left_bg); - mgl::Text time_left_text("Wait " + std::to_string(time_left_until_post_again) + " second(s) before posting again", *FontLoader::get_font(FontLoader::FontType::LATIN, 18 * get_config().scale * get_config().font_scale)); + mgl::Text time_left_text("Wait " + std::to_string(time_left_until_post_again) + " second(s) before posting again", *FontLoader::get_font(FontLoader::FontType::LATIN, 18 * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); time_left_text.set_color(get_theme().text_color); time_left_text.set_position(time_left_bg.get_position() + mgl::vec2f( @@ -5558,18 +5558,18 @@ namespace QuickMedia { // Year 2500.. The year that humanity is wiped out. Also we want our local message to appear at the bottom even if time is not synced with ntp, until it's replaced by the server constexpr int64_t timestamp_provisional_event = 16755030000LL * 1000LL; - const float room_name_text_height = std::floor(get_config().matrix.room_name_font_size * get_config().scale * get_config().font_scale); + const float room_name_text_height = std::floor(get_config().matrix.room_name_font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin_bold); mgl::Text room_name_text("", *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, room_name_text_height)); room_name_text.set_color(get_theme().text_color); const float room_name_text_padding_y = std::floor(10.0f * get_config().scale); const float room_name_total_height = room_name_text_height + room_name_text_padding_y * 2.0f; const float room_avatar_height = 32.0f; - const float room_topic_text_height = std::floor(get_config().matrix.room_description_font_size * get_config().scale * get_config().font_scale); + const float room_topic_text_height = std::floor(get_config().matrix.room_description_font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin); mgl::Text room_topic_text("", *FontLoader::get_font(FontLoader::FontType::LATIN, room_topic_text_height)); room_topic_text.set_color(get_theme().faded_text_color); - mgl::Text room_label(matrix_chat_page->rooms_page->get_title(), *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, get_config().matrix.room_name_font_size * get_config().scale * get_config().font_scale)); + mgl::Text room_label(matrix_chat_page->rooms_page->get_title(), *FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, get_config().matrix.room_name_font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin_bold)); room_label.set_color(get_theme().text_color); room_label.set_position(mgl::vec2f(15.0f, room_name_text_padding_y + 4.0f)); @@ -5689,7 +5689,7 @@ namespace QuickMedia { ChatState chat_state = ChatState::NAVIGATING; std::shared_ptr currently_operating_on_item; - mgl::Text replying_to_text("Replying to:", *FontLoader::get_font(FontLoader::FontType::LATIN, 18 * get_config().scale * get_config().font_scale)); + mgl::Text replying_to_text("Replying to:", *FontLoader::get_font(FontLoader::FontType::LATIN, 18 * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); replying_to_text.set_color(get_theme().text_color); bool draw_room_list = show_room_side_panel; @@ -6057,7 +6057,7 @@ namespace QuickMedia { Mention mention; mention.users_tab_body = tabs[USERS_TAB_INDEX].body.get(); - const float user_mention_body_height = std::floor(300.0f * get_config().scale * get_config().font_scale); + const float user_mention_body_height = std::floor(300.0f * get_config().scale); bool frame_skip_text_entry = false; @@ -7562,8 +7562,8 @@ namespace QuickMedia { const float body_width = window_size.x; this->body_pos = mgl::vec2f(0.0f, tab_shade_height); - if(window_size.x > 900.0f * get_config().scale * get_config().font_scale && show_room_side_panel) { - this->body_size = vec2f_floor(300.0f * get_config().scale * get_config().font_scale, window_size.y - tab_shade_height); + if(window_size.x > 900.0f * get_config().scale && show_room_side_panel) { + this->body_size = vec2f_floor(300.0f * get_config().scale, window_size.y - tab_shade_height); draw_room_list = true; } else { this->body_size = mgl::vec2f(0.0f, 0.0f); @@ -8158,13 +8158,13 @@ namespace QuickMedia { const float spacing_y = std::floor(15.0f * get_config().scale * get_config().spacing_scale); const float loading_bar_height = std::floor(20.0f * get_config().scale); - mgl::Text progress_text("0kb/Unknown", *FontLoader::get_font(FontLoader::FontType::LATIN, 20.0f * get_config().scale * get_config().font_scale)); + mgl::Text progress_text("0kb/Unknown", *FontLoader::get_font(FontLoader::FontType::LATIN, 20.0f * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); progress_text.set_color(get_theme().text_color); - mgl::Text status_text("Downloading", *FontLoader::get_font(FontLoader::FontType::LATIN, 20.0f * get_config().scale * get_config().font_scale)); + mgl::Text status_text("Downloading", *FontLoader::get_font(FontLoader::FontType::LATIN, 20.0f * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); status_text.set_color(get_theme().text_color); - mgl::Text filename_text(filename.c_str(), *FontLoader::get_font(FontLoader::FontType::LATIN, 14.0f * get_config().scale * get_config().font_scale)); + mgl::Text filename_text(filename.c_str(), *FontLoader::get_font(FontLoader::FontType::LATIN, 14.0f * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); filename_text.set_color(get_theme().faded_text_color); - mgl::Text download_speed_text("0 bytes/s", *FontLoader::get_font(FontLoader::FontType::LATIN, 14.0f * get_config().scale * get_config().font_scale)); + mgl::Text download_speed_text("0 bytes/s", *FontLoader::get_font(FontLoader::FontType::LATIN, 14.0f * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); download_speed_text.set_color(get_theme().faded_text_color); bool redraw = true; @@ -8342,13 +8342,13 @@ namespace QuickMedia { const float bottom_panel_padding = std::floor(10.0f * get_config().spacing_scale); const float bottom_panel_spacing = std::floor(10.0f * get_config().spacing_scale); - Button cancel_button("Cancel", FontLoader::get_font(FontLoader::FontType::LATIN, 16 * get_config().scale), 100.0f, &rounded_rectangle_shader, get_config().scale * get_config().font_scale); + Button cancel_button("Cancel", FontLoader::get_font(FontLoader::FontType::LATIN, 16 * get_config().scale), 100.0f, &rounded_rectangle_shader, get_config().scale * get_config().font_scale * get_config().font.scale.latin); cancel_button.set_background_color(get_theme().cancel_button_background_color); - Button save_button("Save", FontLoader::get_font(FontLoader::FontType::LATIN, 16 * get_config().scale), 100.0f, &rounded_rectangle_shader, get_config().scale * get_config().font_scale); + Button save_button("Save", FontLoader::get_font(FontLoader::FontType::LATIN, 16 * get_config().scale), 100.0f, &rounded_rectangle_shader, get_config().scale * get_config().font_scale * get_config().font.scale.latin); save_button.set_background_color(get_theme().confirm_button_background_color); - mgl::Text file_name_label("File name:", *FontLoader::get_font(FontLoader::FontType::LATIN, 16.0f * get_config().scale * get_config().font_scale)); + mgl::Text file_name_label("File name:", *FontLoader::get_font(FontLoader::FontType::LATIN, 16.0f * get_config().scale * get_config().font_scale * get_config().font.scale.latin)); file_name_label.set_color(get_theme().text_color); Entry file_name_entry("", &rounded_rectangle_shader); diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp index 00a66d2..a528c2e 100644 --- a/src/SearchBar.cpp +++ b/src/SearchBar.cpp @@ -18,8 +18,8 @@ namespace QuickMedia { static const float padding_top_default = floor(10.0f * get_config().scale * get_config().spacing_scale); static const float padding_bottom_default = floor(15.0f * get_config().scale * get_config().spacing_scale); static const float background_margin_vertical = floor(4.0f * get_config().scale * get_config().spacing_scale); - static const int character_size = get_config().search.font_size * get_config().scale * get_config().font_scale; - static const int search_icon_padding_x = 7 * get_config().scale * get_config().font_scale; + static const int character_size = get_config().search.font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin; + static const int search_icon_padding_x = 7 * get_config().scale; SearchBar::SearchBar(mgl::Texture *plugin_logo, mgl::Shader *rounded_rectangle_shader, const std::string &placeholder, SearchBarType type) : onTextUpdateCallback(nullptr), diff --git a/src/Tabs.cpp b/src/Tabs.cpp index 339e4db..96f11d2 100644 --- a/src/Tabs.cpp +++ b/src/Tabs.cpp @@ -15,7 +15,7 @@ namespace QuickMedia { return (int)v; } - static const float tab_text_size = floor(get_config().tab.font_size * get_config().scale * get_config().font_scale); + static const float tab_text_size = floor(get_config().tab.font_size * get_config().scale * get_config().font_scale * get_config().font.scale.latin); static const float tab_height = tab_text_size + floor(10.0f * get_config().scale * get_config().spacing_scale); static const float tab_min_width = 250.0f; static const float tab_margin_x = floor(10.0f * get_config().spacing_scale); diff --git a/src/Text.cpp b/src/Text.cpp index a1da8de..2b62798 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -605,7 +605,7 @@ namespace QuickMedia } float Text::font_get_real_height(mgl::Font *font) { - return font->get_glyph('|').size.y + floor(4.0f * ((float)characterSize / (float)14.0f)); + return font->get_glyph('|').size.y + floor(4.0f * ((float)font->get_character_size() / (float)14.0f)); } float Text::get_text_quad_left_side(const VertexRef &vertex_ref) const { @@ -682,9 +682,9 @@ namespace QuickMedia mgl::Font *latin_font; if(bold_font) - latin_font = FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, characterSize); + latin_font = FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, characterSize * get_config().font.scale.latin_bold); else - latin_font = FontLoader::get_font(FontLoader::FontType::LATIN, characterSize); + latin_font = FontLoader::get_font(FontLoader::FontType::LATIN, characterSize * get_config().font.scale.latin); const float vspace = font_get_real_height(latin_font); const float vertex_height = get_text_quad_height(vertices_linear[0]); @@ -765,9 +765,9 @@ namespace QuickMedia mgl::Font *latin_font; if(bold_font) - latin_font = FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, characterSize); + latin_font = FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, characterSize * get_config().font.scale.latin_bold); else - latin_font = FontLoader::get_font(FontLoader::FontType::LATIN, characterSize); + latin_font = FontLoader::get_font(FontLoader::FontType::LATIN, characterSize * get_config().font.scale.latin); const float latin_font_width = latin_font->get_glyph(' ').advance; const float vspace = font_get_real_height(latin_font); @@ -917,13 +917,13 @@ namespace QuickMedia // TODO: CJK monospace if(is_symbol_codepoint(codepoint)) { - ff = FontLoader::get_font(FontLoader::FontType::SYMBOLS, characterSize); + ff = FontLoader::get_font(FontLoader::FontType::SYMBOLS, characterSize * get_config().font.scale.symbols); vertices_index = FONT_INDEX_SYMBOLS; } else if(is_cjk_codepoint(codepoint)) { - ff = FontLoader::get_font(FontLoader::FontType::CJK, characterSize); + ff = FontLoader::get_font(FontLoader::FontType::CJK, characterSize * get_config().font.scale.cjk); vertices_index = FONT_INDEX_CJK; } else if(monospace) { - ff = FontLoader::get_font(FontLoader::FontType::LATIN_MONOSPACE, characterSize); + ff = FontLoader::get_font(FontLoader::FontType::LATIN_MONOSPACE, characterSize * get_config().font.scale.latin_monospace); vertices_index = FONT_INDEX_MONOSPACE; if(hspace_monospace == 0) hspace_monospace = ff->get_glyph(' ').advance + characterSpacing; @@ -1198,9 +1198,9 @@ namespace QuickMedia mgl::Font *latin_font; if(bold_font) - latin_font = FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, characterSize); + latin_font = FontLoader::get_font(FontLoader::FontType::LATIN_BOLD, characterSize * get_config().font.scale.latin_bold); else - latin_font = FontLoader::get_font(FontLoader::FontType::LATIN, characterSize); + latin_font = FontLoader::get_font(FontLoader::FontType::LATIN, characterSize * get_config().font.scale.latin); const float vspace = font_get_real_height(latin_font); @@ -1547,23 +1547,28 @@ namespace QuickMedia mgl::vec2f pos = position; + float char_scale = 1.0f; FontLoader::FontType latin_font_type; - if(bold_font) + if(bold_font) { latin_font_type = FontLoader::FontType::LATIN_BOLD; - else + char_scale = get_config().font.scale.latin_bold; + } else { latin_font_type = FontLoader::FontType::LATIN; - mgl::Font *latin_font = FontLoader::get_font(latin_font_type, characterSize); + char_scale = get_config().font.scale.latin; + } + mgl::Font *latin_font = FontLoader::get_font(latin_font_type, characterSize * char_scale); const float vspace = font_get_real_height(latin_font); pos.y += floor(vspace*0.25f); // Origin is at bottom left, we want it to be at top left assert(FONT_ARRAY_SIZE == 6); const FontLoader::FontType font_types[] = { latin_font_type, FontLoader::FontType::LATIN_MONOSPACE, FontLoader::FontType::CJK, FontLoader::FontType::SYMBOLS }; + const float font_scales[] = { char_scale, get_config().font.scale.latin_monospace, get_config().font.scale.cjk, get_config().font.scale.symbols }; for(size_t i = 0; i < FONT_INDEX_EMOJI; ++i) { if(vertex_buffers[i].size() == 0) continue; - mgl::Font *font = FontLoader::get_font(font_types[i], characterSize); + mgl::Font *font = FontLoader::get_font(font_types[i], characterSize * font_scales[i]); if(!font) continue; -- cgit v1.2.3