LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Font selection

Solved!
Go to solution

The property nodes for controls allow one to specify a font name, but how is one meant to know what choices are available? Is it possible to get a list of possible font names, then ideally display this to a user as a drop-down menu?

0 Kudos
Message 1 of 7
(3,424 Views)
Solution
Accepted by topic author owen.premecha

Ah, good question! I saw a couple of discussions on this forum dealing with this, and I have to admit I don't remember what the answer was, but for sure if you only want this to work on Windows you'll find a way, I'm pretty sure it's easy to do with .NET.

With a quick google search you'll find that in windows 7 fonts files are stored in C:\Windows\fonts, so that the system can use the fonts you might have to register them in some sort of way (that's only if you want to add non default fonts) so they appear in the registry somewhere under this HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 2 of 7
(3,409 Views)

thanks for your help. After you suggested accessing the registry, I managed to find some code that does this:

http://forums.ni.com/t5/LabVIEW/How-to-get-list-of-avaiable-fonts/m-p/451002?query.id=8609#M219140

Message 3 of 7
(3,386 Views)

Cool!

Thanks for the link!


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 7
(3,372 Views)

I tried unsuccessfully to use the .NET Font dialog (as suggested here). The Font dialog did not open in front of the calling VI, and I was unable to get a reference to the window with calls to the user32.dll FindWindow and FindWindowEx methods presumably because it is not listed in the taskbar.

 

Instead, I used a .NET constructor node linked to System.Drawing, System.Drawing.Text, InstalledFontCollection. You can pull out the Families property and read each property's Name. This gives you an alphabetized list of all fonts installed on the system. Shove that into a ring control to give your users an easy way to select a font. See the snippet below. You could also get fancy and search for a particular default font and select it if it's found.

 

InstalledFontCollection.png

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
Message 5 of 7
(3,318 Views)

I tried both registry and .net approach, and it seems they yield different results. They both also differ from LVs list. I installed the Tratex font and in the .net it didn't show, but in the registry one it did. I also installed the .pfm version, which the registry version made no difference of, but LV listed 2 fonts ...

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 7
(3,238 Views)

Hello Yamaeda,

 

It appears as though this forum post has already been marked as being solved, and it was last updated in 2013.

 

Please make a new forum post, referencing this one.  This will increase the visibility of your issue.

 

Regards,

Thomas C.
FlexRIO Product Support Engineer
National Instruments
0 Kudos
Message 7 of 7
(3,199 Views)