davidp
|
|
« on: September 02, 2010, 01:11:32 PM » |
|
So i've embededd font to my code: [Embed(source = '../bin/44v2.ttf', fontFamily = "n_font")] private static var n_font:Class; turned on embedFonts on text field: textField.embedFonts = true; and assigned font to formatting: 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
|
|
« Reply #1 on: September 02, 2010, 02:09:04 PM » |
|
In the same class as where you're embedding the font, add the 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: [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
|
|
« Reply #2 on: September 02, 2010, 09:33:45 PM » |
|
still doesn't work :/ full code for font usage: [Embed(source = '../bin/44v2.ttf', fontName = "n_font", mimeType = "application/x-font-truetype")] private static var n_font:Class; public function addText():void { 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
|
|
« 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: 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! )
|
|
|
Logged
|
|
|
|
davidp
|
|
« Reply #4 on: September 03, 2010, 12:00:40 AM » |
|
yeah, i haven't pasted the whoooole text function, but i have 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
|
|
« 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
|
|
« Reply #6 on: September 03, 2010, 04:08:09 AM » |
|
If you're using Flex 4 to compile, they broke font embedding. You want: [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
|
|
« Reply #7 on: September 03, 2010, 07:06:21 AM » |
|
everything was fine, except for missing this: so now i have: [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 ammoFormat.font = "n_font"; works like a charm thank you all, you saved me again
|
|
|
Logged
|
|
|
|
agj
|
|
« Reply #8 on: September 03, 2010, 05:44:14 PM » |
|
Man, I hate font embedding.
|
|
|
Logged
|
|
|
|
davidp
|
|
« Reply #9 on: September 03, 2010, 10:59:57 PM » |
|
why?
|
|
|
Logged
|
|
|
|
agj
|
|
« 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
|
|
« 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!
|
|
« 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. embedAsCFF = "false" works for me also! so not intuitive solution and -1 for adobe but +1 for Draknek and TIG
|
|
|
Logged
|
|
|
|
|