Ejemplo n.º 1
0
        public static System.Drawing.FontStyle ToSystemDrawing(this FontStyle fontStyle)
        {
            var result = System.Drawing.FontStyle.Regular;

            if (fontStyle == FontStyle.Regular)
            {
                return(result);
            }

            if (fontStyle.HasFlag(FontStyle.Bold))
            {
                result |= System.Drawing.FontStyle.Bold;
            }
            if (fontStyle.HasFlag(FontStyle.Italic))
            {
                result |= System.Drawing.FontStyle.Italic;
            }
            if (fontStyle.HasFlag(FontStyle.Underline))
            {
                result |= System.Drawing.FontStyle.Underline;
            }
            if (fontStyle.HasFlag(FontStyle.StrikeThrough))
            {
                result |= System.Drawing.FontStyle.Strikeout;
            }

            return(result);
        }
Ejemplo n.º 2
0
        private TextDrawer(string family, FontStyle s)
        {
            familyName = family + " ";

            if (s.HasFlag(FontStyle.Regular))
            {
                familyName += "Regular";
            }
            if (s.HasFlag(FontStyle.Bold))
            {
                familyName += "Bold";
            }
            if (s.HasFlag(FontStyle.Italic))
            {
                familyName += "Italic";
            }
            if (s.HasFlag(FontStyle.Underline))
            {
                familyName += "Underline";
            }
            if (s.HasFlag(FontStyle.Strikeout))
            {
                familyName += "Strikeout";
            }
        }
Ejemplo n.º 3
0
        public static NSFontTraitMask ToNSFontTraitMask(this FontStyle fontStyle)
        {
            NSFontTraitMask mask = (NSFontTraitMask)0;

            if (fontStyle.HasFlag(FontStyle.Bold))
            {
                mask = mask.SetFlags(NSFontTraitMask.Bold);
            }

            if (fontStyle.HasFlag(FontStyle.Italic))
            {
                mask = mask.SetFlags(NSFontTraitMask.Italic);
            }

            if (fontStyle.HasFlag(FontStyle.Regular))
            {
            }

            if (fontStyle.HasFlag(FontStyle.Strikeout))
            {
            }

            if (fontStyle.HasFlag(FontStyle.Underline))
            {
            }

            return(mask);
        }
Ejemplo n.º 4
0
        private string GetStyleFlag(FontStyle style)
        {
            var sb = new StringBuilder();

            if (style.HasFlag(FontStyle.Bold))
            {
                sb.Append("B");
            }

            if (style.HasFlag(FontStyle.Italic))
            {
                sb.Append("I");
            }

            if (style.HasFlag(FontStyle.Underline))
            {
                sb.Append("U");
            }

            if (style.HasFlag(FontStyle.Strikeout))
            {
                sb.Append("S");
            }

            return(sb.ToString());
        }
Ejemplo n.º 5
0
        private void updateStyleButtons()
        {
            if (notepadText.SelectionFont == null)
            {
                return;
            }
            FontStyle style     = notepadText.SelectionFont.Style;
            bool      bold      = false;
            bool      italic    = false;
            bool      strikeout = false;
            bool      underline = false;

            if (style.HasFlag(FontStyle.Bold))
            {
                bold = true;
            }
            if (style.HasFlag(FontStyle.Italic))
            {
                italic = true;
            }
            if (style.HasFlag(FontStyle.Strikeout))
            {
                strikeout = true;
            }
            if (style.HasFlag(FontStyle.Underline))
            {
                underline = true;
            }

            btnFormatBold.Checked      = bold;
            btnFormatItalic.Checked    = italic;
            btnFormatStrikeout.Checked = strikeout;
            btnFormatUnderline.Checked = underline;
        }
Ejemplo n.º 6
0
        void SetStyle(FontStyle style)
        {
            WpfFontWeight = style.HasFlag(FontStyle.Bold) ? sw.FontWeights.Bold : sw.FontWeights.Normal;

            WpfFontStyle = style.HasFlag(FontStyle.Italic) ? sw.FontStyles.Italic : sw.FontStyles.Normal;

            WpfFontStretch = sw.FontStretches.Normal;
        }
