Example #1
0
            /// <summary>
            /// Creates a run reflecting the current context settings.
            /// </summary>
            /// <returns></returns>
            public Run CreateRun(string text)
            {
                var run = new Run {
                    Text = text
                };

                if (FontSize.HasValue)
                {
                    run.FontSize = FontSize.Value;
                }
                if (FontWeight.HasValue)
                {
                    run.FontWeight = FontWeight.Value;
                }
                if (FontStyle.HasValue)
                {
                    run.FontStyle = FontStyle.Value;
                }
                if (FontVariants.HasValue)
                {
                    Typography.SetVariants(run, FontVariants.Value);
                }
                if (Foreground != null)
                {
                    run.Foreground = Foreground;
                }
                if (FontFamily != null)
                {
                    run.FontFamily = FontFamily;
                }
                run.TextDecorations = TextDecorations;
                return(run);
            }
Example #2
0
        /// <summary>
        /// Inits the font family names from DirectWrite
        /// </summary>
        private void InitTextFormatLayout()
        {
            FontFamilyName = "Gabriola";
            FontSize       = 72;
            FontText       = "Client Drawing Effect Example!";

            // Initialize a TextFormat
            CurrentTextFormat = new TextFormat(FactoryDWrite, FontFamilyName, FontSize)
            {
                TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center
            };

            CurrentTextLayout = new TextLayout(FactoryDWrite, FontText, CurrentTextFormat, ClientRectangle.Width, ClientRectangle.Height);

            RedDrawingeffect   = new ColorDrawingEffect(new Color4(1, 1, 0, 0));
            BlueDrawingEffect  = new ColorDrawingEffect(new Color4(1, 0, 0, 1));
            GreenDrawingEffect = new ColorDrawingEffect(new Color4(1, 0, 1, 0));

            CurrentTextLayout.SetDrawingEffect(RedDrawingeffect, new TextRange(0, 14));
            CurrentTextLayout.SetDrawingEffect(BlueDrawingEffect, new TextRange(14, 7));
            CurrentTextLayout.SetDrawingEffect(GreenDrawingEffect, new TextRange(21, 8));

            // Set a stylistic typography
            var typo = new Typography(FactoryDWrite);

            typo.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1));
            CurrentTextLayout.SetTypography(typo, CurrentTextRange);
            typo.Release();
        }
