yj821005 发表于 2005-7-27 08:33:00

[求助]定义字体问题

Const DEFAULT_CHARSET As Long = 1
    Const FIXED_PITCH As Long = 1
    Const FF_ROMAN As Long = 16
    Dim TextColl As AcadTextStyles
    Set TextColl = ThisDrawing.TextStyles
    Dim textStyle As AcadTextStyle
    Set textStyle = TextColl.Add("Yujun")
    Dim TypeFace As String
    Dim Bold As Boolean
    Dim Italic As Boolean
    Dim CharSet As Long
    Dim PitchAndFamily As Long
    TypeFace = 仿宋_GB2312"
    Bold = False
    Italic = False
    CharSet = DEFAULT_CHARSET
    PitchAndFamily = FIXED_PITCH Or FF_ROMAN
    textStyle.SetFont TypeFace, Bold, Italic, CharSet, PitchAndFamily
    textStyle.height = 3
    textStyle.Width = 0.7
以上代码是我定义的一种字体,但是用的是仿宋_GB2312,也就是Windows自带的字体,但是我想改成CAD特有的.shx字体,如simplex9.shx如何修改,将TypeFace = 仿宋_GB2312"直接改成TypeFace = simplex9.shx"好像不对,
请问各位如何解决,谢谢!

wyj7485 发表于 2005-7-27 10:49:00

直接这样定义:
Dim MyTxtType As AcadTextStyle
Set MyTxtType = ThisDrawing.TextStyles.Add("Yujun")
MyTxtType.SetFont "simplex9.shx", False, False, 0, 0

sharksun 发表于 2005-7-27 19:46:00


    应该是setfont "simplex", 没有.shx,只有设置大字体时,才需要后缀的。

另外,楼主,simplex9是什么字体?fonts文件里没有的话,当然会出错的。

yj821005 发表于 2005-7-28 08:23:00

郁闷,好像两位说的都不行啊,字体文件里面肯定有的。刚才试了试好像只有“txt”是能通过的,其他都不能通过,而且运行完了好像并没有设置为“txt”字体

wyj7485 发表于 2005-7-28 08:58:00

以上这种设置对汉字体有用
采用以下语句就可以了:
Dim MyTxtType As AcadTextStyle
Set MyTxtType = ThisDrawing.TextStyles.Add("Yujun")
MyTxtType.fontFile = "simplex9.shx"

yj821005 发表于 2005-7-28 09:40:00

谢谢楼上的,送鲜花一朵!呵呵
页: [1]
查看完整版本: [求助]定义字体问题