private void DynamicFontSizeApply(Graphics graphics)
        {
            var minFontSize = 0;
            var maxFontSize = Height;
            int fontSize    = Height / 2;

            while (minFontSize != maxFontSize)
            {
                var fontFamilyAttempt = new FontFamily(Font);
                var fontAttempt       = new Font(fontFamilyAttempt, fontSize, FontStyle);
                var fontToolAttempt   = new FontTool(graphics, fontAttempt, FontStyle, fontFamilyAttempt);
                var measurement       = fontToolAttempt.Measure(Content);
                if (measurement.Width > Width || measurement.Height > Height)
                {
                    maxFontSize = fontSize - 1;
                }
                else
                {
                    minFontSize = fontSize;
                }
                fontSize = (int)(Math.Ceiling((decimal)(maxFontSize - minFontSize) / 2) + minFontSize);
            }
            var fontFamily     = new FontFamily(Font);
            var font           = new Font(fontFamily, fontSize, FontStyle);
            var fontTool       = new FontTool(graphics, font, FontStyle, fontFamily);
            var backgroundTool = new BackgroundTool(graphics, BackgroundColor, BackgroundBorderColor, BackgroundBorderThickness);
            var textBlock      = new TextBlock(Width, LineAlignment, WordAlignment, fontTool, backgroundTool);

            textBlock.Add(new CharacterSequence(Content, Color, OutlineColor, OutlineThickness, fontTool), fontTool, backgroundTool);
            Finalize(graphics, textBlock);
        }
        public CharacterSequence(string content, Color color, Color outlineColor, int outlineThickness, FontTool fontTool)
        {
            _content          = content;
            _fontTool         = fontTool;
            _primaryBrush     = new SolidBrush(color);
            _hasOutline       = outlineColor.A != Color.Transparent.A && _outlineThickness > 0;
            _outlineBrush     = new SolidBrush(outlineColor);
            _outlineThickness = outlineThickness;
            var size = _fontTool.Measure(_content);

            Width  = size.Width;
            Height = _fontTool.LineHeight;
        }
 public void Add(IDrawableSegment segment, FontTool fontTool, BackgroundTool backgroundTool)
 {
     if (_textLines.Last().Width + segment.Width > _maxWidth)
     {
         _spaces.Clear();
         NewLine(fontTool, backgroundTool);
         _textLines.Last().Add(segment);
     }
     else
     {
         _textLines.Last().Add(_spaces);
         _spaces.Clear();
         _textLines.Last().Add(segment);
     }
 }
        public TextStyling(Graphics graphics, string fontName, int fontSize, FontStyle fontStyle, Color color, Color backgroundColor, Color backgroundBorderColor, int backgroundBorderThickness, Color outlineColor, int outlineThickness)
        {
            FontName                  = fontName;
            FontSize                  = fontSize;
            FontStyle                 = fontStyle;
            Color                     = color;
            BackgroundColor           = backgroundColor;
            BackgroundBorderColor     = backgroundBorderColor;
            BackgroundBorderThickness = backgroundBorderThickness;
            OutlineColor              = outlineColor;
            OutlineThickness          = outlineThickness;
            var fontFamily = new FontFamily(fontName);
            var font       = new Font(fontFamily, FontSize, FontStyle);

            FontTool       = new FontTool(graphics, font, fontStyle, fontFamily);
            BackgroundTool = new BackgroundTool(graphics, backgroundColor, backgroundBorderColor, backgroundBorderThickness);
        }
 public Glyph(string symbol, string templateDir, Graphics graphics, CustomJPrototypeResolver resolver, Color opacity, FontTool font)
 {
     _image    = Path.GetFullPath(Path.Combine(templateDir, resolver.GetRootValue(symbol)));
     _graphics = graphics;
     _opacity  = (decimal)opacity.A / 255;
     Width     = font.GlyphHeight;
     Height    = font.GlyphHeight;
 }
 public void NewLine(FontTool fontTool, BackgroundTool backgroundTool) => _textLines.Add(new TextSequence(_wordAlignment, backgroundTool, fontTool.LineHeight));
 public TextBlock(int maxWidth, HorizontalAlignment lineAlignment, VerticalAlignment wordAlignment, FontTool fontTool, BackgroundTool backgroundTool)
 {
     _maxWidth      = maxWidth;
     _lineAlignment = lineAlignment;
     _wordAlignment = wordAlignment;
     NewLine(fontTool, backgroundTool);
 }