Example #3
0
        /// <summary>
        /// Inits the font family names from DirectWrite
        /// </summary>
        private void InitTextFormatLayout()
        {
            FontFamilyName = "Gabriola";
            FontSize       = 72;
            FontText       = "Client Drawing Effect Example!";

            // Initialize a TextFormat
            CurrentTextFormat = new TextFormat(FactoryDWrite, FontFamilyName, FontSize);
            CurrentTextFormat.TextAlignment      = TextAlignment.Center;
            CurrentTextFormat.ParagraphAlignment = ParagraphAlignment.Center;

            CurrentTextLayout = new TextLayout(FactoryDWrite, FontText, CurrentTextFormat, ClientRectangle.Width, ClientRectangle.Height);

            RedDrawingeffect   = new ColorDrawingEffect(Color.Red);
            BlueDrawingEffect  = new ColorDrawingEffect(Color.Blue);
            GreenDrawingEffect = new ColorDrawingEffect(Color.Green);

            CurrentTextLayout.SetDrawingEffect(RedDrawingeffect, new TextRange(0, 14));
            CurrentTextLayout.SetDrawingEffect(BlueDrawingEffect, new TextRange(14, 7));
            CurrentTextLayout.SetDrawingEffect(GreenDrawingEffect, new TextRange(21, 8));
            CurrentTextLayout.SetUnderline(true, new TextRange(0, 20));
            CurrentTextLayout.SetStrikethrough(true, new TextRange(22, 7));

            // Set a stylistic typography
            using (var typo = new Typography(FactoryDWrite))
            {
                typo.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1));
                CurrentTextLayout.SetTypography(typo, CurrentTextRange);
            }
        }
            public object Render(Blade blade)
            {
                object PrepareBody(object body)
                {
                    if (body is string strBody)
                    {
                        return(Typography.P(strBody));
                    }
                    return(body);
                }

                Controls.Button RenderButton(AlertAction action)
                {
                    return(new Controls.Button(action.Label, (_) =>
                    {
                        blade.Manager.CloseSideBlade(action);
                    }, theme: action.IsPrimary?Theme.Primary: Theme.Secondary));
                }

                var primary = RenderButton(_builder._actions.Single(e => e.IsPrimary));
                var buttons = new[] { primary }.Union(_builder._actions.Where(e => !e.IsPrimary).Select(RenderButton));

                IContentFormatter formatter = new DefaultContentFormatter();

                return(Layout.Vertical(
                           formatter.Format(PrepareBody(_builder._body)),
                           _builder._editor?.Render(primary),
                           Layout.Horizontal(buttons)
                           ));
            }
        /// <summary>
        /// update the capitals for all of the TextBlock elements in a panel.
        /// </summary>
        /// <param name="customCaptionSettings">the custom caption settings
        /// </param>
        /// <param name="panel">the panel</param>
        /// <exception cref="ArgumentNullException">if customCaptionSettings
        /// or panel are null.</exception>
        private static void UpdateCaptials(
            CustomCaptionSettings customCaptionSettings,
            Panel panel)
        {
            if (customCaptionSettings == null)
            {
                throw new ArgumentNullException(
                          "customCaptionSettings",
                          "customCaptionSettings cannot be null.");
            }

            if (panel == null)
            {
                return;
            }

            var children = panel.Children.OfType <TextBlock>();

            foreach (var item in children)
            {
                if (customCaptionSettings.FontFamily == Model.FontFamily.Smallcaps)
                {
                    Typography.SetCapitals(item, FontCapitals.SmallCaps);
                }
                else
                {
                    Typography.SetCapitals(item, FontCapitals.Normal);
                }
            }
        }
 public void ShowException(Exception ex, Action <AlertAction> onClose = null)
 {
     _title = ex.GetType().Name;
     _body  = Layout.Vertical(Typography.P(ex.Message), new CollapsablePanel("Stack Trace", Typography.Code(ex.StackTrace)));
     _actions.Add(AlertAction.Ok);
     Show(onClose);
 }
Example #7
0
        /// <summary>
        /// update the capitals for all of the TextBlock elements in a panel.
        /// </summary>
        /// <param name="customCaptionSettings">the custom caption settings
        /// </param>
        /// <param name="panel">the panel</param>
        /// <exception cref="ArgumentNullException">if customCaptionSettings
        /// or panel are null.</exception>
        private static void UpdateCaptials(
            CustomCaptionSettings customCaptionSettings,
            Panel panel)
        {
            if (customCaptionSettings == null)
            {
                throw new ArgumentNullException(
                          "customCaptionSettings",
                          "customCaptionSettings cannot be null.");
            }

            if (panel == null)
            {
                throw new ArgumentNullException(
                          "panel",
                          "panel cannot be null.");
            }

            var children = panel.Children.OfType <TextBlock>();

            foreach (var item in children)
            {
                if (customCaptionSettings.FontFamily == Model.FontFamily.Smallcaps)
                {
                    Typography.SetCapitals(item, FontCapitals.SmallCaps);
                }
                else
                {
                    Typography.SetCapitals(item, FontCapitals.Normal);
                }

                ////System.Diagnostics.Debug.WriteLine("Captials for {0} are {1}", item.Name, Typography.GetCapitals(item));
            }
        }
        protected override void OnCreateDeviceResources(WindowRenderTarget renderTarget)
        {
            base.OnCreateDeviceResources(renderTarget);

            float width  = ClientSize.Width / _dpiScaleX;
            float height = ClientSize.Height / _dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout(
                _text,
                this._textFormat,
                width,
                height);

            using (Typography typography = DirectWriteFactory.CreateTypography())
            {
                typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
                this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
            }

            Bitmap bitmap = RenderTarget.CreateBitmap(this.GetType(), "heart.png");

            this._bitmapInlineObject = new BitmapInlineObject(RenderTarget, bitmap);

            this._textLayout.SetInlineObject(this._bitmapInlineObject, new TextRange(2, 1));

            this._blackBrush = renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.Black, 1));
        }
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);

            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola",
                                                                   FontWeight.Normal,
                                                                   FontStyle.Normal,
                                                                   FontStretch.Normal,
                                                                   72);

            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;

            float width  = ClientSize.Width / _dpiScaleX;
            float height = ClientSize.Height / _dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout(
                _text,
                this._textFormat,
                width,
                height);

            using (Typography typography = DirectWriteFactory.CreateTypography())
            {
                typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
                this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
            }

            Bitmap bitmap = RenderTarget.CreateBitmap(this.GetType(), "heart.png");

            this._bitmapInlineObject = new BitmapInlineObject(RenderTarget, bitmap);

            this._textLayout.SetInlineObject(this._bitmapInlineObject, new TextRange(2, 1));
        }
