1 // 2 // Description: 3 // SWFFont Class 4 // 5 // Authors: 6 // Jonathan Shore <jshore@e-shuppan.com> 7 // Based on php wrapper developed by <dave@opaque.net> 8 // 9 // Copyright: 10 // Copyright 2001 E-Publishing Group Inc. Permission is granted to use or 11 // modify this code provided that the original copyright notice is included. 12 // 13 // This software is distributed with no warranty of liability, merchantability, 14 // or fitness for a specific purpose. 15 // 16 17 18 19 20 21 22 23 // 24 // SWFFont Class 25 // font specification & attributes 26 // 27 // Notes 28 // - 29 // 30 public class SWFFont extends SWFObject implements SWFFontI { 31 SWFFont(String font)32 public SWFFont (String font) 33 throws SWFException 34 { 35 if (font.endsWith (".fdb")) { 36 setHandle (nNewFileFont (font)); 37 browserfont = false; 38 } else { 39 setHandle (nNewBrowserFont (font)); 40 browserfont = true; 41 } 42 } 43 finalize()44 protected void finalize() 45 throws Throwable 46 { 47 if (browserfont) 48 nDestroyBrowserFont (handle); 49 else 50 nDestroyFileFont (handle); 51 super.finalize(); 52 } 53 54 getStringWidth(String string)55 public float getStringWidth (String string) 56 { return nGetStringWidth (handle, string); } getAscent()57 public float getAscent () 58 { return nGetAscent (handle); } getDescent()59 public float getDescent () 60 { return nGetDescent (handle); } getLeading()61 public float getLeading () 62 { return nGetLeading (handle); } 63 64 65 // native methods 66 nNewFileFont(String font)67 protected native int nNewFileFont (String font); nNewBrowserFont(String font)68 protected native int nNewBrowserFont (String font); nDestroyFileFont(int handle)69 protected native void nDestroyFileFont (int handle); nDestroyBrowserFont(int handle)70 protected native void nDestroyBrowserFont (int handle); 71 nGetStringWidth(int handle, String string)72 protected native float nGetStringWidth (int handle, String string); nGetAscent(int handle)73 protected native float nGetAscent (int handle); nGetDescent(int handle)74 protected native float nGetDescent (int handle); nGetLeading(int handle)75 protected native float nGetLeading (int handle); 76 77 78 // variables 79 80 private boolean browserfont; 81 }; 82 83 84 85 86