Custom Font problems


#1

Hi,

i try to use custom, embeded fonts, but it does not work.

I have uses the FontSerializer and with the BinaryBuilder i have created the .cpp and .h file. That files I have included in my project and like to use that font e.g. for a label text.

Here a sample code (i found in the forum).

Font* myNewFont = NULL;
MemoryInputStream font_stream(MyFont::MyFont_ttf, MyFont::MyFont_ttfSize, false);
Typeface* typeFace = new CustomTypeface (font_stream);
myNewFont = new Font (typeFace);
 

aLabel->setFont(*typeFace);

But the label did not use this font to render the text.

What do I wrong? 

Thanks


#2

If you have no glyph in your font, then a fallback font will be used anyway.


#3

If you used the font serialiser, then why is it called "MyFont.ttf"?

Anyway, nowadays I'd actually recommend using this instead: http://www.juce.com/forum/topic/embedded-font-support


#4

If you used the font serialiser, then why is it called "MyFont.ttf"?

I have used the original font file name with extension for the generated.

Anyway, nowadays I'd actually recommend using this instead: http://www.juce.com/forum/topic/embedded-font-support

I will try this way now.

 

Thanks!


#5

This works very well!

I have spend two days to read across the forum and tried X-ways - but/and this I did not find in your api docu.

Thanks a lot!!!


#6

Good point - I'll add a note somewhere about this..


#7

I have tested it on iOS, but it's not working. Is there also an easy way to get it working on iOS?


#8

Are you sure? iOS uses the same code as for OSX.


#9

Little moment, i have only tested it with Linux and iOS yet.


#10

Yes, on OSX it works (tested on 10.9).


#11

Excuse me! There was some out commented code for IOS!

It works!!


#12

Hi monotomy,

 

can you share with us how you made it ?

 

Thanks,

Paulo


#13

Hi Paulo,

sorry, I was a week offline.

You simply add the font as binary resource to a gui file/class with the introjucer and then use the resource like this:

a_label->setFont( 
  Typeface::createSystemTypefaceFor(
    font_added_as_resource_in_jucer_ttf,
    font_added_as_resource_in_jucer_ttfSize ) );

Thats all.
Does this help?

Cheers