Example #10
0
        public override List <Run> DisplayText()
        {
            List <Run> display = new List <Run>();

            display.Add(new Run()
            {
                Text = "("
            });
            foreach (Element e in Elements)
            {
                display.AddRange(e.DisplayText());
            }
            display.Add(new Run()
            {
                Text = ")"
            });
            if (Subscript > 1)
            {
                Run r = new Run()
                {
                    Text = Subscript.ToString()
                };
                Typography.SetVariants(r, Windows.UI.Xaml.FontVariants.Subscript);
                display.Add(r);
            }

            return(display);
        }
Example #11
0
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);

            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 72);

            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;

            float width  = ClientSize.Width / _dpiScaleX;
            float height = ClientSize.Height / _dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout(
                _text,
                this._textFormat,
                width,
                height);

            this._textLayout.SetFontSize(100, new TextRange(20, 6));
            this._textLayout.SetUnderline(true, new TextRange(20, 11));
            this._textLayout.SetFontWeight(FontWeight.Bold, new TextRange(20, 11));

            using (Typography typography = DirectWriteFactory.CreateTypography())
            {
                typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
                this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
            }
        }
Example #12
0
 public MudTheme()
 {
     Palette          = new Palette();
     Shadows          = new Shadow();
     Typography       = new Typography();
     LayoutProperties = new LayoutProperties();
     ZIndex           = new ZIndex();
 }
Example #13
0
 public MudTheme()
 {
     Palette          = new Palette();
     PaletteDark      = Palette.ConvertToDarkTheme(new Palette());
     Shadows          = new Shadow();
     Typography       = new Typography();
     LayoutProperties = new LayoutProperties();
     ZIndex           = new ZIndex();
 }
Example #14
0
        protected override void OnInitialized()
        {
            DefaultTypographyOptions defaultTheme = new DefaultTypographyOptions
            {
                Plugins = new List <IPlugin> {
                    new CodePlugn()
                }
            };

            Typography.ApplyTypography(defaultTheme);
        }
Example #15
0
        private void Button11_Click(object sender, EventArgs e)
        {
            MessageBox.Show(Typography.INCHtoCM(textBox17.Text, true, true, 2, "Error!") + " - INCH => CM");
            MessageBox.Show(Typography.INCHtoPX(textBox17.Text, true, true, 2, "Error!") + " - INCH => PX");

            MessageBox.Show(Typography.CMtoINCH(textBox17.Text, true, true, 2, "Error!") + " - CM => INCH");
            MessageBox.Show(Typography.CMtoPX(textBox17.Text, true, true, 2, "Error!") + " - CM => PX");

            MessageBox.Show(Typography.PXtoINCH(textBox17.Text, true, true, 2, "Error!") + " - PX => INCH");
            MessageBox.Show(Typography.PXtoCM(textBox17.Text, true, true, 2, "Error!") + " - PX => CM");
        }
            protected override void DoApply(TextLayout layout, TextRange range)
            {
                Typography tp = new Typography(this.dwFactory);
                tp.AddFeature(new FontFeature()
                    {
                        NameTag = tag,
                        Value = 1
                    });

                layout.SetTypography(tp, range);
            }
