LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get outline of character from a .ttf font file

I am looking for a way to get the outline points/curves from a given character and .ttf (or from built in fonts if that is somehow easier). I am guessing if this does exist it is somewhere deep in the bowels of the code base. I have found some VIs that my be using something internally that might get me there. There is Get Text Rect.vi discussed in 

https://forums.ni.com/t5/LabVIEW/Calculating-Height-and-Width-of-Text-String-in-6-1/td-p/34865?profi...

that returns the bounding rectangle.

Also there is a VI in the library "Labview Icon API.lvlib" "Generate LV Icon Text Layer.vi" that seems like it might have the data I would need internal to it. 

And there is also the "NI_3D Picture control.lvlib:Create Text.vi" that puts text with a font from a .ttf file into a 3D scene object. 

I am not sure if any of these actually use the outline data I am looking for or if they somehow pass the information out to the graphics processor and it takes care of all of that.

I also found a windows thing https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getglyphoutlinea that looks like it might be the right direction but I have no idea how to implement it.

 

My alternative options I have thought of are all not pleasing.

1) Write a .ttf file parser myself to get at the data (really unpleasant to think about and probably not going to happen)

2) Use some other program to build my own data set of outlines character by character for some small number (1 to 3) of fonts and then store all of that data somewhere (Really tedious and I would really like the flexibility to use any font).

3) Display the character in a large font size in an indicator, get an image of the indicator, step through pixels and find edges between background and character. (this outline is then steppy and will have many more points than I want but could work in general)

 

Any great Ideas out there. How does the font rendering in labview work in general? Is that all handled by outside calls? What about when text is embedded in images or 3D scenes? Is there a way to get back the geometry of an object from a 3D Scene?

Any help is greatly appreciated.

0 Kudos
Message 1 of 2
(2,017 Views)

Quick follow up. I tried my hand at method 3

3) Display the character in a large font size in an indicator, get an image of the indicator, step through pixels and find edges between background and character. (this outline is then steppy and will have many more points than I want but could work in general)

It was able to generate an outline that looks ok zoomed out if I used a huge font (like 500) to do it. And It runs fairly quick. However it is not useful in the code I need it for as there are just too many edges. It need roughly 1000 times as many edges to get similar appearance as another method of generating the perimeter. Then my downstream code takes 10000 times longer. I really don't want to create my own library of fonts character by character. And I really would like something else to handle all of the character spacing ideally.

Is there a way to Pair down my steppy boundary (smooth it out and reduce line count)?

0 Kudos
Message 2 of 2
(1,982 Views)