mirror of https://github.com/buggins/dlangide.git
allow selecting non-monospace fonts - for #12
This commit is contained in:
parent
38f3547fdd
commit
2815b6a02e
2
dub.json
2
dub.json
|
@ -12,7 +12,7 @@
|
||||||
"stringImportPaths": ["views", "views/res", "views/res/i18n", "views/res/mdpi", "views/res/hdpi"],
|
"stringImportPaths": ["views", "views/res", "views/res/i18n", "views/res/mdpi", "views/res/hdpi"],
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dlangui": "==0.9.7",
|
"dlangui": "==0.9.15",
|
||||||
"dcd": "~>0.8.0"
|
"dcd": "~>0.8.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,28 @@ SettingsPage createSettingsPages() {
|
||||||
import dlangui.graphics.fonts;
|
import dlangui.graphics.fonts;
|
||||||
import std.utf : toUTF32;
|
import std.utf : toUTF32;
|
||||||
FontFaceProps[] allFaces = FontManager.instance.getFaces();
|
FontFaceProps[] allFaces = FontManager.instance.getFaces();
|
||||||
for (int i = 0; i < allFaces.length; i++) {
|
import std.algorithm.sorting : sort;
|
||||||
if (allFaces[i].family == FontFamily.MonoSpace)
|
auto fontComp = function(ref FontFaceProps a, ref FontFaceProps b) {
|
||||||
faces ~= StringListValue(allFaces[i].face, toUTF32(allFaces[i].face));
|
if (a.family == FontFamily.MonoSpace && b.family != FontFamily.MonoSpace)
|
||||||
|
return -1;
|
||||||
|
if (a.family != FontFamily.MonoSpace && b.family == FontFamily.MonoSpace)
|
||||||
|
return 1;
|
||||||
|
if (a.face < b.face)
|
||||||
|
return -1;
|
||||||
|
if (a.face > b.face)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
//auto sorted = allFaces.sort!((a, b) => (a.family == FontFamily.MonoSpace && b.family != FontFamily.MonoSpace) || (a.face < b.face));
|
||||||
|
auto sorted = sort!((a, b) => fontComp(a, b) < 0)(allFaces);
|
||||||
|
|
||||||
|
//allFaces = allFaces.sort!((a, b) => a.family == FontFamily.MonoSpace && b.family == FontFamily.MonoSpace || a.face < b.face);
|
||||||
|
//for (int i = 0; i < allFaces.length; i++) {
|
||||||
|
foreach (face; sorted) {
|
||||||
|
if (face.family == FontFamily.MonoSpace)
|
||||||
|
faces ~= StringListValue(face.face, "*"d ~ toUTF32(face.face));
|
||||||
|
else
|
||||||
|
faces ~= StringListValue(face.face, toUTF32(face.face));
|
||||||
}
|
}
|
||||||
texted.addStringComboBox("editors/textEditor/fontFace", UIString("Font face"d), faces);
|
texted.addStringComboBox("editors/textEditor/fontFace", UIString("Font face"d), faces);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue