Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411914 Posts in 69430 Topics- by 58477 Members - Latest Member: KriegsHetzer

June 10, 2024, 12:22:26 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Flash font embedding problem (font not showing)
Pages: [1]
Print
Author Topic: Flash font embedding problem (font not showing)  (Read 7551 times)
davidp
Level 6
*



View Profile WWW
« on: September 02, 2010, 01:11:32 PM »

So i've embededd font to my code:

Code:
[Embed(source = '../bin/44v2.ttf', fontFamily = "n_font")] private static var n_font:Class;

turned on embedFonts on text field:

Code:
textField.embedFonts = true;

and assigned font to formatting:

Code:
textFormat.font = "n_font";

but font doesn't show up :/ I've been using Arial as font before, white color and it was visible, so i know everything else should be working.

any ideas?

Logged

Sam
Level 3
***



View Profile WWW
« Reply #1 on: September 02, 2010, 02:09:04 PM »

In the same class as where you're embedding the font, add the code:

Code:
flash.text.Font.registerFont(n_font)

That's my best guess anyway.  Flash's font handling is largely cruel and mysterious.

The code I use has the embed specify a mimeType and a fontName instead of fontFamily.  I don't think it should matter, but anyway:

Code:
[Embed(source = 'visitor1.ttf', fontName = "Pixel", mimeType = "application/x-font-truetype")]
private var PixelFont:Class;

// later..

Font.registerFont(PixelFont)
//skipping the flash.text. prefix as FlashDevelop just adds in an import statement for the Font class for me automatically.
Logged
davidp
Level 6
*



View Profile WWW
« Reply #2 on: September 02, 2010, 09:33:45 PM »

still doesn't work :/


full code for font usage:

Code:
[Embed(source = '../bin/44v2.ttf', fontName = "n_font", mimeType = "application/x-font-truetype")] private static var n_font:Class;

public function addText():void
Code:
{
  flash.text.Font.registerFont(n_font);
  ammoText = new TextField();
  ammoFormat = new TextFormat();

  ammoText.background = false;
  ammoText.border = false;
  ammoText.embedFonts = true;

  ammoFormat.color = 0xFFFFFF;
  ammoFormat.size = 16;
  ammoFormat.font = "n_font";
}
Logged

bateleur
Level 10
*****



View Profile
« Reply #3 on: September 02, 2010, 11:53:30 PM »

I use CS4 rather than FlashDevelop, but there may be some similarities. I don't know whether your embed line is correct, but to use a font I'd do this:

Code:
static var gameFont:n_font = new n_font();

...

ammoFormat.font = gameFont.fontName;

ammoText.embedFonts = true;
ammoText.defaultFormat = ammoFormat;
ammoText.text = "Oh noes - out of boolits!";

(Although obviously I'd never have a classname beginning with a lowercase letter like that! Tongue)
Logged

davidp
Level 6
*



View Profile WWW
« Reply #4 on: September 03, 2010, 12:00:40 AM »

yeah, i haven't pasted the whoooole text function, but i have

Code:
ammoText.defaultFormat = ammoFormat;

in there too. it's too important to forgot about it, sloppy of me.
i'll try your method too, bateleur.

funny thing is i've been trying all kinds of different methods, but most of them are pretty much the same i'm already using but i don't see shit of my text now and that's really depressing.

hm, i'm not specifying weight and style, that could be a problem.
« Last Edit: September 03, 2010, 12:15:36 AM by davidp » Logged

bateleur
Level 10
*****



View Profile
« Reply #5 on: September 03, 2010, 02:30:25 AM »

If you trace out the font name property from an instance of the font created at runtime (as per my code example above), what does it say?
Logged

Draknek
Level 6
*


"Alan Hazelden" for short


View Profile WWW
« Reply #6 on: September 03, 2010, 04:08:09 AM »

If you're using Flex 4 to compile, they broke font embedding. You want:
Code:
[Embed(source = '../bin/44v2.ttf', fontFamily = "n_font", embedAsCFF="false")]

Or you can tell it to use the Flex 3 behaviour with the compiler parameter -compatibility-version=3.0.0
Logged

davidp
Level 6
*



View Profile WWW
« Reply #7 on: September 03, 2010, 07:06:21 AM »

everything was fine, except for missing this:

Code:
embedAsCFF = 'false'

so now i have:

Code:
[Embed(source = '../bin/44v2.ttf', fontFamily = "n_font", fontStyle = "normal", 
  fontWeight = "normal", mimeType = "application/x-font-truetype", embedAsCFF = "false")]
  private static var n_font:Class;

and

Code:
ammoFormat.font = "n_font";

works like a charm Smiley thank you all, you saved me again Kiss
Logged

agj
Level 10
*****



View Profile WWW
« Reply #8 on: September 03, 2010, 05:44:14 PM »

Man, I hate font embedding.
Logged

davidp
Level 6
*



View Profile WWW
« Reply #9 on: September 03, 2010, 10:59:57 PM »

why?
Logged

agj
Level 10
*****



View Profile WWW
« Reply #10 on: September 04, 2010, 12:17:12 PM »

Do you really have to ask why after this thread? It's a pain.
Logged

Nix
Guest
« Reply #11 on: September 06, 2010, 05:43:57 PM »

Do you really have to ask why after this thread? It's a pain.

Agreed. But at least it's one of those things that you don't have to touch once you get it working.
Logged
agj
Level 10
*****



View Profile WWW
« Reply #12 on: September 06, 2010, 06:48:44 PM »

Not really. Depends on what you're doing. If you're using the new text engine, embedded fonts are treated differently, for instance. I've had trouble embedding some fonts and not others, as well. It's all just full of complications.
Logged

tain
Level 0
*


PLEESTOP TO INFINITY!


View Profile
« Reply #13 on: September 30, 2010, 01:52:55 PM »

omg
i have been searching and searching.
i completely stopped using CS5 because of this.
i am so happy i can go back to it now.

Quote
embedAsCFF = "false"
works for me also!

so not intuitive solution and -1 for adobe but +1 for Draknek and TIG  Beer!
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic