明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3825|回复: 7

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

[复制链接]
发表于 2003-1-28 14:13:00 | 显示全部楼层 |阅读模式
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. [U]The only valid file type is SHX.[/U]This property cannot be set to NULL or an empty string.
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 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" "")
发表于 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字体也不用路径了
函数我把它加到函数栏目中吧
发表于 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)字型如何设定????

发表于 2012-10-4 16:07:39 | 显示全部楼层
mccad 发表于 2003-1-28 19:53
(defun CH_TXTSTYLE (TextStyleName FontName BigFontName / TxtStyle Doc)
  (setq TxtStyle (vla-Item
...

error:Automation 错误。 文件处理器错误
发表于 2015-7-13 14:54:23 | 显示全部楼层
xp里没有SIMSUN.TTF但有SIMSUN.TTc
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-10-1 15:40 , Processed in 0.170096 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表