added font option
This commit is contained in:
parent
7dc483c8f6
commit
5b27fa3806
75
4ed.cpp
75
4ed.cpp
|
@ -936,6 +936,7 @@ enum Command_Line_Action{
|
|||
CLAct_WindowStreamMode,
|
||||
CLAct_FontSize,
|
||||
CLAct_FontStartHinting,
|
||||
CLAct_FontCustom,
|
||||
CLAct_Count
|
||||
};
|
||||
|
||||
|
@ -945,8 +946,7 @@ enum Command_Line_Mode{
|
|||
};
|
||||
|
||||
void
|
||||
init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
||||
Command_Line_Parameters clparams){
|
||||
init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings, Command_Line_Parameters clparams){
|
||||
char *arg = 0;
|
||||
Command_Line_Mode mode = CLMode_App;
|
||||
Command_Line_Action action = CLAct_Nothing;
|
||||
|
@ -984,6 +984,8 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case 'u': action = CLAct_UserFile; strict = 0; break;
|
||||
case 'U': action = CLAct_UserFile; strict = 1; break;
|
||||
|
||||
case 'c': action = CLAct_FontCustom; break;
|
||||
|
||||
case 'd': action = CLAct_CustomDLL; strict = 0; break;
|
||||
case 'D': action = CLAct_CustomDLL; strict = 1; break;
|
||||
|
||||
|
@ -1087,6 +1089,16 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_FontCustom:
|
||||
{
|
||||
if ((i + 3) <= clparams.argc){
|
||||
settings->custom_font_file = clparams.argv[i++];
|
||||
settings->custom_font_name = clparams.argv[i++];
|
||||
settings->custom_font_size = str_to_int_c(clparams.argv[i]);
|
||||
}
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_FontStartHinting:
|
||||
{
|
||||
plat_settings->use_hinting = 1;
|
||||
|
@ -1126,18 +1138,14 @@ app_setup_memory(System_Functions *system, Application_Memory *memory){
|
|||
return(vars);
|
||||
}
|
||||
|
||||
inline App_Settings
|
||||
app_settings_zero(){
|
||||
App_Settings settings={0};
|
||||
return(settings);
|
||||
}
|
||||
static App_Settings null_app_settings = {0};
|
||||
|
||||
App_Read_Command_Line_Sig(app_read_command_line){
|
||||
i32 out_size = 0;
|
||||
App_Vars *vars = app_setup_memory(system, memory);
|
||||
App_Settings *settings = &vars->models.settings;
|
||||
|
||||
*settings = app_settings_zero();
|
||||
*settings = null_app_settings;
|
||||
settings->font_size = 16;
|
||||
|
||||
if (clparams.argc > 1){
|
||||
|
@ -1422,8 +1430,6 @@ App_Init_Sig(app_init){
|
|||
{
|
||||
models->font_set = &target->font_set;
|
||||
|
||||
font_set_init(models->font_set, partition, 16, 5);
|
||||
|
||||
struct Font_Setup{
|
||||
char *c_file_name;
|
||||
i32 file_name_len;
|
||||
|
@ -1434,38 +1440,39 @@ App_Init_Sig(app_init){
|
|||
|
||||
i32 font_size = models->settings.font_size;
|
||||
|
||||
char *custom_font_file = models->settings.custom_font_file;
|
||||
char *custom_font_name = models->settings.custom_font_name;
|
||||
i32 custom_font_size = models->settings.custom_font_size;
|
||||
b32 use_custom_font = true;
|
||||
if (!custom_font_file){
|
||||
use_custom_font = false;
|
||||
custom_font_file = "";
|
||||
custom_font_name = "";
|
||||
}
|
||||
|
||||
if (font_size < 8) font_size = 8;
|
||||
|
||||
Font_Setup font_setup[] = {
|
||||
{literal("LiberationSans-Regular.ttf"),
|
||||
literal("Liberation Sans"),
|
||||
font_size},
|
||||
|
||||
{literal("liberation-mono.ttf"),
|
||||
literal("Liberation Mono"),
|
||||
font_size},
|
||||
|
||||
{literal("Hack-Regular.ttf"),
|
||||
literal("Hack"),
|
||||
font_size},
|
||||
|
||||
{literal("CutiveMono-Regular.ttf"),
|
||||
literal("Cutive Mono"),
|
||||
font_size},
|
||||
|
||||
{literal("Inconsolata-Regular.ttf"),
|
||||
literal("Inconsolata"),
|
||||
font_size},
|
||||
{literal("LiberationSans-Regular.ttf"), literal("Liberation Sans"), font_size},
|
||||
{literal("liberation-mono.ttf"), literal("Liberation Mono"), font_size},
|
||||
{literal("Hack-Regular.ttf"), literal("Hack"), font_size},
|
||||
{literal("CutiveMono-Regular.ttf"), literal("Cutive Mono"), font_size},
|
||||
{literal("Inconsolata-Regular.ttf"), literal("Inconsolata"), font_size},
|
||||
{custom_font_file, str_size(custom_font_file),
|
||||
custom_font_name, str_size(custom_font_name),
|
||||
custom_font_size},
|
||||
};
|
||||
i32 font_count = ArrayCount(font_setup);
|
||||
if (!use_custom_font){
|
||||
--font_count;
|
||||
}
|
||||
|
||||
font_set_init(models->font_set, partition, 16, 6);
|
||||
|
||||
for (i32 i = 0; i < font_count; ++i){
|
||||
String file_name = make_string(font_setup[i].c_file_name,
|
||||
font_setup[i].file_name_len);
|
||||
String name = make_string(font_setup[i].c_name,
|
||||
font_setup[i].name_len);
|
||||
String file_name = make_string(font_setup[i].c_file_name, font_setup[i].file_name_len);
|
||||
String name = make_string(font_setup[i].c_name, font_setup[i].name_len);
|
||||
i32 pt_size = font_setup[i].pt_size;
|
||||
|
||||
font_set_add(partition, models->font_set, file_name, name, pt_size);
|
||||
}
|
||||
}
|
||||
|
|
2
4ed.h
2
4ed.h
|
@ -63,7 +63,7 @@ typedef struct Plat_Settings{
|
|||
b8 use_hinting;
|
||||
} Plat_Settings;
|
||||
|
||||
#define App_Read_Command_Line_Sig(name) \
|
||||
#define App_Read_Command_Line_Sig(name) \
|
||||
i32 name(System_Functions *system, \
|
||||
Application_Memory *memory, \
|
||||
String current_directory, \
|
||||
|
|
|
@ -1072,7 +1072,7 @@ DOC_SEE(begin_buffer_creation)
|
|||
}
|
||||
|
||||
if (!do_new_file){
|
||||
Assert(!handle_equal(handle, handle_zero()));
|
||||
Assert(!handle_equal(handle, null_plat_handle));
|
||||
|
||||
i32 size = system->load_size(handle);
|
||||
b32 in_general_mem = 0;
|
||||
|
|
|
@ -16,12 +16,16 @@ struct App_Settings{
|
|||
char *init_files[8];
|
||||
i32 init_files_count;
|
||||
i32 init_files_max;
|
||||
|
||||
|
||||
i32 initial_line;
|
||||
b32 lctrl_lalt_is_altgr;
|
||||
|
||||
i32 font_size;
|
||||
|
||||
char *custom_font_file;
|
||||
char *custom_font_name;
|
||||
i32 custom_font_size;
|
||||
|
||||
i32 custom_arg_start;
|
||||
i32 custom_arg_end;
|
||||
};
|
||||
|
|
|
@ -13,11 +13,7 @@ struct Plat_Handle{
|
|||
u32 d[4];
|
||||
};
|
||||
|
||||
inline Plat_Handle
|
||||
handle_zero(void){
|
||||
Plat_Handle result = {0};
|
||||
return(result);
|
||||
}
|
||||
static Plat_Handle null_plat_handle = {0};
|
||||
|
||||
inline int32_t
|
||||
handle_equal(Plat_Handle a, Plat_Handle b){
|
||||
|
|
|
@ -2231,12 +2231,7 @@ WinMain(HINSTANCE hInstance,
|
|||
char **files = 0;
|
||||
i32 *file_count = 0;
|
||||
|
||||
win32vars.app.read_command_line(&win32vars.system,
|
||||
&memory_vars,
|
||||
current_directory,
|
||||
&win32vars.settings,
|
||||
&files, &file_count,
|
||||
clparams);
|
||||
win32vars.app.read_command_line(&win32vars.system, &memory_vars, current_directory, &win32vars.settings, &files, &file_count, clparams);
|
||||
|
||||
sysshared_filter_real_files(files, file_count);
|
||||
|
||||
|
|
Loading…
Reference in New Issue