TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: bmossman on January 11, 2008, 10:36:20 AM

Title: Is there a way to modify the Font Style
Post by: bmossman on January 11, 2008, 10:36:20 AM
using lisp...ie, control whether it's roman, bold, italic?
Code: [Select]
(defun c:SIMPLEX (/)
(command "-style"
"SIMPLEX" ; name of text style
"SIMPLEX" ; font name
"0" ; height of text
"1" ; width factor
"0" ; obliquing angle
"n" ; text backwards
"n" ; text upside-down
""
)
(princ)
)
Title: Re: Is there a way to modify the Font Style
Post by: Guest on January 11, 2008, 10:40:30 AM
For starters, you can't apply the bold property to SIMPLEX.

BUT...  If you use Arial and want to make it bold, you have to enter ARIALBD.TTF to make the text style Arial Bold.  Confused?

Code: [Select]
(command "-style" "TAGS1" "arialbd.ttf" "20.0" "1" "0" "n" "n")
Title: Re: Is there a way to modify the Font Style
Post by: bmossman on January 11, 2008, 10:58:58 AM
What about swiss.ttf? How would you control the font style using lisp?
Title: Re: Is there a way to modify the Font Style
Post by: Guest on January 11, 2008, 11:03:44 AM
What I just did was create a text style that uses the Swiss 721 Black BT.ttf font style, then from the command line, found out what the name is...


Quote
Command: -style
Enter name of text style or [?] <TAGS1>:

Existing style. Full font name = Swiss 721 Black BT
Specify full font name or font filename (TTF or SHX) <swissk.ttf>:
Specify height of text or [Annotative] <1'-8">:
Specify width factor <1.0000>:
Specify obliquing angle <0.00>:
Display text backwards? [Yes/No] <No>:
Display text upside-down? [Yes/No] <No>:
"TAGS1" is now the current text style.

Command:
Title: Re: Is there a way to modify the Font Style
Post by: bmossman on January 11, 2008, 11:10:14 AM
I just figured it out after I explored the fonts directory & saw the different font types. Thanks for your help!
Title: Re: Is there a way to modify the Font Style
Post by: ronjonp on January 11, 2008, 11:12:31 AM
Here is what I use:

Code: [Select]
(defun c:af (/ doc txtstyle)
  (setq doc (vla-get-activedocument (vlax-get-acad-object))
txtstyle (vla-add (vla-get-textstyles doc) "Arial")
  )
  (vlax-put-property txtstyle 'fontfile "arial.ttf")
  (vlax-put-property txtstyle 'width 1.0)
  (vlax-put-property txtstyle 'height 0.0)
  (vla-put-activetextstyle doc txtstyle)
  (princ "\nARIAL is now the current text style")
  (princ)
)
Title: Re: Is there a way to modify the Font Style
Post by: Guest on January 11, 2008, 11:13:49 AM
I just figured it out after I explored the fonts directory...

Lucky.... I can't see my "C" drive.  They've locked us out, so I've learned to do things the hard way.


And, you're welcome.
Title: Re: Is there a way to modify the Font Style
Post by: daron on January 11, 2008, 11:18:27 AM
Man, I hate when ITwit's do that. I worked at a company that made it so we couldn't alter one word in a folder structure to switch to another folder, like:
c:\this\that\images
to
c:\this\these\images
Had to go about it the long way. Annoying.
Title: Re: Is there a way to modify the Font Style
Post by: bmossman on January 11, 2008, 11:19:49 AM
Quote
Lucky.... I can't see my "C" drive.  They've locked us out, so I've learned to do things the hard way.
Damn communists! :-D
Title: Re: Is there a way to modify the Font Style
Post by: Guest on January 11, 2008, 11:20:11 AM
Man, I hate when ITwit's do that. I worked at a company that made it so we couldn't alter one word in a folder structure to switch to another folder, like:
c:\this\that\images
to
c:\this\these\images
Had to go about it the long way. Annoying.

Yup.... we've got that too.
Title: Re: Is there a way to modify the Font Style
Post by: Harrie on January 14, 2008, 05:59:16 AM
Here is what I use:

Code: [Select]
(defun c:af (/ doc txtstyle)
  (setq doc (vla-get-activedocument (vlax-get-acad-object))
txtstyle (vla-add (vla-get-textstyles doc) "Arial")
  )
  (vlax-put-property txtstyle 'fontfile "arial.ttf")
  (vlax-put-property txtstyle 'width 1.0)
  (vlax-put-property txtstyle 'height 0.0)
  (vla-put-activetextstyle doc txtstyle)
  (princ "\nARIAL is now the current text style")
  (princ)
)

Dear Ron,

When I use your program. I get:
Error: Automation Error. Filer error

Regards
Title: Re: Is there a way to modify the Font Style
Post by: ronjonp on January 14, 2008, 09:46:26 AM
Not sure about that one.....maybe add (vl-load-com) to the top line?
Title: Re: Is there a way to modify the Font Style
Post by: GDF on January 14, 2008, 11:31:56 AM
Not sure about that one.....maybe add (vl-load-com) to the top line?

Ron

That was it. I also get the error.


Command: af
; error: Automation Error. Filer error
Command:

Gary
Title: Re: Is there a way to modify the Font Style
Post by: T.Willey on January 14, 2008, 11:38:59 AM
Wonder if it can't find the file.  Try (findfile "arial.ttf") and see what it returns.

/guess
Title: Re: Is there a way to modify the Font Style
Post by: ronjonp on January 14, 2008, 11:40:40 AM
Not sure about that one.....maybe add (vl-load-com) to the top line?

Ron

That was it. I also get the error.


Command: af
; error: Automation Error. Filer error
Command:

Gary

Good to hear...thanks Gary.
Title: Re: Is there a way to modify the Font Style
Post by: CAB on January 14, 2008, 01:17:55 PM
Remember this thread?
http://www.theswamp.org/index.php?topic=15317.msg186243#msg186243