Author: hqm
Date: 2008-01-16 08:54:08 -0800 (Wed, 16 Jan 2008)
New Revision: 7839
Added:
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzFontManager.as
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/lfc/LaszloLibrary.lzs
openlaszlo/branches/devildog/WEB-INF/lps/lfc/controllers/LaszloAnimation.js
openlaszlo/branches/devildog/WEB-INF/lps/lfc/helpers/Library.lzs
openlaszlo/branches/devildog/WEB-INF/lps/lfc/helpers/LzFont.lzs
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/Library.lzs
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
openlaszlo/branches/devildog/test/swf9/hello-font.lzx
Log:
Change 20080116-hqm-2 by [EMAIL PROTECTED] on 2008-01-16 11:49:32 EST
in /cygdrive/c/users/hqm/openlaszlo/devildog2
for http://svn.openlaszlo.org/openlaszlo/branches/devildog
Summary: first cut at embedded font
New Features:
Bugs Fixed:
Technical Reviewer: hqm
QA Reviewer: max
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
add in support for embedded fonts, font manager.
This stuff needs to be looked at again, it is assuming the swf6/7/8 model
of fonts. The swf9 runtime Font class does not appear to have any font metrics,
I haven't found if there is any API to get them, so maybe we have to continue to
use JGenerator font parsing code on the server to generate a font metrics table?
Do we use any of those font metrics at runtime? Do we really need them?
Tests:
Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/LaszloLibrary.lzs
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/LaszloLibrary.lzs
2008-01-16 04:40:20 UTC (rev 7838)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/LaszloLibrary.lzs
2008-01-16 16:54:08 UTC (rev 7839)
@@ -24,7 +24,7 @@
#include "views/Library.lzs"
#include "controllers/Library.lzs"
- //#include "helpers/Library.lzs"
+#include "helpers/Library.lzs"
// #include "data/Library.lzs"
#include "services/Library.lzs"
//#include "glue/Library.lzs"
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/lfc/controllers/LaszloAnimation.js
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/controllers/LaszloAnimation.js
2008-01-16 04:40:20 UTC (rev 7838)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/controllers/LaszloAnimation.js
2008-01-16 16:54:08 UTC (rev 7839)
@@ -88,14 +88,14 @@
*
* @type String
*/
-LzAnimation.setters.motion = "setMotion";
+LzAnimator.setters.motion = "setMotion";
/**
* The destination value for the animator.
*
* @type Number
*/
-LzAnimation.setters.to = "setTo";
+LzAnimator.setters.to = "setTo";
/**
Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/helpers/Library.lzs
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/helpers/Library.lzs
2008-01-16 04:40:20 UTC (rev 7838)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/helpers/Library.lzs
2008-01-16 16:54:08 UTC (rev 7839)
@@ -1,24 +1,36 @@
/**
* Library.lzs
*
- * @copyright Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved.
+ * @copyright Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved.
* Use is subject to license terms.
*
* @access private
*/
+
#include "helpers/LzFont.lzs"
+
+if ($swf9) {
+
+} else {
+
#include "helpers/LzSelectionManager.lzs"
#include "helpers/LzDataSelectionManager.lzs"
#include "helpers/LzCommand.lzs"
+}
if ($as2) {
+} else if ($swf9) {
} else if ($js1) {
//
} else {
Debug.error('helpers/Library.lzs unsupported runtime %s', $runtime);
}
-#include "helpers/LzState.lzs"
+if ($swf9) {
+} else {
+ #include "helpers/LzState.lzs"
+}
+
Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/helpers/LzFont.lzs
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/helpers/LzFont.lzs
2008-01-16 04:40:20 UTC (rev 7838)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/helpers/LzFont.lzs
2008-01-16 16:54:08 UTC (rev 7839)
@@ -362,6 +362,9 @@
*/
var rsbtable;
+var fontobject;
+
+
function LzFont ( fontobject , attrs , style ){
super();
this.name = fontobject.name;
Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/Library.lzs
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/Library.lzs
2008-01-16 04:40:20 UTC (rev 7838)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/Library.lzs
2008-01-16 16:54:08 UTC (rev 7839)
@@ -12,3 +12,4 @@
#include "kernel/swf9/LzIdleKernel.as"
#include "kernel/swf9/LzSprite.as"
#include "kernel/swf9/LzTextSprite.as"
+#include "kernel/swf9/LzFontManager.as"
Added: openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzFontManager.as
Property changes on:
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzFontManager.as
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
2008-01-16 04:40:20 UTC (rev 7838)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
2008-01-16 16:54:08 UTC (rev 7839)
@@ -30,12 +30,14 @@
public var textfield:TextField = null;
- public static var PAD_TEXTWIDTH:int = 4;
+ public static var PAD_TEXTWIDTH:Number = 4;
+ public static var DEFAULT_SIZE = 11;
-
+ var font = null;
public var fontsize:String = "11";
public var fontstyle:String = "plain";
public var fontname:String = "Verdana";
+ public var lineheight = 11;
public var colorstring:String = "#000000";
public var text:String = "";
@@ -191,7 +193,17 @@
this.setText( this.text );
}
- //public setFontInfo (fontname:String, fontstyle:String,
fontsize:String)
+ function setFontInfo () {
+ this.font = LzFontManager.getFont( this.fontname , this.fontstyle
);
+ //trace('setFontInfo this.font = ', this.font, 'this.fontname = ',
this.fontname, this.fontstyle);
+
+ if (this.font != null) {
+ //trace('font.leading', this.font.leading, 'font.height =
',this.font.height, 'fontsize =',this.fontsize);
+ this.lineheight = Number(this.font.leading) + (
Number(this.font.height) *
+ Number(this.fontsize)
/ DEFAULT_SIZE );
+ }
+ }
+
/**
* Sets the color of all the text in the field to the given hex color.
* @param Number c: The color for the text -- from 0x0 (black) to
0xFFFFFF (white)
@@ -252,14 +264,30 @@
*/
public function __setFormat ():void {
+ this.setFontInfo();
+ var cfontname = LzFontManager.__fontnameCacheMap[this.fontname];
+ if (cfontname == null) {
+ cfontname = LzFontManager.__findMatchingFont(this.fontname);
+ LzFontManager.__fontnameCacheMap[this.fontname] = cfontname;
+ //Debug.write("caching fontname", this.fontname, cfontname);
+ }
+ // trace("__setFormat this.font=", this.font,
'this.fontname = ',this.fontname,
+ //'cfontname=', cfontname);
+
// TODO [make this work when font manager is implemented]
- this.format ="<FONT FACE=\"" + (this.fontname) +
+ this.format ="<FONT FACE=\"" + (this.font == null ? cfontname :
this.font.name) +
"\" SIZE=\"" + this.fontsize + "\" " +
"COLOR=\"" + this.colorstring + "\" >";
this.closeformat = "</FONT>";
- this.textfield.embedFonts = false;
+ // If there is no font found, assume a device font
+ if (this.font == null) {
+ this.textfield.embedFonts = false;
+ } else {
+ this.textfield.embedFonts = true;
+ }
+
if (this.fontstyle == "bold" || this.fontstyle =="bolditalic"){
this.format += "<B>";
this.closeformat = "</B>" + this.closeformat;
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
===================================================================
---
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
2008-01-16 04:40:20 UTC (rev 7838)
+++
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
2008-01-16 16:54:08 UTC (rev 7839)
@@ -17,7 +17,7 @@
import org.openlaszlo.compiler.CompilationEnvironment;
import org.openlaszlo.compiler.ObjectWriter.ImportResourceError;
import org.openlaszlo.compiler.ObjectWriter.Resource;
-
+import org.openlaszlo.iv.flash.api.text.*;
import org.openlaszlo.iv.flash.api.FlashDef;
import org.openlaszlo.media.*;
@@ -47,6 +47,20 @@
private FontManager mFontManager = new FontManager();
private Map mDeviceFontTable = new HashMap();
+ /** Default font */
+ private Font mDefaultFont = null;
+ private String mDefaultFontName = null;
+ private String mDefaultFontFileName = null;
+ private String mDefaultBoldFontFileName = null;
+ private String mDefaultItalicFontFileName = null;
+ private String mDefaultBoldItalicFontFileName = null;
+ // TODO: [2003-12-08 bloch] need logic to set this to true
+ private boolean mDefaultFontUsedForMeasurement = false;
+ /** Height for generated advance (width) table */
+ public static final int DEFAULT_SIZE = 11;
+ /** Leading for text and input text */
+ private int mTextLeading = 2;
+
/** Logger */
protected static Logger mLogger =
org.apache.log4j.Logger.getLogger(SWF9Writer.class);
@@ -420,13 +434,526 @@
}
- public void importFontStyle(String fileName, String face, String style,
- CompilationEnvironment env)
+ /**
+ * Import a font of a given style into the SWF we are writing.
+ *
+ * @param fileName filename for font in LZX
+ * @param face face name of font
+ * @param style style of font
+ */
+ void importFontStyle(String fileName, String face, String style,
+ CompilationEnvironment env)
throws FileNotFoundException, CompilationError {
- env.warn("SWF9Writer does not support importing fonts");
+
+ int styleBits = FontInfo.styleBitsFromString(style);
+
+ mLogger.debug(
+ /* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="importing " + p[0] + " of style " + p[1]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-1225", new Object[] {face,
style})
+ );
+
+ FontInfo fontInfo = mEnv.getCanvas().getFontInfo();
+ boolean isDefault = false;
+
+ Font font = importFont(fileName, face, styleBits, false);
+
+ if (fontInfo.getName().equals(face)) {
+ if (styleBits == FontInfo.PLAIN) {
+ isDefault = true;
+ }
+ }
+
+ FontFamily family = mFontManager.getFontFamily(face, true);
+
+ switch (styleBits) {
+ case FontInfo.PLAIN:
+ if (family.plain != null) {
+ if (!isDefault) {
+ warn(env,
+ /* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="Redefined plain style of font: " + p[0]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-1252", new
Object[] {face})
+ );
+ }
+ }
+ family.plain = font; break;
+ case FontInfo.BOLD:
+ if (family.bold != null) {
+ warn(env,
+ /* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="Redefined bold style of font: " + p[0]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-1265", new Object[]
{face})
+ );
+ }
+ family.bold = font; break;
+ case FontInfo.ITALIC:
+ if (family.italic != null) {
+ warn(env,
+ /* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="Redefined italic style of font: " + p[0]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-1277", new Object[]
{face})
+ );
+ }
+ family.italic = font; break;
+ case FontInfo.BOLDITALIC:
+ if (family.bitalic != null) {
+ warn(env,
+ /* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="Redefined bold italic style of font: " + p[0]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-1289", new Object[]
{face})
+ );
+ }
+ family.bitalic = font; break;
+ default:
+ throw new ChainedException(
+ /* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="Unexpected style"
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-1300")
+ );
+ }
+
+ mLogger.debug(
+ /* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="Adding font family: " + p[0]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-1502", new Object[] {face})
+ );
+
+
+
+ // TODO [ hqm 2008-01 ]
+ // Add entry to LFC font manager table. Do we actually need to add
font metrics ?
+ // Does anybody use them?
+
+ StringBuffer sbuf = new StringBuffer();
+ sbuf.append("LzFontManager.addFont('" + face + "', " );
+ appendFont(sbuf, family.plain, family.getBounds(FontInfo.PLAIN));
+ sbuf.append(",");
+ appendFont(sbuf, family.bold, family.getBounds(FontInfo.BOLD));
+ sbuf.append(",");
+ appendFont(sbuf, family.italic, family.getBounds(FontInfo.ITALIC));
+ sbuf.append(",");
+ appendFont(sbuf, family.bitalic,
family.getBounds(FontInfo.BOLDITALIC));
+ sbuf.append("\n)\n");
+ addScript(sbuf.toString());
}
+ /**
+ * Import a font into the SWF we are writing
+ *
+ * @param fileName name of font file
+ * @param face font name of font in LZX
+ */
+ private Font importFont(String fileName, String face, int styleBits,
+ boolean replace)
+ throws FileNotFoundException, CompilationError {
+
+ if (isDeviceFont(face)) {
+ return Font.createDummyFont(face);
+ }
+
+ File fontFile = new File(fileName);
+
+ String fromType = FontType.fromName(fileName);
+ Font font = Font.createDummyFont(face);
+ long fileSize = FileUtils.getSize(fontFile);
+
+ // TODO [hqm 2008-01] Do we need to parse out the font metrics
+ // here? Code is in SWFWriter, I haven't copied it over here yet.
+ // That requires the JGenerator transcoder, which only does the first
+ // 256 chars in the font, kind of useless.
+
+ Element elt = new Element("font");
+ elt.setAttribute("face", face);
+ elt.setAttribute("style", FontInfo.styleBitsToString(styleBits, true));
+ elt.setAttribute("location", fontFile.getAbsolutePath());
+ elt.setAttribute("source", fileName);
+ elt.setAttribute("filesize", "" + fileSize);
+ mInfo.addContent(elt);
+
+ // Put in our face name
+ font.fontName = face;
+
+ // Clean out existing styles.
+ font.flags &= ~(Font.BOLD | Font.ITALIC);
+
+ // Write in ours.
+ if ((styleBits & FontInfo.BOLD) != 0) {
+ font.flags |= Font.BOLD;
+ }
+ if ((styleBits & FontInfo.ITALIC) != 0) {
+ font.flags |= Font.ITALIC;
+ }
+
+ /*
+ [Embed(mimeType='application/x-font', source='../assets/BELLB.TTF',
+ fontName='myBellFont', fontWeight='bold')]
+ // This variable is not used. It exists so that the compiler will
link
+ // in the font.
+ private var myFontClass:Class;
+
+ */
+
+ StringBuffer sbuf = new StringBuffer();
+ sbuf.append("#passthrough {\n");
+ String rpath;
+ File inputFile = fontFile;
+ try {
+ rpath = inputFile.getCanonicalPath();
+ // Fix Winblows pathname backslash lossage
+ rpath = rpath.replaceAll("\\\\", "/");
+ } catch (IOException e) {
+ throw new ImportResourceError(inputFile.toString(), e, mEnv);
+ }
+ String weight = FontInfo.styleBitsToString(styleBits, true);
+
+ sbuf.append("[Embed(mimeType='application/x-font', source='"+rpath+"',
fontName='"+
+ face+"', fontWeight='"+weight+"')]\n");
+ String assetClassname = "__embed_lzfont_" + face;
+ sbuf.append("var "+assetClassname+":Class;\n");
+ sbuf.append("}#\n");
+ addScript(sbuf.toString());
+ return font;
+ }
+
+
+ /**
+ * @return height of fontinfo in pixels
+ * @param fontInfo
+ */
+ double getFontHeight (FontInfo fontInfo) {
+ return fontHeight(getFontFromInfo(fontInfo));
+ }
+
+ /**
+ * @return lineheight which lfc LzInputText expects for a given fontsize
+ */
+ double getLFCLineHeight (FontInfo fontInfo, int fontsize) {
+ return lfcLineHeight(getFontFromInfo(fontInfo), fontsize);
+ }
+
+ /**
+ * Convert em units to pixels, truncated to 2 decimal places.
+ * Slow float math... but simple code to read.
+ *
+ * @param units number of 1024 em units
+ * @return pixels
+ */
+ private static double emUnitsToPixels(int units) {
+ int x = (100 * units * DEFAULT_SIZE) / 1024;
+ return (double)(x / 100.0);
+ }
+
+ /**
+ * Compute font bounding box
+ *
+ * @param font
+ */
+ static double fontHeight(Font font) {
+ if (font == null) { return 0; }
+ double ascent = emUnitsToPixels(font.ascent);
+ double descent = emUnitsToPixels(font.descent);
+ double leading = emUnitsToPixels(font.leading);
+ double lineheight = ascent+descent+leading;
+ return lineheight;
+ }
+
+ /**
+ * Compute font bounding box
+ *
+ * @param font
+ */
+ double lfcLineHeight(Font font, int fontsize) {
+ double ascent = emUnitsToPixels(font.ascent);
+ double descent = emUnitsToPixels(font.descent);
+ //double leading = emUnitsToPixels(font.leading);
+ double lineheight = mTextLeading + ((ascent+descent) *
((double)fontsize) / DEFAULT_SIZE);
+ return lineheight;
+ }
+
+ /**
+ * Appends font to actionscript string buffer
+ * @param actions string
+ * @param font font
+ */
+ private static void appendFont(StringBuffer actions, Font font,
+ Rectangle2D[] bounds) {
+
+ final String newline = "\n ";
+ actions.append(newline);
+
+ if (font == null) {
+ actions.append("null");
+ return;
+ }
+
+ double ascent = emUnitsToPixels(font.ascent);
+ double descent = emUnitsToPixels(font.descent);
+ double leading = emUnitsToPixels(font.leading);
+
+ final String comma = ", ";
+
+ actions.append("{");
+ actions.append("ascent:");
+ actions.append(ascent);
+ actions.append(comma);
+ actions.append("descent:");
+ actions.append(descent);
+ actions.append(comma);
+ actions.append("leading:");
+ actions.append(leading);
+ actions.append(comma);
+ actions.append("advancetable:");
+
+ int idx, adv;
+
+ actions.append(newline);
+ actions.append("[");
+ // FIXME: [2003-03-19 bloch] We only support ANSI 8bit (up to
+ // 255) char encodings. We lose the higher characters is
+ // UNICODE and we don't support anything else.
+
+ for(int i = 0; i < 256; i++) {
+ idx = font.getIndex(i);
+ adv = font.getAdvanceValue(idx);
+
+ // Convert to pixels rounded to nearest 100th
+ double advance = emUnitsToPixels(adv);
+ actions.append(advance);
+ if (i != 255) {
+ actions.append(comma);
+ }
+
+ if (i%10 == 9) {
+ actions.append(newline);
+ }
+ }
+ actions.append("],");
+ actions.append(newline);
+
+ actions.append("lsbtable:");
+ actions.append(newline);
+ actions.append("[");
+
+ int m;
+ int max;
+ int adj;
+ for(int i = 0; i < 256; i++) {
+ idx = font.getIndex(i);
+ try {
+ m = (int)bounds[idx].getMinX();
+ //max = (int)bounds[idx].getMaxX();
+ } catch (Exception e) {
+ m = 0;
+ //max = 0;
+ }
+ adv = font.getAdvanceValue(idx);
+ adj = m;
+ if (adj < 0) adj = 0;
+
+ /* The following makes the lsb bigger
+ but is strictly wrong */
+ /*max = max - adv;
+ if (max < 0) max = 0;
+
+ if (max > adj) {
+ adj = max;
+ }*/
+
+ // Convert to pixels rounded to nearest 100th
+ double lsb = emUnitsToPixels(adj);
+ actions.append(lsb);
+ if (i != 255) {
+ actions.append(comma);
+ }
+
+ if (i%10 == 9) {
+ actions.append(newline);
+ }
+ }
+
+ actions.append("],");
+
+ actions.append(newline);
+ actions.append("rsbtable:");
+ actions.append(newline);
+ actions.append("[");
+
+ for(int i = 0; i < 256; i++) {
+ idx = font.getIndex(i);
+ try {
+ m = (int)bounds[idx].getMaxX();
+ } catch (Exception e) {
+ m = 0;
+ }
+ adv = font.getAdvanceValue(idx);
+ adj = m - adv;
+ if (adj < 0) adj = 0;
+
+ // Convert to pixels rounded to nearest 100th
+ double rsb = emUnitsToPixels(adj);
+ actions.append(rsb);
+ if (i != 255) {
+ actions.append(comma);
+ }
+
+ if (i%10 == 9) {
+ actions.append(newline);
+ }
+ }
+
+ actions.append("]}");
+ }
+
+
+
+ /**
+ * @return font given a font info
+ */
+ private Font getFontFromInfo(FontInfo fontInfo) {
+ // This will bring in the default bold ofnt if it's not here yet
+ checkFontExists(fontInfo);
+ String fontName = fontInfo.getName();
+ FontFamily family = mFontManager.getFontFamily(fontName);
+ String style = fontInfo.getStyle();
+
+ if (family == null) {
+ return null;
+ /*
+ throw new CompilationError("Font '" + fontName +
+ "' used but not defined");
+ */
+ }
+ Font font = family.getStyle(fontInfo.styleBits);
+ if (font == null) {
+ throw new CompilationError(
+/* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="Font '" + p[0] + "' style ('" + p[1] + "') used but not defined"
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-2089", new
Object[] {fontName, style})
+ );
+ }
+ return font;
+ }
+
+ /**
+ * @return true if the font exists
+ *
+ * If this is the default bold font and it hasn't been
+ * declared, import it.
+ */
+ boolean checkFontExists(FontInfo fontInfo) {
+
+ // Bulletproofing...
+ if (fontInfo.getName() == null) {
+ return false;
+ }
+
+ boolean a = mFontManager.checkFontExists(fontInfo);
+ if (a) {
+ return a;
+ }
+
+ if (fontInfo.getName().equals(mDefaultFontName) &&
+ fontInfo.styleBits == FontInfo.PLAIN) {
+ try {
+ File f = mEnv.resolve(mDefaultFontFileName, null);
+ importFontStyle(f.getAbsolutePath(), mDefaultFontName,
"plain", mEnv);
+ } catch (FileNotFoundException fnfe) {
+ throw new CompilationError(
+/* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="default font " + p[0] + " missing " + p[1]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-2125", new
Object[] {mDefaultFontFileName, fnfe})
+ );
+ }
+ return true;
+ }
+
+ if (fontInfo.getName().equals(mDefaultFontName) &&
+ fontInfo.styleBits == FontInfo.BOLD) {
+ try {
+ File f = mEnv.resolve(mDefaultBoldFontFileName, null);
+ importFontStyle(f.getAbsolutePath(), mDefaultFontName, "bold",
mEnv);
+ } catch (FileNotFoundException fnfe) {
+ throw new CompilationError(
+/* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="default bold font " + p[0] + " missing " + p[1]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-2143", new
Object[] {mDefaultBoldFontFileName, fnfe})
+ );
+ }
+ return true;
+ }
+
+ if (fontInfo.getName().equals(mDefaultFontName) &&
+ fontInfo.styleBits == FontInfo.ITALIC) {
+ try {
+ File f = mEnv.resolve(mDefaultItalicFontFileName, null);
+ importFontStyle(f.getAbsolutePath(), mDefaultFontName,
"italic", mEnv);
+ } catch (FileNotFoundException fnfe) {
+ throw new CompilationError(
+/* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="default italic font " + p[0] + " missing " + p[1]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-2161", new
Object[] {mDefaultItalicFontFileName, fnfe})
+ );
+ }
+ return true;
+ }
+
+ if (fontInfo.getName().equals(mDefaultFontName) &&
+ fontInfo.styleBits == FontInfo.BOLDITALIC) {
+ try {
+ File f = mEnv.resolve(mDefaultBoldItalicFontFileName, null);
+ importFontStyle(f.getAbsolutePath(), mDefaultFontName, "bold
italic", mEnv);
+ } catch (FileNotFoundException fnfe) {
+ throw new CompilationError(
+/* (non-Javadoc)
+ * @i18n.test
+ * @org-mes="default bold italic font " + p[0] + " missing " + p[1]
+ */
+ org.openlaszlo.i18n.LaszloMessages.getMessage(
+ SWFWriter.class.getName(),"051018-2179", new
Object[] {mDefaultBoldItalicFontFileName, fnfe})
+ );
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+
void addPreloaderScript(String script) { } ;
void addPreloader(CompilationEnvironment env) { } ;
Modified: openlaszlo/branches/devildog/test/swf9/hello-font.lzx
===================================================================
--- openlaszlo/branches/devildog/test/swf9/hello-font.lzx 2008-01-16
04:40:20 UTC (rev 7838)
+++ openlaszlo/branches/devildog/test/swf9/hello-font.lzx 2008-01-16
16:54:08 UTC (rev 7839)
@@ -3,14 +3,28 @@
trace('foo oninit handler!');
</handler>
- <font name="Arioso" src="ariosor.ttf" />
+ <font name="xxArioso" src="ariosor.ttf" />
+ <font name="chev" src="chevaraor.ttf"/>
+ <text
+ font="xxArioso">Arioso aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk
lll mmm nnn ooo ppp qqq</text>
- <text fontsize="18" font="Arioso">Arioso aaa bbb ccc ddd eee fff ggg hhh
iii jjj kkk lll mmm nnn ooo ppp qqq</text>
+ <text y="50"
+ fontsize="18" font="xxArioso">Arioso aaa bbb ccc ddd eee fff ggg hhh
iii jjj kkk lll mmm nnn ooo ppp qqq</text>
+
+ <text y="100"
+ fontsize="36" font="xxArioso">Arioso aaa bbb ccc ddd eee fff ggg hhh
iii jjj kkk lll mmm nnn ooo ppp qqq</text>
+
+
+ <text y="150"
+ fontsize="36" font="chev">Chevaraor aaa bbb ccc ddd eee fff ggg hhh
iii jjj kkk lll mmm nnn ooo ppp qqq</text>
+
+
+
</canvas>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved. *
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins