mirror of https://github.com/buggins/dlangui.git
font size fixes
This commit is contained in:
parent
fdb965b45c
commit
b417db74a0
|
@ -66,7 +66,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids>DebugFocus</debugids>
|
<debugids>DebugFocus</debugids>
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>EmbedStandardResources Unicode USE_SDL USE_OPENGL </versionids>
|
<versionids>EmbedStandardResources Unicode</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>0</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>1</createImplib>
|
<createImplib>1</createImplib>
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>Unicode USE_SDL USE_OPENGL</versionids>
|
<versionids>Unicode</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>3</mapverbosity>
|
<mapverbosity>3</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>USE_OPENGL</versionids>
|
<versionids>Unicode</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>3</mapverbosity>
|
<mapverbosity>3</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
@ -89,7 +89,6 @@
|
||||||
<resfile />
|
<resfile />
|
||||||
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
<useStdLibPath>1</useStdLibPath>
|
<useStdLibPath>1</useStdLibPath>
|
||||||
<cRuntime>2</cRuntime>
|
|
||||||
<additionalOptions>-profile</additionalOptions>
|
<additionalOptions>-profile</additionalOptions>
|
||||||
<preBuildCommand />
|
<preBuildCommand />
|
||||||
<postBuildCommand />
|
<postBuildCommand />
|
||||||
|
@ -184,7 +183,6 @@
|
||||||
<resfile />
|
<resfile />
|
||||||
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
<useStdLibPath>1</useStdLibPath>
|
<useStdLibPath>1</useStdLibPath>
|
||||||
<cRuntime>1</cRuntime>
|
|
||||||
<additionalOptions />
|
<additionalOptions />
|
||||||
<preBuildCommand />
|
<preBuildCommand />
|
||||||
<postBuildCommand />
|
<postBuildCommand />
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids />
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>USE_OPENGL</versionids>
|
<versionids>Unicode</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>3</mapverbosity>
|
<mapverbosity>3</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
|
|
|
@ -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.
|
Character glyph.
|
||||||
|
|
||||||
|
|
|
@ -53,17 +53,18 @@ private struct FontDef {
|
||||||
* Font implementation based on Win32 API system fonts.
|
* Font implementation based on Win32 API system fonts.
|
||||||
*/
|
*/
|
||||||
class Win32Font : Font {
|
class Win32Font : Font {
|
||||||
HFONT _hfont;
|
protected HFONT _hfont;
|
||||||
int _size;
|
protected int _dpi;
|
||||||
int _height;
|
protected int _size;
|
||||||
int _weight;
|
protected int _height;
|
||||||
int _baseline;
|
protected int _weight;
|
||||||
bool _italic;
|
protected int _baseline;
|
||||||
string _face;
|
protected bool _italic;
|
||||||
FontFamily _family;
|
protected string _face;
|
||||||
LOGFONTA _logfont;
|
protected FontFamily _family;
|
||||||
Win32ColorDrawBuf _drawbuf;
|
protected LOGFONTA _logfont;
|
||||||
GlyphCache _glyphCache;
|
protected Win32ColorDrawBuf _drawbuf;
|
||||||
|
protected GlyphCache _glyphCache;
|
||||||
|
|
||||||
/// need to call create() after construction to initialize font
|
/// need to call create() after construction to initialize font
|
||||||
this() {
|
this() {
|
||||||
|
@ -250,7 +251,6 @@ class Win32Font : Font {
|
||||||
return _glyphCache.put(ch, g);
|
return _glyphCache.put(ch, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// init from font definition
|
/// init from font definition
|
||||||
bool create(FontDef * def, int size, int weight, bool italic) {
|
bool create(FontDef * def, int size, int weight, bool italic) {
|
||||||
if (!isNull())
|
if (!isNull())
|
||||||
|
@ -259,7 +259,7 @@ class Win32Font : Font {
|
||||||
lf.lfCharSet = ANSI_CHARSET; //DEFAULT_CHARSET;
|
lf.lfCharSet = ANSI_CHARSET; //DEFAULT_CHARSET;
|
||||||
lf.lfFaceName[0..def.face.length] = def.face;
|
lf.lfFaceName[0..def.face.length] = def.face;
|
||||||
lf.lfFaceName[def.face.length] = 0;
|
lf.lfFaceName[def.face.length] = 0;
|
||||||
lf.lfHeight = -size; //size; //-size;
|
lf.lfHeight = size; //pixelsToPoints(size);
|
||||||
lf.lfItalic = italic;
|
lf.lfItalic = italic;
|
||||||
lf.lfWeight = weight;
|
lf.lfWeight = weight;
|
||||||
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; //OUT_OUTLINE_PRECIS; //OUT_TT_ONLY_PRECIS;
|
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; //OUT_OUTLINE_PRECIS; //OUT_TT_ONLY_PRECIS;
|
||||||
|
@ -277,6 +277,7 @@ class Win32Font : Font {
|
||||||
|
|
||||||
_size = size;
|
_size = size;
|
||||||
_height = tm.tmHeight;
|
_height = tm.tmHeight;
|
||||||
|
Log.d("Win32Font.create: height=", _height, " for size=", _size, " points=", lf.lfHeight, " dpi=", _dpi);
|
||||||
_baseline = _height - tm.tmDescent;
|
_baseline = _height - tm.tmDescent;
|
||||||
_weight = weight;
|
_weight = weight;
|
||||||
_italic = italic;
|
_italic = italic;
|
||||||
|
|
|
@ -680,6 +680,10 @@ class Win32Platform : Platform {
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
HDC dc = CreateCompatibleDC(NULL);
|
||||||
|
SCREEN_DPI = GetDeviceCaps(dc, LOGPIXELSY);
|
||||||
|
DeleteObject(dc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
override int enterMessageLoop() {
|
override int enterMessageLoop() {
|
||||||
|
@ -912,7 +916,6 @@ int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdSho
|
||||||
|
|
||||||
// use Win32 font manager
|
// use Win32 font manager
|
||||||
if (FontManager.instance is null) {
|
if (FontManager.instance is null) {
|
||||||
//Win32FontManager fontMan = new Win32FontManager();
|
|
||||||
FontManager.instance = new Win32FontManager();
|
FontManager.instance = new Win32FontManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 = 12;
|
fontSize = 16;
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue