CSS + Embedded font problem

Hi all,
I’ve a problem using embedded font in a dynamic texfield styled with CSS. Without embedded font everything goes ok, but when I include some characters, bold texts disappear, and links underlined via CSS are not underlined…
I’ve tried with different font (Times, Verdana, DIN), but the problem still remains…

Here is the code:

  • AS

import TextField.StyleSheet;

var my_styleSheet:StyleSheet = new StyleSheet();
var str:String = "<p class=\"arancione\">Lorem <span class=\"rosso\">ipsum</span> dolor <b>sit</b> amet, <a href=\"#\">consectetuer</a> adipiscing elit. <a href=\"#\"><b>Fusce</b></a> semper fermentum odio. Proin quis orci. Phasellus posuere nisl nec lectus. Nam arcu lectus, dapibus at, euismod id, condimentum a, lectus. Donec venenatis. Maecenas facilisis convallis sem. Pellentesque euismod metus non massa. Cras eget turpis. Donec cursus scelerisque erat. Pellentesque adipiscing lorem vestibulum sem. Praesent interdum. Nulla mi odio, laoreet sit amet, aliquet et, ornare a, metus.Vivamus sit amet magna non sapien fringilla imperdiet. <b>Donec placerat, nisi tincidunt tempus cursus, dui tortor porta elit, nec placerat erat dolor quis tellus. Etiam mattis tristique felis. Pellentesque rhoncus nunc at nibh. Sed lectus. Proin condimentum pede sit amet odio. Nunc felis turpis, gravida eget, cursus a, tincidunt quis, tellus. Curabitur tincidunt lorem non dui.</b></p>";

my_styleSheet.load("main.css");


my_styleSheet.onLoad = function(success:Boolean)
{
    if (success)
    {
        txtField.styleSheet = my_styleSheet;
        txtField.htmlText = str;
    }
};

  • CSS (main.css)

a:link
{
    color:#00FF00;
    text-decoration: underline;
}

a:hover
{
    color:#00FF00;
    text-decoration: none;
}

.arancione
{
    color:#F7931D;
}

.rosso
{
    color: red;
}

And here you can check the result:

http://amok.zona13.com/test/cssTest/flashCSS/

Can anybody give me a help?

Thanks!

When you embed the font, what sets are you embedding? Try embedding all of the following:

Uppercase
Lowercase
Numerals
Punctuation
Basic Latin

Then scroll down and also select all of the Latin Extended options, think there are 4 or so.

If that doesn’t work, you may want to embed the font into your library, then assign a linkage identifier to the font, then in the css, you can assign the font to that linkage name.

Hope this helps.

No way. Embedding doesn’t work.


then in the css, you can assign the font to that linkage name.

I don’t understand this step. How can I assign the font in the css?
I mean, I’ve my font symbol in the library with its linkage, and then?

Thanks!

Dynamic Text feilds only accept one format per text box, eg all bold or all plain. When you embed fonts, i think you embed either the bold or plain version, but you can’t have both. So its a choice, either split your text boxes into a plain and bold version, of forget embeding fonts and just let CSS handle all the formatting.

I’m assuming you have 'render as HTML" turned on for the text field. I think this can clash with embeded fonts if you also specify fonts in your CSS, this time you didn’t, so it should be OK.

Pablo is correct - I’d forgot about that - but a work around is to embed both the bold and reg versions in the library as separate fonts - then set the linkage identifiers. Then in css, you can set up styles similar to the following where font-family is the name of your identifier:

bodytxt {
font-family: copy_body;
color: #333333;
font-size: 8px;
display: inline;
}

heading {
font-family: copy_bold;
color: #333333;
font-size: 8px;
display: inline;
}

bullet {
font-family: copy_body;
color: #333333;
font-size: 8px;
margin-left: 13px;
display: inline;
}

boldhead {
font-family: copy_kbold;
color: #333333;
font-size: 8px;
display: inline;
}

I know for a fact that this works as I’ve used it numerous times in the past. There may be a trick when to set the stylesheet of the text box, I forget. You either set it prior to placing text or after, or maybe both - I know there’s a small trick or bug there that needs to be worked around, play around with it and it should work for you.