View unanswered posts | View active topics



Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Embedding font unicode ranges 
Author Message
Member

Joined: Tue May 27, 2008 6:37 pm
Posts: 25
Reply with quote
If I embed my fonts in an application like this, everything works fine:
Code:
   [Embed(source="/fonts/SpecificFontFileName.otf",
                    fontName="titleFont",
                    mimeType = "application/x-font")]         
         var TitleFontEmbed:Class;   


However, that is really not going to cut it for deployment versions of any app because the app is embedding way more characters than are needed. So I've read that it is possible to embed unicode ranges by adding the following param:



Code:
   unicodeRange="englishRange"


I've also heard possibly:
Code:
   unicodeRange="English"


...though neither seem to work for me. Any suggestions?


Tue May 27, 2008 6:42 pm
Profile
Member

Joined: Tue May 27, 2008 6:37 pm
Posts: 25
Reply with quote
Post 
OK, so it appears that this works...

Code:
unicodeRange='U+0020-U+007E'


...or at least it doesn't throw an error when compiling.
but the output swf size doesn't look any smaller. hmmm maybe caching?


Tue May 27, 2008 6:54 pm
Profile
Member

Joined: Tue May 27, 2008 6:37 pm
Posts: 25
Reply with quote
Post 
... ah nevermind. recompiling for Release sets it to the correct filesize.
Hope this helps someone else


Tue May 27, 2008 6:56 pm
Profile
Member

Joined: Mon Jun 18, 2007 2:57 pm
Posts: 117
Reply with quote
Post 
Make sure that when changing to debug to release you aren't just removing the debug data from the swf. Specifying the encode characters should lower your filesize in all instances. Please keep us up to date on your solution, font embedding is one of the things I still use the Flash IDE for.

_________________
flash games developer: http://www.urbansquall.com
personal blog and portfolio: http://www.yayitsandrew.com


Thu May 29, 2008 1:55 pm
Profile WWW
Member

Joined: Tue May 27, 2008 6:37 pm
Posts: 25
Reply with quote
Post 
yup, setting the range like this is working correctly. it is just putting in the 90 or so characters for lowercase, caps, punctuation and numerals.

exporting the file for release without the ranges clocks the filesize in at 46691 bytes in this case

exporting the file for release with the ranges specified clocks the filesize in at 28011 bytes

so i think you can safely assume that this is the way to go for embedding fonts.

here is the breakdown of unicode ranges from the flex docs:

U+0020-U+0040, /* Punctuation, Numbers and Symbols */
U+0041-U+005A, /* Upper-Case A-Z */
U+005B-U+0060, /* Punctuation and Symbols */
U+0061-U+007A, /* Lower-Case a-z */
U+007B-U+007E; /* Punctuation and Symbols */


but just specifying U+0020-U+007E will get you all of the above.


Thu May 29, 2008 2:27 pm
Profile
Member

Joined: Tue May 27, 2008 6:37 pm
Posts: 25
Reply with quote
Post 
nice one for a sticky!

i forgot to mention also, that if you want to include ranges that are non-sequential, just delimit them with a comma:

Code:

unicodeRange='U+0020-U+007E, U+005B-U+0060, U+007B-U+007E'



Thu May 29, 2008 8:42 pm
Profile
Member

Joined: Thu Oct 02, 2008 11:01 am
Posts: 31
Reply with quote
Great post! It helped me a lot. Thanks :D
I would vote for sticky.


Wed Nov 12, 2008 1:43 pm
Profile
Member

Joined: Thu Sep 25, 2008 9:23 am
Posts: 20
Reply with quote
Would like to recommend this page: http://rishida.net/scripts/uniview/conversion. This will convert any character to Unicode U+hex notation.


Tue Apr 14, 2009 5:48 am
Profile
Member

Joined: Mon Jun 09, 2008 12:54 pm
Posts: 5
Location: Sweden
Reply with quote
I can't find any information about this, and perhaps it's not possible to do... But I figured that if I made a simple class with a bunch of static constants specifying different unicode ranges, I could use them in the Embed statement:
Code:
[Embed(systemFont="Arial", fontName = "myArial", mimeType = "application/x-font", unicodeRange=FontUtils.PUNCTUATION)]


