Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 13 SystemFont Changes + Previous System Font Issues #1291

Merged
merged 1 commit into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 87 additions & 2 deletions Source/Fuse.Common/Font.uno
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ namespace Fuse
}
}

[UXGlobalResource]
extern (Android) public static readonly Font UltraLight = new SystemFont("sans-serif-thin", SystemFont.Style.Normal, SystemFont.Weight.Thin);

[UXGlobalResource]
extern (Android) public static readonly Font Thin = new SystemFont("sans-serif-thin", SystemFont.Style.Normal, SystemFont.Weight.Thin);

Expand All @@ -100,9 +103,21 @@ namespace Fuse
[UXGlobalResource]
extern (Android) public static readonly Font Medium = new SystemFont("sans-serif", SystemFont.Style.Normal, SystemFont.Weight.Medium);

[UXGlobalResource]
extern (Android) public static readonly Font Semibold = new SystemFont("sans-serif", SystemFont.Style.Normal, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (Android) public static readonly Font Bold = new SystemFont("sans-serif", SystemFont.Style.Normal, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (Android) public static readonly Font Heavy = new SystemFont("sans-serif", SystemFont.Style.Normal, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (Android) public static readonly Font Black = new SystemFont("sans-serif", SystemFont.Style.Normal, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (Android) public static readonly Font UltraLightItalic = new SystemFont("sans-serif-thin", SystemFont.Style.Italic, SystemFont.Weight.Thin);

[UXGlobalResource]
extern (Android) public static readonly Font ThinItalic = new SystemFont("sans-serif-thin", SystemFont.Style.Italic, SystemFont.Weight.Thin);

Expand All @@ -115,9 +130,22 @@ namespace Fuse
[UXGlobalResource]
extern (Android) public static readonly Font MediumItalic = new SystemFont("sans-serif", SystemFont.Style.Italic, SystemFont.Weight.Medium);

[UXGlobalResource]
extern (Android) public static readonly Font SemiboldItalic = new SystemFont("sans-serif", SystemFont.Style.Italic, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (Android) public static readonly Font BoldItalic = new SystemFont("sans-serif", SystemFont.Style.Italic, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (Android) public static readonly Font HeavyItalic = new SystemFont("sans-serif", SystemFont.Style.Italic, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (Android) public static readonly Font BlackItalic = new SystemFont("sans-serif", SystemFont.Style.Italic, SystemFont.Weight.Bold);



[UXGlobalResource]
extern (iOS) public static readonly Font UltraLight = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Normal, SystemFont.Weight.UltraLight);

[UXGlobalResource]
extern (iOS) public static readonly Font Thin = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Normal, SystemFont.Weight.Thin);
Expand All @@ -128,27 +156,57 @@ namespace Fuse
[UXGlobalResource]
extern (iOS) public static readonly Font Regular = new SystemFont(Internal.iOSSystemFont.DefaultFontName);

[UXGlobalResource]
extern (iOS) public static readonly Font Normal = new SystemFont(Internal.iOSSystemFont.DefaultFontName);

[UXGlobalResource]
extern (iOS) public static readonly Font Medium = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Normal, SystemFont.Weight.Medium);

[UXGlobalResource]
extern (iOS) public static readonly Font Semibold = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Normal, SystemFont.Weight.Semibold);

[UXGlobalResource]
extern (iOS) public static readonly Font Bold = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Normal, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (iOS) public static readonly Font Heavy = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Normal, SystemFont.Weight.Heavy);

[UXGlobalResource]
extern (iOS) public static readonly Font Black = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Normal, SystemFont.Weight.Black);

[UXGlobalResource]
extern (iOS) public static readonly Font UltraLightItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.UltraLight);

[UXGlobalResource]
extern (iOS) public static readonly Font ThinItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Light); // Swapped intentionally
extern (iOS) public static readonly Font ThinItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Thin);

[UXGlobalResource]
extern (iOS) public static readonly Font LightItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Thin); // Swapped intentionally
extern (iOS) public static readonly Font LightItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Light);

[UXGlobalResource]
extern (iOS) public static readonly Font Italic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic);

[UXGlobalResource]
extern (iOS) public static readonly Font MediumItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Medium);