Example #17
0
 public ConfigurationBase(string title, MainConfigType mainConfigType, ConfigArea configArea, ValueDataType valueDataType, Typography typography, ValueRepresentation valueRepresentation, ValueEditType valueEditType, ConfigRange configRange, int processingIndex)
 {
     Title = title;
     this.mainConfigType = mainConfigType;
     this.configArea     = configArea;
     ValueDataType       = valueDataType;
     Typography          = typography;
     ValueRepresentation = valueRepresentation;
     ValueEditType       = valueEditType;
     this.configRange    = configRange;
     ProcessingIndex     = processingIndex;
 }
            protected override void DoApply(TextLayout layout, TextRange range)
            {
                Typography tp = new Typography(this.dwFactory);

                tp.AddFeature(new FontFeature()
                {
                    NameTag = tag,
                    Value   = 1
                });

                layout.SetTypography(tp, range);
            }
Example #19
0
 public BaseData(ConfigurationBase initializationData)
 {
     title                = initializationData.Title;
     mainConfigType       = initializationData.GetMainConfigType;
     configArea           = initializationData.GetConfigArea;
     valueDataType        = initializationData.ValueDataType;
     typography           = initializationData.Typography;
     valueRepresentation  = initializationData.ValueRepresentation;
     valueEditType        = initializationData.ValueEditType;
     configRange          = initializationData.configRange;
     this.processingIndex = initializationData.ProcessingIndex;
 }
Example #20
0
        private Inline CreateSubscript(HtmlNode node)
        {
            if (string.IsNullOrEmpty(node.InnerText.Trim()))
            {
                return(null);
            }
            var run = new Run()
            {
                Text = node.InnerText.Trim()
            };

            Typography.SetVariants(run, FontVariants.Subscript);
            return(run);
        }
        /// <summary>
        /// Creates a custom theme definition which can be used with the Customizer.
        /// </summary>
        /// <param name="theme">Partial theme object.</param>
        /// <param name="depComments">Whether to include deprecated tags as comments for deprecated slots.</param>
        /// <returns></returns>
        public Theme CreateTheme(Theme theme, bool depComments = false)
        {
            var newPalette = new Palette();

            newPalette = newPalette.MergeValues(Palette.DefaultPalette, theme.Palette);

            if (theme.Palette == null || theme.Palette.Accent == null)
            {
                newPalette.Accent = newPalette.ThemePrimary;
            }
            var newSemacticColors = new SemanticColors().MergeValues(newPalette.MakeSemanticColors(theme?.IsInverted == true, depComments), theme.SemanticColors);

            var typography = new Typography().MergeValues(Typography.DefaultTypography, theme.Typography);

            var types = typography.Types;

            foreach (var typeName in types)
            {
                var type = typeName.Value;

                string fontFamily;
                if (!string.IsNullOrWhiteSpace(type.FontFamily) && typography.Families.TryGetValue(type.FontFamily, out fontFamily))
                {
                    type.FontFamily = fontFamily;
                }

                string fontSize;
                if (type.FontSize != null && typography.Sizes.TryGetValue((string)type.FontSize, out fontSize))
                {
                    type.FontSize = typography.Sizes[fontSize];
                }

                string fontWeight;
                if (type.FontWeight != null && typography.Families.TryGetValue((string)type.FontWeight, out fontWeight))
                {
                    type.FontWeight = fontWeight;
                }
            }

            return(new Theme()
            {
                Palette = newPalette,
                Fonts = new FontStyles().MergeValues(FontStyles.DefaultFontStyle, theme.Fonts),
                SemanticColors = newSemacticColors,
                IsInverted = theme?.IsInverted == true,
                DisableGlobalCalssNames = theme?.DisableGlobalCalssNames == true,
                Typography = typography
            });
        }
