From f1ef6c2544b0e879572b80e1e275c188ee9fb5ed Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Thu, 21 Jan 2016 11:41:23 +0300 Subject: [PATCH] increase standard font face priorities when searching for fonts --- src/dlangui/graphics/ftfonts.d | 29 ++++++++++++++++++++++++++++- src/dlangui/widgets/srcedit.d | 2 +- views/res/theme_default.xml | 5 +++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/dlangui/graphics/ftfonts.d b/src/dlangui/graphics/ftfonts.d index 0e1882fd..51f3124e 100644 --- a/src/dlangui/graphics/ftfonts.d +++ b/src/dlangui/graphics/ftfonts.d @@ -22,6 +22,33 @@ import std.file; import std.string; import std.utf; +immutable int[string] STD_FONT_FACES = [ + "Arial": 12, + "Times New Roman": 12, + "Courier New": 10, + "DejaVu Serif": 10, + "DejaVu Sans": 10, + "DejaVu Sans Mono": 10, + "Liberation Serif": 11, + "Liberation Sans": 11, + "Liberation Mono": 11, + "Verdana": 10, + "Menlo": 13, + "Consolas": 12, + "DejaVuSansMono": 10, + "Lucida Sans Typewriter": 10, + "Lucida Console": 12, + "FreeMono": 8, + "FreeSans": 8, + "FreeSerif": 8, +]; + +int stdFontFacePriority(string face) { + if (auto p = (face in STD_FONT_FACES)) + return *p; + return 0; +} + /// define debug=FontResources for logging of font file resources creation/freeing //debug = FontResources; @@ -505,7 +532,7 @@ class FreeTypeFontManager : FontManager { return 200; } } - return 0; + return stdFontFacePriority(existing) * 10; } private FontFileItem findBestMatch(int weight, bool italic, FontFamily family, string face) { diff --git a/src/dlangui/widgets/srcedit.d b/src/dlangui/widgets/srcedit.d index 34f2ab50..d74e3ea9 100644 --- a/src/dlangui/widgets/srcedit.d +++ b/src/dlangui/widgets/srcedit.d @@ -25,7 +25,7 @@ import dlangui.widgets.styles; class SourceEdit : EditBox { this(string ID) { super(ID); - fontFace = "Menlo,Consolas,DejaVuSansMono,Lucida Sans Typewriter,Courier New,Lucida Console"; + fontFace = "Menlo,Consolas,DejaVuSansMono,DejaVu Sans Mono,Liberation Mono,Lucida Sans Typewriter,Courier New,Lucida Console"; //fontFace = "Consolas,Lucida Console,Courier New"; fontFamily = FontFamily.MonoSpace; fontSize = makePointSize(10); diff --git a/views/res/theme_default.xml b/views/res/theme_default.xml index c03c1fce..21fdfce5 100644 --- a/views/res/theme_default.xml +++ b/views/res/theme_default.xml @@ -1,7 +1,7 @@ @@ -422,7 +422,8 @@ layoutWidth="FILL_PARENT" layoutHeight="WRAP_CONTENT" align="Left|VCenter" - textFlags="Parent"> + textFlags="Parent" + >