Skip to content

Instantly share code, notes, and snippets.

@larsiusprime
Created July 8, 2016 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsiusprime/5df42543a4b09e07274cce2ad9943b83 to your computer and use it in GitHub Desktop.
Save larsiusprime/5df42543a4b09e07274cce2ad9943b83 to your computer and use it in GitHub Desktop.
package;
import flash.text.TextFormat;
import openfl.Assets;
import openfl.display.Sprite;
import openfl.Lib;
import openfl.text.TextField;
import openfl.text.TextFieldAutoSize;
import openfl.text.TextFormatAlign;
/**
* ...
* @author
*/
class Main extends Sprite
{
public function new()
{
super();
var textJP = "蘇りし死体\n奈落では、死体が数日後に生き返ることがある。これらのモンスターは「レブナント」と呼ばれており、これは「帰りし者」を意味する。";
var textEN = "Reanimated Corpse\nIn the pit, corpses often rise again several days after death.\n\nThese monsters are known as \"Revenant,\" meaning, \"Those who Return.\"";
var textRU = "Оживший мертвец\nВ преисподней трупы часто воскресают через несколько дней после смерти.,\nЭти монстры известны как ''загробник'', что означает: ''тот, кто возвратился.''";
drawField(textJP, 20, 20, TextFormatAlign.LEFT);
drawField(textJP, 230, 20, TextFormatAlign.RIGHT);
drawField(textJP, 440, 20, TextFormatAlign.CENTER);
drawField(textEN, 20, 150, TextFormatAlign.LEFT);
drawField(textEN, 230, 150, TextFormatAlign.RIGHT);
drawField(textEN, 440, 150, TextFormatAlign.CENTER);
drawField(textRU, 20, 280, TextFormatAlign.LEFT);
drawField(textRU, 230, 280, TextFormatAlign.RIGHT);
drawField(textRU, 440, 280, TextFormatAlign.CENTER);
}
function drawField(text:String, x:Int, y:Int, align:TextFormatAlign):Void
{
var field:TextField = new TextField();
field.width = 200;
field.setTextFormat(new TextFormat(font("mplus2cb.ttf"),null,null,null,null,null,null,null,align));
field.border = true;
field.wordWrap = true;
field.height = 120;
field.text = text;
field.x = x;
field.y = y;
addChild(field);
}
function font(str:String):String
{
var f = Assets.getFont("assets/" + str);
if (f != null)
{
return f.fontName;
}
return str;
}
}
available here:
http://www.fonts2u.com/m-2c-bold.font
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- NMML reference: https://gist.github.com/1763850 -->
<!-- metadata, make sure 'package' is at least 3 segments (ie. com.mycompany.myproject) -->
<meta title="BadJPText" package="BadJPText" version="1.0.0" company="" />
<!-- output -->
<app main="Main" file="BadJPText" path="bin" />
<window background="#FFFFFF" fps="60" />
<window width="800" height="480" unless="mobile" />
<window orientation="landscape" vsync="false" antialiasing="0" if="cpp" />
<!-- classpath, haxe libs -->
<source path="src" />
<haxelib name="openfl" />
<haxelib name="actuate" />
<!-- assets -->
<icon path="assets/openfl.svg" />
<assets path="assets/img" rename="img" />
<assets path="assets" include="*.ttf" type="font"/>
<!-- optimize output
<haxeflag name="-dce full" /> -->
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment