| java.lang.Object org.openlaszlo.compiler.TextCompiler
TextCompiler | abstract class TextCompiler (Code) | | Utility functions for measuring HTML content, and translating it into Flash strings.
author: Henry Minsky |
Method Summary | |
public static void | checkFontExists(SWFWriter generator, FontInfo fontInfo) | public static double | computeTextWidth(String text, FontInfo fontInfo, SWFWriter generator) | public static double | computeTextWidth(String text, FontInfo fontInfo, SWFWriter generator, LineMetrics lm) | static LineMetrics | getElementWidth(Element e, FontInfo fontInfo, SWFWriter generator) Measure the content text allowing for "HTML" markup. | static void | getElementWidth(Element e, FontInfo fontInfo, SWFWriter generator, LineMetrics lm) Processes the text content of the element. | static String | getHTMLContent(Element e) | static String | getInputText(Element e) Return text suitable for passing to Laszlo inputtext component. | static double | getTextWidth(String str, FontInfo fontInfo, SWFWriter generator, LineMetrics lm) Compute the text width of a string. |
checkFontExists | public static void checkFontExists(SWFWriter generator, FontInfo fontInfo)(Code) | | Check if a specified font is known by the Font Manager
Parameters: generator - Parameters: fontInfo - the font spec you want to checkThis will throw an informative CompilationError if the font does not exist. |
computeTextWidth | public static double computeTextWidth(String text, FontInfo fontInfo, SWFWriter generator, LineMetrics lm) throws CompilationError(Code) | | Compute text width for a given font
Parameters: text - text stringtext string Parameters: fontInfo - font info for this text text width in pixels |
getElementWidth | static LineMetrics getElementWidth(Element e, FontInfo fontInfo, SWFWriter generator)(Code) | | Measure the content text allowing for "HTML" markup.
This uses rules similar to how you would measure browser HTML text:
- All text is whitespace normalized, except that which occurs between <pre> tags
- Linebreaks occur only when <br/> or <p/> elements occur, or when a newline
is present inside of a <pre> region.
- When multiple text lines are present, the length of the longest line is returned.
|
getElementWidth | static void getElementWidth(Element e, FontInfo fontInfo, SWFWriter generator, LineMetrics lm)(Code) | | Processes the text content of the element. The element
content may contain XHTML markup elements, which we will
interpret as we map over the content. Normally, whitespace
will be normalized away. However, preformat <pre> tags
will cause the enclosed text to be treated as verbatim,
meaning means that whitespace and linebreaks will be
preserved.
Supported XHTML markup is currently:
- P, BR cause linebreaks
- PRE sets verbatim (literal whitespace) mode
- font face control: B, I, FONT tags modify the font
- A [href] indicates a hyperlink
|
getHTMLContent | static String getHTMLContent(Element e)(Code) | | Gets the text content, with HTML normalization rules applied
|
getInputText | static String getInputText(Element e)(Code) | | Return text suitable for passing to Laszlo inputtext component.
This means currently no HTML tags are supported except PRE
|
getTextWidth | static double getTextWidth(String str, FontInfo fontInfo, SWFWriter generator, LineMetrics lm)(Code) | | Compute the text width of a string. If there are multiple
lines, return the maximum line width.
The only multi-line strings we will ever see here will be
non-normalized text such as inside <pre;> verbatim
regions, because in normal running HTML text, the normalization
will have stripped out newlines.
The LineMetrics holds state from possibly a previous text run
on the same line, telling us whether we need to prepend an
extra whitespace.
|
|
|