mirror of https://github.com/buggins/dlangui.git
ftfonts fixes
This commit is contained in:
parent
3491c35d89
commit
1aa4617872
|
@ -1226,7 +1226,9 @@ static if (_WIN32_IE >= 0x400) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SHGetFolderPath in shfolder.dll on W9x, NT4, also in shell32.dll on W2K */
|
/* SHGetFolderPath in shfolder.dll on W9x, NT4, also in shell32.dll on W2K */
|
||||||
|
extern (Windows)
|
||||||
HRESULT SHGetFolderPathA(HWND, int, HANDLE, DWORD, LPSTR);
|
HRESULT SHGetFolderPathA(HWND, int, HANDLE, DWORD, LPSTR);
|
||||||
|
extern (Windows)
|
||||||
HRESULT SHGetFolderPathW(HWND, int, HANDLE, DWORD, LPWSTR);
|
HRESULT SHGetFolderPathW(HWND, int, HANDLE, DWORD, LPWSTR);
|
||||||
|
|
||||||
static if (_WIN32_WINNT >= 0x500) {
|
static if (_WIN32_WINNT >= 0x500) {
|
||||||
|
|
|
@ -268,6 +268,7 @@
|
||||||
<File path="3rdparty\win32\rpcnsip.d" />
|
<File path="3rdparty\win32\rpcnsip.d" />
|
||||||
<File path="3rdparty\win32\rpcnterr.d" />
|
<File path="3rdparty\win32\rpcnterr.d" />
|
||||||
<File path="3rdparty\win32\shellapi.d" />
|
<File path="3rdparty\win32\shellapi.d" />
|
||||||
|
<File path="3rdparty\win32\shlobj.d" />
|
||||||
<File path="3rdparty\win32\unknwn.d" />
|
<File path="3rdparty\win32\unknwn.d" />
|
||||||
<File path="3rdparty\win32\uuid.d" />
|
<File path="3rdparty\win32\uuid.d" />
|
||||||
<File path="3rdparty\win32\w32api.d" />
|
<File path="3rdparty\win32\w32api.d" />
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
<cv2pdbOptions />
|
<cv2pdbOptions />
|
||||||
<objfiles />
|
<objfiles />
|
||||||
<linkswitches />
|
<linkswitches />
|
||||||
<libfiles>libpng15.lib dlangui.lib phobos.lib ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib dlangui.lib</libfiles>
|
<libfiles>libpng15.lib dlangui.lib phobos.lib ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib dlangui.lib</libfiles>
|
||||||
<libpaths>../../Debug ../../3rdparty/libpng/lib 3rdparty/libpng/lib ../../../DerelictOpenGL3/source</libpaths>
|
<libpaths>../../Debug ../../3rdparty/libpng/lib 3rdparty/libpng/lib ../../../DerelictOpenGL3/source</libpaths>
|
||||||
<deffile />
|
<deffile />
|
||||||
<resfile />
|
<resfile />
|
||||||
|
|
|
@ -4,6 +4,24 @@ module dlangui.graphics.ftfonts;
|
||||||
import dlangui.graphics.fonts;
|
import dlangui.graphics.fonts;
|
||||||
|
|
||||||
import derelict.freetype.ft;
|
import derelict.freetype.ft;
|
||||||
|
private import dlangui.core.logger;
|
||||||
|
|
||||||
|
private struct FontDef {
|
||||||
|
immutable FontFamily _family;
|
||||||
|
immutable string _face;
|
||||||
|
immutable bool _italic;
|
||||||
|
immutable int _weight;
|
||||||
|
@property FontFamily family() { return _family; }
|
||||||
|
@property string face() { return _face; }
|
||||||
|
@property bool italic() { return _italic; }
|
||||||
|
@property int weight() { return _weight; }
|
||||||
|
this(FontFamily family, string face, bool italic, int weight) {
|
||||||
|
_family = family;
|
||||||
|
_face = face;
|
||||||
|
_italic = italic;
|
||||||
|
_weight = weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// FreeType based font manager.
|
/// FreeType based font manager.
|
||||||
class FreeTypeFontManager : FontManager {
|
class FreeTypeFontManager : FontManager {
|
||||||
|
@ -32,6 +50,7 @@ class FreeTypeFontManager : FontManager {
|
||||||
|
|
||||||
/// register freetype font by filename - optinally font properties can be passed if known (e.g. from libfontconfig).
|
/// register freetype font by filename - optinally font properties can be passed if known (e.g. from libfontconfig).
|
||||||
bool registerFont(string filename, FontFamily family = FontFamily.SansSerif, string face = null, bool italic = false, int weight = 0) {
|
bool registerFont(string filename, FontFamily family = FontFamily.SansSerif, string face = null, bool italic = false, int weight = 0) {
|
||||||
|
Log.d("FreeTypeFontManager.registerFont ", filename, " ", family, " ", face, " italic=", italic, " weight=", weight);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import std.utf;
|
||||||
//return toUTFz!(const(wchar)*)(s);
|
//return toUTFz!(const(wchar)*)(s);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
struct FontDef {
|
private struct FontDef {
|
||||||
immutable FontFamily _family;
|
immutable FontFamily _family;
|
||||||
immutable string _face;
|
immutable string _face;
|
||||||
immutable ubyte _pitchAndFamily;
|
immutable ubyte _pitchAndFamily;
|
||||||
|
|
|
@ -417,9 +417,38 @@ int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
|
||||||
Win32FontManager fontMan = new Win32FontManager();
|
Win32FontManager fontMan = new Win32FontManager();
|
||||||
FontManager.instance = fontMan;
|
FontManager.instance = fontMan;
|
||||||
|
|
||||||
/// testing freetype font manager
|
{
|
||||||
import dlangui.graphics.ftfonts;
|
/// testing freetype font manager
|
||||||
FreeTypeFontManager ftfontMan = new FreeTypeFontManager();
|
import dlangui.graphics.ftfonts;
|
||||||
|
import win32.shlobj;
|
||||||
|
FreeTypeFontManager ftfontMan = new FreeTypeFontManager();
|
||||||
|
string fontsPath = "c:\\Windows\\Fonts\\";
|
||||||
|
static if (false) { // SHGetFolderPathW not found in shell32.lib
|
||||||
|
WCHAR szPath[MAX_PATH];
|
||||||
|
const CSIDL_FLAG_NO_ALIAS = 0x1000;
|
||||||
|
const CSIDL_FLAG_DONT_UNEXPAND = 0x2000;
|
||||||
|
if(SUCCEEDED(SHGetFolderPathW(NULL,
|
||||||
|
CSIDL_FONTS|CSIDL_FLAG_NO_ALIAS|CSIDL_FLAG_DONT_UNEXPAND,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
szPath.ptr)))
|
||||||
|
{
|
||||||
|
fontsPath = toUTF8(fromWStringz(szPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "arial.ttf", FontFamily.SansSerif, "Arial", false, FontWeight.Normal);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "arialbd.ttf", FontFamily.SansSerif, "Arial", false, FontWeight.Bold);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "arialbi.ttf", FontFamily.SansSerif, "Arial", true, FontWeight.Bold);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "ariali.ttf", FontFamily.SansSerif, "Arial", true, FontWeight.Normal);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "cour.ttf", FontFamily.MonoSpace, "Courier New", false, FontWeight.Normal);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "courbd.ttf", FontFamily.MonoSpace, "Courier New", false, FontWeight.Bold);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "courbi.ttf", FontFamily.MonoSpace, "Courier New", true, FontWeight.Bold);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "couri.ttf", FontFamily.MonoSpace, "Courier New", true, FontWeight.Normal);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "times.ttf", FontFamily.Serif, "Times New Roman", false, FontWeight.Normal);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "timesbd.ttf", FontFamily.Serif, "Times New Roman", false, FontWeight.Bold);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "timesbi.ttf", FontFamily.Serif, "Times New Roman", true, FontWeight.Bold);
|
||||||
|
ftfontMan.registerFont(fontsPath ~ "timesi.ttf", FontFamily.Serif, "Times New Roman", true, FontWeight.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
version (USE_OPENGL) {
|
||||||
import derelict.opengl3.gl3;
|
import derelict.opengl3.gl3;
|
||||||
|
|
Loading…
Reference in New Issue