我用VBA写字体出现了一些问题,请高手指教:
(1)、我用BigFontFile方法生成字体,在一张CAD图纸上第一次生成的是我所要的字体,见截图(一)。但我在该张图纸上按同样的方法生成字体,却变成了另外一种字体,见截图(二)。这是为何啊?函数和测试程序如下,
Function InsertTextWithStyle(TextString As String, insertionPoint As Variant, Height As Double, Alignment As Integer, shxFile As String, TextStyleName As String, Scalefactor As Double) Dim Text As AcadText Dim pTextStyle As AcadTextStyle Set pTextStyle = ThisDrawing.TextStyles.Add(TextStyleName) pTextStyle.BigFontFile = shxFile ThisDrawing.ActiveTextStyle = pTextStyle Set Text = ThisDrawing.ModelSpace.AddText(TextString, insertionPoint, Height) Text.Alignment = Alignment Text.TextAlignmentPoint = insertionPoint Text.Scalefactor = Scalefactor Text.Color = acWhite Text.Update End Function Sub test1() Dim BasePnt As Variant BasePnt = ThisDrawing.Utility.GetPoint(, "选择一点:") Dim pTextStle As AcadTextStyle Dim TextString As String Dim TextHeight As Double Dim Alignment As Integer Dim pTextStyle As AcadTextStyle Dim TextStyleName As String Dim TTFName As String Dim shxFile As String Dim Scalefactor As Double TextString = " 明经通道CAD社区!" TextHeight = 10 Alignment = 1 TextStyleName = "HZ" Scalefactor = 0.8 shxFile = "hztxt.shx" Call InsertTextWithStyle(TextString, BasePnt, TextHeight, Alignment, shxFile, TextStyleName, Scalefactor) End Sub
这个测试程序多次生成不会出现上述现象,但其他程序调用这个函数就会出现这种字体不一致的问题!
(2)、还有一种字体不知道如何生成,见截图(三),我生成的字体总是无法加粗,尽管我用ThisDrawing.ActiveTextStyle.SetFont TTFName, True, True, 0, 0方法加粗,但仍然与我要的有很大的区别,这是为何?请高手赐教!谢谢!
截图(一)
截图(二)
截图(三)
|