AS3 FlashDevelop Font Library Template


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2. Suggested workflow:
  3. - create a fontLibrary subfolder in your project (NOT in /bin or /src)
  4. - for example: /lib/fontLibrary
  5. - copy font files in this location
  6. - create a FontLibrary class in the same location
  7. - one font library can contain several font classes (duplicate embed and registration code)
  8.  
  9. FlashDevelop QuickBuild options: (just press Ctrl+F8 to compile this library)
  10. @mxmlc -o bin/NewFontLibrary.swf -noplay
  11. */
  12. package
  13. {
  14. import flash.display.Sprite;
  15. import flash.text.Font;
  16.  
  17. /**
  18. * Font library
  19. * @author XXXXXX
  20. */
  21. public class NewFontLibrary extends Sprite
  22. {
  23. /*
  24. Common unicode ranges:
  25. Uppercase : U+0020,U+0041-U+005A
  26. Lowercase : U+0020,U+0061-U+007A
  27. Numerals : U+0030-U+0039,U+002E
  28. Punctuation : U+0020-U+002F,U+003A-U+0040,U+005B-U+0060,U+007B-U+007E
  29. Basic Latin : U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E
  30. Latin I : U+0020,U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
  31. Latin Ext. A: U+0100-U+01FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
  32. Latin Ext. B: U+0180-U+024F,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
  33. Greek : U+0374-U+03F2,U+1F00-U+1FFE,U+2000-U+206f,U+20A0-U+20CF,U+2100-U+2183
  34. Cyrillic : U+0400-U+04CE,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183
  35. Armenian : U+0530-U+058F,U+FB13-U+FB17
  36. Arabic : U+0600-U+06FF,U+FB50-U+FDFF,U+FE70-U+FEFF
  37. Hebrew : U+05B0-U+05FF,U+FB1D-U+FB4F,U+2000-U+206f,U+20A0-U+20CF,U+2100-U+2183
  38.  
  39. About 'embedAsCFF' attribute:
  40. - is Flex 4 only
  41. - is 'true' by default, meaning the font is embedded for the new TextLayout engine only
  42. - you must set explicitely to 'false' for use in regular TextFields
  43.  
  44. More information:
  45. http://help.adobe.com/en_US/Flex/4.0/UsingSDK/WS2db454920e96a9e51e63e3d11c0bf69084-7f5f.html
  46. */
  47.  
  48. [Embed(source='NewFontLibrary.ttf'
  49. ,fontFamily ='NewFontLibrary'
  50. ,fontStyle ='normal' // normal|italic
  51. ,fontWeight ='normal' // normal|bold
  52. ,unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E'
  53. //,embedAsCFF='false'
  54. )]
  55. public static const fontClass:Class;
  56.  
  57. public function NewFontLibrary()
  58. {
  59. Font.registerFont(fontClass);
  60.  
  61. }
  62.  
  63. }
  64.  
  65. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.