diff --git a/lime/tools/platforms/HTML5Platform.hx b/lime/tools/platforms/HTML5Platform.hx
index f879a17e3..df6e40360 100644
--- a/lime/tools/platforms/HTML5Platform.hx
+++ b/lime/tools/platforms/HTML5Platform.hx
@@ -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 = [];
diff --git a/templates/haxe/ManifestResources.hx b/templates/haxe/ManifestResources.hx
index 9f9d144ac..ee755e1af 100644
--- a/templates/haxe/ManifestResources.hx
+++ b/templates/haxe/ManifestResources.hx
@@ -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