/// <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
        /// <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;
            }
        }