diff --git a/examples/example1/src/example1.d b/examples/example1/src/example1.d index 2f5cd79f..c7d2a90e 100644 --- a/examples/example1/src/example1.d +++ b/examples/example1/src/example1.d @@ -188,6 +188,14 @@ extern (C) int UIAppMain(string[] args) { // embed resources listed in views/resources.list into executable embeddedResourceList.addResources(embedResourcesFromList!("resources.list")()); + version (USE_OPENGL) { + // you can turn on subpixel font rendering (ClearType) here + FontManager.subpixelRenderingMode = SubpixelRenderingMode.None; // + } else { + // you can turn on subpixel font rendering (ClearType) here + FontManager.subpixelRenderingMode = SubpixelRenderingMode.BGR; //SubpixelRenderingMode.None; // + } + // select translation file - for english language Platform.instance.uiLanguage = "en"; // load theme from file "theme_default.xml" diff --git a/src/dlangui/platforms/windows/win32fonts.d b/src/dlangui/platforms/windows/win32fonts.d index 9e83d41d..f8a1975c 100644 --- a/src/dlangui/platforms/windows/win32fonts.d +++ b/src/dlangui/platforms/windows/win32fonts.d @@ -271,11 +271,6 @@ class Win32Font : Font { bool needSubpixelRendering = FontManager.subpixelRenderingMode && antialiased; MAT2 scaleMatrix = { {0,1}, {0,0}, {0,0}, {0,1} }; - int xdivider = 1; - if (needSubpixelRendering) { - scaleMatrix.eM11.value = 3; // request glyph 3 times wider for subpixel antialiasing - xdivider = 3; - } uint res; res = GetGlyphOutlineW( _drawbuf.dc, cast(wchar)ch, @@ -286,6 +281,22 @@ class Win32Font : Font { &scaleMatrix ); if (res == GDI_ERROR) return null; + + Glyph * g = new Glyph; + version (USE_OPENGL) { + g.id = nextGlyphId(); + } + //g.blackBoxX = cast(ushort)metrics.gmBlackBoxX; + //g.blackBoxY = cast(ubyte)metrics.gmBlackBoxY; + //g.originX = cast(byte)metrics.gmptGlyphOrigin.x; + //g.originY = cast(byte)metrics.gmptGlyphOrigin.y; + //g.width = cast(ubyte)metrics.gmCellIncX; + g.subpixelMode = SubpixelRenderingMode.None; + + if (needSubpixelRendering) { + scaleMatrix.eM11.value = 3; // request glyph 3 times wider for subpixel antialiasing + } + int gs = 0; // calculate bitmap size if (antialiased) { @@ -307,17 +318,24 @@ class Win32Font : Font { if (gs >= 0x10000 || gs < 0) return null; - Glyph * g = new Glyph; - version (USE_OPENGL) { - g.id = nextGlyphId(); - } - g.blackBoxX = cast(ushort)metrics.gmBlackBoxX; - g.blackBoxY = cast(ubyte)metrics.gmBlackBoxY; - g.originX = cast(byte)(needSubpixelRendering ? ((metrics.gmptGlyphOrigin.x + 0) / 3) : (metrics.gmptGlyphOrigin.x)); - g.originY = cast(byte)metrics.gmptGlyphOrigin.y; - g.width = cast(ubyte)(needSubpixelRendering ? (metrics.gmCellIncX + 0) / 3 : metrics.gmCellIncX); - g.subpixelMode = needSubpixelRendering ? FontManager.subpixelRenderingMode : SubpixelRenderingMode.None; - //g.glyphIndex = cast(ushort)glyphIndex; + if (needSubpixelRendering) { + //Log.d("ch=", ch); + //Log.d("NORMAL: blackBoxX=", g.blackBoxX, " \tblackBoxY=", g.blackBoxY, " \torigin.x=", g.originX, " \torigin.y=", g.originY, "\tgmCellIncX=", g.width); + g.blackBoxX = cast(ushort)metrics.gmBlackBoxX; + g.blackBoxY = cast(ubyte)metrics.gmBlackBoxY; + g.originX = cast(byte)((metrics.gmptGlyphOrigin.x + 0) / 3); + g.originY = cast(byte)metrics.gmptGlyphOrigin.y; + g.width = cast(ubyte)((metrics.gmCellIncX + 2) / 3); + g.subpixelMode = FontManager.subpixelRenderingMode; + //Log.d(" *3 : blackBoxX=", metrics.gmBlackBoxX, " \tblackBoxY=", metrics.gmBlackBoxY, " \torigin.x=", metrics.gmptGlyphOrigin.x, " \torigin.y=", metrics.gmptGlyphOrigin.y, " \tgmCellIncX=", metrics.gmCellIncX); + //Log.d(" /3 : blackBoxX=", g.blackBoxX, " \tblackBoxY=", g.blackBoxY, " \torigin.x=", g.originX, " \torigin.y=", g.originY, "\tgmCellIncX=", g.width); + } else { + g.blackBoxX = cast(ushort)metrics.gmBlackBoxX; + g.blackBoxY = cast(ubyte)metrics.gmBlackBoxY; + g.originX = cast(byte)metrics.gmptGlyphOrigin.x; + g.originY = cast(byte)metrics.gmptGlyphOrigin.y; + g.width = cast(ubyte)metrics.gmCellIncX; + } if (g.blackBoxX > 0 && g.blackBoxY > 0) { g.glyph = new ubyte[g.blackBoxX * g.blackBoxY]; diff --git a/src/dlangui/widgets/srcedit.d b/src/dlangui/widgets/srcedit.d index 43600217..3c824019 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 = 16; + fontSize = 17; layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT); minFontSize(10).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel _showLineNumbers = true; diff --git a/views/res/theme_default.xml b/views/res/theme_default.xml index cc3763a0..f18ac6cf 100644 --- a/views/res/theme_default.xml +++ b/views/res/theme_default.xml @@ -1,5 +1,8 @@ - +