Example #22
0
        private void CTB_Click(object sender, EventArgs e)
        {
            try
            {
                string TA = TACB.SelectedItem.ToString();
                string TB = TBCB.SelectedItem.ToString();
                int    PC = string.IsNullOrEmpty(BTTB.Text) ? 2 : Convert.ToInt32(BTTB.Text);
                BTTB.Text = PC.ToString();

                if (TA == "INCH")
                {
                    if (TB == "CM")
                    {
                        TRTB.Text = Typography.INCHtoCM(TVTB.Text, DL, CA, PC);
                    }
                    else if (TB == "PX")
                    {
                        TRTB.Text = Typography.INCHtoPX(TVTB.Text, DL, CA, PC);
                    }
                }
                else if (TA == "CM")
                {
                    if (TB == "INCH")
                    {
                        TRTB.Text = Typography.CMtoINCH(TVTB.Text, DL, CA, PC);
                    }
                    else if (TB == "PX")
                    {
                        TRTB.Text = Typography.CMtoPX(TVTB.Text, DL, CA, PC);
                    }
                }
                else if (TA == "PX")
                {
                    if (TB == "INCH")
                    {
                        TRTB.Text = Typography.PXtoINCH(TVTB.Text, DL, CA, PC);
                    }
                    else if (TB == "CM")
                    {
                        TRTB.Text = Typography.PXtoCM(TVTB.Text, DL, CA, PC);
                    }
                }
            }
            catch
            {
                //
            }
        }
Example #23
0
        private void InitializeMultiformattedText()
        {
            _mainForm.MultiformattedTextRenderPanel.InitializeDevice();
            _multiformattedTextBrush = new SolidColorBrush(MultiformattedRenderTarget, new Color4(0.0f, 0.0f, 0.0f));
            string text = "Hello World using   DirectWrite!";

            _multiformattedLayout = _writeFactory.CreateTextLayout(text, _textFormat, 640.0f, 480.0f);
            _multiformattedLayout.SetFontSize(100.0f, new TextRange(20, 6));
            _multiformattedLayout.SetUnderline(true, new TextRange(20, 11));
            _multiformattedLayout.SetFontWeight(FontWeight.Bold, new TextRange(20, 11));
            using (Typography typography = _writeFactory.CreateTypography())
            {
                typography.AddFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1));
                _multiformattedLayout.SetTypography(typography, new TextRange(0, text.Length));
            }
        }
        /// <summary>
        /// Apply the font family
        /// </summary>
        /// <param name="e">the caption text event arguments</param>
        private void ApplyFontFamily(CaptionTextEventArgs e)
        {
            switch (this.Settings.FontFamily)
            {
            case PlayerFramework.CaptionSettings.Model.FontFamily.Smallcaps:
                Typography.SetCapitals(e.TextBlock, FontCapitals.SmallCaps);
                break;

            case PlayerFramework.CaptionSettings.Model.FontFamily.Default:
                break;

            default:
                e.TextBlock.FontFamily = this.GetFont();
                break;
            }
        }
        /// <summary>
        /// Apply the font family
        /// </summary>
        /// <param name="e">the caption text event arguments</param>
        private void ApplyFontFamily(CaptionTextEventArgs e)
        {
            switch (ClosedCaptionProperties.FontStyle)
            {
            case ClosedCaptionStyle.SmallCapitals:
                Typography.SetCapitals(e.TextBlock, FontCapitals.SmallCaps);
                break;

            case ClosedCaptionStyle.Default:
                break;

            default:
                e.TextBlock.FontFamily = GetFont();
                break;
            }
        }
Example #26
0
 public static Boolean TryParse(String[] parts, out Typography typo)
 {
     int a, b, c, d;
     typo = new Typography();
     if (!(int.TryParse(parts[0], out a) && int.TryParse(parts[1], out b) && int.TryParse(parts[2], out c) && int.TryParse(parts[3], out d)))
         return false;
     if (a == -1)
         typo |= Typography.Bold;
     if (b == -1)
         typo |= Typography.Italic;
     if (c == -1)
         typo |= Typography.Underline;
     if (d == -1)
         typo |= Typography.StrikeOut;
     return true;
 }
