CtrlCore, ide: Cocoa Ctrl+Space issue, CT_Font caching

git-svn-id: svn://ultimatepp.org/upp/trunk@12142 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-08-03 16:44:39 +00:00
parent a77c6e46df
commit 18bd1f3b00
3 changed files with 44 additions and 19 deletions

View file

@ -7,8 +7,8 @@
namespace Upp {
CTFontRef CT_Font(Font fnt)
{ // TODO: Caching (?)
CTFontRef CT_Font0(Font fnt, bool& synth)
{
CFRef<CFStringRef> s = CFStringCreateWithCString(NULL, ~fnt.GetFaceName(), kCFStringEncodingUTF8);
CFRef<CTFontRef> ctfont0 = CTFontCreateWithName(s, fnt.GetHeight(), NULL);
if(fnt.IsItalic() || fnt.IsBold()) {
@ -18,12 +18,40 @@ CTFontRef CT_Font(Font fnt)
if(fnt.IsItalic())
symbolicTraits |= kCTFontItalicTrait;
CGAffineTransform transform = CGAffineTransformIdentity;
return CTFontCreateCopyWithSymbolicTraits(ctfont0, fnt.GetHeight(),
CFRef<CTFontRef> ctfont = CTFontCreateCopyWithSymbolicTraits(ctfont0, fnt.GetHeight(),
&transform, symbolicTraits, symbolicTraits);
if(ctfont)
return ctfont.Detach();
synth = true;
}
return ctfont0.Detach();
}
CTFontRef CT_Font(Font fnt)
{
struct Entry {
Font font;
CTFontRef ctfont = NULL;
bool synth = false;
void Free() { if(ctfont) CFRelease(ctfont); ctfont = NULL; }
Entry() { font.Height(-22222); }
~Entry() { Free(); }
};
const int FONTCACHE = 64;
static Entry cache[FONTCACHE];
for(int i = 0; i < FONTCACHE; i++)
if(cache[i].font == fnt)
return cache[i].ctfont;
Entry& e = cache[Random(FONTCACHE)];
e.Free();
e.font = fnt;
e.ctfont = CT_Font0(fnt, e.synth);
return e.ctfont;
}
GlyphInfo GetGlyphInfoSys(CTFontRef ctfont, int chr)
{
GlyphInfo gi;
@ -49,7 +77,7 @@ CommonFontInfo GetFontInfoSys(Font font)
{
CommonFontInfo fi;
String path;
CFRef<CTFontRef> ctfont = CT_Font(font);
CTFontRef ctfont = CT_Font(font);
if(ctfont) {
#if 0
DDUMP(font);
@ -84,7 +112,7 @@ CommonFontInfo GetFontInfoSys(Font font)
GlyphInfo GetGlyphInfoSys(Font font, int chr)
{
LTIMING("GetGlyphInfoSys");
CFRef<CTFontRef> ctfont = CT_Font(font);
CTFontRef ctfont = CT_Font(font);
return GetGlyphInfoSys(ctfont, chr);
}
@ -151,9 +179,8 @@ void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font fon
CGContextRestoreGState(cgHandle);
return;
}
CFRef<CTFontRef> ctfont = CT_Font(font);
CFRef<CGFontRef> cgFont = CTFontCopyGraphicsFont(ctfont, NULL);
CFRef<CGFontRef> cgFont = CTFontCopyGraphicsFont(CT_Font(font), NULL);
CGContextSetFont(cgHandle, cgFont);

View file

@ -1,11 +1,7 @@
sooner:
- X11 on option
- OSX flag
- flagCOCOA
- USEMALLOC
- triple click, hold...
- Ctrl+Space assist
- package organizer initial size too small
- rect loop (ViewDraw)
@ -15,28 +11,24 @@ sooner:
- not all additional cursors are correct
- Synthetise fonts
- Sort fonts
- fix link options (joining link options missing space)
later:
- void WakeUpGuiThread(void)
- fullscreen mode issues
- missing cursors (add to iml, use undocumented cursor)
- PrinterJob
- DrawDragRect
- CT_Font caching
- CommonFontInfo GetFontInfoSys(Font font) metrics
- ROTATED TEXT
- GetGlyphInfoSys metrics
- EndSession ?
- Image::Arrow etc...
- ignoreclick
- event flags
- CachedSetColorKeepAlpha optimize out
- use NSView:needsToDrawRect: for IsPaintingOp
- implement missing Draw ops
- fix rotated text
- fix link options (joining link options missing space)
- set application icons
- fix resizing arrows
- RenderCharacterSys
@ -53,6 +45,11 @@ void SystemDraw::DrawArcOp(const Rect& rc, Point start, Point end, int width, Co
done:
- CT_Font caching
- X11 on option
- OSX flag
- flagCOCOA
- USEMALLOC
- ide: Alt+Tab does not work
- Ctrl+Tab
- Ctrl+Mouse wheel
@ -81,3 +78,4 @@ done:
- Open/OpenMain variants
- initial focus
- Switch does not seem to work for some reason
- Image::Arrow etc...

View file

@ -93,7 +93,7 @@ KEY(QTF, "QTF designer", K_ALT_Q)
KEY(XML, "XML view", K_ALT_X)
KEY(JSON, "JSON view", K_ALT_N)
KEY(ASERRORS, "Interpret text as error list", 0)
KEY(ASSIST, "Assist", ' '|K_CTRL)
KEY(ASSIST, "Assist", K_CTRL|K_SPACE)
KEY(ABBR, "Complete abbreviation", K_CTRL_PERIOD)
KEY(GO_TO_LINE, "Go to line..", K_CTRL|K_SHIFT_G)
KEY(DCOPY, "Copy as definition/declaration", K_ALT_C)