But I get "invalid Unicode range 'PUNCTUATION' " from the compiler.

Is it illegal code or is it something I overlooked?

Code:
public class FontUtils
   {
      
      public static const LOWERCASE_SWEDISH_CHARS:String    = "U+00E5, U+00E4, U+00F6, U+00E9";
      public static const UPPERCASE_SWEDISH_CHARS:String    = "U+00C5, U+00C4, U+00D6, U+00C9";
      public static const NUMBER_CHARS:String          = "U+0030-U+0039";
      public static const UPPERCASE_A_TO_Z:String       = "U+0041-U+005A";
      public static const LOWERCASE_A_TO_Z:String       = "U+0061-U+007A";
      public static const PUNCTUATION:String             = "U+005B-U+0060";
      public static const STANDARD_SWEDISH:String       = LOWERCASE_A_TO_Z + ", " + UPPERCASE_A_TO_Z + ", " + LOWERCASE_SWEDISH_CHARS + ", " + UPPERCASE_SWEDISH_CHARS + ", " + NUMBER_CHARS + ", " + PUNCTUATION;
      
      
      
   }


Sun Apr 26, 2009 3:55 pm
Profile
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1223
Location: Grizzly Flats, CA
Reply with quote
I think that the EMBED tag needs to be a literal value that the compiler will understand. It looks like you can't create a class to represent the characters you are looking for, but perhaps you could create snippets instead?


Sun Apr 26, 2009 7:35 pm
Profile WWW
Member

Joined: Mon Aug 17, 2009 6:52 am
Posts: 6
Location: Yogyakarta, Indonesia
Reply with quote
Code:
[Embed(source="../../../../../lib/calibri.ttf", fontName="MyCalibri", mimeType="application/x-font")]


thats the code but its error somehow....

C:\Documents and Settings\rkits\My Documents\navimp\src\com\wordpress\aqquoz\navimp\Main.as(14): col: 4: Error: An Embed variable must not have an existing value.

anyone know how to embed font for noob...

thx...


Tue Aug 25, 2009 4:19 pm
Profile YIM WWW
Member

Joined: Sun May 11, 2008 3:01 pm
Posts: 895
Reply with quote
This looks like you have declared this [Embed] elsewhere with exact same settings. So, compiler is trying to tell you that you're about to import the same font twice, and, you should probably consider removing one of the imports.

I have realized that the meaning of the error is in fact different. Most of the times when you will get this error it will mean that the carrier variable, on which you are embedding something (not necessarily a font), has some value assigned to it - you should remove the initializer. The initializer is created by compiler when processing your class, but once it finds that the variable already has one, it will prompt you to remove it.
Typically the erroring place would look like so:
Code:
[Embed(source='...')]
private var foo:Class = new SomeThingUnrelated();

to fix it:
Code:
[Embed(source='...')]
private var foo:Class;

_________________
http://www.couchsurfing.com/people/wvxvw


Mon Jan 11, 2010 12:28 am
Profile
Member

Joined: Thu Apr 30, 2009 1:03 pm
Posts: 37
Reply with quote
How to find out the unicode ranges? Does anybody know the Thai alphabet?


Mon Apr 05, 2010 3:32 pm
Profile
Member

Joined: Sun May 11, 2008 3:01 pm
Posts: 895
Reply with quote
Start + R > charmap ?

_________________
http://www.couchsurfing.com/people/wvxvw


Fri Apr 23, 2010 6:41 pm
Profile
Member

Joined: Tue Apr 22, 2008 2:53 pm
Posts: 3
Location: Dnipropetrovs'k, Ukraine
Reply with quote
Also you may use this online service: http://rishida.net/tools/conversion/

_________________
Only strong survive © Allen Iverson


Mon Apr 26, 2010 3:46 pm
Profile ICQ WWW
Display posts from previous:  Sort by  
Reply to topic   [ 17 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.