PHP to generate font code for Flex
I have been loading Fonts for a project for over 2 hours now and I am about 70{9eb845e9932a4c0558a0305a78bf1c2d5042d8a06323e6cdeacdb9c8597fbf65} done. Basically I needed an SWF library of fonts to be used in an application I am developing, problem is the font needs to be registered (loaded) in order for the “New Font” option to see it. Now on the Mac I found adding/deleting fonts is easy, but very time consuming.
This is all being done in AS2, of course my love of Flash comes in to AS3, where I was able to (just for testing) create this little PHP script that reads a directory of fonts and creates the embed tags for me.. figured I would share it, so here it is.
Again, this is ONLY for AS3 (in Flex).
<?php
$dir = opendir('./fonts/');
while (false !== ($file = readdir($dir)))
{
if ($file != "." && $file != "..")
{
print "@font-face {\n\tsrc:url(\"fonts/" . $file . "\");\n\tfontFamily: myFont;\n\tflashType: true;\n}\n";
}
}
closedir($dir);
?>
It repeatedly prints out import blocks, like this:
@font-face {
src:url("fonts/LT_13171.ttf");
fontFamily: myFont;
flashType: true;
}
Now all you do is import the actual font file into your AS3 project and your all setup to use custom fonts that don’t have to be installed on the machine.
Note: This ONLY works for ActionScript 3! This example is for Flex, but it is very similar in Flash
werutzb
October 7, 2008 10:35 pmHi!
I want to improve my SQL experience.
I red really many SQL resources and would like to
read more about SQL for my occupation as db2 database manager.
What would you recommend?
Thanks,
Werutz
mkeefe
October 7, 2008 10:44 pm@werutzb – I recommend books on the subject, do you want to learn about MySQL or MSSQL? That would help me suggest a book.