[UXGlobalResource]
extern (iOS) public static readonly Font SemiboldItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Semibold);

[UXGlobalResource]
extern (iOS) public static readonly Font BoldItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Bold);

[UXGlobalResource]
extern (iOS) public static readonly Font HeavyItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Heavy);

[UXGlobalResource]
extern (iOS) public static readonly Font BlackItalic = new SystemFont(Internal.iOSSystemFont.DefaultFontName, SystemFont.Style.Italic, SystemFont.Weight.Black);




[UXGlobalResource]
/** The default font of the system, in it's thin weight typeface. */
extern (!iOS && !Android) public static readonly Font UltraLight = new Font(import("Internal/DesktopFonts/Roboto-Thin.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's thin weight typeface. */
Expand All @@ -166,10 +224,25 @@ namespace Fuse
/** The default font of the system, in it's medium typeface. */
extern (!iOS && !Android) public static readonly Font Medium = new Font(import("Internal/DesktopFonts/Roboto-Medium.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's bold typeface. */
extern (!iOS && !Android) public static readonly Font Semibold = new Font(import("Internal/DesktopFonts/Roboto-Bold.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's bold typeface. */
extern (!iOS && !Android) public static readonly Font Bold = new Font(import("Internal/DesktopFonts/Roboto-Bold.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's bold typeface. */
extern (!iOS && !Android) public static readonly Font Heavy = new Font(import("Internal/DesktopFonts/Roboto-Bold.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's bold typeface. */
extern (!iOS && !Android) public static readonly Font Black = new Font(import("Internal/DesktopFonts/Roboto-Bold.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's thin weight typeface. */
extern (!iOS && !Android) public static readonly Font UltraLightItalic = new Font(import("Internal/DesktopFonts/Roboto-ThinItalic.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's thin weight typeface. */
Expand All @@ -187,8 +260,20 @@ namespace Fuse
/** The default font of the system, in it's medium and italic typeface. */
extern (!iOS && !Android) public static readonly Font MediumItalic = new Font(import("Internal/DesktopFonts/Roboto-MediumItalic.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's bold and italic typeface. */
extern (!iOS && !Android) public static readonly Font SemiboldItalic = new Font(import("Internal/DesktopFonts/Roboto-BoldItalic.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's bold and italic typeface. */
extern (!iOS && !Android) public static readonly Font BoldItalic = new Font(import("Internal/DesktopFonts/Roboto-BoldItalic.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's bold and italic typeface. */
extern (!iOS && !Android) public static readonly Font HeavyItalic = new Font(import("Internal/DesktopFonts/Roboto-BoldItalic.ttf"));

[UXGlobalResource]
/** The default font of the system, in it's bold and italic typeface. */
extern (!iOS && !Android) public static readonly Font BlackItalic = new Font(import("Internal/DesktopFonts/Roboto-BoldItalic.ttf"));
}
}
16 changes: 16 additions & 0 deletions Source/Fuse.Common/Internal/SystemFont.uno
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ namespace Fuse.Internal
public readonly int Index;
public readonly IEnumerable<string> Styles;

//iOS13+ - for default systemfont
extern(IOS) internal bool IsCustomFont = true;
extern(IOS) internal Fuse.SystemFont.Style FontStyle; //normal/italic
extern(IOS) internal Fuse.SystemFont.Weight FontWeight; //thin/light/regular/bold/etc
extern(IOS) internal Fuse.SystemFont.Design FontDesign; //default/monospaced/rounded/serif
extern(IOS) internal int FontSize; //12/16/etc

/** Create a `FontFaceDescriptor` that selects the face by matching the its string. */
public FontFaceDescriptor(FileSource fileSource, IEnumerable<string> styles)
{
Expand Down Expand Up @@ -52,6 +59,15 @@ namespace Fuse.Internal
}
return hash;
}

extern(IOS) internal void SetFontAttributes(Fuse.SystemFont.Style fontStyle, Fuse.SystemFont.Weight fontWeight, Fuse.SystemFont.Design fontDesign, int fontSize, bool isCustomFont)
{
FontStyle = fontStyle;
FontWeight = fontWeight;
FontDesign = fontDesign;
FontSize = fontSize;
IsCustomFont = isCustomFont;
}
}

static class SystemFont
Expand Down
Loading