HOW to replace all TTF fonts to SHX

HOW to replace all TTF fonts to SHX

Anonymous
Not applicable
7,712 Views
9 Replies
Message 1 of 10

HOW to replace all TTF fonts to SHX

Anonymous
Not applicable

Hi Everyone,

 

Can you help me with a lisp that selects all the fonts in the drawing and replace it to specify SHX fonts.

I mean- I want by calling the lisp:

1. it will ask to select an area or all if an area is selected it allow to select a region to replace only these fonts or all the fonts.

2. it will give a list of the shx fonts style that I have in that drawing, and after selecting one font, it will replace the TTF fonts that have been selected in no.1 to that font.

 

Thank you 

Eyal

0 Likes
Accepted solutions (1)
7,713 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable

Hi all,

 

Can I replace TTF fonts with SHX fonts by lisp?

If you have something similar to do this task will be great.

 

Good day

Eyal

 

0 Likes
Message 3 of 10

hak_vz
Advisor
Advisor

Your request is not so simple to answer.

Text formatting regarding a font is done using font styles. With MTEXT entities, and other entities that incorporate MTEXT to present text, there is possible override of a font stile.

 

For mtext that uses predefined font stile text information looks like this

 

....(1 . "Teste text") (7 . "Standard").....

 

For mtext with overridden formatting this information looks like this (used txt.shx)

 

(1 . "{\\Ftxt|c238;Test text}") (7 . "Standard")

 

  or here with TTF font

(1 . "{\\fVerdana|b1|i1|c238|p34;\\LTest text}") (7 . "Standard")

Here you can find explanation for MTEXT formating codes.

 

Changing mtext formating is not so simple since formatinga are not saved separately, but are coded together with

text information. One would have to read out text information from MTEXT entity and recode it back with new font.

 

For changing MTEXT object, one option is  to define various font styles, explode them, assign new styles and if needed convert back to MTEXT.

 

Read this post for your possible further steps

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 4 of 10

Anonymous
Not applicable

Hi @hak_vz ,

 

Thank you for your explanation, is it possible to replace only the SHX style with another SHX style by a lisp?

 

Eyal

 

 

 

0 Likes
Message 5 of 10

hak_vz
Advisor
Advisor

@Anonymous wrote:

Hi @hak_vz ,

Thank you for your explanation, is it possible to replace only the SHX style with another SHX style by a lisp?


Well, there are text objects inside drawing. If we would change style names then each text objects style would have to be changed to new style. What can be done is to change font of particular existing text stile with new one.

 

Or you can create new style definitions and replace occurrences of old style in existing text objects.

If you have in your drawing MTEXT objects that don't have changed formatting, changing style will affect them too.

 

Provide more details, some sample drawing.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 6 of 10

ronjonp
Mentor
Mentor
Accepted solution

Based on the name of this thread this should do what you want:

(defun c:foo ( / d)
  (vlax-for f (vla-get-textstyles (setq d (vla-get-activedocument (vlax-get-acad-object))))
    (if	(wcmatch (strcase (vla-get-fontfile f)) "*.TTF")
      (vl-catch-all-apply 'vla-put-fontfile (list f "Romans.shx"))
    )
  )
  (vla-Regen d acAllViewports)
  (princ)
)
(vl-load-com)
Message 7 of 10

john.uhden
Mentor
Mentor

First question is why would you want to do that?  I hope you don't think that the old HB.SHX font is better than ArialB.ttf, because it isn't.  The ttf fonts are rock solid, while the shx fonts contain just a lot of pen strokes for fill thus making them vulnerable to the pen width of their color.

The second thing that bothers me is that except for mtext overrides, the font is dependent on the text style definition, so you wouldn't be able to change the font of only selected text entities.

John F. Uhden

0 Likes
Message 8 of 10

Moshe-A
Mentor
Mentor

@Anonymous  hi,

 

Converting a text in hebrew ttf to shx  does not just involves changing the text style\font file, it requires a character conversion between unicode to 8bit cause that still what most of us using here (to my sorrow).

 

WINHEB has a command (from Revit to AutoCAD) to do this conversion. if you do not have that, then this issue is a real pain 😀

 

Moshe

 

0 Likes
Message 9 of 10

Anonymous
Not applicable

Hi,

 

And if I want to change the SHX font style to another SHX font style?

 

I have some SHX fonts in the drawing and I want by calling the lisp to give a list of all the SHX fonts in the current drawing and after selecting one style it will change all the SHX fonts in the drawing to that font style.

 

Could it be made?

 

Thank you, and good day

Eyal 

0 Likes
Message 10 of 10

Moshe-A
Mentor
Mentor

@Anonymous ,

 

For that you do not need any lisp only select the texts and select the style to change from properties palette (style combo box) and bare in mind...in our contry we have 3 types of shx fonts:

1. unicode shx

2. 8bit shx

3. 7bit shx

 

changing from one to another won't go only changing style on the same type.

 

cheers

Moshe