Ejemplo n.º 7
0
        public static NSFontTraitMask ToNS(this FontStyle style)
        {
            var traits = (NSFontTraitMask)0;

            traits |= style.HasFlag(FontStyle.Bold) ? NSFontTraitMask.Bold : NSFontTraitMask.Unbold;
            traits |= style.HasFlag(FontStyle.Italic) ? NSFontTraitMask.Italic : NSFontTraitMask.Unitalic;
            //if (style.HasFlag (FontStyle.Condensed)) traits |= NSFontTraitMask.Condensed;
            //if (style.HasFlag (FontStyle.Light)) traits |= NSFontTraitMask.Narrow;
            return(traits);
        }
Ejemplo n.º 8
0
 private void btnTextBold_Click(object sender, EventArgs e)
 {
     if (_fontStyle.HasFlag(FontStyle.Bold))
     {
         _fontStyle = _fontStyle & ~FontStyle.Bold;
     }
     else
     {
         _fontStyle = _fontStyle | FontStyle.Bold;
     }
     UpdateObject();
 }
Ejemplo n.º 9
0
 public static sd.FontStyle ToSD(this FontStyle style)
 {
     sd.FontStyle ret = sd.FontStyle.Regular;
     if (style.HasFlag(FontStyle.Bold))
     {
         ret |= sd.FontStyle.Bold;
     }
     if (style.HasFlag(FontStyle.Italic))
     {
         ret |= sd.FontStyle.Italic;
     }
     return(ret);
 }
Ejemplo n.º 10
0
 private CTFontSymbolicTraits getTraits(FontStyle style)
 {
     CTFontSymbolicTraits traits = CTFontSymbolicTraits.None;
     if (style.HasFlag(FontStyle.Bold))
     {
         traits |= CTFontSymbolicTraits.Bold;
     }
     if (style.HasFlag(FontStyle.Italic))
     {
         traits |= CTFontSymbolicTraits.Italic;
     }
     return traits;
 }
Ejemplo n.º 11
0
 public void SetFontStyle(FontStyle fontStyle)
 {
     if (fontStyle.HasFlag(FontStyle.Bold))
     {
         _currentTextFormat = _currentTextFormat | TextFormat.Bold;
     }
     else if (fontStyle.HasFlag(FontStyle.Italic))
     {
         _currentTextFormat = _currentTextFormat | TextFormat.Italic;
     }
     else if (fontStyle == FontStyle.NoStyle)
     {
         _currentTextFormat = 0;
     }
 }
Ejemplo n.º 12
0
        public static void Convert(FontStyle value, out sw.FontStyle fontStyle, out sw.FontWeight fontWeight)
        {
            fontStyle  = sw.FontStyle.Normal;
            fontWeight = sw.FontWeight.Normal;

            if (value.HasFlag(FontStyle.Italic))
            {
                fontStyle = sw.FontStyle.Italic;
            }

            if (value.HasFlag(FontStyle.Bold))
            {
                fontWeight = sw.FontWeight.Bold;
            }
        }
Ejemplo n.º 13
0
        public static void FontAdjustment()
        {
            var  currentStyle = new FontStyle();
            byte input;

            do
            {
                Console.WriteLine($"Параметры надписи: {currentStyle}");
                Console.WriteLine("Введите:");
                Console.WriteLine("\t1: bold");
                Console.WriteLine("\t2: italic");
                Console.WriteLine("\t3: underline");
                Console.WriteLine("\t0: exit");
                if (byte.TryParse(Console.ReadLine(), out input))
                {
                    if (input > 3)
                    {
                        Console.WriteLine("Incorrect number");
                        continue;
                    }
                    if (currentStyle.HasFlag((FontStyle)Math.Pow(2, input - 1)))
                    {
                        currentStyle ^= (FontStyle)Math.Pow(2, input - 1);
                    }
                    else
                    {
                        currentStyle ^= (FontStyle)Math.Pow(2, input - 1);
                    }
                }
                else
                {
                    Console.WriteLine("Error");
                }
            }while (input != 0);
        }
