Include metrics of embedded fonts in html5
This commit is contained in:
committed by
Joshua Granick
parent
e084ef7c70
commit
d6dc78ff0c
@@ -3,6 +3,7 @@ package lime.tools.platforms;
|
||||
|
||||
import haxe.io.Path;
|
||||
import haxe.Template;
|
||||
import lime.text.Font;
|
||||
import lime.tools.helpers.DeploymentHelper;
|
||||
import lime.tools.helpers.FileHelper;
|
||||
import lime.tools.helpers.HTML5Helper;
|
||||
@@ -339,6 +340,12 @@ class HTML5Platform extends PlatformTarget {
|
||||
|
||||
if (embeddedAsset.type == "font" && embeddedAsset.sourcePath == asset.sourcePath) {
|
||||
|
||||
// in html5 we cannot compute font metrics, so we store them for known fonts
|
||||
var font = Font.fromFile (asset.sourcePath);
|
||||
embeddedAsset.ascender = font.ascender;
|
||||
embeddedAsset.descender = font.descender;
|
||||
embeddedAsset.unitsPerEM = font.unitsPerEM;
|
||||
|
||||
if (shouldEmbedFont) {
|
||||
|
||||
var urls = [];
|
||||
|
||||
@@ -91,14 +91,14 @@ import sys.FileSystem;
|
||||
|
||||
#else
|
||||
|
||||
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__::flatName::') #if display private #end class __ASSET__::flatName:: extends lime.text.Font { public function new () { #if !html5 __fontPath = "::targetPath::"; #end name = "::fontName::"; super (); }}
|
||||
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__::flatName::') #if display private #end class __ASSET__::flatName:: extends lime.text.Font { public function new () { #if !html5 __fontPath = "::targetPath::"; #else ascender = ::ascender::; descender = ::descender::; unitsPerEM = ::unitsPerEM::; #end name = "::fontName::"; super (); }}
|
||||
::end::::end::::end::
|
||||
|
||||
#end
|
||||
|
||||
#if (openfl && !flash)
|
||||
|
||||
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__OPENFL__::flatName::') #if display private #end class __ASSET__OPENFL__::flatName:: extends openfl.text.Font { public function new () { ::if (embed)::var font = new __ASSET__::flatName:: (); src = font.src; name = font.name;::else::#if !html5 ::if (targetPath != null)::__fontPath = #if (ios || tvos) "assets/" + #end "::targetPath::";::else::::if (library != null)::__fontID = "::library:::::id::";::else::__fontID = "::id::";::end::::end:: #end name = "::fontName::";::end:: super (); }}
|
||||
::if (assets != null)::::foreach assets::::if (type == "font")::@:keep @:expose('__ASSET__OPENFL__::flatName::') #if display private #end class __ASSET__OPENFL__::flatName:: extends openfl.text.Font { public function new () { ::if (embed)::__initFromLimeFont(new __ASSET__::flatName:: ());::else::#if !html5 ::if (targetPath != null)::__fontPath = #if (ios || tvos) "assets/" + #end "::targetPath::";::else::::if (library != null)::__fontID = "::library:::::id::";::else::__fontID = "::id::";::end::::end:: #end name = "::fontName::";::end:: super (); }}
|
||||
::end::::end::::end::
|
||||
|
||||
#end
|
||||
|
||||
Reference in New Issue
Block a user