Completed

Possibility to create Text entity with Font attribute

Hi,

It would be a nice feature if Eyeshot give us the possibility to create a Text entity with a font attribute.

Current constructors only give possibility to define position, text string, height and text alignment.

 

Thanks.

3

Comments

5 comments
Date Votes
  • Official comment

    This is now included in the product.

  • //This takes a True Type font and string and returns EntityList

    class ESFonts
    {
    public EntityList FromFont(Font font, String Text)
    {
    int fontStyle = (int)font.Style;
    int emSize = 1;

    StringFormat stringformat = StringFormat.GenericDefault;
    System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
    if (Text != null)
    {
    PointF zero = new PointF();
    zero.X = zero.Y = 0;
    graphicsPath.AddString(Text, font.FontFamily, fontStyle, emSize, zero, stringformat);
    PointF[] pd = graphicsPath.PathPoints;
    byte[] types = graphicsPath.PathTypes;
    int size = pd.Count();
    return ConvertPointF_To_Mill(pd, types);

    }
    return null;
    }

    private EntityList ConvertPointF_To_Mill(PointF[] ptr, byte[] info)
    {
    EntityList cc = new EntityList();
    int controls = 0;
    int size = ptr.Count();
    if (size != info.Count()) return null;
    int laststarti = 0;
    for (int i = 0; i < size; i++)
    {
    ptr[i] = FlipPoint(ptr[i]);
    byte type = (byte)(info[i] & 0x03);
    if (type == (byte)PathPointType.Line)
    {
    Point3D espt1 = new Point3D(ptr[i - 1].X, ptr[i - 1].Y);
    Point3D espt0 = new Point3D(ptr[i - 0].X, ptr[i - 0].Y);
    Line l = new Line(espt1, espt0);
    cc.Add(l);
    }
    else if (type == (byte)PathPointType.Start)
    {
    laststarti = i;
    }
    else if (type == (byte)PathPointType.Bezier)
    {
    if (controls == 2)
    {
    Point3D espt3 = new Point3D(ptr[i - 3].X, ptr[i - 3].Y);
    Point3D espt2 = new Point3D(ptr[i - 2].X, ptr[i - 2].Y);
    Point3D espt1 = new Point3D(ptr[i - 1].X, ptr[i - 1].Y);
    Point3D espt0 = new Point3D(ptr[i - 0].X, ptr[i - 0].Y);
    Curve c = new Curve(3, new Point3D[] { espt3, espt2, espt1, espt0 });
    cc.Add(c);
    controls = 0;
    }
    else if (controls > 0)
    controls++;
    else
    {
    controls = 1;
    }
    }
    if ((info[i] & 0x80) != 0)
    {
    Point3D espt1 = new Point3D(ptr[laststarti].X, ptr[laststarti].Y);
    Point3D espt0 = new Point3D(ptr[i - 0].X, ptr[i - 0].Y);
    Line l = new Line(espt1, espt0);
    cc.Add(l);
    }
    }
    return cc;
    }
    private PointF FlipPoint(PointF point)
    {
    point.X = point.X;
    point.Y = -point.Y ;
    return point;
    }
    }
    0
  • Hi Alberto,

    You mentioned above this is now included in Eyeshot which is great. Can you provide where we can find this?

    I am trying to produce Text on a curve exactly like your sample program "TextOnCurve" only I would like to be able to select a true type font.

     

    Thanks for any advise

    -Jas

    0
  • Hi Jas,

    You need to create a TextStyle first and add it to the Model.TextStyles master collection.

    Alberto

     

     

     

    0
  • Thanks, I understand now. It works well...

    -Jas

    0

Please sign in to leave a comment.

Didn't find what you were looking for?

New post