Font menu with styled text

Me: M1 mini, Xojo 2022R1, desktop app

My app has a font menu that shows the fonts. Each appears in the system font.

Is there any way to show a font menu in which each font name is displayed in itself? For example, New Times Roman would appear in New Times Roman.

Or more generally, display a font with some style, perhaps bold?

On MacOS, you can add a picture to each new font menuitem that I’m adding to the font menu. Here’s a snippet of what I do for each menuitem, unfortunately it runs out of memory when used on Windows:

Sub AddFontSampleToMenuItem(m as MenuItem, FontNameStr as string)

Dim mp as Picture
Dim p as Picture
Dim h as integer
Dim w as integer

p=New Picture(20,20)

p.Graphics.TextSize=12
p.Graphics.TextFont=FontNameStr
p.Graphics.ForeColor=kBlackRGB
w=Ceil(p.Graphics.StringWidth(FontNameStr))
h=p.Graphics.TextHeight

if h>0 and w>0 and h<32767 and w<32767/2 then
  
p=new picture(w*2,h+4)
p.Graphics.TextSize=12
p.Graphics.TextFont=Astr
p.Graphics.ForeColor=kBlackRGB
p.Graphics.DrawString(FontNameStr, 10,p.Graphics.TextAscent+2)

mp=New Picture(200,16)
mp.Graphics.DrawPicture(p, 0,0,mp.Graphics.Width,mp.Graphics.Height,0,0,mp.Width,mp.Height)
m.Icon=mp

End If

Return
1 Like

In my apps, I show fonts in the same manner as Microsoft Word of Pages by using a listbox as the dropdown of a regular button.