This project has moved. For the latest updates, please go here.

TextStyle

Sep 14, 2015 at 11:49 AM
I want my Text object to have style from font file. I have this following code:
DxfDocument dxfText = new DxfDocument();
TextStyle textStyle = new TextStyle("metaplus.ttf");
Text text = new Text("testing", Vector2.Zero, 6, textStyle);
dxfText.AddEntity(text);
dxfText.Save("text3.dxf");

My text in created .dxf file is like a default without any style. So i have a question, how to make my text to have style, is it even working?
Coordinator
Sep 16, 2015 at 7:53 PM
I have been running a few tests, and yes, some of the true type fonts don't work as intended. AutoCad fails to read them correctly, but with another program I tried, I was able to do it correctly. Sometimes the dxf require to add external data information to the Style definition, a code 1000 with the font family name and a 1071 code that defines the font style, but what it is store there is completely undocumented in the official docs.

The most odd thing is that when you save a dxf from AutoCad using one of the fonts that gives problems, the style definition does not include the code 3 with the font file. I guess AutoCad does something with the Windows registry to check the installed fonts, where you can find the font file name from its font family name.

I have not been able to pin point the problem, when I fix one the other one breaks, and I have no clue about that extended data code 1071, it looks like a bit value. But, as I said there is no documentation about this, so for the moment we will have to live with that.

Daniel