FreeType support stub added

This commit is contained in:
Vadim Lopatin 2014-03-12 10:43:37 +04:00
parent 3113577041
commit 2a50741e52
5 changed files with 58 additions and 7 deletions

View File

@ -47,7 +47,7 @@
<compiler>0</compiler>
<otherDMD>0</otherDMD>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>3rdparty 3rdparty/libpng/source ../DerelictGL3/source ../DerelictUtil/source</imppath>
<imppath>3rdparty 3rdparty/libpng/source ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source</imppath>
<fileImppath />
<outdir>$(ConfigurationName)</outdir>
<objdir>$(OutDir)</objdir>
@ -215,6 +215,11 @@
<File path="..\DerelictGL3\source\derelict\opengl3\wgl.d" />
<File path="..\DerelictGL3\source\derelict\opengl3\wglext.d" />
</Folder>
<Folder name="DerelictFT">
<File path="..\DerelictFT\source\derelict\freetype\ft.d" />
<File path="..\DerelictFT\source\derelict\freetype\functions.d" />
<File path="..\DerelictFT\source\derelict\freetype\types.d" />
</Folder>
<Folder name="gl3n">
<File path="..\gl3n\gl3n\aabb.d" />
<File path="..\gl3n\gl3n\frustum.d" />
@ -294,6 +299,7 @@
<Folder name="graphics">
<File path="src\dlangui\graphics\drawbuf.d" />
<File path="src\dlangui\graphics\fonts.d" />
<File path="src\dlangui\graphics\ftfonts.d" />
<File path="src\dlangui\graphics\gldrawbuf.d" />
<File path="src\dlangui\graphics\glsupport.d" />
<File path="src\dlangui\graphics\images.d" />

View File

@ -4,6 +4,7 @@ public import dlangui.core.types;
public import dlangui.core.logger;
import std.algorithm;
/// font family
enum FontFamily : ubyte {
Unspecified,
SansSerif,
@ -13,6 +14,7 @@ enum FontFamily : ubyte {
MonoSpace
}
/// useful font weight constants
enum FontWeight : int {
Normal = 400,
Bold = 800
@ -192,21 +194,26 @@ struct FontList {
}
}
/// Access points to fonts.
class FontManager {
static __gshared FontManager _instance;
/// sets new font manager singleton instance
static @property void instance(FontManager manager) {
_instance = manager;
}
/// returns font manager singleton instance
static @property FontManager instance() {
return _instance;
}
/// get font instance best matched specified parameters
abstract ref FontRef getFont(int size, int weight, bool italic, FontFamily family, string face);
// clear usage flags for all entries
/// clear usage flags for all entries -- for cleanup of unused fonts
abstract void checkpoint();
// removes entries not used after last call of checkpoint() or cleanup()
/// removes entries not used after last call of checkpoint() or cleanup()
abstract void cleanup();
~this() {}

View File

@ -0,0 +1,34 @@
/// freetype fonts support
module dlangui.graphics.ftfonts;
import dlangui.graphics.fonts;
import derelict.freetype.ft;
/// FreeType based font manager.
class FreeTypeFontManager : FontManager {
private FontList _activeFonts;
private FontRef _nullFontRef;
this() {
// load dynaic library
DerelictFT.load();
}
/// get font instance with specified parameters
override ref FontRef getFont(int size, int weight, bool italic, FontFamily family, string face) {
return _nullFontRef;
}
/// clear usage flags for all entries
override void checkpoint() {
}
/// removes entries not used after last call of checkpoint() or cleanup()
override void cleanup() {
}
~this() {}
}

View File

@ -293,9 +293,9 @@ class Win32Font : Font {
* Font manager implementation based on Win32 API system fonts.
*/
class Win32FontManager : FontManager {
FontList _activeFonts;
FontDef[] _fontFaces;
FontDef*[string] _faceByName;
private FontList _activeFonts;
private FontDef[] _fontFaces;
private FontDef*[string] _faceByName;
/// initialize in constructor
this() {

View File

@ -16,13 +16,17 @@ import dlangui.widgets.styles;
import dlangui.graphics.drawbuf;
import dlangui.graphics.images;
import dlangui.graphics.fonts;
import dlangui.graphics.glsupport;
import dlangui.core.logger;
version (USE_OPENGL) {
import dlangui.graphics.glsupport;
}
pragma(lib, "gdi32.lib");
pragma(lib, "user32.lib");
pragma(lib, "libpng15.lib");
/// this function should be defined in user application!
extern (C) int UIAppMain(string[] args);
immutable WIN_CLASS_NAME = "DLANGUI_APP";