public void DrawString(Graphics graphics, string text, float fontSize, string fontEmphasis, string fontWeight, Brush brush, PointF point) { var x = point.X; var y = point.Y; var letterSpacing = 0.01f; foreach (var c in text) { var g = GetGlyph(fontWeight, fontEmphasis, c.ToString()); if (g != null) { var p = PathConverter.ConvertPath(new SVG.Path() { Commands = g.PathCommands }); var m = new System.Drawing.Drawing2D.Matrix(); var sf = fontSize / 20.0f; m.Scale(sf, sf); m.Translate(x / sf, y / sf + 25f); p.Transform(m); graphics.FillPath(brush, p); x += g.Width * sf + letterSpacing * fontSize * sf; } } }
public static GraphicsPath GetSquareRootPath(Length innerHeight, Length innerWidth) { // True LaTeX square-root shape var svg = "M 9.64216 21.1929 L 5.27964 11.5508 C 5.10613 11.1542 4.9822 11.1542 4.90784 11.1542 C 4.88305 11.1542 4.75911 11.1542 4.48646 11.3525 L 2.13169 13.1371 C 1.80945 13.385 1.80945 13.4594 1.80945 13.5337 C 1.80945 13.6577 1.88382 13.8064 2.05733 13.8064 C 2.20605 13.8064 2.62743 13.4594 2.90009 13.2611 C 3.04881 13.1371 3.42061 12.8645 3.69327 12.6662 L 8.57632 23.399 C 8.74983 23.7956 8.87377 23.7956 9.09685 23.7956 C 9.46865 23.7956 9.54302 23.6468 9.71652 23.2998 L 20.9698 0 C 21.1434 -0.347019 21.1434 -0.446167 21.1434 -0.495741 C 21.1434 -0.743612 20.9451 -0.991482 20.6476 -0.991482 C 20.4493 -0.991482 20.2758 -0.867547 20.0775 -0.470954 L 9.64216 21.1929 Z"; var p = PathConverter.ConvertPath(PathConverter.ParsePath(svg)); return(p); }
protected void ExportBracketExpression(Graphics graphics, BracketExpression bracketExpression) { ExportElement(graphics, bracketExpression.InnerExpression); var g1 = _fontLoader.GetGlyph("normal", "none", "("); var g2 = _fontLoader.GetGlyph("normal", "none", ")"); var w = g1.Width; var h = bracketExpression.InnerExpression.OuterHeight; var x1 = (float)(bracketExpression.Position.X.Quantity); var y1 = (float)bracketExpression.Position.Y.Quantity; var x2 = (float)(bracketExpression.Position.X.Quantity + bracketExpression.InnerExpression.OuterWidth.Quantity); var y2 = (float)bracketExpression.Position.Y.Quantity; var p1 = PathConverter.ConvertPath(new Path() { Commands = g1.PathCommands }); // Paths.GetBracketPath(new PointF(, , (float)h.Quantity); var p2 = PathConverter.ConvertPath(new Path() { Commands = g2.PathCommands }); // Paths.GetBracketPath(new PointF(, ), (float)h.Quantity, ")"); var m1 = new System.Drawing.Drawing2D.Matrix(); var m2 = new System.Drawing.Drawing2D.Matrix(); var sf = (float)h.Quantity / (1.7f * 20.0f); m1.Scale(sf, sf); m1.Translate(x1 / sf, y1 / sf + 25f); m2.Scale(sf, sf); m2.Translate(x2 / sf, y2 / sf + 25f); p1.Transform(m1); p2.Transform(m2); graphics.FillPath(Brushes.Black, p1); graphics.FillPath(Brushes.Black, p2); if (bracketExpression.DrawConstructionLines == true) { DrawConstructionLines(graphics, bracketExpression.Position, bracketExpression.SizeIncludingOuterMargin); } }