diff --git a/Documentation/input/_Head.cshtml b/Documentation/input/_Head.cshtml
index 1c5145a73..588052125 100644
--- a/Documentation/input/_Head.cshtml
+++ b/Documentation/input/_Head.cshtml
@@ -1,3 +1,4 @@
+
\ No newline at end of file
diff --git a/Documentation/input/examples/render-customization/colors-fonts.cshtml b/Documentation/input/examples/render-customization/colors-fonts.cshtml
index bf3560111..5723fff49 100644
--- a/Documentation/input/examples/render-customization/colors-fonts.cshtml
+++ b/Documentation/input/examples/render-customization/colors-fonts.cshtml
@@ -16,7 +16,7 @@ Order: 10
-
copyrightFont
Font
Music copyright information in page layouts
12px Arial bold
+
copyrightFont
Font
Music copyright information in page layouts
bold 12px Arial
titleFont
Font
Title of the song in page layouts
32px Georgia
subTitleFont
Font
Subtitle of the song in page layouts
20px Georgia
wordsFont
Font
Lyrics information of the song in page layouts
15px Georgia
@@ -26,7 +26,7 @@ Order: 10
graceFont
Font
The numbers grace notes in tablature staves
11px Arial
barNumberFont
Font
The numbers above bars
11px Arial
fingeringFont
Font
The numbers shown for fingering information
14px Georgia
-
markerFont
Font
The section marker labels
14px Arial bold
+
markerFont
Font
The section marker labels
bold 14px Arial
staffLineColor
Color
The lines for all staves
rgb(165,165,165)
barSeparatorColor
Color
The lines for bar separators and repeat indicators
rgb(34,34,17)
@@ -44,7 +44,7 @@ Order: 10
Usage of different fonts
- The usage of other fonts can result in alignment or layouting issues and in a slighly worse performance. If such problems are detected, please inform us on GitHub. The format for fonts is similar to the CSS shorthand font declarations but with some limitations: Size Family Style. No relative font sizes are supported and every size beside px will be converted to px. For styles italic and bold are supported.
+ The usage of other fonts can result in alignment or layouting issues and in a slighly worse performance. If such problems are detected, please inform us on GitHub. The format for fonts is similar to the CSS shorthand font declarations but with some limitations: Style Size Family. No relative font sizes are supported and every size beside px will be converted to px. For styles italic and bold are supported.
-For the .net platform any installed font on the system can be used. For JavaScript until this feature is implemented the 2 fonts "Arial" and "Georgia" are officially supported. Due to the nature of Web Workers, no font metrics are available which needs a custom solution for measuring texts.
-
-On .net simply construct the Font object to configure your desired fonts. For JavaScript you can use any CSS font property compliant string. Relative font sizes with percentual values are not supported.
+For the .net platform any installed font on the system can be used. Simply construct the Font object to configure your desired fonts.
+
+
+For the JavaScript platform any font that might be installed on the client machines can be used. Any additional fonts can be added via WebFonts. The rendering of the score will be delayed until it is detected that the font was loaded. Simply use any CSS font property compliant string as configuration. Relative font sizes with percentual values are not supported, remaining values will be considered if supported.
diff --git a/Phase/Mscorlib/system/CsString.hx b/Phase/Mscorlib/system/CsString.hx
index cc6ab031c..a56cabd0f 100644
--- a/Phase/Mscorlib/system/CsString.hx
+++ b/Phase/Mscorlib/system/CsString.hx
@@ -358,4 +358,5 @@ abstract CsString(String) from String to String
@:op(A + B) public static inline function add16(lhs : system.CsString, rhs : system.Single) : system.CsString return lhs + rhs.toString();
@:op(A + B) public static inline function add17(lhs : system.CsString, rhs : system.Double) : system.CsString return lhs + rhs.toString();
@:op(A + B) public static inline function add18(lhs : system.CsString, rhs : system.CsString) : system.CsString return lhs.toHaxeString() + rhs.toHaxeString();
+ @:op(A + B) public static inline function add19(lhs : system.CsString, rhs : system.Boolean) : system.CsString return lhs.toHaxeString() + Std.string(rhs);
}
\ No newline at end of file
diff --git a/Samples/CSharp/AlphaTab.Samples.PngDump/Program.cs b/Samples/CSharp/AlphaTab.Samples.PngDump/Program.cs
index 1cac59557..f1da2231c 100644
--- a/Samples/CSharp/AlphaTab.Samples.PngDump/Program.cs
+++ b/Samples/CSharp/AlphaTab.Samples.PngDump/Program.cs
@@ -52,7 +52,7 @@ private static void Main(string[] args)
var info = new FileInfo(args[0]);
var path = Path.Combine(info.DirectoryName, Path.GetFileNameWithoutExtension(info.Name) + "-" + i + ".png");
- using (var full = SKSurface.Create(totalWidth, totalHeight, SKImageInfo.PlatformColorType, SKAlphaType.Premul))
+ using (var full = SKSurface.Create(new SKImageInfo(totalWidth, totalHeight, SKImageInfo.PlatformColorType, SKAlphaType.Premul)))
{
var y = 0;
foreach (var image in images)
diff --git a/Source/AlphaTab.CSharp/Platform/CSharp/ManagedUiFacade.cs b/Source/AlphaTab.CSharp/Platform/CSharp/ManagedUiFacade.cs
index a7adc889f..05e2f641a 100644
--- a/Source/AlphaTab.CSharp/Platform/CSharp/ManagedUiFacade.cs
+++ b/Source/AlphaTab.CSharp/Platform/CSharp/ManagedUiFacade.cs
@@ -10,7 +10,7 @@
namespace AlphaTab.Platform.CSharp
{
- public abstract class ManagedUiFacade : IUiFacade
+ internal abstract class ManagedUiFacade : IUiFacade
{
protected ConcurrentQueue TotalResultCount { get; private set; }
diff --git a/Source/AlphaTab.CSharp/Platform/Svg/FontSizes.cs b/Source/AlphaTab.CSharp/Platform/Svg/FontSizes.cs
new file mode 100644
index 000000000..b7ab8f728
--- /dev/null
+++ b/Source/AlphaTab.CSharp/Platform/Svg/FontSizes.cs
@@ -0,0 +1,27 @@
+namespace AlphaTab.Platform.Svg
+{
+ ///
+ /// This public class stores text widths for several fonts and allows width calculation
+ ///
+ internal partial class FontSizes
+ {
+ public static void GenerateFontLookup(string family)
+ {
+ if (FontSizeLookupTables == null)
+ {
+ Init();
+ }
+
+ if (FontSizeLookupTables.ContainsKey(family))
+ {
+ return;
+ }
+
+ // TODO: maybe allow fallback to GDI/Skia based on availability?
+ FontSizeLookupTables[family] = new byte[]
+ {
+ 8
+ };
+ }
+ }
+}
diff --git a/Source/AlphaTab.JavaScript/Collections/FastDictionary.cs b/Source/AlphaTab.JavaScript/Collections/FastDictionary.cs
index a1cfe8679..713b2ff02 100644
--- a/Source/AlphaTab.JavaScript/Collections/FastDictionary.cs
+++ b/Source/AlphaTab.JavaScript/Collections/FastDictionary.cs
@@ -1,6 +1,5 @@
using System.Collections;
using System.Collections.Generic;
-using System.Runtime.CompilerServices;
using Phase;
using Phase.Attributes;
diff --git a/Source/AlphaTab.JavaScript/Environment.cs b/Source/AlphaTab.JavaScript/Environment.cs
index fe8ffd375..c542800d5 100644
--- a/Source/AlphaTab.JavaScript/Environment.cs
+++ b/Source/AlphaTab.JavaScript/Environment.cs
@@ -6,6 +6,7 @@
using AlphaTab.Platform.Svg;
using AlphaTab.Rendering.Glyphs;
using AlphaTab.Util;
+using AlphaTab.Utils;
using Haxe;
using Phase;
using StringBuilder = AlphaTab.Collections.StringBuilder;
@@ -20,17 +21,8 @@ namespace AlphaTab
internal partial class Environment
{
public static string ScriptFile { get; set; }
- public static bool IsFontLoaded { get; set; }
- public static event Action FontLoaded;
- private static void OnFontLoaded()
- {
- var handler = FontLoaded;
- if (handler != null)
- {
- handler();
- }
- }
+ public static FontLoadingChecker BravuraFontChecker { get; private set; }
private static void PlatformInit()
{
@@ -133,7 +125,10 @@ private static void PlatformInit()
}
}
- CheckForFontAvailability();
+ BravuraFontChecker = new FontLoadingChecker("alphaTab",
+ "" + (int)MusicFontSymbol.ClefG + ";"
+ );
+ BravuraFontChecker.CheckForFontAvailability();
}
else
{
@@ -207,95 +202,5 @@ private static string ScriptFileFromStack(string stack)
return matches[1];
}
-
- public static void CheckForFontAvailability()
- {
- var isWorker =
- Script.Write(
- "untyped __js__(\"typeof(WorkerGlobalScope) !== 'undefined' && self instanceof WorkerGlobalScope\")");
- if (isWorker)
- {
- // no web fonts in web worker
- IsFontLoaded = false;
- return;
- }
-
- var cssFontLoadingModuleSupported = Browser.Document.Fonts.IsTruthy() &&
- Browser.Document.Fonts.Member