• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Menu item correct size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Menu item correct size


  • Subject: Menu item correct size
  • From: Felipe Monteiro de Carvalho <email@hidden>
  • Date: Thu, 17 Sep 2009 11:17:15 -0300

Hello,

I would like to make the text in a menu item bold, while maintaining
everything else exactly like in other menu items. Reading and
searching I managed to find the appropriate routines to do this, but I
seam to have found a big problem. NSFont menuFontOfSize with 0 as the
font size doesn't give the correct menu font size, it gives a 13 font
size which is smaller then the 14 size of all other menu items.

Is there any reliable way to get the right font size?

If not, what is the recommended way to do this? Just hardcode 14 to
the menu font size? Is this size configurable or does it always stay
14? Or should I just add 1 to the default system font size?

Here is the code in Pascal:

FontManager := NSFontManager.sharedFontManager;
AttrStringFont := NSFont.menuFontOfSize(0); // 0 = default size
AttrStringFont.Handle :=
FontManager.convertFont_toHaveTrait_(AttrStringFont.Handle,
NSBoldFontMask);
AttrDictionary :=
NSDictionary.dictionaryWithObject_forKey(AttrStringFont.Handle,
objc.id(NSFontAttributeName));
AttrString := NSAttributedString.initWithString_attributes(ItemText,
CFDictionaryRef(AttrDictionary.Handle));
if AttrString.Handle <> nil then
 Result.setAttributedTitle(AttrString.Handle);

thanks,
--
Felipe Monteiro de Carvalho
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Menu item correct size
      • From: Peter Ammon <email@hidden>
  • Prev by Date: Reg: outlineView dataSource method outlineView:child:ofItem:
  • Next by Date: iPhone Pref changes
  • Previous by thread: Re: Reg: outlineView dataSource method outlineView:child:ofItem:
  • Next by thread: Re: Menu item correct size
  • Index(es):
    • Date
    • Thread