Пример #1
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));
 }
Пример #2
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));
 }
        // 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);
        }