How do I import a TrueType font?


#1

I purchased a license to bundle an embedded TrueType font to use solely for my application’s usage to display its interface (Helvetica Neue fyi).

Using Juce, how do I import the outlines so that I can use the font? I can’t require that the user add the font to their Windows Fonts (or Macintosh, or Linux) since its a license only to allow embedded usage.

Do I need to use FreeType somehow?


#2

Have a look at the CustomTypeface class.


#3

Thanks for getting back to me. I saw the CustomTypeface class but it seems I have to manually add each glyph, producing my own juce_Path object for each glyph?


#4

No. Look at addGlyphsFromOtherTypeface() and writeToStream().


#5

Hmm…I think there is some confusion

I want to go from my Truetype Font —> to a juce_Typeface

All I have is the font as a binary true type font file. I use the juce binarybuilder to turn it into a byte array in my application and I would like to load that up into a juce_Typeface so I can use it to draw.


#6

did you run across this post when searching the forum?
http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=5699&hilit=Custom+Typeface&p=32110#p32063

it’s a nice round-up of all the steps required to convert, embed and use a custom font in your app.


#7

Oh! That is quite informative.

So they are saying, I should first install the font on my development system, export it using the provided command line application into a “Juce-formatted font file” and then embed that in my application so I can produce a juce_Typeface.

Where does the hinting come into play?


#8

The hinting usually takes place when you render the typeface, not when saving it. And AFAIK, there’s no hinting in the JUCE font rendering.


#9

How can I install a truetype font file into the Windows or Mac operating system at startup, so that Juce will recognize it during enumeration?

I tried AddFontResource on Windows but juce did recognize it.


#10

There's nothing in juce that will help install a font file, you'd need to use OS-specific calls.

The way I normally work is to load custom fonts from memory using Typeface::createSystemTypefaceFor()