Making text Style

Making text Style

kajanthangavel
Advocate Advocate
4,024 Views
7 Replies
Message 1 of 8

Making text Style

kajanthangavel
Advocate
Advocate

I write a lisp code for creating text style, it make 'Bold' text style.

(entmake
(list
'(0 . "STYLE")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbTextStyleTableRecord")
'(2 . "Design-Level")
'(70 . 0)
'(40 . 0.0)
'(41 . 1.0)
'(50 . 0.0)
'(71 . 0)
'(42 . 0.09375)
'(3 . "Arial Narrow.ttf")
'(4 . "")
)
)

please someone correct it

for 'Regular'  font style

0 Likes
Accepted solutions (1)
4,025 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

It doesn't do that for me.  The second line here is Mtext, and I edited the second half of it to ask for it to be Bold, but everything else is just as your code defines it.

Text.PNG

Are the Bold ones in your image Mtext with internal Bold-face override?

 

Kent Cooper, AIA
0 Likes
Message 3 of 8

CodeDing
Advisor
Advisor

@kajanthangavel ,

 

Try this:

'(3 . "ArialN.ttf")

Best,

~DD

 

0 Likes
Message 4 of 8

CodeDing
Advisor
Advisor

For those searching in the future,

 

I tried searching for ways to "ENTMAKE" a BOLD font. There are NO bit values or flags that need to be implemented. it is Entirely dependent on the font file name. In most cases the "xxx.ttf" extension (for True Type Font).

For those using windows, your true type fonts can be located in.. C:/Windows/Fonts

- Navigating to this location will open your fonts

image.png

- You can see that some of these contain multiple files (the stacked images). Double-click one to open its font types (bold/italic/narrow, etc..). In our case we will open Arial..

image.png

- When you see your desired font, right-click > properties and this will show your desired font name when trying to ENTMAKE..

image.png

- Thus, for our situation of "Arial Narrow Bold" we will use..

 

'(3 . "ArialNB.ttf")

 

Also, when all-else fails. THIS POST pointed out that using -STYLE you can merely add "Bold" to the end of your font name to weirdly set the font to bold. [e.g. (command "-STYLE" "MyStyle" "Arial Narrow Bold" "0" "1" "0" "N" "N" "N")]

 

Resource 1 - True Type Fonts

Resource 2 - STYLE

 

...hope this helps!

 

Best,

~DD

0 Likes
Message 5 of 8

CodeDing
Advisor
Advisor

@Kent1Cooper ,

 

I discovered that when using entmake to create a style, it seems that if the current style is set to Bold, so will the new style, and vice-versa.

 

Best,

~DD

0 Likes
Message 6 of 8

ronjonp
Mentor
Mentor
Accepted solution

Give this a try:

(defun c:foo (/ e)
  ;; RJP » 2019-04-24
  (entmake (list '(0 . "STYLE")		     '(100 . "AcDbSymbolTableRecord")
		 '(100 . "AcDbTextStyleTableRecord")
		 '(2 . "Design-Level")	     '(70 . 0)
		 '(40 . 0.0)		     '(41 . 1.0)
		 '(50 . 0.0)		     '(71 . 0)
		 '(42 . 0.09375)	     '(3 . "Arial Narrow.ttf")
		 '(4 . "")
		)
  )
  (if (setq e (tblobjname "style" "Design-Level"))
    (vla-setfont (vlax-ename->vla-object e) "Arial Narrow" :vlax-false :vlax-false 0 34)
  )
  (princ)
)
Message 7 of 8

kajanthangavel
Advocate
Advocate

Thank you. it works good.

0 Likes
Message 8 of 8

ronjonp
Mentor
Mentor

@kajanthangavel wrote:

Thank you. it works good.


You're welcome 🙂

0 Likes