【问题标题】:How do I access various true type fonts through gnuplot with png terminal?如何通过带有 png 终端的 gnuplot 访问各种真字体?
【发布时间】:2016-02-28 04:42:47
【问题描述】:

我正在尝试输出一个 arial 大小为 14 字体的 png 图像。我使用的是 mac OS X 10.6,并没有自己构建 GNUPLOT。我从一个名为 High Performance Computing for OS X 的网站获得了 Octave 软件包中的程序。这是我在 gnuplot 中输入的内容:

G N U P L O T
Version 4.2 patchlevel 5 
last modified Mar 2009
System: Darwin 10.0.0

Copyright (C) 1986 - 1993, 1998, 2004, 2007 - 2009
Thomas Williams, Colin Kelley and many others

Type `help` to access the on-line reference manual.
The gnuplot FAQ is available from http://www.gnuplot.info/faq/

Send bug reports and suggestions to <http://sourceforge.net/projects/gnuplot>


Terminal type set to 'x11'
gnuplot> set term png font "arial" 14
Terminal type set to 'png'
No TTF font support, using internal non-scalable font
                                   ^
         invalid color spec, must be xRRGGBB

gnuplot> 

任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    以下适用于通过 MacPorts 安装 gnuplot 的 Mac OS X 10.5:

    set terminal png font "/Library/Fonts/Arial.ttf" 14
    

    文档可通过help terminal png(强调我的)获得:

    如果 gnuplot 是在支持 TrueType (.ttf) 或 Adob​​e Type 1 的情况下构建的 (.pfa) 字体,可以使用 'font {}' 选择它们 选项。是字体文件的完整路径名,或者是字体 假定为文件名的第一部分的面部名称 GDFONTPATH 环境变量中列出的目录。那是, 'set term png font "Face"' 将寻找一个名为的字体文件 /Face.ttf 或 /Face.pfa。 TrueType 和 Adobe Type 1 字体是完全可缩放的,并且可以旋转任意角度。 如果没有指定字体,gnuplot 会检查环境变量 GNUPLOT_DEFAULT_GDFONT 查看是否有首选的默认字体。

    更新:我刚刚注意到您的 gnuplot 安装抱怨“不支持 TTF 字体”,因此上述内容可能不适合您。为了使真正的字体能够正常工作,您可能必须重新安装 gnuplot。

    【讨论】:

    • 这是这个问题的唯一真正答案,很容易用谷歌搜索。两者都 +1!
    • 这很好用!但不适用于符号。有人对符号有修复吗?例如 {/Symbol a} 给出 alpha?
    • 我的 Arial.tty 不在那里。我不得不寻找它。不过,道具!
    【解决方案2】:

    谢谢! $GDFONTPATH 的信息在 MacOS 上非常有用。

    添加行:

    export GDFONTPATH=/System/Library/Fonts:$GDFONTPATH
    

    到我的 /Users/username/.profile 为我解决了问题。不要忘记获取.profile文件的来源。或者重新启动终端。这样变量就被加载了。

    【讨论】:

    • 我的 Arial.tty 位于“/Library/Fonts/Microsoft/Arial.tty”,但设置它对我有用!
    【解决方案3】:

    取决于终端类型

    (X)Ubuntu LTS GNU/Linux 上,gnuplot 似乎默认在一大堆目录中查找字体。例如,以下行默认使用terminal png

    set terminal png font "texgyrepagella-regular.otf" 12
    

    即使我没有设置环境变量并且包管理器之前已经在/usr/share/texmf/fonts/opentype/public/tex-gyre 中安装了这个字体。不错!

    但是,如果我使用更高级的terminal pngcairo,则其名称会指定完全相同的字体;不是它的文件名。更好!

    set terminal pngcairo font "TeX Gyre Pagella, 12"
    

    请注意指定字体大小的语法差异。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-26
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      • 2014-05-14
      相关资源
      最近更新 更多