You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to add monospace text to file. There is a TextStyleName property, which is the most relevant for my question, but I am not sure how to use it. I am using DxfText class for text
The text was updated successfully, but these errors were encountered:
Presumably this is for display purposes in AutoCAD? First, I'll say that AutoCAD is really particular about what values it will accept and what ones it won't, so everything below this point is pure theory because I don't have AutoCAD available to test this with, but as I get time I can try it with LibreCAD.
The TextStyleName property on a TEXT entity needs to have a corresponding entry in the Styles property of DxfFile, and in that DxfStyle entry you'd specify the font in the PrimaryFontFileName property. E.g., something like this:
// n.b., this is untested, but you get the ideavarfile=newDxfFile();varmyTextStyle=newDxfStyle("MY_STYLE_NAME");myTextStyle.PrimaryFontFileName="the-font-name-that-i-want-to-use";file.Styles.Add(myTextStyle);vartext=newDxfText("this is a text entity");text.TextStyleName=myTextStyle.Name;// you could also directly set it to "MY_STYLE_NAME"file.Entities.Add(text);
Btw, it's the best way to add text - declare your style and then use it anywhere you need a text in dxf file. The STANDARD style does not explicitly specify a font to use, and sometimes Autocad shows wrong characters with STANDARD style.
I ended up specifying Consolas font explicitly
I'd like to add monospace text to file. There is a
TextStyleName
property, which is the most relevant for my question, but I am not sure how to use it. I am using DxfText class for textThe text was updated successfully, but these errors were encountered: