Example #1
0
        public SizeF GetTextSize(string text, TextEffects effects)
        {
            float width  = 0;
            float height = effects.font.Size.Height;

            foreach (char c in text)
            {
                StrokeChar ch = new StrokeChar(newstroke_font[(int)c - 32]);
                width += ch.Width * effects.font.Size.Width;
            }
            return(new SizeF(width, height));
        }
Example #2
0
        // todo: bold, italic, mirror, (flip?)
        // align horiz/vert
        // overbar (~)
        // rotation

        public void DrawText(kicad_pcb k_pcb, PointF pos, string text, TextEffects effects, string layer)
        {
            foreach (char c in text)
            {
                StrokeChar ch = new StrokeChar(newstroke_font[(int)c - 32]);

                foreach (VectorPath path in ch.Paths)
                {
                    for (int j = 0; j < path.Points.Count - 1; j++)
                    {
                        PointF p1 = pos.Add(path.Points[j].Scale(effects.font.Size));
                        PointF p2 = pos.Add(path.Points[j + 1].Scale(effects.font.Size));

                        gr_line line = new gr_line(p1, p2, layer, effects.font.thickness);
                        k_pcb.Drawings.Add(line);
                    }
                }

                pos.X += ch.Width * effects.font.Size.Width;
            }
        }