상속: ILanguageFontGroup
        /// <summary>
        /// This is the click handler for the 'Scenario1InputButton' button.  You would replace this with your own handler
        /// if you have a button or buttons on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario1InputButton_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;
            if (b != null)
            {
                var languageFontGroup = new LanguageFontGroup("ja-JP");
                var headingUI = (Windows.UI.Xaml.Controls.TextBlock)this.Scenario1Heading;
                var textUI = (Windows.UI.Xaml.Controls.TextBlock)this.Scenario1Text;

                if (this.oriHeadingUI == null)
                {
                    // Store original font style for Reset
                    this.oriHeadingUI = new LocalFontInfo();
                    this.oriTextUI = new LocalFontInfo();
                    this.oriHeadingUI.Set(headingUI);
                    this.oriTextUI.Set(textUI);
                }

                // Change the Font value with selected font from LanguageFontGroup API
                this.SetFont(headingUI, languageFontGroup.UIHeadingFont);
                this.SetFont(textUI, languageFontGroup.UITextFont);

                this.Output.Visibility = Visibility.Visible;
            }
        }
예제 #2
0
        LocalizationService()
        {
#if HAS_UNO
            m_language      = "en-US";
            m_flowDirection = FlowDirection.LeftToRight;
#else
            m_language      = ApplicationLanguages.Languages[0];
            m_flowDirection =
                ResourceContext.GetForCurrentView().QualifierValues["LayoutDirection"] != "LTR" ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
#endif

            var resourceLoader = AppResourceProvider.GetInstance();
            m_fontFamilyOverride = resourceLoader.GetResourceString("LocalizedFontFamilyOverride");

            string reserved = "RESERVED_FOR_FONTLOC";

            m_overrideFontApiValues = ((m_fontFamilyOverride != null) && (m_fontFamilyOverride != reserved));
            if (m_overrideFontApiValues)
            {
                string localizedUICaptionFontSizeFactorOverride = resourceLoader.GetResourceString("LocalizedUICaptionFontSizeFactorOverride");
                string localizedUITextFontSizeFactorOverride    = resourceLoader.GetResourceString("LocalizedUITextFontSizeFactorOverride");
                string localizedFontWeightOverride = resourceLoader.GetResourceString("LocalizedFontWeightOverride");

                // If any of the font overrides are modified then all of them need to be modified
                Debug.Assert(localizedFontWeightOverride != reserved);
                Debug.Assert(localizedUITextFontSizeFactorOverride != reserved);
                Debug.Assert(localizedUICaptionFontSizeFactorOverride != reserved);

                m_fontWeightOverride               = ParseFontWeight(localizedFontWeightOverride);
                m_uiTextFontScaleFactorOverride    = double.Parse(localizedUITextFontSizeFactorOverride);
                m_uiCaptionFontScaleFactorOverride = double.Parse(localizedUICaptionFontSizeFactorOverride);
            }

            m_fontGroup = new LanguageFontGroup(m_language);
        }
예제 #3
0
        /// <summary>
        /// This is the click handler for the 'Scenario2InputButton' button.  You would replace this with your own handler
        /// if you have a button or buttons on this page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scenario2InputButton_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;
            if (b != null)
            {
                var languageFontGroup = new LanguageFontGroup("hi");
                var headingUI = (Windows.UI.Xaml.Controls.TextBlock)this.Scenario2Heading;
                var textUI = (Windows.UI.Xaml.Controls.TextBlock)this.Scenario2Text;

                if (this.oriHeadingDoc == null)
                {
                    this.oriHeadingDoc = new LocalFontInfo();
                    this.oriTextDoc = new LocalFontInfo();
                    this.oriHeadingDoc.Set(headingUI);
                    this.oriTextDoc.Set(textUI);
                }

                this.SetFont(headingUI, languageFontGroup.DocumentHeadingFont);

                // Not all scripts have recommended fonts for "document alternate"
                // categories, so need to verify before using it. Note that Hindi does
                // have document alternate fonts, so in this case the fallback logic is
                // unnecessary, but (for example) Japanese does not have recommendations
                // for the document alternate 2 category.
                if (languageFontGroup.DocumentAlternate2Font != null)
                {
                    this.SetFont(textUI, languageFontGroup.DocumentAlternate2Font);
                }
                else if (languageFontGroup.DocumentAlternate1Font != null)
                {
                    this.SetFont(textUI, languageFontGroup.DocumentAlternate1Font);
                }
                else
                {
                    this.SetFont(textUI, languageFontGroup.ModernDocumentFont);
                }

                this.Output.Visibility = Visibility.Visible;
            }
        }