From 6a8c2e38aa15f8bc21d2fe7ecefe1c65b92f3f8c Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 7 May 2021 17:26:03 -0700 Subject: [PATCH] make fonts still visible when config.4coder missing --- 4ed_font_provider_freetype.cpp | 3 ++- custom/4coder_config.cpp | 9 +++++++-- custom/generated/command_metadata.h | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/4ed_font_provider_freetype.cpp b/4ed_font_provider_freetype.cpp index eaaf4e65..a6470b3f 100644 --- a/4ed_font_provider_freetype.cpp +++ b/4ed_font_provider_freetype.cpp @@ -174,7 +174,8 @@ ft__font_make_face(Arena *arena, Face_Description *description, f32 scale_factor if (error == 0){ face = push_array_zero(arena, Face, 1); - u32 pt_size = (u32)(description->parameters.pt_size*scale_factor); + u32 pt_size_unscaled = Max(description->parameters.pt_size, 8); + u32 pt_size = (u32)(pt_size_unscaled*scale_factor); b32 hinting = description->parameters.hinting; FT_Size_RequestRec_ size = {}; diff --git a/custom/4coder_config.cpp b/custom/4coder_config.cpp index a83a4a64..070ee09b 100644 --- a/custom/4coder_config.cpp +++ b/custom/4coder_config.cpp @@ -1478,7 +1478,7 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, i32 override_fon if (data.str != 0){ parsed = def_config_from_text(app, scratch, str8_lit("config.4coder"), data); } - } + } if (parsed != 0){ // Errors @@ -1491,7 +1491,9 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, i32 override_fon // NOTE(allen): Save As Variables if (error_text.str == 0){ // TODO(allen): this always applies to "def_config" need to get "usr_config" working too - Variable_Handle config_var = def_fill_var_from_config(app, vars_get_root(), vars_save_string_lit("def_config"), parsed); + Variable_Handle config_var = def_fill_var_from_config(app, vars_get_root(), + vars_save_string_lit("def_config"), + parsed); vars_print(app, config_var); print_message(app, string_u8_litexpr("\n")); } @@ -1531,6 +1533,9 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, i32 override_fon else{ description.parameters.pt_size = (i32)def_get_config_u64(app, vars_save_string_lit("default_font_size")); } + if (description.parameters.pt_size == 0){ + description.parameters.pt_size = 12; + } b32 default_font_hinting = def_get_config_b32(vars_save_string_lit("default_font_hinting")); description.parameters.hinting = default_font_hinting || override_hinting; diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index 018cb3f6..bc7ee0a4 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -326,7 +326,7 @@ static Command_Metadata fcoder_metacmd_table[252] = { { PROC_LINKS(execute_any_cli, 0), false, "execute_any_cli", 15, "Queries for an output buffer name and system command, runs the system command as a CLI and prints the output to the specified buffer.", 133, "W:\\4ed\\code\\custom\\4coder_cli_command.cpp", 41, 22 }, { PROC_LINKS(execute_previous_cli, 0), false, "execute_previous_cli", 20, "If the command execute_any_cli has already been used, this will execute a CLI reusing the most recent buffer name and command.", 126, "W:\\4ed\\code\\custom\\4coder_cli_command.cpp", 41, 7 }, { PROC_LINKS(exit_4coder, 0), false, "exit_4coder", 11, "Attempts to close 4coder.", 25, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 846 }, -{ PROC_LINKS(go_to_user_directory, 0), false, "go_to_user_directory", 20, "Go to the 4coder user directory", 31, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1648 }, +{ PROC_LINKS(go_to_user_directory, 0), false, "go_to_user_directory", 20, "Go to the 4coder user directory", 31, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1650 }, { PROC_LINKS(goto_beginning_of_file, 0), false, "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2247 }, { PROC_LINKS(goto_end_of_file, 0), false, "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "W:\\4ed\\code\\custom\\4coder_helper.cpp", 36, 2255 }, { PROC_LINKS(goto_first_jump, 0), false, "goto_first_jump", 15, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "W:\\4ed\\code\\custom\\4coder_jump_sticky.cpp", 41, 525 }, @@ -375,7 +375,7 @@ static Command_Metadata fcoder_metacmd_table[252] = { { PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 }, { PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 }, { PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 823 }, -{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1604 }, +{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1606 }, { PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 535 }, { PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 554 }, { PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1495 },