Author: hqm
Date: 2007-06-22 10:07:33 -0700 (Fri, 22 Jun 2007)
New Revision: 5502
Modified:
openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
Log:
Change 20070622-hqm-2 by [EMAIL PROTECTED] on 2007-06-22 12:52:47 EDT
in /cygdrive/c/users/hqm/openlaszlo/legals3
for http://svn.openlaszlo.org/openlaszlo/branches/legals
Summary: Add workaround for loading fonts at runtime from alternate URL
New Features:
Bugs Fixed: LPP-4084
Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
Tests:
test case in bug report, needs to be set up as two different 'web contexts'
(servlet paths) on
a Tomcat server.
test/snippets/ test cases including font loading
Modified:
openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
===================================================================
---
openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
2007-06-22 12:47:46 UTC (rev 5501)
+++
openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
2007-06-22 17:07:33 UTC (rev 5502)
@@ -54,6 +54,9 @@
/** Fonts being collected. */
private FontsCollector mPreloaderFontsCollector = new FontsCollector();
private FontManager mFontManager = new FontManager();
+ /** Have any fonts been imported into this swf movie? */
+ private boolean mLibFontsDefined = false;
+
/** True iff close() has been called. */
private boolean mCloseCalled = false;
@@ -925,27 +928,45 @@
mFlashFile.setCompressed(true);
- ////////////////////////////////////////////////////////////////
- // Add an ImportAssets(2?) to import assets.
- // This actually doesn't seem to be of any use (importing our own
assets)
- // but it does cause the main app to be able to load our fonts for
some reason.
+ // If any fonts have been declared in this library, add an
+ // ImportAssets(2?) to import assets. While this doesn't seem
+ // to be of any use (importing our own assets) it does cause
+ // the font assets to become visible to the main app for some
+ // reason.
+ //
+ // Note: This trick doesn't seem to work for image resource,
+ // unfortunately; we haven't figured out a way to make the
+ // imported image assets be visible/attachable to the loading
+ // movieclip.
- ImportAssets2 ia = new ImportAssets2();
- //System.err.println("setting ImportAssets url="+this.liburl);
- ia.setUrl(this.liburl);
+
+ if (mLibFontsDefined) {
+ ImportAssets2 ia = new ImportAssets2();
+ //System.err.println("setting ImportAssets url="+this.liburl);
+ //get property of base url for fonts to import
+ String importFontUrlPath = LPS.getProperty("import.font.base.url");
+ if (importFontUrlPath != null) {
+ if (importFontUrlPath.endsWith("/") == false) {
+ importFontUrlPath += "/";
+ }
+ if (liburl.startsWith("/")) {
+ liburl = liburl.substring(1);
+ }
+ liburl = importFontUrlPath + liburl;
+ }
+ ia.setUrl(liburl);
+
+ Enumeration enu = mFlashFile.definitions();
+ while (enu.hasMoreElements()) {
+ FlashDef def = (FlashDef) enu.nextElement();
+ ia.addAsset(def.getName(), def);
+ }
- Enumeration enum = mFlashFile.definitions();
- while (enum.hasMoreElements()) {
- FlashDef def = (FlashDef) enum.nextElement();
- ia.addAsset(def.getName(), def);
- //System.err.println("adding def named "+def.getName()+
"[id="+def.getID()+"] to ImportAssets2 defs");
+ Timeline timeline = mFlashFile.getMainScript().getTimeline();
+ Frame frame = timeline.getFrameAt(timeline.getFrameCount() - 1);
+ frame.addFlashObject(ia);
}
- Timeline timeline = mFlashFile.getMainScript().getTimeline();
- Frame frame = timeline.getFrameAt(timeline.getFrameCount() - 1);
- frame.addFlashObject(ia);
-
-
////////////////////////////////////////////////////////////////
// Make sure we stop
@@ -1005,6 +1026,7 @@
boolean isDefault = false;
Font font = importFont(fileName, face, styleBits, false);
+ mLibFontsDefined = true;
if (fontInfo.getName().equals(face)) {
if (styleBits == FontInfo.PLAIN) {
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins