首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在gnuplot中使用自定义unicode字体的斜体和粗体拉丁文和希腊字母来生成(e)ps或pdf

在gnuplot中使用自定义unicode字体的斜体和粗体拉丁文和希腊字母来生成(e)ps或pdf
EN

Stack Overflow用户
提问于 2019-05-28 01:52:03
回答 2查看 0关注 0票数 0

我想创造一个后记或pdf图形,增强符号,斜体或粗体拉丁字符,有时(正常)希腊字符。一般怎么做呢?

Let's say I downloaded CMU Sans Serif, a font that has glyphs for all the strange characters I ever want to use. I converted them to pfa with an online tool and copied the files to the path of working directory.

Expectations

Let's say I'd like to produce the following notation somewhere.


What I tried: original

我创建了一个在utf-8文件(没有bom)中编码的具有以下内容的gnuart脚本。

代码语言:txt
复制
set term postscript eps enhanced "CMUSansSerif" 15 fontfile add 'CMUSansSerif.pfa' fontfile add 'CMUSansSerif-Oblique.pfa' fontfile add 'CMUSansSerif-Bold.pfa'
set encoding utf8
set o "print.eps"

p x t "Label: {/CMUSansSerif-Bold important }{/CMUSansSerif-Oblique note}: ∫⟨α₂ + β²⟩ = äßű"
set o

and executed with the newest gnuplot, version 5.2.6.

What I got

I used a vector graphics editor to open the eps file and relevant part looks like this:


What I also tried

According to Ethan's answer I added adobeglyphnames to the termoptions. It made at least the letters available but other Unicode symbols are still unavailable. The result is:


Question

What went wrong? How could I produce the desired output?

So many possibilities, where things can go wrong: Is the font not suitable for this task? Did I download a wrong version of it? Did the pfa converter do a bad job? Did I include the font files incorrectly? Was there something wrong with the set encoding? Do I use a bad vector graphics editor? Do I have wrong fonts installed and the vector graphics editor tries to use them?

EN

回答 2

Stack Overflow用户

发布于 2019-05-28 10:47:40

恐怕答案是,总的来说,后记是错误的工具。如果您完全有可能使用PDF输出,我建议您这样做。甚至可以通过标准工具(例如pdf2ps)将生成的PDF文件转换为PostScript文件。如果非ascii字符仅限于希腊语和其他相对常见的符号,那么这很可能有效,但我不知道这些标准工具涵盖了多少完整的Unicode表。

If you really need to produce PostScript with additional unicode characters directly from gnuplot, you can find full instructions and sample character encoding tables in the gnuplot distribution files:

代码语言:txt
复制
.../term/PostScript/unicode_maps.README
.../term/PostScript/unicode_big.map
.../term/PostScript/unicode_small.map

I am not familiar with the online tool font conversion you used but probably it failed because it did not have, or at any rate did not use, suitable character encoding tables for the desired conversion.

===

One other thought. There are two ways that a *.pfa font can encode unicode characters that are common enough to have a name assigned by Adobe for use in PostScript. (1) It may use generic names like uni0439 for Unicode code points. (2) It may use Adobe-specific names from the list here: agl-aglfn glyph list

When selecting PostScript output from gnuplot you can tell it which of these two conventions is used by the font you provide. The default is "noadobeglyphnames".

代码语言:txt
复制
set term postscript {no}adobeglyphnames

==

(recipe for using "set term pdfcairo")

Font handling is unfortunately system-specific, so I cannot tell you how to install or configure fonts on all your target machines. I will show you a procedure that works on a linux desktop that uses the fontconfig utilities for system font handling.

  1. Create directory /home/share/fonts/CMUSans
  2. Add this directory to the search list in file /etc/fonts/local.conf
  3. Copy *.ttf files into this directory from the CMU Sans Serif zip archive you link to in your original query. The system fontconfig system tools should now be able to find these fonts. By inspection they self-report as "CMU Sans Serif"
  4. in gnuplot (tested with version 5.2.6) set term pdfcairo font "CMU Sans Serif,15" set output 'enhanced_utf8.pdf' load 'enhanced_utf8.dem'
  5. convert output pdf file to PostScript with the following command pdf2ps enhanced_utf8.pdf enhanced_utf8.ps

Screenshot of the result is shown below

票数 0
EN

Stack Overflow用户

发布于 2019-05-28 11:13:48

似乎CMU Sans Serif不包含您所要求的UTF-8字符。使用字体编辑器检查字体,如Birdfont。尽管网页显示要使用的符号,但字体本身并不包含这些符号。但是,您的浏览器可能会显示符号,但它们只是其他字体的后备表示。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100009060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档