public void ChangeFont(NSFontManager sender) { var font = sender.ConvertFont(NSFont.SystemFontOfSize(NSFont.SystemFontSize)); Handler.Font = font != null ? new Font(new FontHandler(font)) : null; Handler.Callback.OnFontChanged(Handler.Widget, EventArgs.Empty); }
public void ChangeFont(NSFontManager sender) { // 選択されたフォントを取得する Label.Font = sender.ConvertFont(Label.Font); // 選択されたフォントで表示する Label.StringValue = Label.Font.FontName; }
public static NSFont ToNsFont(this Font font) { if (font == null) { return(NSFont.SystemFontOfSize(NSFont.SystemFontSize)); } NSFontManager fontManager = NSFontManager.SharedFontManager; NSFont theFont = fontManager.FontWithFamily(font.Name, getFontTraits(font), 0, font.Size); return(theFont); }
public void changeFont(NSFontManager sender) { var font = sender.ConvertFont(NSFont.SystemFontOfSize(NSFont.SystemFontSize)); if (font != null) { Handler.Font = new Font(Handler.Widget.Generator, new FontHandler(font)); } else { Handler.Font = null; } Handler.Widget.OnFontChanged(EventArgs.Empty); }
void PrepareTextAttributes() { mTextAttributes = new NSMutableDictionary(); NSFontManager fontManager = NSFontManager.SharedFontManager; NSFont font = NSFont.UserFontOfSize(75.0f); if (Bold) { font = fontManager.ConvertFont(font, NSFontTraitMask.Bold); } if (Italic) { font = fontManager.ConvertFont(font, NSFontTraitMask.Italic); } mTextAttributes.Add(NSStringAttributeKey.Font, font); mTextAttributes.Add(NSStringAttributeKey.ForegroundColor, NSColor.Black); }
public void ChangeFont(NSFontManager sender) { // 選択されたフォントを取得する TextField.Font = sender.ConvertFont(TextField.Font); TextField.StringValue = TextField.Font.FamilyName; }
public void ChangeFont (NSFontManager sender) { arcView.Font = sender.ConvertFont (arcView.Font); updateDisplay (); }
public void ChangeFont(NSFontManager sender) { arcView.Font = sender.ConvertFont(arcView.Font); updateDisplay(); }
public void ChangeFont(NSFontManager sender) { SetFont(sender.ConvertFont(myFont)); }
public static NSFont GetSystemFontOfSize(nfloat fontSize, nfloat weight) { // not possible to use NSFont.SystemFontOfSize because it supported only since macOS 10.11+ NSFont f = NSFont.SystemFontOfSize(fontSize);//, weight); NSFontManager manger = NSFontManager.SharedFontManager; // Full details here – https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSFontManager_Class/#//apple_ref/occ/instm/NSFontManager/convertWeight:ofFont: // // 1 – ultralight // 2 – thin // 3 – light, extralight // 4 – book // 5 – regular, display // 6 – medium // 7 – demi, demibold // 8 – semi, semibold // 9 – bold // 10 – extra, extrabold // 11 – heavy // 12 – black // 13 – ultrablack // 14 – extrablack int w = 5; if (weight == NSFontWeight.UltraLight) { w = 1; } else if (weight == NSFontWeight.Thin) { w = 2; } else if (weight == NSFontWeight.Light) { w = 3; } else if (weight == NSFontWeight.Regular) { w = 5; } else if (weight == NSFontWeight.Medium) { w = 6; } else if (weight == NSFontWeight.Semibold) { w = 8; } else if (weight == NSFontWeight.Bold) { w = 9; } else if (weight == NSFontWeight.Heavy) { w = 11; } else if (weight == NSFontWeight.Black) { w = 12; } NSFont ret = manger.FontWithFamily(f.FamilyName, manger.TraitsOfFont(f), w, fontSize); return(ret); }