CtrlCore: Cocoa: Fonts are now sorted by name

git-svn-id: svn://ultimatepp.org/upp/trunk@12192 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-08-26 12:53:25 +00:00
parent d3ad7c1528
commit b962ef83c2
2 changed files with 23 additions and 19 deletions

View file

@ -137,40 +137,44 @@ GlyphInfo GetGlyphInfoSys(Font font, int chr)
Vector<FaceInfo> GetAllFacesSys()
{
Index<String> facename;
Index<bool> fixedpitch;
facename.Add("Arial"); // TODO: This should be default GUI font
facename.Add("Times New Roman");
facename.Add("Arial");
facename.Add("Courier New");
int oi = facename.GetCount();
AutoreleasePool __;
CFRef<CTFontCollectionRef> collection = CTFontCollectionCreateFromAvailableFonts(0);
if(collection) {
CFRef<CFArrayRef> fonts = CTFontCollectionCreateMatchingFontDescriptors(collection);
if(fonts) {
CFRef<CTFontCollectionRef> collection = CTFontCollectionCreateFromAvailableFonts(0);
if(collection) {
CFRef<CFArrayRef> fonts = CTFontCollectionCreateMatchingFontDescriptors(collection);
if(fonts) {
int count = CFArrayGetCount(fonts);
for(int i = 0; i < count; ++i) {
for(int i = 0; i < count; ++i) {
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fonts, i);
CFRef<CFStringRef> family_name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
facename.FindAdd(ToString(family_name));
}
}
}
}
}
Vector<String> h = facename.PickKeys();
Sort(SubRange(h, oi, h.GetCount() - oi));
Vector<FaceInfo> r;
for(String s : facename) {
FaceInfo& fi = r.Add();
for(String s : h) {
FaceInfo& fi = r.Add();
fi.name = s;
fi.info = Font::TTF;
CFRef<CFStringRef> fs = CFStringCreateWithCString(NULL, ~s, kCFStringEncodingUTF8);
CFRef<CTFontRef> ctfont = CTFontCreateWithName(fs, 12, NULL);
if(CTFontGetSymbolicTraits(ctfont) & kCTFontMonoSpaceTrait)
fi.info |= Font::FIXEDPITCH;
}
return r;
CFRef<CTFontRef> ctfont = CTFontCreateWithName(fs, 12, NULL);
if(CTFontGetSymbolicTraits(ctfont) & kCTFontMonoSpaceTrait)
fi.info |= Font::FIXEDPITCH;
}
return r;
}
String GetFontDataSys(Font font)

View file

@ -2,9 +2,7 @@ sooner:
- default GUI font
- minimize, maximaze
- numpad Enter does not do K_ENTER
- Sort fonts
- not all additional cursors are correct
- fix package organiser link options (joining link options missing space)
@ -12,6 +10,7 @@ sooner:
later:
- apple debugger
- package organizer initial size too small
- void WakeUpGuiThread(void)
- fullscreen mode issues
@ -39,6 +38,7 @@ void SystemDraw::DrawArcOp(const Rect& rc, Point start, Point end, int width, Co
done:
- numpad Enter does not do K_ENTER
- Synthetise fonts
- RenderCharacterSys
- ROTATED TEXT