Ejemplo n.º 14
0
 public static TypefaceStyle Convert(this FontStyle style)
 {
     if (style.HasFlag(FontStyle.Bold))
     {
         if (!style.HasFlag(FontStyle.Italic))
         {
             return(TypefaceStyle.Bold);
         }
         return(TypefaceStyle.BoldItalic);
     }
     if (style.HasFlag(FontStyle.Italic))
     {
         return(TypefaceStyle.Italic);
     }
     return(TypefaceStyle.Normal);
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Renders the <see cref="Duality.Resources.FontRasterizer"/> using the specified system font family.
        /// </summary>
        private FontData RenderGlyphs(FontFamily fontFamily, float emSize, FontStyle style, FontCharSet extendedSet, FontRenderMode renderMode, bool antialiasing, bool monospace)
        {
            // Determine System.Drawing font style
            SysDrawFontStyle systemStyle = SysDrawFontStyle.Regular;

            if (style.HasFlag(FontStyle.Bold))
            {
                systemStyle |= SysDrawFontStyle.Bold;
            }
            if (style.HasFlag(FontStyle.Italic))
            {
                systemStyle |= SysDrawFontStyle.Italic;
            }

            // Create a System.Drawing font
            SysDrawFont internalFont = null;

            if (fontFamily != null)
            {
                try { internalFont = new SysDrawFont(fontFamily, emSize, systemStyle); } catch (Exception e) {
                    Console.WriteLine(
                        "Failed to create System Font '{1} {2}, {3}' for rendering: {0}",
                        /*LogFormat.Exception(*/ e /*)*/,
                        fontFamily.Name,
                        emSize,
                        style);
                }
            }

            // If creating the font failed, fall back to a default one
            if (internalFont == null)
            {
                internalFont = new SysDrawFont(FontFamily.GenericMonospace, emSize, systemStyle);
            }

            // Render the font's glyphs
            using (internalFont) {
                return(this.RenderGlyphs(
                           internalFont,
                           FontCharSet.Default.MergedWith(extendedSet),
                           renderMode,
                           antialiasing,
                           monospace));
            }
        }
Ejemplo n.º 16
0
 private void ChangeOptionFont(FontStyle fontStyle, TextBox text, bool b)
 {
     if (b == false)
     {
         if ((OptionsFontActived.HasFlag(fontStyle)))
         {
             OptionsFontActived -= fontStyle;
         }
     }
     else
     {
         if (!(OptionsFontActived.HasFlag(fontStyle)))
         {
             OptionsFontActived |= fontStyle;
         }
     }
     text.Font = new Font(text.Font.FontFamily, text.Font.Size, OptionsFontActived);
 }
Ejemplo n.º 17
0
        private CTFontDescriptor getDescriptor(FontStyle style)
        {
            if (!style.HasFlag(FontStyle.Underline) && !style.HasFlag(FontStyle.Strikeout)) return null;

            NSMutableDictionary dict = new NSMutableDictionary();
            if (style.HasFlag(FontStyle.Underline))
            {
                NSString underline = UIStringAttributeKey.UnderlineStyle;
                dict[underline] = NSNumber.FromInt32((int)NSUnderlineStyle.Single);
            }
            if (style.HasFlag(FontStyle.Strikeout))
            {
                NSString strike = UIStringAttributeKey.StrikethroughStyle;
                dict[strike] = NSNumber.FromInt32((int)NSUnderlineStyle.Single);
            }
            CTFontDescriptorAttributes attrs = new CTFontDescriptorAttributes(dict);
            CTFontDescriptor desc = new CTFontDescriptor(attrs);
            return desc;
        }
Ejemplo n.º 18
0
 public ContentStyle Underline(bool enable = true)
 {
     if (enable)
     {
         FontStyle |= FontStyle.Underline;
     }
     else
     if (FontStyle.HasFlag(FontStyle.Underline))
     {
         FontStyle -= FontStyle.Underline;
     }
     return(this);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Gives the index of the font style. Not taken into account are <see cref="FontStyle.Underline"/> and <see cref="FontStyle.Italic"/>.
        /// These two flags are ignored.
        /// </summary>
        /// <param name="fontStyle">The font style.</param>
        /// <returns></returns>
        protected static int FontStyleToIndex(FontStyle fontStyle)
        {
            bool isBold   = fontStyle.HasFlag(FontStyle.Bold);
            bool isItalic = fontStyle.HasFlag(FontStyle.Italic);

            if (isBold && isItalic)
            {
                return(IdxBoldItalic);
            }
            else if (isItalic)
            {
                return(IdxItalic);
            }
            else if (isBold)
            {
                return(IdxBold);
            }
            else
            {
                return(IdxRegular);
            }
        }
Ejemplo n.º 20
0
 public ContentStyle Italic(bool enable = true)
 {
     if (enable)
     {
         FontStyle |= FontStyle.Italic;
     }
     else
     if (FontStyle.HasFlag(FontStyle.Italic))
     {
         FontStyle -= FontStyle.Italic;
     }
     return(this);
 }
Ejemplo n.º 21
0
        public static BCFontStyle GetBCStyleFromGDIPlusStyle(FontStyle pSrc)
        {
            BCFontStyle result = BCFontStyle.Regular;

            if (pSrc.HasFlag(System.Drawing.FontStyle.Bold))
            {
                result |= BCFontStyle.Bold;
            }
            if (pSrc.HasFlag(System.Drawing.FontStyle.Italic))
            {
                result |= BCFontStyle.Italic;
            }
            if (pSrc.HasFlag(System.Drawing.FontStyle.Underline))
            {
                result |= BCFontStyle.Underline;
            }
            if (pSrc.HasFlag(System.Drawing.FontStyle.Strikeout))
            {
                result |= BCFontStyle.Strikeout;
            }

            return(result);
        }
Ejemplo n.º 22
0
        public ContentStyle Bold(bool enable = true)
        {
            if (enable)
            {
                FontStyle |= FontStyle.Bold;
            }
            else
            if (FontStyle.HasFlag(FontStyle.Bold))
            {
                FontStyle -= FontStyle.Bold;
            }

            return(this);
        }
Ejemplo n.º 23
0
        private IFontInstance LoadInstanceInternal()
        {
            var instance = Family.Find(requestedStyle);

            if (instance == null && requestedStyle.HasFlag(FontStyle.Italic))
            {
                // can find style requested and they want one thats atleast partial itallic try the regual italic
                instance = Family.Find(FontStyle.Italic);
            }

            if (instance == null && requestedStyle.HasFlag(FontStyle.Bold))
            {
                // can find style requested and they want one thats atleast partial bold try the regular bold
                instance = Family.Find(FontStyle.Bold);
            }

            if (instance == null)
            {
                // cant find style requested and lets just try returning teh default
                instance = Family.Find(Family.DefaultStyle);
            }

            return(instance);
        }
Ejemplo n.º 24
0
        private bool NativeStyleAvailable(FontStyle style)
        {
            // we are going to actually have to create a font object here
            // will not create an actual variable for this yet.  We may
            // want to do this in the future so that we do not have to keep
            // creating it over and over again.
            using (var baseFont = new CTFont(nativeFontDescriptor, 0))
            {
                var traits = CTFontSymbolicTraits.None;
                traits |= style.HasFlag(FontStyle.Bold) ? CTFontSymbolicTraits.Bold : 0;
                traits |= style.HasFlag(FontStyle.Italic) ? CTFontSymbolicTraits.Italic : 0;

                using (var font = baseFont.WithSymbolicTraits(0, traits, traits))
                {
                    if (font == null)
                    {
                        return(false);
                    }

                    if (style.HasFlag(FontStyle.Bold) && !font.SymbolicTraits.HasFlag(CTFontSymbolicTraits.Bold))
                    {
                        return(false);
                    }

                    if (style.HasFlag(FontStyle.Italic) && !font.SymbolicTraits.HasFlag(CTFontSymbolicTraits.Italic))
                    {
                        return(false);
                    }

                    if (style.HasFlag(FontStyle.Regular))
                    {
                        if (font.SymbolicTraits.HasFlag(CTFontSymbolicTraits.Condensed) || font.SymbolicTraits.HasFlag(CTFontSymbolicTraits.Expanded))
                        {
                            return(false);
                        }
                    }

                    if (style.HasFlag(FontStyle.Underline) && font.UnderlineThickness == 0)
                    {
                        return(false);
                    }

                    // TODO:
                    //if (font.HasFlag(FontStyle.Strikeout))
                    //	return false;
                }
                return(true);
            }
        }
Ejemplo n.º 25
0
        private string GetFontStyleString(FontStyle style)
        {
            var result = new StringBuilder();

            foreach (var s in new FontStyle[] { FontStyle.Bold, FontStyle.Italic, FontStyle.Underline, FontStyle.Strikeout, FontStyle.Strikeout })
            {
                if (style.HasFlag(s))
                {
                    result.Append(s.ToString());
                    result.Append(", ");
                }
            }

            if (result.Length > 0)
            {
                result.Remove(result.Length - 2, 2);
                return(result.ToString());
            }
            else
            {
                return("Regular");
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Creates a new style that matches the style of a selection, with a given FontStyle toggled
        /// </summary>
        /// <param Name="selection">The selection to get the style from</param>
        /// <param Name="style">The FontStyle to toggle</param>
        /// <returns>A new Style with the FontStyle toggled</returns>
        protected Style ToggleFontStyle(Selection selection, FontStyle style)
        {
            //This cannot work on a null selection
            if (selection != null)
            {
                //Get the current FontStyle of the selection
                FontStyle curStyle = selection.Font.Style;

                //If the specified style is active, deactivate it
                if (curStyle.HasFlag(style))
                {
                    curStyle &= ~style;
                }
                //If the specified style is inactive, activate it
                else
                {
                    curStyle |= style;
                }

                //Merge the new FontStyle with the Selection'sections Style and return it
                return(MergeStyles(GetStyle(selection), style: curStyle, overwriteFontStyle: true));
            }
            return(null);
        }
Ejemplo n.º 27
0
 public void StyleCheck(FontStyle fS)
 {
     if (fS.HasFlag(FontStyle.Bold)){ this.Button_Bold.BackgroundImage = Properties.Resources.Font_Bold_Actived; }
     else this.Button_Bold.BackgroundImage = Properties.Resources.Font_Bold;
     if (fS.HasFlag(FontStyle.Italic)) { this.Button_Italic.BackgroundImage = Properties.Resources.Font_Italic_Actived; }
     else this.Button_Italic.BackgroundImage = Properties.Resources.Font_Italic;
     if (fS.HasFlag(FontStyle.Underline)) { this.Button_Underline.BackgroundImage = Properties.Resources.Font_Underline_Actived; }
     else this.Button_Underline.BackgroundImage = Properties.Resources.Font_Underline;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Sets editor style font style properties
 /// </summary>
 /// <param name="index"></param>
 /// <param name="style"></param>
 private void SetEditorStyle(int index, FontStyle style)
 {
     Editor.Styles[index].Bold = style.HasFlag(FontStyle.Bold);
     Editor.Styles[index].Italic = style.HasFlag(FontStyle.Italic);
     Editor.Styles[index].Underline = style.HasFlag(FontStyle.Underline);
 }
Ejemplo n.º 29
0
        public void DrawString(SpriteBatch sb, string text, Vector2 position,
                               TextColor color,
                               FontStyle style       = FontStyle.None, Vector2?scale = null,
                               float opacity         = 1f,
                               float rotation        = 0f, Vector2?origin = null,
                               SpriteEffects effects = SpriteEffects.None,
                               float layerDepth      = 0f)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            var originVal = origin ?? Vector2.Zero;
            var scaleVal  = scale ?? Vector2.One;

            //scaleVal *= Scale;

            originVal *= scaleVal;

            var flipAdjustment = Vector2.Zero;

            var flippedVert = (effects & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically;
            var flippedHorz = (effects & SpriteEffects.FlipHorizontally) == SpriteEffects.FlipHorizontally;

            if (flippedVert || flippedHorz)
            {
                Vector2 size;

                MeasureString(text, out size);

                if (flippedHorz)
                {
                    originVal.X     *= -1;
                    flipAdjustment.X = -size.X;
                }

                if (flippedVert)
                {
                    originVal.Y     *= -1;
                    flipAdjustment.Y = LineSpacing - size.Y;
                }
            }

            Matrix transformation = Matrix.Identity;
            float  cos = 0, sin = 0;

            if (rotation == 0)
            {
                transformation.M11 = (flippedHorz ? -scaleVal.X : scaleVal.X);
                transformation.M22 = (flippedVert ? -scaleVal.Y : scaleVal.Y);
                transformation.M41 = ((flipAdjustment.X - originVal.X) * transformation.M11) + position.X;
                transformation.M42 = ((flipAdjustment.Y - originVal.Y) * transformation.M22) + position.Y;
            }
            else
            {
                cos = (float)Math.Cos(rotation);
                sin = (float)Math.Sin(rotation);
                transformation.M11 = (flippedHorz ? -scaleVal.X : scaleVal.X) * cos;
                transformation.M12 = (flippedHorz ? -scaleVal.X : scaleVal.X) * sin;
                transformation.M21 = (flippedVert ? -scaleVal.Y : scaleVal.Y) * (-sin);
                transformation.M22 = (flippedVert ? -scaleVal.Y : scaleVal.Y) * cos;
                transformation.M41 = (((flipAdjustment.X - originVal.X) * transformation.M11) + (flipAdjustment.Y - originVal.Y) * transformation.M21) + position.X;
                transformation.M42 = (((flipAdjustment.X - originVal.X) * transformation.M12) + (flipAdjustment.Y - originVal.Y) * transformation.M22) + position.Y;
            }

            var offset           = Vector2.Zero;
            var firstGlyphOfLine = true;

            TextColor styleColor = color;

            bool styleRandom        = false,
                 styleBold          = style.HasFlag(FontStyle.Bold),
                 styleItalic        = style.HasFlag(FontStyle.Italic),
                 styleUnderline     = style.HasFlag(FontStyle.Underline),
                 styleStrikethrough = style.HasFlag(FontStyle.StrikeThrough),
                 dropShadow         = style.HasFlag(FontStyle.DropShadow);

            var blendFactor = sb.GraphicsDevice.BlendFactor;

            sb.GraphicsDevice.BlendFactor = Color.White * opacity;

            for (int i = 0; i < text.Length; i++)
            {
                char c = text[i];

                if (c == '\r')
                {
                    continue;
                }

                if (c == '\n')
                {
                    offset.X  = 0.0f;
                    offset.Y += LineSpacing;

                    firstGlyphOfLine = true;

                    styleRandom        = false;
                    styleBold          = false;
                    styleStrikethrough = false;
                    styleUnderline     = false;
                    styleItalic        = false;
                    styleColor         = color;
                }
                else if (c == '\x00A7')
                {
                    // Formatting

                    // Get next character
                    if (i + 1 >= text.Length)
                    {
                        continue;
                    }

                    i++;
                    var formatChar = text.ToLower()[i];
                    if ("0123456789abcdef".IndexOf(formatChar) > 0)
                    {
                        styleColor = TextColor.GetColor(formatChar);
                    }
                    else if (formatChar == 'k')
                    {
                        styleRandom = true;
                    }
                    else if (formatChar == 'l')
                    {
                        styleBold = true;
                    }
                    else if (formatChar == 'm')
                    {
                        styleStrikethrough = true;
                    }
                    else if (formatChar == 'n')
                    {
                        styleUnderline = true;
                    }
                    else if (formatChar == 'o')
                    {
                        styleItalic = true;
                    }
                    else if (formatChar == 'r')
                    {
                        styleRandom        = false;
                        styleBold          = false;
                        styleStrikethrough = false;
                        styleUnderline     = false;
                        styleItalic        = false;
                        styleColor         = color;
                    }
                }
                else
                {
                    var glyph = GetGlyphOrDefault(c);


                    if (firstGlyphOfLine)
                    {
                        //	offset.X += CharacterSpacing;
                        firstGlyphOfLine = false;
                    }

                    //if (styleRandom)
                    //{
                    //	c =
                    //}

                    var p     = offset;
                    var width = glyph.Width + (styleBold ? 1 : 0) + CharacterSpacing;

                    if (dropShadow)
                    {
                        var shadowP = p + Vector2.One;

                        if (styleBold)
                        {
                            var boldShadowP = Vector2.Transform(shadowP + Vector2.UnitX, transformation);

                            sb.Draw(glyph.Texture, boldShadowP, styleColor.BackgroundColor * opacity, rotation, originVal, scaleVal * Scale, effects, layerDepth);
                        }

                        shadowP = Vector2.Transform(shadowP, transformation);

                        sb.Draw(glyph.Texture, shadowP, styleColor.BackgroundColor * opacity, rotation, originVal, scaleVal * Scale, effects, layerDepth);
                    }

                    if (styleBold)
                    {
                        var boldP = Vector2.Transform(p + Vector2.UnitX, transformation);
                        sb.Draw(glyph.Texture, boldP, styleColor.ForegroundColor * opacity, rotation, originVal, scaleVal * Scale, effects, layerDepth);
                    }

                    /*	if (styleUnderline)
                     *      {
                     *              var lineStart = Vector2.Transform(p + new Vector2(0, 8), transformation);
                     *
                     *              sb.DrawLine(2, lineStart, new Vector2(lineStart.X + width, lineStart.Y), styleColor.ForegroundColor * opacity, scaleVal * Scale, layerDepth);
                     *      }*/

                    p = Vector2.Transform(p, transformation);

                    sb.Draw(glyph.Texture, p, styleColor.ForegroundColor * opacity, rotation, originVal, scaleVal * Scale, effects, layerDepth);

                    offset.X += width;
                }
            }

            sb.GraphicsDevice.BlendFactor = blendFactor;
        }
Ejemplo n.º 30
0
        private static void format_change()
        {
            FontStyle fontStyle = new FontStyle();

            int n;

            do
            {
                if (!fontStyle.HasFlag(FontStyle.none) && !fontStyle.HasFlag(FontStyle.bold) && !fontStyle.HasFlag(FontStyle.inderline) && !fontStyle.HasFlag(FontStyle.italic))
                {
                    fontStyle = FontStyle.none;
                }

                //Not working
                //foreach (FontStyle isChek in Enum.GetValues(typeof(FontStyle)))
                //{
                //    if (fontStyle.HasFlag(isChek))
                //    {
                //        fontStyle = FontStyle.none;
                //    }
                //}

                Console.WriteLine($"Параметры надписи: {fontStyle}");
                Console.WriteLine("Введите:\n" + "1: Bold\n2: italic\n3: underline\n0: Exit");

                n = int.Parse(Console.ReadLine());

                if (n == 1)
                {
                    if (fontStyle.HasFlag(FontStyle.none))
                    {
                        fontStyle = FontStyle.bold;
                    }
                    else
                    {
                        fontStyle ^= FontStyle.bold;
                    }
                }
                else if (n == 2)
                {
                    if (fontStyle == FontStyle.none)
                    {
                        fontStyle = FontStyle.italic;
                    }
                    else
                    {
                        fontStyle ^= FontStyle.italic;
                    }
                }
                else if (n == 3)
                {
                    if (fontStyle == FontStyle.none)
                    {
                        fontStyle = FontStyle.inderline;
                    }
                    else
                    {
                        fontStyle ^= FontStyle.inderline;
                    }
                }
                // Не понимаю почему если у fontstyle сбросить все значения то у него 0
                // Приходится делать костыль
                if (fontStyle == 0)
                {
                    Console.WriteLine("None");
                }
                else
                {
                    Console.WriteLine(fontStyle);
                }
            }while (n != 0);

            Console.WriteLine();
        }
Ejemplo n.º 31
0
		public static void Convert(FontStyle value, out sw.FontStyle fontStyle, out sw.FontWeight fontWeight)
		{
			fontStyle = sw.FontStyle.Normal;
			fontWeight = sw.FontWeight.Normal;

			if (value.HasFlag(FontStyle.Italic))
				fontStyle = sw.FontStyle.Italic;

			if (value.HasFlag(FontStyle.Bold))
				fontWeight = sw.FontWeight.Bold;
		}