明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 6775|回复: 32

[求助]请教高手,如何知道文件中哪些文字样式缺少字体?

  [复制链接]
发表于 2009-4-13 18:54:00 | 显示全部楼层 |阅读模式
请教高手,如何知道文件中哪些文字样式缺少字体?
"觉得好,就打赏"
还没有人打赏,支持一下
 楼主| 发表于 2009-4-14 16:34:00 | 显示全部楼层
这种情况我们经常会遇到,怎么会没人关注呢?
 楼主| 发表于 2009-4-15 10:07:00 | 显示全部楼层
我是想实现这样的功能

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2009-4-15 10:38:00 | 显示全部楼层
自动判断文字样式是否缺少字体并进行替换.
发表于 2009-4-16 13:14:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2009-4-16 13:23:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2009-4-16 13:24:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2009-4-16 14:09:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2009-4-16 15:25:00 | 显示全部楼层
本帖最后由 作者 于 2009-4-16 15:26:47 编辑

;;;得到所有TextStyle Name

;;;从网上得到
(defun GetAllTextStyleNames (/ names)
   (or Gb:AcO (setq Gb:AcO (vlax-get-acad-object)))
   (or Gb:AcD (setq Gb:AcD (vla-get-ActiveDocument Gb:AcO)))
   (vlax-for Sty (vla-get-TextStyles Gb:AcD)
      (setq names (cons (vla-get-Name Sty) names))
   )
   names
)


;;判断一个style的font是否找得到

;;对windos字体不完善
(defun IsTextStyleFontOk (sty / f3 f4 )
   (and (setq f4 (tblsearch "style"  sty))       
        (or (findfile (setq f3 (cdrassoc 3 f4)))
            (findfile (strcat f3 ".shx"))
     (findfile (strcat "C:\\WINDOWS\\Fonts\\" f3))
     (and (= f3 "SimSun.ttf")
   (findfile "c:/windows/fonts/simsun.ttc")
     )  
        )
        (or (null (setq f4 (cdrassoc 4 f4)))
     (= "" f4)
            (findfile f4)
     (findfile (strcat f4 ".shx"))
        )
   )
)

 楼主| 发表于 2009-4-17 00:48:00 | 显示全部楼层
;将不认识的字体自动替换成,自己定义的字体。
(defun ukword (bit kwd msg def / inp)
  (if (and
 def
 (/= def "")
      )
    (setq msg (strcat "\n" msg "<" def ">:")
   bit (* 2 (fix (/ bit 2)))
    )
    (setq msg (strcat "\n" msg ":"))
  )
  (initget bit kwd)
  (setq inp (getkword msg))
  (if inp
    inp
    def
  )
)
(defun c:gps_txt_rep ( / cn elist en enl nm gps_hzstyle);!!!<-字体样式自动替换 
  (setq ukw (ukword 2 "Y N" "\n缺少字体自动替换成._txt.shx,hztxt.确认修改?[是(Y)/否(N)]" "Y"))
  (if (= "Y" ukw)
    (progn 
      (if (not $gps_hztxt_e) (setq $gps_hztxt_e "_txt.shx"))
  (if (not $gps_hztxt)   (setq $gps_hztxt "hztxt.shx"))
  (setq gps_hzstyle (strcat $gps_hztxt_e "," $gps_hztxt ))
    (setq elist (tblnext "STYLE" T))
    (while (/= elist nil)
      (setq nm (cdr (assoc 2 elist))
            en (cdr (assoc 3 elist))
            cn (cdr (assoc 4 elist))
           enl (strlen en)
      )
      (if (and
             (/= en nil)
             (= cn nil)
             (= (findfile en) nil)
             (= (strcase (substr en (- enl 2))) "SHX")
           )
         (command "_style" nm $gps_hztxt_e "0.0" "0.7" "" "" "" "")
      )
      (if (and
             (/= cn nil)
             (= (findfile cn) nil)
           )
         (command "_style" nm  gps_hzstyle "0.0" "0.7" "" "" "" "")
      )
     (setq elist (tblnext "STYLE"))
   )
    )
  )
 )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-9-25 02:46 , Processed in 0.197393 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表