mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-17 09:29:30 +08:00
Menu bar font fix
This commit is contained in:
parent
cf23bffc67
commit
26ed8002b9
@ -578,30 +578,26 @@ id processCheckboxMenuItem(Menu *menu, id parentmenu, const char *title, const c
|
|||||||
|
|
||||||
id createAttributedString(const char* title, const char* fontName, int fontSize, const char* RGBA) {
|
id createAttributedString(const char* title, const char* fontName, int fontSize, const char* RGBA) {
|
||||||
|
|
||||||
// Process Menu Item attributes
|
// Create new Dictionary
|
||||||
id dictionary = ALLOC_INIT("NSMutableDictionary");
|
id dictionary = ALLOC_INIT("NSMutableDictionary");
|
||||||
|
|
||||||
// Process font
|
|
||||||
CGFloat fontSizeFloat = (CGFloat)fontSize;
|
CGFloat fontSizeFloat = (CGFloat)fontSize;
|
||||||
|
|
||||||
// Check if valid
|
// Use default font
|
||||||
id fontNameAsNSString = str(fontName);
|
id font = ((id(*)(id, SEL, CGFloat))objc_msgSend)(c("NSFont"), s("menuBarFontOfSize:"), fontSizeFloat);
|
||||||
id font = ((id(*)(id, SEL, id, CGFloat))objc_msgSend)(c("NSFont"), s("fontWithName:size:"), fontNameAsNSString, fontSizeFloat);
|
|
||||||
if( font == NULL ) {
|
// Check user supplied font
|
||||||
bool supportsMonospacedDigitSystemFont = (bool) ((id(*)(id, SEL, SEL))objc_msgSend)(c("NSFont"), s("respondsToSelector:"), s("monospacedDigitSystemFontOfSize:weight:"));
|
if( STR_HAS_CHARS(fontName) ) {
|
||||||
if( supportsMonospacedDigitSystemFont ) {
|
id fontNameAsNSString = str(fontName);
|
||||||
font = ((id(*)(id, SEL, CGFloat, CGFloat))objc_msgSend)(c("NSFont"), s("monospacedDigitSystemFontOfSize:weight:"), fontSizeFloat, (CGFloat)NSFontWeightRegular);
|
id userFont = ((id(*)(id, SEL, id, CGFloat))objc_msgSend)(c("NSFont"), s("fontWithName:size:"), fontNameAsNSString, fontSizeFloat);
|
||||||
} else {
|
if( userFont != NULL ) {
|
||||||
font = ((id(*)(id, SEL, CGFloat))objc_msgSend)(c("NSFont"), s("menuFontOfSize:"), fontSizeFloat);
|
font = userFont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add font to dictionary
|
// Add font to dictionary
|
||||||
id fan = lookupStringConstant(str("NSFontAttributeName"));
|
id fan = lookupStringConstant(str("NSFontAttributeName"));
|
||||||
msg_id_id(dictionary, s("setObject:forKey:"), font, fan);
|
msg_id_id(dictionary, s("setObject:forKey:"), font, fan);
|
||||||
id offset = msg_float(c("NSNumber"), s("numberWithFloat:"), (float)0.0);
|
|
||||||
id offsetAttrName = lookupStringConstant(str("NSBaselineOffsetAttributeName"));
|
|
||||||
msg_id_id(dictionary, s("setObject:forKey:"), offset, offsetAttrName);
|
|
||||||
// RGBA
|
// RGBA
|
||||||
if( RGBA != NULL && strlen(RGBA) > 0) {
|
if( RGBA != NULL && strlen(RGBA) > 0) {
|
||||||
unsigned short r, g, b, a;
|
unsigned short r, g, b, a;
|
||||||
|
Loading…
Reference in New Issue
Block a user