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