/** * @(#) $RCSfile: FontDataTable.as,v $ $Revision: 1.2 $ $Date: 2003/01/29 18:10:26 $ * * Copyright 2003 Orgdot AS. All Rights Reserved. * http://dev.swfit.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * Table for faking font data in Flash 4/5. The rules are: * a) the point size is fixed - use ratios in other tables * b) split all chars into six different widhts: * - small, small_slim, small_wide * - caps, caps_slim, caps_wide * c) set the corresponding strings to these 6 widths (will vary for serifs and sansserifs), * and include extra chars were you see fit * d) include spacing after all other vals are set - so we can reuse the same set of data * for different spacings ... * The font data here approximates Arial, the most common font in most projects. There is * little work involved in modifying the strings below to suit other fonts. Note that these * are not exact measurements - instead they give an approximation based on YOUR idea of * letter spacing for a particular font. * See LetterDance.swf for a (rather ugly) implemetation. * * @author Olaf Havnes * @version $Revision: 1.2 $ $Date: 2003/01/29 18:10:26 $ * @since SWFIT1.0 */ // Loop up a table for widths for a selected font. fontsize = 10; spacing = 2.0; // regular small letters: abc etc. small = 5.0; // super slim small letters small_super_slim = 1.3; small_super_slim_letters = "il'!.,:;|"; // slim small letters (space is included here) small_slim = 3.0; small_slim_letters = "fjtr "; // wide small letters small_wide = 7.5; small_wide_letters = "mw"; // regular capital letters: ABC etc caps = 6.0; // super slim capital letters caps_super_slim = 3.0; caps_super_slim_letters = "I"; // slim capital letters caps_slim = 4.0; caps_slim_letters = "J"; // wide capital letters caps_wide = 8.5; caps_wide_letters = "W"; // generate the table: // 1) set all 256 chars to the witdh of the small letters i = 0; while (i < 256) { set ("c_" add i, small); i++; } // 2) set the chars A -> Z to caps i = ord ('A'); while (i <= ord ('Z')) { set ("c_" add i, caps); i++; } // 3) set the chars À -> Ý to caps i = 192; while (i <= 221) { set ("c_" add i, caps); i++; } // handle special cases // 4) set the super slim small letters i = 0; while (i < length (small_super_slim_letters)) { ord_letter = ord (substring (small_super_slim_letters, i + 1, 1)); set ("c_" add ord_letter, small_super_slim); i++; } // 5) set the slim small letters i = 0; while (i < length (small_slim_letters)) { ord_letter = ord (substring (small_slim_letters, i + 1, 1)); set ("c_" add ord_letter, small_slim); i++; } // 6) set the wide small letters i = 0; while (i < length (small_wide_letters)) { ord_letter = ord (substring (small_wide_letters, i + 1, 1)); set ("c_" add ord_letter, small_wide); i++; } // 7) set the super slim capital letters i = 0; while (i < length (caps_super_slim_letters)) { ord_letter = ord (substring (caps_super_slim_letters, i + 1, 1)); set ("c_" add ord_letter, caps_super_slim); i++; } // 8) set the slim capital letters i = 0; while (i < length (caps_slim_letters)) { ord_letter = ord (substring (caps_slim_letters, i + 1, 1)); set ("c_" add ord_letter, caps_slim); i++; } // 9) set the wide capital letters i = 0; while (i < length (caps_wide_letters)) { ord_letter = ord (substring (caps_wide_letters, i + 1, 1)); set ("c_" add ord_letter, caps_wide); i++; } // add the spacing for all letters and store in _level0. i = 0; while (i < 256) { set ("/:basefont_" add i, eval ("c_" add i) + spacing); i++; } // store the basefont_size in _level0: set ("/:basefont_size", fontsize); // finally - set line break, form feed and tab to zero (they should not exist here anyway) set ("/:basefont_" add ord ("\n"), 0); set ("/:basefont_" add ord ("\r"), 0); set ("/:basefont_" add ord ("\t"), 0);