Skip to content
This repository has been archived by the owner on Jan 1, 2021. It is now read-only.

Commit

Permalink
Reinstate embedded fonts (we need them for the rotated text, d'oh) bu…
Browse files Browse the repository at this point in the history
…t move to a separate SWF so that they will hopefully be cached by the browser
  • Loading branch information
systemed committed Jul 16, 2009
1 parent d503a1f commit b7fb5dc
Show file tree
Hide file tree
Showing 28 changed files with 25 additions and 9 deletions.
9 changes: 9 additions & 0 deletions fonts/FontLibrary.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package {
import flash.display.Sprite;
public class FontLibrary extends Sprite {
[Embed(source="fonts/DejaVuSans.ttf", fontFamily="DejaVu", fontWeight="normal", mimeType="application/x-font-truetype")]
public static var DejaVu:Class;

}

}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion halcyon_viewer.as
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ package {
t.multiline=true;
addChild(t);
Globals.vars.debug=t;
t.visible = true;
t.visible = false;

theMap = new Map(this.loaderInfo.parameters);
theMap.updateSize(stage.stageWidth, stage.stageHeight);
Expand Down
13 changes: 11 additions & 2 deletions net/systemeD/halcyon/Map.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package net.systemeD.halcyon {

import flash.text.TextField;
import flash.display.DisplayObjectContainer;
import flash.display.Loader;
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Stage;
import flash.display.BitmapData;
import flash.display.LoaderInfo;
import flash.text.Font;
import flash.utils.ByteArray;
import flash.events.*;
import flash.net.*;
Expand Down Expand Up @@ -99,7 +101,6 @@ package net.systemeD.halcyon {
connection.addEventListener(Connection.NEW_WAY, newWayCreated);
connection.addEventListener(Connection.NEW_POI, newPOICreated);
connection.getEnvironment(new Responder(gotEnvironment,connectionError));

}

private function getPaintSprite():Sprite {
Expand All @@ -109,6 +110,15 @@ package net.systemeD.halcyon {
}

public function gotEnvironment(r:Object):void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, gotFont);
loader.load(new URLRequest("FontLibrary.swf"));
}

public function gotFont(r:Event):void {
var FontLibrary:Class = r.target.applicationDomain.getDefinition("FontLibrary") as Class;
Font.registerFont(FontLibrary.DejaVu);

if (initparams.hasOwnProperty('lat')) {
// parameters sent from HTML
init(initparams['lat'],
Expand Down Expand Up @@ -311,7 +321,6 @@ package net.systemeD.halcyon {
}

public function mouseUpHandler(event:MouseEvent):void {
addDebug("up");
if (!dragging) { return; }
dragging=false;
updateCoords(x,y);
Expand Down
2 changes: 1 addition & 1 deletion net/systemeD/halcyon/POI.as
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package net.systemeD.halcyon {
private var iconname:String=''; // name of icon

public static const DEFAULT_TEXTFIELD_PARAMS:Object = {
embedFonts: true,
// embedFonts: true,
antiAliasType: AntiAliasType.ADVANCED,
gridFitType: GridFitType.NONE
};
Expand Down
4 changes: 1 addition & 3 deletions net/systemeD/halcyon/WayUI.as
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ package net.systemeD.halcyon {
antiAliasType: AntiAliasType.ADVANCED,
gridFitType: GridFitType.NONE
};
// [Embed(source="fonts/DejaVuSans.ttf", fontFamily="DejaVu", fontWeight="normal", mimeType="application/x-font-truetype")]
// public static var DejaVu:Class;
public var nameformat:TextFormat;


Expand Down Expand Up @@ -316,10 +314,10 @@ package net.systemeD.halcyon {

private function rotatedLetter(char:String, t:Number, w:Number, h:Number, a:Number, o:Number):TextField {
var tf:TextField = new TextField();
tf.embedFonts = true;
tf.mouseEnabled = false;
tf.mouseWheelEnabled = false;
tf.defaultTextFormat = nameformat;
tf.embedFonts = true;
tf.text = char;
tf.width = tf.textWidth+4;
tf.height = tf.textHeight+4;
Expand Down
4 changes: 2 additions & 2 deletions net/systemeD/halcyon/styleparser/TextStyle.as
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package net.systemeD.halcyon.styleparser {
public var sublayer:uint=0;

public function getTextFormat():TextFormat {
return new TextFormat(font_name ? font_name : "_sans",
return new TextFormat(font_name ? font_name : "DejaVu",
text_size ? text_size : 8,
text_colour ? text_colour: 0,
font_bold ? font_bold : false,
Expand All @@ -41,7 +41,7 @@ package net.systemeD.halcyon.styleparser {
var tf:TextField = new TextField();
var n:TextFormat = getTextFormat();
n.align = "center";
// tf.embedFonts = true;
tf.embedFonts = true;
tf.defaultTextFormat = n;
tf.text = a;
if (text_width) {
Expand Down
Binary file added resources/FontLibrary.swf
Binary file not shown.

0 comments on commit b7fb5dc

Please sign in to comment.