Example #27
0
        protected void OnChangeSelected(UIChangeEventArgs e)
        {
            Selected = (string)e.Value;
            ITypographyOptions theme = Typography.ThemeForName(Selected);

            Fontsize      = Typography.Unitless(theme.BaseFontSize) + ".00";
            Lineheight    = theme.BaseLineHeight;
            Ratio         = theme.ScaleRatio.ToString();
            Spacing       = theme.BlockMarginBottom;
            HeaderFont    = theme.HeaderFontFamily[0];
            BodyFont      = theme.BodyFontFamily[0];
            HeaderWeights = GetWeightForDropdown(HeaderFont);
            HeaderWeight  = theme.HeaderWeight;
            BodyWeights   = GetWeightForDropdown(BodyFont);
            BodyWeight    = theme.BodyWeight;
            BoldWeights   = GetWeightForDropdown(BodyFont);
            BoldWeight    = theme.BoldWeight;
        }
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);

            this._redColorDrawingEffect   = new ColorDrawingEffect(Color.FromARGB(Colors.Red, 1));
            this._greenColorDrawingEffect = new ColorDrawingEffect(Color.FromARGB(Colors.Green, 1));
            this._blueColorDrawingEffect  = new ColorDrawingEffect(Color.FromARGB(Colors.Blue, 1));

            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola",
                                                                   FontWeight.Normal,
                                                                   FontStyle.Normal,
                                                                   FontStretch.Normal,
                                                                   72);

            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;

            float width  = ClientSize.Width / _dpiScaleX;
            float height = ClientSize.Height / _dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout(
                _text,
                this._textFormat,
                width,
                height);

            this._textLayout.SetFontSize(100, new TextRange(20, 6));

            this._textLayout.SetDrawingEffect(_blueColorDrawingEffect, new TextRange(6, 5));
            this._textLayout.SetDrawingEffect(_redColorDrawingEffect, new TextRange(20, 6));
            this._textLayout.SetDrawingEffect(_greenColorDrawingEffect, new TextRange(26, 5));

            ClientDrawingEffect effect = this._textLayout.GetDrawingEffect(7);

            this._textLayout.SetUnderline(true, new TextRange(20, 11));
            this._textLayout.SetFontWeight(FontWeight.Bold, new TextRange(20, 11));

            using (Typography typography = DirectWriteFactory.CreateTypography())
            {
                typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
                this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
            }
        }
Example #29
0
        /// <summary>
        /// Updates the TextFormat and TextLayout.
        /// </summary>
        private void UpdateTextFormatAndLayout()
        {
            try
            {
                if (CurrentTextFormat != null)
                {
                    CurrentTextFormat.Dispose();
                    CurrentTextFormat = null;
                }

                if (CurrentTextLayout != null)
                {
                    CurrentTextLayout.Dispose();
                    CurrentTextLayout = null;
                }

                // Initialize a TextFormat
                CurrentTextFormat = new TextFormat(FactoryDWrite, FontFamilyName, FontSize)
                {
                    TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center
                };

                CurrentTextLayout = new TextLayout(FactoryDWrite, FontText, CurrentTextFormat, renderControl.Width, renderControl.Height);

                // Set a stylistic typography
                var typo = new Typography(FactoryDWrite);
                typo.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1));
                CurrentTextLayout.SetTypography(typo, CurrentTextRange);
                typo.Dispose();

                UpdateBold();
                UpdateItalic();
                UpdateUnderline();
                UpdateFontSize();
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
Example #30
0
 private Inline CreateSuperscript(HtmlNode node)
 {
     if (node.Descendants().Any(p => p.Name == "a"))
     {
         var linkNode = node.Descendants().Where(p => p.Name == "a").FirstOrDefault();
         var hyp      = CreateHyperLink(linkNode, true);
         return(hyp);
     }
     else
     {
         if (string.IsNullOrEmpty(node.InnerText.Trim()))
         {
             return(null);
         }
         var run = new Run()
         {
             Text = node.InnerText.Trim()
         };
         Typography.SetVariants(run, FontVariants.Superscript);
         return(run);
     }
 }
