Пример #1
0
        // Adapted from Group.RenderText
        public static void TextTex(this Group group, TextGlyph glyph, IndentedTextWriter writer, Graphics g, RenderInformation rendinfo, Group refgroup, double scale, Hashtable fontTexTable)
        {
            writer.WriteLine("{");
            writer.Indent += 1;
            CommentTex(glyph, group, writer);
            string text = glyph.GetTextToDraw();
            RectangleF bound_rectangle = glyph.Bounds.toRect();

            Font font = group.GetScaledFont(scale, refgroup);
            SizeF string_size = g.MeasureString(text, font);
            PointF text_coord = group.GetPoint(group, bound_rectangle);

            Color text_color = group.GetStrokeColor(rendinfo, refgroup);
            if (!text_color.Equals(Color.Empty))
            {
                // refer stroke information to a ColorDefinition ID or assign a new colordefinition to "curLineColor"
                string strokeRef = FillColor.getStrokeRef(group, rendinfo, refgroup);
                if (String.IsNullOrEmpty(strokeRef) || !FillColor.isColorID(strokeRef, rendinfo.ColorDefinitions))
                {
                    strokeRef = "curLineColor";
                    FillColor.AssignColorRGBTex(text_color, "curLineColor", writer);
                }

                //adapted from Group.CorrectPosition
                switch (group.GetTextAnchor(group))
                {
                    // TikZ text is automatically centered at the drawing point
                    case Text.TextAnchors.start:
                        text_coord.X += string_size.Width / 2f;
                        break;
                    case Text.TextAnchors.end:
                        text_coord.X -= string_size.Width / 2f;
                        break;
                }

                writer.WriteLine("\\draw ({0}pt, {1}pt) node[text = {7}{2}, font = \\fontsize{{ {3} }} {{ {4} }}\\fontfamily{6}\\selectfont] {{ {5} }};",
                    (text_coord.X).ToString(),
                    (text_coord.Y).ToString(),
                    FillColor.AlphaValTex(text_color),
                    font.SizeInPoints,
                    font.SizeInPoints,
                    correctText(text),
                    FontTex(font, fontTexTable),
                    strokeRef);
            }
            writer.Indent -= 1;
            writer.WriteLine("}");
        }