From 865eaab4cbc642488aa842a1664c7ffe3d0b01bd Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 23 Mar 2015 11:40:00 +0300 Subject: [PATCH] DPI aware font size in log windows: fix issue #76 --- src/dlangui/core/types.d | 10 ++++++++++ src/dlangui/widgets/editors.d | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dlangui/core/types.d b/src/dlangui/core/types.d index 425607c5..2099b568 100644 --- a/src/dlangui/core/types.d +++ b/src/dlangui/core/types.d @@ -207,6 +207,16 @@ Rect toPixels(const Rect sz) { return Rect(toPixels(sz.left), toPixels(sz.top), toPixels(sz.right), toPixels(sz.bottom)); } +/// make size value with SIZE_IN_POINTS_FLAG set +int makePointSize(int pt) { + return pt | SIZE_IN_POINTS_FLAG; +} + +/// make size value with SIZE_IN_PERCENTS_FLAG set +int makePercentSize(int percent) { + return (percent * 100) | SIZE_IN_PERCENTS_FLAG; +} + /// screen dots per inch private __gshared int PRIVATE_SCREEN_DPI = 96; diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index 3326704a..6027a36c 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -2371,11 +2371,11 @@ class LogWidget : EditBox { _scrollLock = true; _enableScrollAfterText = false; enabled = false; - fontSize = 14; + fontSize = makePointSize(9); //fontFace = "Consolas,Lucida Console,Courier New"; fontFace = "Consolas,DejaVuSansMono,Lucida Sans Typewriter,Courier New,Lucida Console"; fontFamily = FontFamily.MonoSpace; - minFontSize(8).maxFontSize(32); // allow font zoom with Ctrl + MouseWheel + minFontSize(pointsToPixels(6)).maxFontSize(pointsToPixels(32)); // allow font zoom with Ctrl + MouseWheel onThemeChanged(); }