diff --git a/dlanguilib.visualdproj b/dlanguilib.visualdproj
index 03b447c7..5ab7b4e8 100644
--- a/dlanguilib.visualdproj
+++ b/dlanguilib.visualdproj
@@ -66,7 +66,7 @@
0
DebugFocus
0
- EmbedStandardResources Unicode USE_SDL USE_OPENGL
+ EmbedStandardResources Unicode
0
0
1
diff --git a/examples/example1/example1.visualdproj b/examples/example1/example1.visualdproj
index 5d641638..3a6f08da 100644
--- a/examples/example1/example1.visualdproj
+++ b/examples/example1/example1.visualdproj
@@ -66,7 +66,7 @@
0
0
- Unicode USE_SDL USE_OPENGL
+ Unicode
0
3
0
diff --git a/examples/helloworld/helloworld.visualdproj b/examples/helloworld/helloworld.visualdproj
index 9dd8c4f3..7b835226 100644
--- a/examples/helloworld/helloworld.visualdproj
+++ b/examples/helloworld/helloworld.visualdproj
@@ -66,7 +66,7 @@
0
0
- USE_OPENGL
+ Unicode
0
3
0
@@ -89,7 +89,6 @@
$(OutDir)\$(ProjectName).exe
1
- 2
-profile
@@ -184,7 +183,6 @@
$(OutDir)\$(ProjectName).exe
1
- 1
diff --git a/examples/tetris/tetris.visualdproj b/examples/tetris/tetris.visualdproj
index 924f10f9..17dfdc14 100644
--- a/examples/tetris/tetris.visualdproj
+++ b/examples/tetris/tetris.visualdproj
@@ -66,7 +66,7 @@
0
0
- USE_OPENGL
+ Unicode
0
3
0
diff --git a/src/dlangui/core/types.d b/src/dlangui/core/types.d
index 80033e12..5c7622df 100644
--- a/src/dlangui/core/types.d
+++ b/src/dlangui/core/types.d
@@ -173,6 +173,30 @@ struct Rect {
}
}
+/// screen dots per inch
+private __gshared int PRIVATE_SCREEN_DPI = 96;
+
+@property int SCREEN_DPI() {
+ return PRIVATE_SCREEN_DPI;
+}
+
+@property void SCREEN_DPI(int dpi) {
+ PRIVATE_SCREEN_DPI = dpi;
+}
+
+/// one point is 1/72 of inch
+immutable int POINTS_PER_INCH = 72;
+
+/// convert points (1/72in units) to pixels according to SCREEN_DPI
+int pointsToPixels(int pt) {
+ return pt * SCREEN_DPI / POINTS_PER_INCH;
+}
+
+/// convert points (1/72in units) to pixels according to SCREEN_DPI
+int pixelsToPoints(int px) {
+ return px * POINTS_PER_INCH / SCREEN_DPI;
+}
+
/**
Character glyph.
diff --git a/src/dlangui/platforms/windows/win32fonts.d b/src/dlangui/platforms/windows/win32fonts.d
index cb0287a8..7cc6e193 100644
--- a/src/dlangui/platforms/windows/win32fonts.d
+++ b/src/dlangui/platforms/windows/win32fonts.d
@@ -53,17 +53,18 @@ private struct FontDef {
* Font implementation based on Win32 API system fonts.
*/
class Win32Font : Font {
- HFONT _hfont;
- int _size;
- int _height;
- int _weight;
- int _baseline;
- bool _italic;
- string _face;
- FontFamily _family;
- LOGFONTA _logfont;
- Win32ColorDrawBuf _drawbuf;
- GlyphCache _glyphCache;
+ protected HFONT _hfont;
+ protected int _dpi;
+ protected int _size;
+ protected int _height;
+ protected int _weight;
+ protected int _baseline;
+ protected bool _italic;
+ protected string _face;
+ protected FontFamily _family;
+ protected LOGFONTA _logfont;
+ protected Win32ColorDrawBuf _drawbuf;
+ protected GlyphCache _glyphCache;
/// need to call create() after construction to initialize font
this() {
@@ -250,7 +251,6 @@ class Win32Font : Font {
return _glyphCache.put(ch, g);
}
-
/// init from font definition
bool create(FontDef * def, int size, int weight, bool italic) {
if (!isNull())
@@ -259,7 +259,7 @@ class Win32Font : Font {
lf.lfCharSet = ANSI_CHARSET; //DEFAULT_CHARSET;
lf.lfFaceName[0..def.face.length] = def.face;
lf.lfFaceName[def.face.length] = 0;
- lf.lfHeight = -size; //size; //-size;
+ lf.lfHeight = size; //pixelsToPoints(size);
lf.lfItalic = italic;
lf.lfWeight = weight;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; //OUT_OUTLINE_PRECIS; //OUT_TT_ONLY_PRECIS;
@@ -277,6 +277,7 @@ class Win32Font : Font {
_size = size;
_height = tm.tmHeight;
+ Log.d("Win32Font.create: height=", _height, " for size=", _size, " points=", lf.lfHeight, " dpi=", _dpi);
_baseline = _height - tm.tmDescent;
_weight = weight;
_italic = italic;
@@ -314,7 +315,7 @@ class Win32FontManager : FontManager {
private FontList _activeFonts;
private FontDef[] _fontFaces;
private FontDef*[string] _faceByName;
-
+
/// initialize in constructor
this() {
debug Log.i("Creating Win32FontManager");
diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d
index ed85adfb..07924e44 100644
--- a/src/dlangui/platforms/windows/winapp.d
+++ b/src/dlangui/platforms/windows/winapp.d
@@ -680,6 +680,10 @@ class Win32Platform : Platform {
{
return false;
}
+ HDC dc = CreateCompatibleDC(NULL);
+ SCREEN_DPI = GetDeviceCaps(dc, LOGPIXELSY);
+ DeleteObject(dc);
+
return true;
}
override int enterMessageLoop() {
@@ -912,7 +916,6 @@ int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdSho
// use Win32 font manager
if (FontManager.instance is null) {
- //Win32FontManager fontMan = new Win32FontManager();
FontManager.instance = new Win32FontManager();
}
diff --git a/src/dlangui/widgets/srcedit.d b/src/dlangui/widgets/srcedit.d
index 44501cec..43600217 100644
--- a/src/dlangui/widgets/srcedit.d
+++ b/src/dlangui/widgets/srcedit.d
@@ -27,7 +27,7 @@ class SourceEdit : EditBox {
super(ID);
fontFace = "Consolas,Lucida Console,Courier New";
fontFamily = FontFamily.MonoSpace;
- fontSize = 12;
+ fontSize = 16;
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
minFontSize(10).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel
_showLineNumbers = true;