CXFONTCHK整理バージョン 1.0.0AutoCAD で動作確認済み
フォントファイルが見つからない文字スタイルを一覧表示
すべての文字スタイルを調べ、参照先の 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