Exemple #1
0
        internal static Typeface ToTypeface(this IFontElement self)
        {
            if (self.IsDefault())
            {
                return(s_defaultTypeface ?? _DefaultTypeface_Get());
            }

            var      key = new Tuple <string, FontAttributes>(self.FontFamily, self.FontAttributes);
            Typeface result;

            if (Typefaces.TryGetValue(key, out result))
            {
                return(result);
            }

            if (self.FontFamily == null)
            {
                var style = ToTypefaceStyle(self.FontAttributes);
                result = Typeface.Create(_DefaultTypeface_Get(), style);
            }
            else if (LoadFromAssets.IsMatch(self.FontFamily))
            {
                result = Typeface.CreateFromAsset(AApplication.Context.Assets, FontNameToFontFile(self.FontFamily));
            }
            else
            {
                var style = ToTypefaceStyle(self.FontAttributes);
                result = Typeface.Create(self.FontFamily, style);
            }
            return(Typefaces[key] = result);
        }
Exemple #2
0
        internal static Typeface ToTypeface(this IFontElement self)
        {
            if (self.IsDefault())
            {
                return(_sDefaultTypeface ?? (_sDefaultTypeface = Typeface.Default));
            }

            var key = new Tuple <string, FontAttributes>(self.FontFamily, self.FontAttributes);

            if (Typefaces.TryGetValue(key, out var result))
            {
                return(result);
            }

            if (self.FontFamily == null)
            {
                var style = ToTypefaceStyle(self.FontAttributes);
                result = Typeface.Create(Typeface.Default, style);
            }
            else if (IsAssetFontFamily(self.FontFamily))
            {
                result = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, FontNameToFontFile(self.FontFamily));
            }
            else
            {
                var style = ToTypefaceStyle(self.FontAttributes);
                result = Typeface.Create(self.FontFamily, style);
            }

            return(Typefaces[key] = result);
        }
Exemple #3
0
        internal static Typeface ToTypeface(this IFontElement self)
        {
            if (self.IsDefault())
            {
                return(s_defaultTypeface ?? (s_defaultTypeface = Typeface.Default));
            }

            return(ToTypeface(self.FontFamily, self.FontAttributes));
        }
Exemple #4
0
        internal static Typeface ToTypeface(this IFontElement self)
        {
            if (self.IsDefault())
            {
                return(Forms.FontManager.DefaultTypeface);
            }

            return(Forms.FontManager.GetTypeface(Font.OfSize(self.FontFamily, self.FontSize).WithAttributes(self.FontAttributes)));
        }
Exemple #5
0
        internal static Typeface ToTypeface(this IFontElement self)
        {
            if (self.IsDefault())
            {
                return(CompatServiceProvider.FontManager.DefaultTypeface);
            }

            var font = Font.OfSize(self.FontFamily, self.FontSize).WithAttributes(self.FontAttributes);

            return(CompatServiceProvider.FontManager.GetTypeface(font));
        }