Java Doc for Font.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » iv » flash » api » text » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » Laszlo 4.0.10 » org.openlaszlo.iv.flash.api.text 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.openlaszlo.iv.flash.api.text.Font

Font
final public class Font (Code)
This class defines flash font.

Flash text has been designed to be completely device independent. Text is guaranteed to look exactly the same on every device, regardless of which fonts are installed on the client machine. The SWF format achieves this by including the exact shape of every letter, number (or other text character) used in the movie. These character shape definitions are called glyphs.

Defining each and every glyph increases the size of a SWF file, particularly if the font is complex. However, it is a necessary tradeoff. At design time, Flash knows nothing about the capabilities of the client device, therefore glyphs must always be included in the SWF file, even if the desired font is already on the client machine.

To guarantee text is reproduced correctly, SWF also includes the exact position of every character in a text block. Again, this adds to the file size, but allows sophisticated text layout effects (like kerning and text wrapping) without requiring a complex layout engine built into the Flash player.

Glyph Definitions

Glyphs are defined once in a standard coordinate space called the EM square. The same set of glyphs are used for every point size of a given font. To render a glyph at different point sizes, the Flash player scales the glyph from EM coordinates to point-size coordinates.

Flash fonts do not include any hinting information for improving the quality of small font sizes. However, antialiasing dramatically improves the legibility of down-scaled text. Flash text remains legible down to about 12-points (viewed at 100%). Below that, text may appear fuzzy and blurred. In any case, it is rare for Flash movies to be used for large bodies of text with small point sizes.

TrueType fonts can be readily converted to SWF glyphs. A simple algorithm can replace the Quadratic B-splines (used by TrueType) with Quadratic Bezier curves (used by SWF).

The EM Square

The EM square is an imaginary square that is used to size and align glyphs. The EM square is generally large enough to completely contain all glyphs, including accented glyphs. It includes the font's ascent, descent, and some extra spacing to prevent lines of text from colliding.

SWF glyphs are always defined on an EM square of 1024 by 1024 units. Glyphs from other sources (such as TrueType fonts) may be defined on a different EM square. To use these glyphs in SWF, they should be scaled to fit an EM square of 1024.

Kerning and Advance Values

Kerning defines the horizontal distance between two glyphs. This distance may be smaller or larger than the width of the left-hand glyph. Some kerning pairs are more aesthetically pleasing if they are moved closer together.

SWF stores kerning information as an advance value. That is, the horizontal advance from one glyph to another. SWF stores an advance value for every character in a text block.

The DefineFont Tag

The DefineFont tag defines the shape outlines of each glyph used in a particular font. Only the glyphs that are used by subsequent DefineText tags are actually defined.

The FontId uniquely identifies the font. It can be used by subsequent DefineText tags to select the font.

The offset table and shape table are used together. These tables have the same number of entries, and there is a one-to-one ordering match between the order of the offsets, and the order of the shapes. The offset table points to locations in the shape table. Each offset entry stores the difference (in bytes) between the start of the offset table and the location of the corresponding shape:

 Location of ShapeRecord[n] = StartOfOffsetTable + OffsetTable[n]
 
Because the ShapeTable immediately follows the OffsetTable, the number of entries in both tables can be inferred by dividing the first offset by two:
 Shape count = OffsetTable[0] / 2
 

Mapping to Native Fonts

SWF also supports the use of native fonts. Rather than using the glyph outlines in the DefineFont tag, fonts can be rendered using the client machine's font engine. Since most native font engines include hinting techniques, they may produce better results at very small point sizes.

The DefineFontInfo tag defines the mapping of a Flash font to a native font. It includes the font name, font style - bold, italic, or plain, and the encoding scheme used - ANSI, Unicode or ShiftJIS. It also defines a mapping of glyph indices to character codes. Thus if 'a' were the first character in your DefineFont tag, the DefineFontInfo tag would map index zero to the character code for 'a'.

DefineFont2

The DefineFont2 tag extends the functionality of DefineFont. Enhancements include:

  • 32-bit entries in the OffsetTable, for fonts with more than 64K glyphs.
  • Mapping to native fonts, by incorporating all the functionality of DefineFontInfo.
  • Ascent, descent and leading information.
  • An advance table that defines the advance for each glyph (in EM square coordinates).
  • A bounds table that defines the bounding-box of each glyph (in EM square coordinates).
  • A table of kerning pairs that defines the distance between pairs of glyphs

Kerning Record

A Kerning Record defines the distance between two glyphs in EM square coordinates. Certain pairs of glyphs appear more aesthetically pleasing if they are moved closer together, or farther apart. The FontKerningCode1 and FontKerningCode2 fields are the character codes for the left and right characters. The FontKerningAdjustment field is a signed integer that defines the offset from the advance value of the left-hand character. The distance between two characters can be calculated like this:

 Distance = FontAdvanceTable[ord(FontKerningCode1)] + FontKerningAdjustment
 

author:
   Dmitry Skavish


Field Summary
final public static  intANSI
    
final public static  intBOLD
    
final public static  intHAS_LAYOUT
    
final public static  intITALIC
    
