mirror of https://github.com/buggins/dlangui.git
support getting list of font faces from fontManager
This commit is contained in:
parent
6c8785e9dd
commit
fc57073d1a
|
@ -53,11 +53,14 @@ Currently implemented widgets:
|
|||
* CheckBox - check button with label
|
||||
* RadioButton - radio button with label
|
||||
* SwitchButton - a toggle switch button
|
||||
* GroupBox - frame and caption for grouping other controls
|
||||
* EditLine - single line edit
|
||||
* EditBox - multiline editor
|
||||
* VSpacer - vertical spacer - just an empty widget with layoutHeight == FILL_PARENT, to fill vertical space in layouts
|
||||
* HSpacer - horizontal spacer - just an empty widget with layoutWidth == FILL_PARENT, to fill horizontal space in layouts
|
||||
* ScrollBar - scroll bar
|
||||
* SliderWidget - slider
|
||||
* ProgressBarWidget - progress bar
|
||||
* TabControl - tabs widget, allows to select one of tabs
|
||||
* TabHost - container for pages controlled by TabControl
|
||||
* TabWidget - combination of TabControl and TabHost
|
||||
|
|
|
@ -652,6 +652,14 @@ enum HintingMode : int {
|
|||
Light // 3
|
||||
}
|
||||
|
||||
/// font face properties item
|
||||
struct FontFaceProps {
|
||||
/// font face name
|
||||
string face;
|
||||
/// font family
|
||||
FontFamily family;
|
||||
}
|
||||
|
||||
/// Access points to fonts.
|
||||
class FontManager {
|
||||
protected static __gshared FontManager _instance;
|
||||
|
@ -676,6 +684,11 @@ class FontManager {
|
|||
/// get font instance best matched specified parameters
|
||||
abstract ref FontRef getFont(int size, int weight, bool italic, FontFamily family, string face);
|
||||
|
||||
/// override to return list of font faces available
|
||||
FontFaceProps[] getFaces() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// clear usage flags for all entries -- for cleanup of unused fonts
|
||||
abstract void checkpoint();
|
||||
|
||||
|
|
|
@ -495,6 +495,25 @@ class FreeTypeFontManager : FontManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
/// override to return list of font faces available
|
||||
override FontFaceProps[] getFaces() {
|
||||
FontFaceProps[] res;
|
||||
for (int i = 0; i < _fontFiles.length; i++) {
|
||||
FontFaceProps item = FontFaceProps(_fontFiles[i].def.face, _fontFiles[i].def.family);
|
||||
bool found = false;
|
||||
for (int j = 0; j < res.length; j++) {
|
||||
if (res[j].face == item.face) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
res ~= item;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
private static int faceMatch(string requested, string existing) {
|
||||
if (!requested.icmp("Arial")) {
|
||||
if (!existing.icmp("DejaVu Sans")) {
|
||||
|
|
|
@ -496,7 +496,26 @@ class Win32FontManager : FontManager {
|
|||
private FontList _activeFonts;
|
||||
private FontDef[] _fontFaces;
|
||||
private FontDef*[string] _faceByName;
|
||||
|
||||
|
||||
/// override to return list of font faces available
|
||||
override FontFaceProps[] getFaces() {
|
||||
FontFaceProps[] res;
|
||||
for (int i = 0; i < _fontFaces.length; i++) {
|
||||
FontFaceProps item = FontFaceProps(_fontFaces[i].face, _fontFaces[i].family);
|
||||
bool found = false;
|
||||
for (int j = 0; j < res.length; j++) {
|
||||
if (res[j].face == item.face) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
res ~= item;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/// initialize in constructor
|
||||
this() {
|
||||
debug Log.i("Creating Win32FontManager");
|
||||
|
|
|
@ -22,10 +22,12 @@ import dlangui.graphics.fonts;
|
|||
import dlangui.widgets.editors;
|
||||
import dlangui.widgets.styles;
|
||||
|
||||
enum DEFAULT_SOURCE_EDIT_FONT_FACES = "Menlo,Consolas,DejaVuSansMono,DejaVu Sans Mono,Liberation Mono,Lucida Sans Typewriter,Courier New,Lucida Console";
|
||||
|
||||
class SourceEdit : EditBox {
|
||||
this(string ID) {
|
||||
super(ID);
|
||||
fontFace = "Menlo,Consolas,DejaVuSansMono,DejaVu Sans Mono,Liberation Mono,Lucida Sans Typewriter,Courier New,Lucida Console";
|
||||
fontFace = DEFAULT_SOURCE_EDIT_FONT_FACES;
|
||||
//fontFace = "Consolas,Lucida Console,Courier New";
|
||||
fontFamily = FontFamily.MonoSpace;
|
||||
fontSize = makePointSize(10);
|
||||
|
|
Loading…
Reference in New Issue