CXFONTCHK清理版本 1.0.0已在 AutoCAD 中测试
列出字体文件缺失的文字样式
检查每个文字样式,列出指向的 SHX 字体文件找不到的那些。这正是文字显示成问号的常见原因。
怎么用
- 输入 CXFONTCHK。
- 查看样式和缺失文件的清单。
- 用 CXFONTSUB 把它们改成你有的字体。
需要知道
- 这里不检查 TrueType 字体。
在 AutoCAD 中加载
- 把文件保存在任意位置。
- 输入 APPLOAD,选择文件,点“加载”。
- 输入命令名:CXFONTCHK。
想每次启动都可用,在同一个对话框里加入“启动组”,或用可选的加载器一次加载整个文件夹。 关于可选的加载器
已在 AutoCAD(完整版)中测试。其他能运行 AutoLISP 的软件也许可用,但未经测试。
代码
纯文本,没有任何隐藏内容。复制后存成名为 cxfontchk.lsp 的文件,或直接下载。
;;; ============================================================================
;;; CXFONTCHK - List text styles whose font file is missing
;;; Version 1.0.0
;;; CADXChange LISP tools - https://cadxchange.net/resources/lisp/cxfontchk
;;; Tested in: AutoCAD (full version). Other programs that run AutoLISP may work but are not tested.
;;; Copyright (c) CADXChange. Free for personal and commercial use; do not resell or
;;; republish it as a collection. Terms: https://cadxchange.net/legal/lisp-terms
;;; ============================================================================
;; The text styles whose font file cannot be found by the program: ((style . file) ...).
;; Only .shx fonts are checked; TrueType fonts and shape files are skipped.
(defun cx:fontchk-run ( / r out file)
(setq r (tblnext "STYLE" T))
(while r
(setq file (cx:dxf 3 r))
(if (and (= (logand 1 (cx:dxf 70 r)) 0)
file
(wcmatch (strcase file) "*.SHX")
(not (findfile file)))
(setq out (cons (cons (cx:dxf 2 r) file) out)))
(setq r (tblnext "STYLE")))
(reverse out))
(defun c:CXFONTCHK ( / *error* cx:sv rows)
(setq *error* cx:err)
(setq rows (cx:fontchk-run))
(if rows
(progn
(princ "\nText styles with a missing font file:")
(foreach r rows (princ (strcat "\n " (car r) " " (cdr r))))
(princ "\nCXFONTSUB can replace a missing font by another one."))
(princ "\nEvery shx font file used by a text style was found."))
(princ))
;;; ---- Shared helpers (used by the command above; identical in every CADXChange tool) ----
(defun cx:dxf (code ed)
(cdr (assoc code ed)))
;; Close the undo step and put the system variables back.
(defun cx:end ()
(foreach v cx:sv (setvar (car v) (cdr v)))
(command "_.UNDO" "_End")
(setq cx:sv nil)
(princ))
;; Error handler: restores everything, stays quiet on Esc.
(defun cx:err (msg)
(if (> (getvar "CMDACTIVE") 0) (command))
(cx:end)
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")))
(princ (strcat "\nError: " msg)))
(princ))
(princ "\nCXFONTCHK loaded. Type CXFONTCHK to start.")
(princ)
版本记录
版本 1.0.0 · 2026年10月27日
首个版本。
要对很多张图一起做?
TextSync 可以对整个文件夹的图纸一次完成这类工作。
TextSync