Author Topic: Mtext with Arial font creation routine  (Read 2771 times)

0 Members and 1 Guest are viewing this topic.

T-Square

  • Guest
Mtext with Arial font creation routine
« on: September 20, 2013, 02:36:55 PM »
Hello All,

For some reason I can't get this routine to create a text style with the Arial.ttf font file. The routine creates the text style ok, but it's "Font Name" is "Arabic Transparent". I don't know why but I believe it may have something to do with the fonts installed on my system. Code and screen shot attached.

I know this is not the best way of doing this, just piecing together bits of code to accomplish the task. :-)

Update: So I am using AC2012(vanilla) and having the problem. I tested the same routine on an AC2008 install and Map 2012. Neither of them created the problem. So, must be something with my install of AC2012.

Code: [Select]
;;;
;;; Mtext Creation Routine
;;; Original Code by Lee Mac
;;;
(defun c:mtx ( / e h p s )
(setvar "CMDECHO" 1)
(command ".undo" "end")
(command ".undo" "m")
(setvar "CECOLOR" "bylayer")
(setvar "CELTYPE" "bylayer")
(setvar "CELWEIGHT" -1)
(setvar "SNAPMODE" 0)
;;;
(MAKEMTSTYLE)
(MAKETLAYER)
(GETSPACE)
(graphscr)

    (setq s "NEW-ARIAL"
          h (* DIMSC 0.093750)
    )   
    (if (setq p (getpoint "\nPoint for MText: "))
        (progn
            (setq e
                (entmakex
                    (list
                       '(0 . "MTEXT")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbMText")
                       '(1 . "")
                        (cons 10 (trans p 1 0))
                        (cons 40 h)
                        (cons 07 (if (tblsearch "STYLE" s) s "Standard"))
                    )
                )
            )
            (command "_.mtedit" e)
        )
    )
;;;
(command ".undo" "end")
(princ)
)
;;;
(defun MAKEMTSTYLE (/)
(setvar "CMDECHO" 1)
(if (not (tblsearch "style" "NEW-ARIAL"))
(command ".-style" "NEW-ARIAL" "ARIAL.ttf" 0.00000000 1.00000000 0.00000000 "N" "N")
(progn
(princ "\nText Style \"NEW-ARIAL\" Already Exists... Text Style Un-Changed... ")
(setvar "TEXTSTYLE" "NEW-ARIAL")
)
)
)
;;;
(defun GETSPACE (/)
(if (and (equal (getvar "TILEMODE") 0)
(equal (getvar "CVPORT") 1)
)
(setq CSPACE 1);paper space
(setq CSPACE 0);model space.
)
(if (= CSPACE 1)
(setq DIMSC 1.0)
(setq DIMSC(getvar "DIMSCALE"))
)
)
;;;
(defun MAKETLAYER (/)
(setq DISL "G-ANNO-TEXT")
(command ".-layer" "thaw" DISL "on" DISL "unlock" DISL "make" DISL "color" "4" DISL "lt" "continuous" DISL "")
(setvar "clayer" DISL)
)
« Last Edit: September 20, 2013, 03:05:43 PM by T-Square »

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Mtext with Arial font creation routine
« Reply #1 on: September 20, 2013, 03:29:41 PM »
This is what I use .. maybe it will help.



Code: [Select]

(defun _makefonts (listoffonts / doc font fntdir st)
  (setq doc    (vla-get-activedocument (vlax-get-acad-object))
fntdir (strcat (getenv "windir") "\\Fonts\\")
  )
  (foreach f listoffonts
    (cond ((or (setq font (findfile (cdr f)))
       (and (setq font (findfile (strcat fntdir (cdr f)))) (findfile font))
   )
   (setq st (vla-add (vla-get-textstyles doc) (car f)))
   (vlax-put-property st 'fontfile font)
   (vlax-put-property st 'width 1.0)
   (vlax-put-property st 'height 0.0)
  )
    )
  )
  (princ)
)


;; Usage
(_makefonts
  '(("Arial" . "Arial.ttf")
    ("ArialNarrow" . "ArialN.ttf")
    ("ArialNarrowItalic" . "ArialNI.ttf")
    ("Calibri" . "Calibri.ttf")
    ("Romans" . "Romans.shx")
    ("Simplex" . "Simplex.shx")
    ("Technic_" . "technic_.ttf")
   )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T-Square

  • Guest
Re: Mtext with Arial font creation routine
« Reply #2 on: September 20, 2013, 03:35:37 PM »
ronjonp,

Worked like a charm for every font name except the Arial one. Still gives me the "Arabic Transparent" font name. I must have an error or something with the installed fonts on my machine. Yet, I can manually create the font correctly.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Mtext with Arial font creation routine
« Reply #3 on: September 20, 2013, 03:43:40 PM »
Maybe your arial font got over written?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T-Square

  • Guest
Re: Mtext with Arial font creation routine
« Reply #4 on: September 20, 2013, 03:44:55 PM »
But, it works fine in AC2008 and AC Map 3D 2012?

T-Square

  • Guest
Re: Mtext with Arial font creation routine
« Reply #5 on: September 20, 2013, 03:53:55 PM »
Got it. Font was overwritten. Appears to work fine now.

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: Mtext with Arial font creation routine
« Reply #6 on: April 07, 2014, 05:17:07 AM »
This is what I use .. maybe it will help.
...
How to make this textstyle annotative?