You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CLISP使用vecto库触发ZPB-TTF字体魔数错误,如何正确指定字体?

问题根因

ZPB-TTF::BAD-MAGIC错误说明get-font函数读取的目标文件不是合法的TTF格式字体,触发原因通常为三类:路径拼写错误、文件不存在、目标文件本身损坏/并非TTF格式。

正确指定字体文件的方法

  • 优先使用绝对路径指定字体文件,避免CLISP运行时工作目录不匹配导致的读取失败,不同系统的参考路径如下:
    • Windows系统默认Times New Roman字体:(get-font "C:/Windows/Fonts/times.ttf")
    • Linux系统安装msttcorefonts包后路径:(get-font "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf")
    • macOS系统默认路径:(get-font "/Library/Fonts/Times New Roman.ttf")
  • 若要使用相对路径,先在CLISP中执行(pwd)命令查看当前工作目录,将验证过的合法TTF字体文件放到该目录下,再直接传入文件名即可
  • 验证方法:可先单独执行(get-font "你的字体路径"),如果没有抛出BAD-MAGIC错误,说明路径和文件都符合要求

修改后的代码示例

(defun radiant-lambda (file)
  (with-canvas (:width 80 :height 80) 
    (let ((font (get-font "替换为你自己的字体绝对路径"))
          (step (/ pi 7)))
      (set-font font 40)
      (translate 45 45)
      (draw-centered-string 0 -10 #(#x3BB))
      (set-rgb-stroke 1 0 0)
      (centered-circle-path 0 0 35)
      (stroke)
      (set-rgba-stroke 0 0 1.0 0.5)
      (set-line-width 4)
      (dotimes (i 14)
        (with-graphics-state 
          (rotate (* i step))
          (move-to 30 0)
          (line-to 40 0)
          (stroke)))
      (save-png file))))

内容的提问来源于stack exchange,提问作者Gayathri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 08:57:05