mirror of https://github.com/buggins/dlangui.git
turn on subpixel antialiasing (ClearType) for win32 fonts / no opengl
This commit is contained in:
parent
ae75f40323
commit
a6f68a5f52
|
@ -188,6 +188,14 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
// embed resources listed in views/resources.list into executable
|
// embed resources listed in views/resources.list into executable
|
||||||
embeddedResourceList.addResources(embedResourcesFromList!("resources.list")());
|
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
|
// select translation file - for english language
|
||||||
Platform.instance.uiLanguage = "en";
|
Platform.instance.uiLanguage = "en";
|
||||||
// load theme from file "theme_default.xml"
|
// load theme from file "theme_default.xml"
|
||||||
|
|
|
@ -271,11 +271,6 @@ class Win32Font : Font {
|
||||||
|
|
||||||
bool needSubpixelRendering = FontManager.subpixelRenderingMode && antialiased;
|
bool needSubpixelRendering = FontManager.subpixelRenderingMode && antialiased;
|
||||||
MAT2 scaleMatrix = { {0,1}, {0,0}, {0,0}, {0,1} };
|
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;
|
uint res;
|
||||||
res = GetGlyphOutlineW( _drawbuf.dc, cast(wchar)ch,
|
res = GetGlyphOutlineW( _drawbuf.dc, cast(wchar)ch,
|
||||||
|
@ -286,6 +281,22 @@ class Win32Font : Font {
|
||||||
&scaleMatrix );
|
&scaleMatrix );
|
||||||
if (res == GDI_ERROR)
|
if (res == GDI_ERROR)
|
||||||
return null;
|
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;
|
int gs = 0;
|
||||||
// calculate bitmap size
|
// calculate bitmap size
|
||||||
if (antialiased) {
|
if (antialiased) {
|
||||||
|
@ -307,17 +318,24 @@ class Win32Font : Font {
|
||||||
if (gs >= 0x10000 || gs < 0)
|
if (gs >= 0x10000 || gs < 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Glyph * g = new Glyph;
|
if (needSubpixelRendering) {
|
||||||
version (USE_OPENGL) {
|
//Log.d("ch=", ch);
|
||||||
g.id = nextGlyphId();
|
//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.blackBoxX = cast(ushort)metrics.gmBlackBoxX;
|
||||||
g.blackBoxY = cast(ubyte)metrics.gmBlackBoxY;
|
g.blackBoxY = cast(ubyte)metrics.gmBlackBoxY;
|
||||||
g.originX = cast(byte)(needSubpixelRendering ? ((metrics.gmptGlyphOrigin.x + 0) / 3) : (metrics.gmptGlyphOrigin.x));
|
g.originX = cast(byte)((metrics.gmptGlyphOrigin.x + 0) / 3);
|
||||||
g.originY = cast(byte)metrics.gmptGlyphOrigin.y;
|
g.originY = cast(byte)metrics.gmptGlyphOrigin.y;
|
||||||
g.width = cast(ubyte)(needSubpixelRendering ? (metrics.gmCellIncX + 0) / 3 : metrics.gmCellIncX);
|
g.width = cast(ubyte)((metrics.gmCellIncX + 2) / 3);
|
||||||
g.subpixelMode = needSubpixelRendering ? FontManager.subpixelRenderingMode : SubpixelRenderingMode.None;
|
g.subpixelMode = FontManager.subpixelRenderingMode;
|
||||||
//g.glyphIndex = cast(ushort)glyphIndex;
|
//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) {
|
if (g.blackBoxX > 0 && g.blackBoxY > 0) {
|
||||||
g.glyph = new ubyte[g.blackBoxX * g.blackBoxY];
|
g.glyph = new ubyte[g.blackBoxX * g.blackBoxY];
|
||||||
|
|
|
@ -27,7 +27,7 @@ class SourceEdit : EditBox {
|
||||||
super(ID);
|
super(ID);
|
||||||
fontFace = "Consolas,Lucida Console,Courier New";
|
fontFace = "Consolas,Lucida Console,Courier New";
|
||||||
fontFamily = FontFamily.MonoSpace;
|
fontFamily = FontFamily.MonoSpace;
|
||||||
fontSize = 16;
|
fontSize = 17;
|
||||||
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||||
minFontSize(10).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel
|
minFontSize(10).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel
|
||||||
_showLineNumbers = true;
|
_showLineNumbers = true;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<theme id="theme_default" fontSize="15" >
|
<theme id="theme_default" fontSize="15"
|
||||||
|
fontFace="Verdana,Arial,DejaVu Sans"
|
||||||
|
fontFamily="SansSerif"
|
||||||
|
>
|
||||||
<style id="BUTTON"
|
<style id="BUTTON"
|
||||||
backgroundImageId="btn_background"
|
backgroundImageId="btn_background"
|
||||||
align="Center"
|
align="Center"
|
||||||
|
@ -313,9 +316,7 @@
|
||||||
minHeight="16"
|
minHeight="16"
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
layoutHeight="WRAP_CONTENT"
|
layoutHeight="WRAP_CONTENT"
|
||||||
fontFace="Arial"
|
fontSize="17">
|
||||||
fontFamily="SansSerif"
|
|
||||||
fontSize="16">
|
|
||||||
</style>
|
</style>
|
||||||
<style id="TREE_ITEM_EXPAND_ICON"
|
<style id="TREE_ITEM_EXPAND_ICON"
|
||||||
margins="2,0,2,0"
|
margins="2,0,2,0"
|
||||||
|
@ -338,7 +339,7 @@
|
||||||
layoutHeight="WRAP_CONTENT"
|
layoutHeight="WRAP_CONTENT"
|
||||||
align="Left|VCenter"
|
align="Left|VCenter"
|
||||||
textFlags="Parent"
|
textFlags="Parent"
|
||||||
fontSize="16"
|
fontSize="17"
|
||||||
/>
|
/>
|
||||||
<style id="RESIZER_VERTICAL"
|
<style id="RESIZER_VERTICAL"
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
|
|
Loading…
Reference in New Issue