[swfmill] How to reference an embedded font in AS?
gregor.karl.frey at t-online.de
Tue Oct 4 00:27:03 PDT 2005
finally I found out that I had to use the setNewTextFormat function of
the TextField instead of the simple setTextFormat function. As I
understand the difference between the two functions, the first sets the
format for the current and all future texts in the TextField whereas the
second function operates only on the current text. But given this
difference, why does setTextFormat do the job in your example?
But even if there are some open questions for me, my application works
fine now. Thanks to the great open source flash tools!
The new name attribute in 0.2.11 makes it much easier to use the font
import! Great! And the fact that the verbose output of swfmill shows the
exported font names helps too.
daniel fischer wrote:
>sorry for the late answer, but here you go:
>Gregor Frey <gregor.karl.frey at t-online.de> (on Thu, 29 Sep 2005 11:41:30 +0200):
> > Hi,
> > what is the right way to declare a font in the swfmill-xml and refer to
> > it in action script?
> > My xml looks like the following:
> > <library>
> > <font id="vera" name="vera" import="Vera.ttf" bold="false"/>
> > <font id="vera_bold" name="vera" import="VeraBd.ttf"
> > bold="true"/>
> > <clip id="Application" class="Application" />
> > <clip id="MoveableTextField" class="MoveableTextField" />
> > </library>
> > Inside my Application class I
> > - create a TextField by calling the MovieClips "createTextField"
> > - set the "embedFonts" attribute of the TextField to true
> > - create a new TextFormat and assign it to the TextField
> > - assign a string to the text attribute of the TextField
> > But the running application doesn't show the text. The text fields
> > remain empty.
> > Questions:
> > 1. Is the glyphs atttribute required for the font tag? In my case the
> > swf-files are bigger if I remove the explicit glyphs. Thus I expect that
> > without an explicit glyph setting all characters are imported, right?
> > 2. How does the string look like, by which I refer to the imported font?
> > I tried the following:
> > - textFormat.font = "vera(Vera.ttf)";
> > - textFormat.font = "Bitstream Vera Sans";
> > - textFormat.font = "vera";
> > The result was always the same, the text was not displayed.
>"Bitstream Vera Sans" _should_ be right. With 0.2.11, things have improved a little in the area, so you might want to try that, with the -v option, then the actual family name should be printed on the console during conversion.
>why did you put the "name" and "bold" attributes in your font tags? is there some old info on the web? @bold does nothing, the bold flag is figured from the TTF. in contrast, @name should work, but only since 0.2.11. if you do name="vera" like above with 0.2.11, textFormat.font should be "vera", too.
>as i see no obvious mistake, if you still have no luck with 0.2.11, i'd ask you to send me a (if possible, boiled-down) example so i can look at all parts of the pictore..
> > Could anyone please give me an example how embeded fonts are used in
> > actionscript, or point out, what is wrong with my procedure?
>you could take a look at my late example:
More information about the swfmill