Trouble displaying Text Style

Trouble displaying Text Style

Anonymous
Not applicable
740 Views
2 Replies
Message 1 of 3

Trouble displaying Text Style

Anonymous
Not applicable

This is my code for creating the text style.  I am trying to create a text style called romans using the romans.shx font.  However, when I display my text using romans, the text looks thick.  When I type in style at the command line to look at the new style, it is showing Regular in the Font Style section.  It normally is not supposed to show anything.  Also the Vertical box is highlighted.  If I change the font manually to a different one and then back to romans.shx the font goes back to normal.  What am I missing in my code that will fix that?

 

 

'Setup a transaction to the drawing
Using lock As DocumentLock = MyDrawing.LockDocument
Using acTrans As Transaction = MyDrawing.TransactionManager.StartTransaction()

Dim strTableTextStyle As String = "romans"

 

'' Open the Text style table for read
Dim myTextStyleTable As TextStyleTable = acTrans.GetObject(MyDrawingDb.TextStyleTableId, OpenMode.ForRead)

 

'Check if text style exists in table
If myTextStyleTable.Has(strTableTextStyle) = False Then

     'Create a new Text style record

     Dim myTextStyleTableRec As TextStyleTableRecord = New TextStyleTableRecord

 

     ''Assign the Text style name
     myTextStyleTableRec.Name = strTableTextStyle 'name

 

     'Get the font
     Dim myNewTextStyle As New GraphicsInterface.FontDescriptor(strTableTextStyle, False, False, 0, 0)

 

     ''Assign the Text style properties
     myTextStyleTableRec.Font = myNewTextStyle 'font .shx file
     myTextStyleTableRec.TextSize = 0.125 'text size
     myTextStyleTableRec.XScale = 0.85 'width factor

 

     '' Upgrade the Textstyle table for write

     myTextStyleTable.UpgradeOpen()

 

     '' Append the new textstyle to the textstyle table and the transaction
     myTextStyleTable.Add(myTextStyleTableRec)
     acTrans.AddNewlyCreatedDBObject(myTextStyleTableRec, True)
     acTrans.commit()
End If

End Using

End Using

0 Likes
741 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

I don't think you can use TextStyleTableRecord.Font with an .shx-based font.  Use TextStyleTableRecord.FileName instead.

 

-drg

 

 

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Excellent. That worked. Thanks.

0 Likes