Example #31
0
        public override List <Run> DisplayText()
        {
            List <Run> display = new List <Run>();

            display.Add(new Run()
            {
                Text = Symbol
            });
            if (Subscript > 1)
            {
                Run r = new Run()
                {
                    Text = Subscript.ToString()
                };
                Typography.SetVariants(r, Windows.UI.Xaml.FontVariants.Subscript);
                display.Add(r);
            }
            if (Charge != 0)
            {
                if (Charge < 0)
                {
                    //This won't convert a - to a ⁻ for some reason?
                    Run r1 = new Run()
                    {
                        Text = "⁻"
                    };
                    display.Add(r1);
                }

                Run r = new Run()
                {
                    Text = Math.Abs(Charge).ToString()
                };
                Typography.SetVariants(r, Windows.UI.Xaml.FontVariants.Superscript);
                display.Add(r);
            }

            return(display);
        }
Example #32
0
        /// <summary>
        /// Copy the attributes from the textBlock to the new text blocks
        /// </summary>
        /// <param name="textBlock">the original text block</param>
        /// <param name="newTextBlocks">the new text blocks</param>
        /// <param name="parent">the parent to add the new items to</param>
        /// <param name="opacity">the opacity to use</param>
        /// <param name="zIndex">the z index to use for the new text blocks</param>
        private static void CopyAttributes(TextBlock textBlock, TextBlock[] newTextBlocks, UIElement parent, double opacity, int zIndex = 1)
        {
            var border = parent as Border;

            Panel panel;

            if (border != null)
            {
                panel = new Grid();

                border.Child = panel;

                panel.Children.Add(textBlock);
            }
            else
            {
                panel = parent as Panel;
            }

            foreach (var item in newTextBlocks)
            {
                item.Foreground           = new Media.SolidColorBrush(ColorsNS.Colors.Black);
                item.Text                 = textBlock.Text;
                item.FontFamily           = textBlock.FontFamily;
                item.FontSize             = textBlock.FontSize;
                item.LineHeight           = textBlock.LineHeight;
                item.LineStackingStrategy = textBlock.LineStackingStrategy;
                item.Opacity              = opacity;
                item.FontStyle            = textBlock.FontStyle;
                item.FontWeight           = textBlock.FontWeight;
                item.Margin               = textBlock.Margin;

                Canvas.SetZIndex(item, zIndex);

                Typography.SetCapitals(item, Typography.GetCapitals(textBlock));

                panel.Children.Add(item);
            }
        }
Example #33
0
 public Style()
 {
     Name = "Default";
     FontName = "Arial";
     FontSize = 20;
     FontColors = new Colors(new SColor(255, 255, 255), new SColor(0, 0, 255), new SColor(0, 0, 0, 0),
         new SColor(0, 0, 0, 0));
     FontTypography = new Typography();
     Scale = new Vector2(100, 100);
     Spacing = 0;
     Angle = 0;
     FontBorder = new Border();
     Alignment = Align.LowerCenter;
     FontMargin = new Margin();
     Encoding = 1;
 }
Example #34
0
        public Style(String name, String fontName, Int32 fontSize, Colors fontColors, Border fontBorder, Vector2 scale,
			Typography fontTypography, Align alignment, Double spacing, Double angle, Margin fontMargin,
			Int32 encoding = 1)
        {
            Name = name;
            FontName = fontName;
            FontSize = fontSize;
            FontColors = fontColors;
            FontBorder = fontBorder;
            Scale = scale;
            FontTypography = fontTypography;
            Alignment = alignment;
            Spacing = spacing;
            Angle = angle;
            FontMargin = fontMargin;
            Encoding = encoding;
        }