龙龙仔 发表于 2003-1-28 14:13:00

VLISP無法設定WINDOWS字型(TTF)????

Specifies the name of the big font file associated with the text or attribute.

Signature

object.BigFontFile

object        TextStyle The object or objects this property applies to.
BigFontFile        String; read-write The name of the big font file.

Remarks

This property is similar to the FontFile property, except it is used to specify an Asian-language big font file. The only valid file type is SHX.This property cannot be set to NULL or an empty string.

mccad 发表于 2003-1-28 16:44:00

你所指的是大字体,其实TTF字体你只要指定fontFile属性就行

Specifies the primary font file path and name.

Signature

object.FontFile

object

TextStyle:
The object or objects this property applies to.

FontFile:
String; read-write
The primary font file path.

Remarks :
To specify an Asian-language font file, use the BigFontFile property.

Fonts define the shapes of the text characters that make up each character set.

NOTE: Once this property has been set, you must call the Regen method to see the changes to the text.

从字面上看没有对TTF字体的限制,而实际操作中,使用TTF字体时必须指定路径,因为字体不在AutoCAD的支持路径中。
以下程序(VBA)调用正常:

Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    If (CommandName = "TEXT" Or CommandName = "MTEXT") And _
    ThisDrawing.ActiveTextStyle.BigFontFile = "" And _
    LCase(Right(ThisDrawing.ActiveTextStyle.fontFile, 4)) <> ".ttf" Then
      ThisDrawing.ActiveTextStyle.fontFile = "c:\windows\fonts\SIMSUN.TTF"
    End If

End Sub

龙龙仔 发表于 2003-1-28 17:00:00

為何失敗????

;;By LUCAS
;;修改字型
;;usage: (ch_txtstyle "simplex.shx" "dayuxp.shx")
;;usage: (ch_txtstyle <英文字型> <中文字型>)
(defun CH_TXTSTYLE (FONT BIGFONT / TXT TXTSTYLES DOC)
(setq        TXTSTYLES (vla-get-textstyles
                  (setq DOC (vla-get-activedocument
                                (vlax-get-acad-object)
                              )
                  )
                  )
)
(vlax-for TXT TXTSTYLES
      (vla-put-fontfile TXT FONT)
      (vla-put-bigfontfile TXT BIGFONT)
)
(vla-regen DOC acallviewports)
(vlax-release-object DOC)
(vlax-release-object TXTSTYLES)
(princ)
)

;;為何失敗
;;(CH_TXTSTYLE "c:\windows\fonts\MINGLIU.TTF" "")

mccad 发表于 2003-1-28 19:29:00

没有失败,你试试...

(CH_TXTSTYLE (strcat (getenv "Windir") "\\fonts\\SIMSUN.TTF") "")

你把“\\”给忘了。
其实中间那一段可以这样写:

(vlax-for TXT TXTSTYLES
    (if (= (strcase (substr Font (- (strlen Font) 3) 4)) ".TTF")
      (vla-put-fontfile
      txt
      (strcat (getenv "Windir") "\\fonts\\" FONT)
      )
      (progn
      (vla-put-fontfile TXT FONT)
      (vla-put-bigfontfile TXT BIGFONT)
      )
    )
)

这样设置TTF字体也不用路径了
函数我把它加到函数栏目中吧

mccad 发表于 2003-1-28 19:53:00

呵呵,函数略做改动,只对改动指定的文字样式

(defun CH_TXTSTYLE (TextStyleName FontName BigFontName / TxtStyle Doc)
(setq TxtStyle (vla-Item
                   (vla-get-textstyles
                     (setq Doc (vla-get-activedocument
                                 (vlax-get-acad-object)
                               )
                     )
                   )
                   TextStyleName
               )
)
(if (= (strcase (substr FontName (- (strlen FontName) 3) 4))
         ".TTF"
      )
    (vla-put-fontfile
      TxtStyle
      (strcat (getenv "Windir") "\\fonts\\" FontName)
    )
    (progn
      (vla-put-fontfile TxtStyle FontName)
      (vla-put-bigfontfile TxtStyle BigFontName)
    )
)

(vla-regen Doc acallviewports)
(vlax-release-object Doc)
(vlax-release-object TxtStyle)
(princ)
)
;;示例:将文字样式设为TTF字体-宋体
(CH_TXTSTYLE "STANDARD" "SIMSUN.TTF" "")

龙龙仔 发表于 2003-1-29 07:58:00

但windows(ttc)字型如何设定????

yjtdkj 发表于 2012-10-4 16:07:39

mccad 发表于 2003-1-28 19:53 static/image/common/back.gif
(defun CH_TXTSTYLE (TextStyleName FontName BigFontName / TxtStyle Doc)
(setq TxtStyle (vla-Item
...

error:Automation 错误。 文件处理器错误

smzwx 发表于 2015-7-13 14:54:23

xp里没有SIMSUN.TTF但有SIMSUN.TTc
页: [1]
查看完整版本: VLISP無法設定WINDOWS字型(TTF)????