From be668a965a382fc1de2f9711282b5ec897d55ca5 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 4 Apr 2014 14:52:38 -0400 Subject: Fixed Mac OS X Button appearance; turns out it was using the wrong font. Also updated the TODO file to mark this fix and remove other stale/already fixed details. --- bleh_darwin.m | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'bleh_darwin.m') diff --git a/bleh_darwin.m b/bleh_darwin.m index 720da0f..e4b774f 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -21,6 +21,7 @@ Go wrapper functions (bleh_darwin.go) call these directly and take care of stdin #include #include #include +#include /* exception to the above: cgo doesn't like Nil and delegate_darwin.go has //export so I can't have this there */ Class NilClass = Nil; @@ -317,3 +318,33 @@ struct xpoint getTranslatedEventPoint(id self, id event) ret.y = (int64_t) p.y; return ret; } + +/* +we don't need this here technically — it can be done in Go just fine — but it's easier here +*/ + +static id c_NSFont; +static SEL s_setFont; +static SEL s_systemFontOfSize; +static SEL s_systemFontSizeForControlSize; +static BOOL setFont_init = NO; + +static CGFloat (*objc_msgSend_cgfloatret)(id, SEL, ...) = + (CGFloat (*)(id, SEL, ...)) objc_msgSend_fpret; + +void objc_setFont(id what, unsigned int csize) +{ + CGFloat size; + + if (setFont_init == NO) { + c_NSFont = objc_getClass("NSFont"); + s_setFont = sel_getUid("setFont:"); + s_systemFontOfSize = sel_getUid("systemFontOfSize:"); + s_systemFontSizeForControlSize = sel_getUid("systemFontSizeForControlSize:"); + setFont_init = YES; + } + + size = objc_msgSend_cgfloatret(c_NSFont, s_systemFontSizeForControlSize, (NSControlSize) csize); + objc_msgSend(what, s_setFont, + objc_msgSend(c_NSFont, s_systemFontOfSize, size)); +} -- cgit v1.2.3