A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: external font need help

  1. #1
    Senior Member
    Join Date
    May 2016
    Posts
    451

    external font need help

    hello all



    I'm trying to use an external font in flash
    I used the Html txt method

    The code works in html file

    code:

    PHP Code:
    <style type="text/css">p{color:red;text-align:center;font-family"kofa";font-size50px;}@font-face {font-family"kofa";srcurl(kofa.ttfformat("truetype");}</style><p>hello world</p

    But it doesn't work in flash

    code:

    PHP Code:
    onFrame (1) {
        
    stop();
    //---------------- simple text works fine -------------------------    
        
    this.createTextField("simple_txt"this.getNextHighestDepth(),0,30,200,50);
        
    simple_txt.html true;
        
    simple_txt.htmlText "<b> this is simple text </b>";

    //---------------- external font text is not working --------------------

        
    this.createTextField("external_font"this.getNextHighestDepth(),0,90,200,50); 
        
    external_font.html true;     
        
    external_font.htmlText='<style type="text/css">p{color:red;text-align:center;font-family: "kofa";font-size: 50px;}@font-face {font-family: "kofa";src: url(kofa.ttf) format("truetype");}</style><p>hello world</p>' 
         


    Any Help

    swishmax file:

    https://app.box.com/s/h14q8278n33pmtykmlpvndl9c7ondafj

  2. #2
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Do you still need this answer? It should be possible by installing it & running swish.

  3. #3
    Senior Member
    Join Date
    May 2016
    Posts
    451
    Yes, I need this answer

  4. #4
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    When you open the font & click install, the actual name of the font is this: MO_Nawel




    PHP Code:
    this.createTextField("simple_txt"this.getNextHighestDepth(),0,30,5000,5000);//create text field

    var text_format:TextFormat = new TextFormat();//TextFormat is a set of properties you can set up in an object to apply it to various textfields.
    text_format.size 50;//set size
    text_format.font="MO_Nawel"//font name after installing the font & restarting swish
    simple_txt.setNewTextFormat(text_format);//set the txtformat properties to simple_text.text field


    simple_txt.html true;   //only after the textformat settings get applied you can add text & html to simple_txt field
    simple_txt.htmlText='<b><p>The quick brown fox jumped over the lazy dog</p></b>' 
    When you compile the .swf it will come with the font inside for the other computers.

    download external font 0.2
    Last edited by AS3.0; 07-16-2022 at 03:52 PM.

  5. #5
    Senior Member
    Join Date
    May 2016
    Posts
    451
    What I want is for the font file to be in the same path as the flash file and not to be installed in the computer

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    The html for the as2 textfield seems to implement a couple useful features from the html engine but not all.

    For example, you can use the FONT tag, but "style" is not used by the interpreter.

    Some things you can do with the font tag is include, font name, font size & font color, the font must be installed on the developers computer before compiling.
    PHP Code:
    this.createTextField("simple_txt"this.getNextHighestDepth(),0,30,5000,5000);

    var 
    text_format:TextFormat = new TextFormat();//TextFormat is a set of property settings you can setup to apply to various text fields.

    simple_txt.setNewTextFormat(text_format);//set the txtformat properties to simple_text.text field

    simple_txt.html true;   
    simple_txt.htmlText='<FONT FACE="MO_Nawel" SIZE="50" COLOR="#370640">This is kofa font</FONT>' 
    If "style" is allowed by the interpreter it must be that the html page is not being written exactly as it should, for example, start with HTML header etc... I don't see a limitation to this unless you were designing a page that presents font's, In that case you can do that in Actionscript 3.0 even if it was not an implementation in AS3.0 you could create the font from hex arrays using bytearrays which I have not fully studied yet but the concept would be to draw the pixels out based on the array & scale it.
    Last edited by AS3.0; 07-18-2022 at 08:14 PM.

  7. #7
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I have a bad idea, you could

    option #1:
    Put the font file into a convertor program each time so they convert to xml files in the same folder where you could draw the text using lines which would modify the look of the font for the most part.

    option #2:
    You could convert the fonts into arrays (not in swish) & store them in swish & if the file needs more you can have it imported by the user through the network socket and store more font arrays which would modify the look of the font though because it would look like lines maybe I wont use curves.

    option #3:
    We can do a font builder program in swish that turns them into xml files.
    We can create another program that uses the xml fonts.
    Last edited by AS3.0; 07-18-2022 at 09:21 PM.

  8. #8
    Senior Member
    Join Date
    May 2016
    Posts
    451
    I will try to study more codes until I find a solution to this problem
    thanks for help

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