除了 (command"style"...etc)方式外,有两种方式设置truetype fonts,但你必须知道所设置字体的.ttf名称。
The old AutoLISP approach, using entmake:
[code=lisp]
;;Style: myNewStyle
;;Font Name: Swiss 721 Bold Condensed Outline BT
;;Fontfile: swisscbo.ttf
(if (not (tblsearch "STYLE" "myNewStyle"))
(entmake '((0 . "STYLE")
(100 . "AcDbSymbolTableRecord")
(100 . "AcDbTextStyleTableRecord")
(2 . "myNewStyle") ;style name
(3 . "swisscbo.ttf") ;font file
(70 . 0)
(40 . 0.0)
(41 . 1.0)
(50 . 0.0)
(71 . 0)
)
)
(princ "\n Style already defined")
)
The Visual LISP (ActiveX) approach is as follows:
;;Style: myNewStyle
;;Font Name: Swiss 721 Bold Condensed Outline BT
;;Fontfile: swisscbo.ttf
(vl-load-com)
(setq acadApp (vlax-get-Acad-object))
(setq acadDoc (vla-get-ActiveDocument acadApp))
(setq styles (vla-get-textstyles acadDoc))
;; Add the style named "myNewStyle"
(setq objStyle (vla-add styles "myNewStyle"))
;; Assign fontfile "swisscbo.ttf" to the style
(setq ff "c:\\winnt\\fonts\\swisscbo.ttf") ;your path may be different
(vla-put-fontfile objStyle ff)
;; Optional: Make the new style Active
(vla-put-activetextstyle acadDoc objStyle)
(princ)