如何编程创建一个新的文字样式(使用truetype字体)
Issue
When I create new text styles based on truetype fonts, how do I know which fonts are available?When I type certain font names as they are listed in the STYLE dialog box, AutoCAD tells me that the font name does not exist.
Using Visual LISP, how do I create a new style without using (command "style" new-style full-style-name "" "" "" "" "" "") ?
Solution
It seems that with some fonts, mostly Swiss and Dutch, the font name is abbreviated in AutoCAD's STYLE dialog.Some of the common abbreviations used are:
Bd = Bold
Blk = Black
Cn = Condensed
Ex = Extended
It = Italic
Out = Outline
Rm = Roman
Xbd = Extra Bold
For example:
Swis721 BlkEx BTwould be written asSwiss 721 Black Extended BT
Swis721 BdCnOut BTwould be written asSwiss 721 Bold Condensed Outline BT
Dutch801 Rm BTwould be written asDutch 801 Roman BT
Dutch801 Xbd BTwould be written asDutch 801 Extra Bold BT
Note: Using Windows Explorer, you can see the actual spelling of the font names, in theFonts directory (ex: C:\Windows\Fonts).
There are two lisp approaches to create a new style, without using (command "style"...etc), but you will need the name of the actual .ttf file to do so.Again, Windows' Fonts directory lists the font names and the related .ttf filename.For example: Swiss 721 Bold Condensed Outline BT is found in the file swisscbo.ttf.With this information, we can proceed to entmake a new text style.First, the old AutoLISP approach, using entmake:
使用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")
)
下面是使用VLISP(AcTivex):
**** Hidden Message *****
具体应用中,用你期望的字体替代程序里面的ttf文件名。
回复,向版主学习程序 回复学习学习! 向N版学习 回复,向版主学习。 想班组学习一下。。。。。。。。。。 good good.
看一看,学一学
学习。。。。。。。
看一下VLISP代码 谢谢!!!!学习!!!
回复看看---------------------- good good.
回复,下载,学习!!!!!!!
回复看看----------------------