Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Highlighted
Developer
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified
Accepted Solution

Embedded font does not work on BB10

[ Edited ]

Hello,

 

I'm trying to port my PlayBook app to BB10, but I can't make custom fonts to work.

 

Here is the code:

 

[Embed(source="assets/segoescb.ttf", fontName="Font1", fontStyle="normal", fontWeight= "normal", mimeType="application/x-font", embedAsCFF="false")]
public static const Myfont:Class;


//...

myLabel.text = "Hello World!";
myLabel.height = 80;
myLabel.width = 200;
			
var myFormat:TextFormat = new TextFormat();
myFormat.font = "Font1";
myFormat.color = 0x00FF00;
myFormat.size = 80;

myLabel.format = myFormat;			

 In the app the size and color of TextFormat are applied fine, but font is not loaded and standard font used instead.

 

I checked similar posts here, but there are either no answer or the problem is not the same.

 

The code looks fine for AIR API, and moreover, it works fine for PlayBook.

 

Are there any specifics for BB10 in fonts embedding?

 

Any help is highly appreciated.

Thanks

Developer
Posts: 194
Registered: ‎11-12-2010
My Device: Not Specified

Re: Embedded font does not work on BB10

I've never embedded fonts this way (I do it in Flash & export a .swc), but as a guess you probably have to create an instance of your font class. Something like this:

 

private var myFont:Myfont = new Myfont();


//and then for your format
	
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont.name;

 (Sorry, can't try it out myself right now - so it's just an idea)

 


My app : Get set - Get up!   Get ready for the snooze revolution.

Developer
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: Embedded font does not work on BB10

Thanks for reply, but I tried that way without success.

Is there a way to export font to .swc from Flash Builder?
Developer
Posts: 194
Registered: ‎11-12-2010
My Device: Not Specified

Re: Embedded font does not work on BB10

Hm, not that I know of ...

 

And you're right, my suggestion above was nonsense, there should be no need to instantiate the embedded font. I actually just read up on it and then played around a bit - but I can't get it to work either ... Hopefully someone else can shed light on this!

 


My app : Get set - Get up!   Get ready for the snooze revolution.

Developer
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: Embedded font does not work on BB10

BTW, I found that there is no .embedFonts property for qnx.fuse.ui.text.Label (BB10 SDK), which was in qnx.ui.text.Label in PlayBook SDK.

 

Can this be a real source of problem with embedded font?

Developer
Posts: 194
Registered: ‎11-12-2010
My Device: Not Specified

Re: Embedded font does not work on BB10

Here is another complete stab in the dark ... are you using FlashBuilder 4.7 ?  I just happened to read something about the new compiler ASC 2.0 that's used in 4.7 and it says

 

"Font transcoding has been removed from [Embed] syntax. Fonts should be pre-transcoded and embedded as a SWF, which can be performed using a tool like fontswf or Flash Professional CS6."

 

If I understand it right, I guess that could be the cause of your trouble ... (?)

(The info is from http://www.bytearray.org/?p=4789 )

 

 


My app : Get set - Get up!   Get ready for the snooze revolution.

Developer
Posts: 93
Registered: ‎02-05-2011
My Device: Not Specified

Re: Embedded font does not work on BB10

I'm using both FB 4.6 (win) and 4.7 (mac) on different machines but issue is the same.
As I understand, the problem is in latest BB10 AIR SDK.

Is there any alternative solution to embed font as SWC/SWF without Flash Pro? I don't like the idea to install another IDE just to make one file with font...

Developer
Posts: 194
Registered: ‎11-12-2010
My Device: Not Specified

Re: Embedded font does not work on BB10

It mentions fontswf, which apparently is part of the flex SDK

http://rodneypillay.wordpress.com/2010/05/18/fontswf-utility-in-flex-sdk-4/

 


My app : Get set - Get up!   Get ready for the snooze revolution.

New Contributor
Posts: 8
Registered: ‎12-18-2012
My Device: Playbook
My Carrier: None

Re: Embedded font does not work on BB10

I use font embedding and have recently ported my apps over to BB10. I am using Flash Builder 4.6 and the BB10 3.0.0 SDK. I haven't experienced any problems. I've pasted some of my code to hopefully help you identify the problem.

 

This is my embed code.

       

[Embed(source="embedded_assets/fonts/ssm_ldo.ttf", fontFamily="ssm_ldo", unicodeRange = "U+0020-007E", embedAsCFF="false")]
public static const SSM_LDO_FontClass:Class;

 

Here's the usage code.

 

var l_text:TextField = new TextField();
var l_format:TextFormat = new TextFormat();
l_format.font = "ssm_ldo";
/* Other format properties set here. */

l_text.embedFonts = true;
l_text.defaultTextFormat = l_format;
/* Other field properties set here. */
l_text.text = a_string;

 

Ken Tylman
Grim Guy Gameworks
BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: Embedded font does not work on BB10

There is a big difference between the internal text renderer used on PlayBook versus BB10.

 

On PlayBook Label used a TextField to render it's text, which is extremely limited. 

 

On BB10 Label, and all text components for that matter, use the Flash Text Engine( FTE ) to render text. This was done so that we could support complex script, such as Thai, right-to-left text and also be able to provide other platform behaviors such as text selection, auto complete, etc....

 

I haven't done much embedded font stuff, but I do know that you must set embedAsCFF = true in order for it to work. There may be some more work to do in the text components to make this work as well. If setting embedAsCFF to true does not fix the issue, please file a issue tracker ticket and attach your font that you are trying to embed. 

 

Julian