> this works fine, and I have a popup with all the font families listed, each 
> one rendered with the correct font, but the result is pretty ugly, because 
> each font renders differently in size and space above and below, resulting in 
> a list of items with different heights and position of the string relative to 
> the menuitem rect.

for me, it looks good. But I see a problem with extra space below/after the 
font line.

But I would calculate height and only show those who fit in size like this 
code: 


Sub ApplyFontsToItems(xp as PopupMenu)
  #if TargetCocoa then
    dim g as new NSGraphicsMBS
    dim p as NSPopUpButtonMBS = xp.NSPopUpButtonMBS
    dim m as NSMenuMBS = p.menu
    dim si as new NSSizeMBS(1000, 1000)
    dim fontSize as Double = xp.TextSize
    if fontsize <= 8 then
      fontsize = NSFontMBS.systemFontSize
    end if
    
    dim mu as integer = m.numberOfItems-1
    for mi as integer = 0 to mu
      
      dim item as NSMenuItemMBS = m.Item(mi)
      dim name as string = item.Title
      
      dim f as NSFontMBS = NSFontMBS.fontWithName(name, fontSize)
      dim a as new NSMutableAttributedStringMBS
      if a.initWithString(name) then
        dim r as new NSRangeMBS(0, a.length)
        a.addAttribute(a.NSFontAttributeName, f, r)
        
        dim re as NSRectMBS = g.boundingRectWithSize(a, si, 0)
        
        if re.Height <= 22 then 
          // only apply if height is not too much
          item.attributedTitle = a
        end if
      end if
    next
  #endif
End Sub



Greetings
Christian

-- 
Read our blog about news on our plugins:

http://www.mbsplugins.de/

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
mbsplugins@monkeybreadsoftware.info
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Reply via email to