From 0d643844253c3730aa744854fc1f951aaaf4abb3 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 19 Jan 2017 06:28:50 +0000 Subject: [PATCH] fontsize in pixels; not using screen_dpi for now until we test more... --- Common/DefaultOptions.h | 8 ++++---- Common/Options.cpp | 5 +++-- Fltk/drawContextFltk.h | 12 +++++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index e3057f9237..bce2c93adf 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -531,12 +531,12 @@ StringXNumber GeneralOptions_Number[] = { { F|S, "FltkColorScheme" , opt_general_gui_color_scheme , 0. , "FLTK user interface color theme (0: standard, 1:dark)" }, { F|O, "FontSize" , opt_general_fontsize , -1. , - "Size of the font in the user interface (-1=automatic)" }, + "Size of the font in the user interface, in pixels (-1: automatic)" }, { F|O, "GraphicsFontSize" , opt_general_graphics_fontsize , 15. , - "Size of the font in the graphic window" }, + "Size of the font in the graphic window, in pixels" }, { F|O, "GraphicsFontSizeTitle" , opt_general_graphics_fontsize_title , 18. , - "Size of the font in the graphic window for titles" }, + "Size of the font in the graphic window for titles, in pixels" }, { F|S, "GraphicsHeight" , opt_general_graphics_size1 , 600. , "Height (in pixels) of the graphic window" }, { F|S, "GraphicsPositionX" , opt_general_graphics_position0 , 50. , @@ -655,7 +655,7 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "MeshDiscrete" , opt_general_meshdiscrete , 0. , "Mesh discrete surfaces through automatic parametrization (MUMPS required for efficiency) (0)" }, { F|O, "MessageFontSize" , opt_general_message_fontsize , -1. , - "Size of the font in the message window (-1=automatic)" }, + "Size of the font in the message window, in pixels (-1: automatic)" }, { F|S, "MessageHeight" , opt_general_message_size , 300. , "Height (in pixels) of the message console when it is visible (should be > 0)" }, { F, "MinX" , opt_general_xmin , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 72a7e0eebc..8b0ac7c3c7 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -2097,8 +2097,9 @@ double opt_general_initial_context(OPT_ARGS_NUM) double opt_general_fontsize(OPT_ARGS_NUM) { - if(action & GMSH_SET) + if(action & GMSH_SET){ CTX::instance()->fontSize = (int)val; + } return CTX::instance()->fontSize; } @@ -2794,7 +2795,7 @@ double opt_general_scale2(OPT_ARGS_NUM) double opt_general_clip_factor(OPT_ARGS_NUM) { if(action & GMSH_SET){ - // should NEVER be zero (or negative) + // should never be zero (or negative) if(val < 0.01) CTX::instance()->clipFactor = 0.01; else diff --git a/Fltk/drawContextFltk.h b/Fltk/drawContextFltk.h index 0d8da3088c..16c733c0ea 100644 --- a/Fltk/drawContextFltk.h +++ b/Fltk/drawContextFltk.h @@ -122,10 +122,16 @@ class drawContextFltk : public drawContextGlobal{ return CTX::instance()->fontSize; } else{ - float dpih, dpiv; - Fl::screen_dpi(dpih,dpiv); - return (int)(dpih/10); + int w = Fl::w(); + if(w <= 1024) return 11; + else if(w <= 1440) return 12; + else if(w <= 1680) return 13; + else if(w <= 1920) return 14; + return (w - 1920) / 160 + 15; } + //float dpih, dpiv; + //Fl::screen_dpi(dpih, dpiv); + //return (int)(dpih * CTX::instance()->fontSize / 96.); } void setFont(int fontid, int fontsize) { -- GitLab