-h flag to enable hinting
This commit is contained in:
parent
eec3475ee2
commit
6599cac5e9
50
4ed.cpp
50
4ed.cpp
|
@ -1357,6 +1357,7 @@ enum Command_Line_Action{
|
|||
CLAct_WindowMaximize,
|
||||
CLAct_WindowPosition,
|
||||
CLAct_FontSize,
|
||||
CLAct_FontStopHinting,
|
||||
CLAct_Count
|
||||
};
|
||||
|
||||
|
@ -1378,11 +1379,11 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
if (arg[0] == '-'){
|
||||
action = CLAct_Ignore;
|
||||
switch (arg[1]){
|
||||
case 'u': action = CLAct_UserFile; strict = 0; break;
|
||||
case 'U': action = CLAct_UserFile; strict = 1; break;
|
||||
case 'u': action = CLAct_UserFile; strict = false; break;
|
||||
case 'U': action = CLAct_UserFile; strict = true; break;
|
||||
|
||||
case 'd': action = CLAct_CustomDLL; strict = 0; break;
|
||||
case 'D': action = CLAct_CustomDLL; strict = 1; break;
|
||||
case 'd': action = CLAct_CustomDLL; strict = false;break;
|
||||
case 'D': action = CLAct_CustomDLL; strict = true; break;
|
||||
|
||||
case 'i': action = CLAct_InitialFilePosition; break;
|
||||
|
||||
|
@ -1391,6 +1392,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case 'p': action = CLAct_WindowPosition; break;
|
||||
|
||||
case 'f': action = CLAct_FontSize; break;
|
||||
case 'h': action = CLAct_FontStopHinting; --i; break;
|
||||
}
|
||||
}
|
||||
else if (arg[0] != 0){
|
||||
|
@ -1430,7 +1432,7 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case CLAct_WindowSize:
|
||||
{
|
||||
if (i + 1 < clparams.argc){
|
||||
plat_settings->set_window_size = 1;
|
||||
plat_settings->set_window_size = true;
|
||||
plat_settings->window_w = str_to_int(clparams.argv[i]);
|
||||
plat_settings->window_h = str_to_int(clparams.argv[i+1]);
|
||||
|
||||
|
@ -1442,14 +1444,14 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
case CLAct_WindowMaximize:
|
||||
{
|
||||
--i;
|
||||
plat_settings->maximize_window = 1;
|
||||
plat_settings->maximize_window = true;
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_WindowPosition:
|
||||
{
|
||||
if (i + 1 < clparams.argc){
|
||||
plat_settings->set_window_pos = 1;
|
||||
plat_settings->set_window_pos = true;
|
||||
plat_settings->window_x = str_to_int(clparams.argv[i]);
|
||||
plat_settings->window_y = str_to_int(clparams.argv[i+1]);
|
||||
|
||||
|
@ -1465,6 +1467,12 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
|
|||
}
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
|
||||
case CLAct_FontStopHinting:
|
||||
{
|
||||
plat_settings->use_hinting = true;
|
||||
action = CLAct_Nothing;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1488,22 +1496,6 @@ app_setup_memory(Application_Memory *memory){
|
|||
return(vars);
|
||||
}
|
||||
|
||||
internal i32
|
||||
execute_special_tool(void *memory, i32 size, Command_Line_Parameters clparams){
|
||||
i32 result;
|
||||
char message[] = "tool was not specified or is invalid";
|
||||
result = sizeof(message) - 1;
|
||||
memcpy(memory, message, result);
|
||||
if (clparams.argc > 2){
|
||||
if (match(clparams.argv[2], "version")){
|
||||
result = sizeof(VERSION) - 1;
|
||||
memcpy(memory, VERSION, result);
|
||||
((char*)memory)[result++] = '\n';
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
inline App_Settings
|
||||
app_settings_zero(){
|
||||
App_Settings settings={0};
|
||||
|
@ -1511,17 +1503,10 @@ app_settings_zero(){
|
|||
}
|
||||
|
||||
App_Read_Command_Line_Sig(app_read_command_line){
|
||||
App_Vars *vars;
|
||||
App_Settings *settings;
|
||||
i32 out_size = 0;
|
||||
App_Vars *vars = app_setup_memory(memory);
|
||||
App_Settings *settings = &vars->models.settings;
|
||||
|
||||
if (clparams.argc > 1 && match(clparams.argv[1], "-T")){
|
||||
out_size = execute_special_tool(memory->target_memory, memory->target_memory_size, clparams);
|
||||
}
|
||||
else{
|
||||
vars = app_setup_memory(memory);
|
||||
|
||||
settings = &vars->models.settings;
|
||||
*settings = app_settings_zero();
|
||||
settings->font_size = 16;
|
||||
|
||||
|
@ -1531,7 +1516,6 @@ App_Read_Command_Line_Sig(app_read_command_line){
|
|||
|
||||
*files = vars->models.settings.init_files;
|
||||
*file_count = &vars->models.settings.init_files_count;
|
||||
}
|
||||
|
||||
return(out_size);
|
||||
}
|
||||
|
|
1
4ed.h
1
4ed.h
|
@ -72,6 +72,7 @@ struct Plat_Settings{
|
|||
i32 window_x, window_y;
|
||||
b8 set_window_pos, set_window_size;
|
||||
b8 maximize_window;
|
||||
b8 use_hinting;
|
||||
};
|
||||
|
||||
#define App_Read_Command_Line_Sig(name) \
|
||||
|
|
|
@ -494,10 +494,7 @@ stb_font_load(Partition *part,
|
|||
|
||||
// NOTE(allen): Thanks to insofaras.
|
||||
// This is copy-pasted from some work he
|
||||
// did to get free type working on linux.
|
||||
// Once it is working on both sides it might
|
||||
// be possible to pull some parts out as
|
||||
// portable FT rendering.
|
||||
// did to get free type working on Linux.
|
||||
|
||||
#undef internal
|
||||
#include <ft2build.h>
|
||||
|
@ -524,7 +521,8 @@ font_load_freetype(Partition *part,
|
|||
Render_Font *rf,
|
||||
char *filename,
|
||||
i32 pt_size,
|
||||
i32 tab_width){
|
||||
i32 tab_width,
|
||||
b32 use_hinting){
|
||||
|
||||
memset(rf, 0, sizeof(*rf));
|
||||
|
||||
|
@ -584,10 +582,18 @@ font_load_freetype(Partition *part,
|
|||
u32* pixels = push_array(part, u32, tex_width * tex_height);
|
||||
memset(pixels, 0, tex_width * tex_height * sizeof(u32));
|
||||
|
||||
// XXX: test if AUTOHINT looks better or not
|
||||
// NOTE(allen): As of now FT_LOAD_FORCE_AUTOHINT looks much better for
|
||||
// Liberation Mono which is one of the included 4coder fonts.
|
||||
const u32 ft_extra_flags = use_lcd_filter ? FT_LOAD_TARGET_LCD : FT_LOAD_FORCE_AUTOHINT;
|
||||
u32 ft_extra_flags = 0;
|
||||
if (use_lcd_filter){
|
||||
ft_extra_flags = FT_LOAD_TARGET_LCD;
|
||||
}
|
||||
else{
|
||||
if (use_hinting){
|
||||
ft_extra_flags = FT_LOAD_FORCE_AUTOHINT;
|
||||
}
|
||||
else{
|
||||
ft_extra_flags = (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < NUM_GLYPHS; ++i){
|
||||
if(FT_Load_Char(face, i, FT_LOAD_RENDER | ft_extra_flags) != 0) continue;
|
||||
|
|
|
@ -1124,7 +1124,8 @@ Font_Load_Sig(system_draw_font_load){
|
|||
font_out,
|
||||
filename,
|
||||
pt_size,
|
||||
tab_width);
|
||||
tab_width,
|
||||
win32vars.settings.use_hinting);
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
// portable FT rendering.
|
||||
|
||||
internal b32
|
||||
win32_ft_font_load(Partition *part, Render_Font *rf, char *name, i32 pt_size, i32 tab_width){
|
||||
win32_ft_font_load(Partition *part, Render_Font *rf, char *name,
|
||||
i32 pt_size, i32 tab_width, b32 use_hinting){
|
||||
|
||||
b32 result = 0;
|
||||
|
||||
|
@ -18,7 +19,7 @@ win32_ft_font_load(Partition *part, Render_Font *rf, char *name, i32 pt_size, i3
|
|||
String str = make_string(filename, 0, 256);
|
||||
sysshared_to_binary_path(&str, name);
|
||||
|
||||
result = font_load_freetype(part, rf, filename, pt_size, tab_width);
|
||||
result = font_load_freetype(part, rf, filename, pt_size, tab_width, use_hinting);
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
|
|
Loading…
Reference in New Issue