final public static  intSHIFT_JIS
    
final public static  intUNICODE
    
final public static  intWIDE_CODES
    
final public static  intWIDE_OFFSETS
    
public  int[]advanceTable
    
public  intascent
    
public  intblankPos
    
public  byte[]boundsBuffer
    
public  intboundsLength
    
public  intboundsOffset
    
public  booleancached
    
public  int[]codeTable
    
public  intdescent
    
public  byte[]fileBuffer
    
public  intflags
    
public  StringfontKey
    
public  StringfontName
    
public  int[]glyphOffsets
    
public  int[]kernAdjustment
    
public  int[]kernLeftCodes
    
public  int[]kernRightCodes
    
public  intleading
    

Constructor Summary
public  Font()
    

Method Summary
public  voidcopyTo(Font font)
    
public static  FontcreateDummyFont(String fontName)
     Creates empty font of given name.
public  intgetAdvanceValue(int idx)
     Returns advance value for the character at specified index.
public  StringgetFontName()
    
public  intgetFontSize()
     Returns approximate size in bytes occupied by this font

Used mainly in caching algorithm.

public  Rectangle2D[]getGlyphBounds()
    
public  intgetGlyphTableSize()
     Returns size of glyphs table.
public  BareShape[]getGlyphs()
    
public  intgetIndex(int ch)
     Returns index of specified character in codetable.
public  intgetKerning(int ch_left, int ch_right)
    
public  intgetNumGlyph()
    
public  booleanisLargeThan(Font f)
    
public  voidprintContent(PrintStream out, String indent, int id)
    

Field Detail
ANSI
final public static int ANSI(Code)



BOLD
final public static int BOLD(Code)



HAS_LAYOUT
final public static int HAS_LAYOUT(Code)



ITALIC
final public static int ITALIC(Code)



SHIFT_JIS
final public static int SHIFT_JIS(Code)



UNICODE
final public static int UNICODE(Code)



WIDE_CODES
final public static int WIDE_CODES(Code)



WIDE_OFFSETS
final public static int WIDE_OFFSETS(Code)



advanceTable
public int[] advanceTable(Code)



ascent
public int ascent(Code)



blankPos
public int blankPos(Code)



boundsBuffer
public byte[] boundsBuffer(Code)



boundsLength
public int boundsLength(Code)



boundsOffset
public int boundsOffset(Code)



cached
public boolean cached(Code)



codeTable
public int[] codeTable(Code)



descent
public int descent(Code)



fileBuffer
public byte[] fileBuffer(Code)



flags
public int flags(Code)



fontKey
public String fontKey(Code)



fontName
public String fontName(Code)



glyphOffsets
public int[] glyphOffsets(Code)



kernAdjustment
public int[] kernAdjustment(Code)



kernLeftCodes
public int[] kernLeftCodes(Code)



kernRightCodes
public int[] kernRightCodes(Code)



leading
public int leading(Code)




Constructor Detail
Font
public Font()(Code)




Method Detail
copyTo
public void copyTo(Font font)(Code)
Copy all data from this font to the specified one
Parameters:
  font - specified font copy all the data to



createDummyFont
public static Font createDummyFont(String fontName)(Code)
Creates empty font of given name.
Parameters:
  fontName - name of the created font created empty font



getAdvanceValue
public int getAdvanceValue(int idx)(Code)
Returns advance value for the character at specified index.
Parameters:
  idx - index of character which advance value is to be returned advance value at specified index



getFontName
public String getFontName()(Code)
Returns font name font name



getFontSize
public int getFontSize()(Code)
Returns approximate size in bytes occupied by this font

Used mainly in caching algorithm. size of this font in bytes




getGlyphBounds
public Rectangle2D[] getGlyphBounds()(Code)
Returns array of bounds of all glyphs of this font array of glyphs bounds



getGlyphTableSize
public int getGlyphTableSize()(Code)
Returns size of glyphs table.

Since glyph table has one additional element to hold offset after the last element then number of glyphs of the font is one less than the size of the glyph table. number of glyphs + 1




getGlyphs
public BareShape[] getGlyphs()(Code)
Returns array of shapes of all glyphs of this font

Shapes parsing can be delayed until they are requested by this call array of font glyphs




getIndex
public int getIndex(int ch)(Code)
Returns index of specified character in codetable.
Parameters:
  ch - specified character which index is to be returned index of specified character or -1 if there is no such character



getKerning
public int getKerning(int ch_left, int ch_right)(Code)
Return adjustment from kerning table for specified pair of characters

MAY BE IMPROVED BY USING BINARY SEARCH !!!!!!!!!!!!
Parameters:
  ch_left - left character
Parameters:
  ch_right - right character adjustment value for the pair of character




getNumGlyph
public int getNumGlyph()(Code)
Returns number of glyphs in the font number of glyphs



isLargeThan
public boolean isLargeThan(Font f)(Code)
Returns true if this font is large then the specified one

Font is considered large if it has more glyphs and layout
Parameters:
  f - font to be compared with true if this font is large then the specified one




printContent
public void printContent(PrintStream out, String indent, int id)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.