A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Can't get font styles to work

  1. #1
    Senior Member
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    326

    Can't get font styles to work

    I've added the 'Bembo Std' font into my Library, set the character ranges, the font style and gave it a name:
    scherm1.png
    Gave it an AS linkage:
    scherm2.png
    Did the same for the Bold version of Bembo Std:
    Scherm3.png
    scherm4.png

    Now I want to create a textfield using Bembo Std AND use the html bold tag on it. So I'm using this code:

    Code:
    var textFormat:TextFormat = new TextFormat();
    textFormat.bold = true;
    textFormat.size = 30;
    textFormat.font = "Bembo Std";
    
    this.createTextField("my_txt", 1, 10, 10, 400, 200);
    my_txt.html = true;
    my_txt.embedFonts = true;
    my_txt.setNewTextFormat(textFormat);
    my_txt.htmlText = "This is <b>just</b> some text";
    Which just gives me a line of text in all regular style characters, no bold.

    Then I tried it using this line, to reference to the library font:
    Code:
    textFormat.font = "BemboRegular";
    Same thing, all regular style characters.

    Finally I tried:
    Code:
    textFormat.font = "BemboBold";
    This time I'm getting all bold characters.

    What am I missing here? What do I have to do to get the Bembo Std embedded font working AND make it use the bold tags? I've tried it with several fonts but the result always is the same. I can't get both regular and bold tags used in the same textfield.

    Am I doing something wrong? By the way, I know I could try css, but I'd like to know why it doesn't work like this. As far as I can tell I do everything like it is documented.

    Illustration | Animation | Web Banners | Graphic Design
    Ducklord Studio

  2. #2
    Senior Member
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    326
    Another approach on anther font. I embedded two variations of the same font, 'regular' and 'bold'. Also gave them AS linkages. Then used this code:

    Code:
    this.createTextField("my_txt",1,10,10,400,200);
    my_txt.multiline = true;
    my_txt.html = true;
    my_txt.embedFonts = true;
    my_txt.htmlText = "<font size='30' face='EuroComic'>This word is not <b>BOLD</b></font></ br>";
    Which partly works. The textfield gets the embedded font. I can tell by running the swf after deactivating the font in question. However, the word 'BOLD' isn't in bold. All characters are in regular style font.

    I can also use this:

    Code:
    this.createTextField("my_txt",1,10,10,400,200);
    my_txt.multiline = true;
    my_txt.html = true;
    my_txt.embedFonts = true;
    my_txt.htmlText = "<font size='30' face='EuroComicRegular'>This word is not <b>BOLD</b></font></ br>";
    Which the same result. Only this time I'm sure it's using the AS Linkage name. But all characters still in regular style font. Deactivating the font still makes the text use it's embedded font.

    Finally I tried the css way:

    Code:
    import TextField.StyleSheet;
    var myCSS:StyleSheet = new StyleSheet();
    myCSS.setStyle("body",{fontSize:'45', fontFamily:'EuroComicRegular'});
    myCSS.setStyle("vet",{fontSize:'15', fontFamily:'EuroComicBold'});
    myHTML.styleSheet = myCSS;
    myHTML.html = true;
    myHTML.embedFonts = true;
    myHTML.htmlText = "<body>Is dit <vet>vette</vet> tekst?</body>";
    Which works. If my text still contains <b> tags I first have to replace them with my custom <vet> tags, but the result is that characters between <vet> are shown in bold.

    Wondering though why the first two options - without css - don't work, since as far as I can tell I did everything 'by the book'. Embedded all variations of the font, embedded all glyphs, gave AS linkages. Shouldn't I then be able to use bold and italic tags on any html text? Can someone explain this to me?

    Using CS6 for Mac by the way.

    Illustration | Animation | Web Banners | Graphic Design
    Ducklord Studio

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