示例#1
0
 public int GetFontWeight(AdaptiveFontType fontType, AdaptiveTextWeight requestedWeight)
 {
     return(FontTypes.GetFontType(fontType).FontWeights.GetFontWeight(requestedWeight)
            ?? FontTypes.Default.FontWeights.GetFontWeight(requestedWeight)
            ?? FontWeights.GetFontWeight(requestedWeight)
            ?? FontWeightsConfig.GetDefaultFontWeight(requestedWeight));
 }
示例#2
0
 public int GetFontSize(AdaptiveFontType fontType, AdaptiveTextSize requestedSize)
 {
     return(FontTypes.GetFontType(fontType).FontSizes.GetFontSize(requestedSize)
            ?? FontTypes.Default.FontSizes.GetFontSize(requestedSize)
            ?? FontSizes.GetFontSize(requestedSize)
            ?? FontSizesConfig.GetDefaultFontSize(requestedSize));
 }
        public FontStyleConfig GetFontType(AdaptiveFontType fontType)
        {
            switch (fontType)
            {
            case AdaptiveFontType.Monospace:
                return(Monospace);

            case AdaptiveFontType.Default:
            default:
                return(Default);
            }
        }
示例#4
0
#pragma warning restore 0618

        private string GetDefaultFontFamily(AdaptiveFontType fontType)
        {
            switch (fontType)
            {
            case AdaptiveFontType.Monospace:
                return("Courier New");

            case AdaptiveFontType.Default:
            default:
                // Leave it up to the platform.
                // Renderer default is usually "Segoe UI"
                return("");
            }
        }
示例#5
0
// Ignore deprecation warnings for Font[Family|Weights|Sizes]
#pragma warning disable 0618
        // Handles inheritance behavior for retrieving the name of the font family given the desired AdaptiveFontType
        public string GetFontFamily(AdaptiveFontType fontType)
        {
            // Value saved in FontTypes.<desiredStyle>
            string fontFamilyValue = FontTypes.GetFontType(fontType).FontFamily;

            if (string.IsNullOrWhiteSpace(fontFamilyValue))
            {
                if (fontType == AdaptiveFontType.Monospace)
                {
                    fontFamilyValue = GetDefaultFontFamily(fontType);
                }
                else
                {
                    // Fallback to deprecated fontFamily value
                    fontFamilyValue = FontFamily;
                    if (string.IsNullOrEmpty(fontFamilyValue))
                    {
                        // Fallback to predefined system default value
                        fontFamilyValue = GetDefaultFontFamily(fontType);
                    }
                }
            }
            return(fontFamilyValue);
        }