コード例 #1
0
 public int GetFontSize(AdaptiveFontStyle fontStyle, AdaptiveTextSize requestedSize)
 {
     return(FontStyles.GetFontStyle(fontStyle).FontSizes.GetFontSize(requestedSize)
            ?? FontStyles.Default.FontSizes.GetFontSize(requestedSize)
            ?? FontSizes.GetFontSize(requestedSize)
            ?? FontSizesConfig.GetDefaultFontSize(requestedSize));
 }
コード例 #2
0
 public int GetFontWeight(AdaptiveFontStyle fontStyle, AdaptiveTextWeight requestedWeight)
 {
     return(FontStyles.GetFontStyle(fontStyle).FontWeights.GetFontWeight(requestedWeight)
            ?? FontStyles.Default.FontWeights.GetFontWeight(requestedWeight)
            ?? FontWeights.GetFontWeight(requestedWeight)
            ?? FontWeightsConfig.GetDefaultFontWeight(requestedWeight));
 }
コード例 #3
0
        // Handles inheritance behavior for retrieving the name of the font family given the desired AdaptiveFontStyle
        public string GetFontFamily(AdaptiveFontStyle fontStyle)
        {
            // Value saved in FontStyles.<desiredStyle>
            string fontFamilyValue = FontStyles.GetFontStyle(fontStyle).FontFamily;

            if (string.IsNullOrEmpty(fontFamilyValue))
            {
                if (fontStyle == AdaptiveFontStyle.Monospace)
                {
                    fontFamilyValue = GetDefaultFontFamily(fontStyle);
                }
                else
                {
                    // Fallback to default fontStyle value
                    fontFamilyValue = FontStyles.Default.FontFamily;
                    if (string.IsNullOrEmpty(fontFamilyValue))
                    {
                        // Fallback to deprecated fontFamily value
                        fontFamilyValue = FontFamily;
                        if (string.IsNullOrEmpty(fontFamilyValue))
                        {
                            // Fallback to predefined system default value
                            fontFamilyValue = GetDefaultFontFamily(fontStyle);
                        }
                    }
                }
            }
            return(fontFamilyValue);
        }
コード例 #4
0
        public FontStyleConfig GetFontStyle(AdaptiveFontStyle fontStyle)
        {
            switch (fontStyle)
            {
            case AdaptiveFontStyle.Monospace:
                return(Monospace);

            case AdaptiveFontStyle.Default:
            default:
                return(Default);
            }
        }
コード例 #5
0
        private string GetDefaultFontFamily(AdaptiveFontStyle fontStyle)
        {
            switch (fontStyle)
            {
            case AdaptiveFontStyle.Monospace:
                return("Courier New");

            case AdaptiveFontStyle.Default:
            default:
                // Leave it up to the platform.
                // Renderer default is usually "Segoe UI"
                return("");
            }
        }