如何使用 png 终端通过 gnuplot 访问各种 true type 字体?

发布于 2024-08-04 06:31:33 字数 838 浏览 2 评论 0原文

我正在尝试输出 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> 

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

I am trying to output a png image with an arial size 14 font. I use mac OS X 10.6 and did not build GNUPLOT myself. I got the program from a website called High Performance Computing for OS X in the package for Octave. Here is what I entered in 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> 

Any help would be greatly appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

慢慢从新开始 2024-08-11 06:31:33

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

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

该文档可通过 helpterminal 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 字体支持”,因此上述内容可能不适合您。为了让 true type 字体完全正常工作,您可能必须重新安装 gnuplot。

The following works on Mac OS X 10.5 with gnuplot installed via MacPorts:

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

The documentation is available via help terminal png (emphasis mine):

If gnuplot was built with support for TrueType (.ttf) or Adobe Type 1
(
.pfa) fonts, they may be selected using the 'font {}'
option. is either the full pathname to the font file, or a font
face name that is assumed to be the first part of a filename in one of the
directories listed in the GDFONTPATH environmental variable
. That is,
'set term png font "Face"' will look for a font file named either
/Face.ttf or /Face.pfa. Both TrueType and
Adobe Type 1 fonts are fully scalable and may be rotated through any angle.
If no font is specified, gnuplot checks the environmental variable
GNUPLOT_DEFAULT_GDFONT to see if there is a preferred default font.

Update: I just noticed that your gnuplot installation complains about "No TTF font support", so the above may not work for you. In order to get true type fonts to work at all, you probably have to re-install gnuplot.

番薯 2024-08-11 06:31:33

谢谢! $GDFONTPATH 的信息对于 MacOS 确实很有帮助。

添加行:

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

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

Thanks! The info with $GDFONTPATH was really helpful for on MacOS.

Adding the line:

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

to my /Users/username/.profile solved the Problem for me. Don't forget to source the .profilefile. Or to restart the Terminal. So that the variable gets loaded.

抱猫软卧 2024-08-11 06:31:33

这取决于终端类型

(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"

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

It depends on the terminal type

On (X)Ubuntu LTS GNU/Linux, gnuplot seems to look up fonts in a whole host of directories by default. For example, the following line worked by default with the terminal png:

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

Even though I had no environment variables set and the package manager had previously installed this font in /usr/share/texmf/fonts/opentype/public/tex-gyre. Nice!

However, if I employ the more advanced terminal pngcairo, the very same font is specified by its name; not its filename. Even nicer!

set terminal pngcairo font "TeX Gyre Pagella, 12"

Please, also notice the syntactic difference in specifying the font size.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文