Exemple #1
0
        public static FontDecoration ToEtoDecoration(this sd.FontStyle style)
        {
            var ret = FontDecoration.None;

            if (style.HasFlag(sd.FontStyle.Underline))
            {
                ret |= FontDecoration.Underline;
            }
            if (style.HasFlag(sd.FontStyle.Strikeout))
            {
                ret |= FontDecoration.Strikethrough;
            }
            return(ret);
        }
Exemple #2
0
        public static FontStyle ToEtoStyle(this sd.FontStyle style)
        {
            var ret = FontStyle.None;

            if (style.HasFlag(sd.FontStyle.Bold))
            {
                ret |= FontStyle.Bold;
            }
            if (style.HasFlag(sd.FontStyle.Italic))
            {
                ret |= FontStyle.Italic;
            }
            return(ret);
        }
Exemple #3
0
        public static SizedFontProperties CreateSizedFontProperties(this AppSettings.ToolsSection toolSettings, IFontMap fontMap)
        {
            FontProperties fontProperties;
            FontWeight     bold;

            PaintDotNet.DirectWrite.FontStyle italic;
            string displayName = toolSettings.Text.FontFamilyName.Value;

            string[] namesToTry = new string[] { displayName, "Segoe UI", "Arial" };
            try
            {
                fontProperties = fontMap.GetFontProperties(namesToTry);
            }
            catch (NoFontException)
            {
                fontProperties = new FontProperties(displayName, string.Empty, FontWeight.Normal, FontStretch.Normal, PaintDotNet.DirectWrite.FontStyle.Normal, TextDecorations.None);
            }
            System.Drawing.FontStyle style = toolSettings.Text.FontStyle.Value;
            FontWeight weight = fontProperties.Weight;

            if (style.HasFlag(System.Drawing.FontStyle.Bold) && (weight <= FontWeight.DemiBold))
            {
                bold = FontWeight.Bold;
            }
            else
            {
                bold = weight;
            }
            FontStretch stretch = fontProperties.Stretch;

            PaintDotNet.DirectWrite.FontStyle style2 = fontProperties.Style;
            if (style.HasFlag(System.Drawing.FontStyle.Italic) && (style2 == PaintDotNet.DirectWrite.FontStyle.Normal))
            {
                italic = PaintDotNet.DirectWrite.FontStyle.Italic;
            }
            else
            {
                italic = style2;
            }
            TextDecorations decorations = (fontProperties.Decorations | (style.HasFlag(System.Drawing.FontStyle.Underline) ? TextDecorations.Underline : TextDecorations.None)) | (style.HasFlag(System.Drawing.FontStyle.Strikeout) ? TextDecorations.Strikethrough : TextDecorations.None);
            float           dipSize     = (toolSettings.Text.FontSize.Value * 96f) / 72f;

            return(new SizedFontProperties(new FontProperties(fontProperties.DisplayName, fontProperties.FontFamilyName, bold, stretch, italic, decorations), dipSize));
        }