A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Embedded fonts in share library with FLASH CS3

  1. #1
    Junior Member
    Join Date
    Dec 2000
    Posts
    2

    Embedded fonts in share library with FLASH CS3

    Hi!

    Since Flash8, i use a share library with embed fonts. These fonts (Century Gothic, MS UI Gothic, SimHei and Avant Garde) are used in a multi language training application showing 218 swf files.
    All my dynamic and imput textfields use these fonts as embedded font.
    These 4 fonts are duplicate in 4 "embedded fonts version" to cover regular, bold, italic and bold italic mode.

    So, i've 16 fonts in my share library as this method. for example :
    Font name with regular mode -> Font_Name__Normal
    Font name with bold mode -> Font_Name__Bold
    Font name with italicmode -> Font_Name__Italic
    Font name with bold and italic mode -> Font_Name__Bold_Italic

    Thanks to this method, i can set a font to my textfield according to the user language mode. For exemple Century Gothic is set for English users, MS UI Gothic for Japanese users and SimHei for Chinese users.

    I would like to migrate this Flash8 application to Flash CS3. So i open my library, rigth click and select new font. Next, select linkage and check "Export for runtime sharing".

    At this moment, a class name and a base class are set bu Flash CS3. I just write the URL like that "./fla_name.swf" and press ok button.

    A warning messagebox tells me "A definition for this class could not be found in the classpath, so one will be automatically generated in the swf file upon export."

    As i don't know what type of class i need to create (i just start AS3, never used it before), I accept and export my flash file.

    The Flash CS3 swf size is 18KB and the Flash 8 swf size is 38MB. I conclude that my fonts are not embedded in my file.

    To conclude, how to do it with Flash CS3 ?

    thanks for your help

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Ok,

    I did a lot of research myself. The embedding does not work in Flash CS3. Also there is a problem when a new textfield instance is created and embedFonts are set to true. May be I have not done it correctly, but did not work.

    I don't know regarding sharing, because I have not come yet to that point. When you want to embed fonts, 1. create a textfield on the stage, 2. do a basic embedding of capital, small letters etc, and 3. use a stylesheet.
    4. Load your Stylesheet as if you load any kind of text.
    5. Once loaded add these lines:

    function loadSt(e:Event):void
    {
    var style:StyleSheet = new StyleSheet();
    style.parseCSS(e.target.data);
    my_txt.styleSheet = style;
    my_txt.htmlText = xmlData;

    xmlData is an xml file, which has the text and tags.

    6. In order to have several styles in the stylesheet, create new fonts in the library and create a class for each font. It can be automatically created by Flash. IMPORTANT: in the stylesheet name the font itself and not the class.

    I will probably write an article about that.

    To use XML as textsource check this tutorial:

    http://www.flashscript.biz/MX2004/em...embedmask.html
    Last edited by cancerinform; 05-05-2007 at 05:41 PM.
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Junior Member
    Join Date
    May 2007
    Posts
    6
    i`m not really sure how shared libraries work but there is an example here of using fonts embedded in an external swf -may be useful to you
    http://www.fmx6.com/teststuff/loadfonts.zip
    I think the thing that is missing is the inclusion of
    Code:
    Font.registerFont(Font)
    on the first frame of the movie which is being loaded in.

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I modified your example, since it did not work.
    1. In the library the actual font name has to stay and the class name will be a new name, Chick.
    2. Do not use the class name as reference in the html tag but the actual font name, as I described above for the stylesheet.
    Attached Files Attached Files
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Junior Member
    Join Date
    May 2007
    Posts
    6
    it works fine for me Do you have the font "Chick"?
    your example did not work for me but only because i don`t have the font you embedded.
    I just thought it was clearer to use the class name the same as the font-it may not be good practice to do so.

  7. #7
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    No, I don't have the font. I didn't know there is such font, sorry for that. But the example I posted should work for you unless you don't have Helvetica. It works for me, weird .
    - The right of the People to create Flash movies shall not be infringed. -

  8. #8
    Junior Member
    Join Date
    May 2007
    Posts
    6
    No I don`t have it but as i said as soon as i changed the font it worked fine.
    Your file will also work with classname/fontname the same.Is it bad practice to do this? If not it does simplify things.

  9. #9
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I don't think it can be called bad practice, but I usually prefer to give a different names. Thanks for your example. I am now writing something about using embedded fonts with stylesheets and adding a scrollbar. I will post the link here when it is done.
    - The right of the People to create Flash movies shall not be infringed. -

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Ok, here is the article. We have now covered the embedded fonts issue in AS3 here.

    http://flashscript.biz/flashas3/text...tyleClass.html
    - The right of the People to create Flash movies shall not be infringed. -

  11. #11
    Junior Member
    Join Date
    Dec 2000
    Posts
    2
    Hi cancerinform !

    This seems to work in the case of users have fonts installed in their computer.
    In my case, i need to use font without installation, only in a library.

    Just for detail, in my application users can change of language without reloading all. Textfields created by designers in Flash change when the user change the language. More, users can use another application to translate in another language, so i can't use css style.

    Thanks for your help and your work.
    Last edited by cooladn; 05-07-2007 at 11:37 AM.

  12. #12
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You mean loading a stylesheet? I tested that on a different computer with bitmap fonts, which were not installed there and that worked.

    If you make the movie on your computer and you do not have the fonts installed, of course it will never work. But if you publish a movie with fonts installed on your computer the font will be embedded in the movie textfield and others can see it.

    hope that clarifies.
    - The right of the People to create Flash movies shall not be infringed. -

  13. #13
    Junior Member
    Join Date
    Feb 2007
    Posts
    1
    Hi there,
    I was interested if it's possible to load the font at run time and not to embed it at compile time. It was just a thing for some features that may be added (like the user uploading the font himself). I want to know if it is possbile to do it using only flash IDE because a workaround would be to generate a library swf using swfmill or smth similar and to load it from there. Do you have any ideea if it possilble to load it at runtime?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center