gpt4 book ai didi

latex - gnuplot pdfcairo 匹配 latex 字体大小

转载 作者:行者123 更新时间:2023-12-02 01:00:40 31 4
gpt4 key购买 nike

我使用 gnuplot 5.0 和 pdfcairo 终端绘制了一个 pdf 图,然后使用 latex 将该图插入到 pdf 文件中。但是,我发现 gunplot 中的字体大小与 Latex 中的字体大小不同,尽管我将它们设置为相同。

为了使gnuplot和latex中的字体大小一致,我必须将gnuplot中的fontscale设置为0.75,如下代码所示。

gnuplot 代码:以蓝色(Helvetica,大小 12,字体比例 0.75)绘制一个“A”。

set terminal pdfcairo font 'Helvetica,12' size 1cm,1cm fontscale 0.75
set output 'test0.pdf'
set xrange [-1:1]
set yrange [-1:1]
unset xtics
unset ytics
unset border
set label 'A' at 0,0 textcolor 'blue'
p 1/0 notitle

Latex 代码:插入原始尺寸的前一个数字,并在前一个“A”旁边写一个黑色的“A”(Helvetica,尺寸 12)。
\documentclass[12pt]{standalone}
\usepackage{tikz}
\usepackage{helvet}
\usepackage{graphicx}
\begin{document}
\begin{tikzpicture}
\node at (0,0) {\includegraphics{test0.pdf}};
\node at (0.3, -0.025) {\textsf{A}};
\end{tikzpicture}
\end{document}

You can see the final pdf file here.现在我们可以看到这两个 'A' 在 gnuplot 设置 'fontscale 0.75' 下的大小完全相同。我不明白为什么在 gnuplot 中应该使用“fontscale 0.75”,而不是“fontscale 1”?
这是开罗的问题吗?有没有什么优雅的方法来处理这个字体大小问题?

简短回答:gnuplot 使用 72dpi,而 cairo 使用 96dpi。 (96/72=4/3)

注意:出于同样的原因,如果使用 pngcairo,还应该使用 'fontscale 0.75' 来获得正确的字体大小。

替代解决方案:cairolatex。 @用户8153

最佳答案

我认为这可能是由于开罗渲染。为了设置字体大小,Gnuplot 调用函数 pango_font_description_set_size使用提供的尺寸,即在您的情况下为 12。然而,这然后被翻译成开罗单位:

the size of the font in points, scaled by PANGO_SCALE. (That is, a size value of 10 * PANGO_SCALE is a 10 point font. The conversion factor between points and device units depends on system configuration and the output device. For screen display, a logical DPI of 96 is common, in which case a 10 point font corresponds to a 10 * (96 / 72) = 13.3 pixel font.



此外,来自函数的文档 pango_cairo_font_map_set_resolution :
/**
* pango_cairo_font_map_set_resolution:
* @fontmap: a #PangoCairoFontMap
* @dpi: the resolution in "dots per inch". (Physical inches aren't actually
* involved; the terminology is conventional.)
*
* Sets the resolution for the fontmap. This is a scale factor between
* points specified in a #PangoFontDescription and Cairo units. The
* default value is 96, meaning that a 10 point font will be 13
* units high. (10 * 96. / 72. = 13.3).
*
* Since: 1.10
**/

所以总而言之,似乎提供的大小是为了渲染的目的乘以 96/72 = 4/3这有效地产生了大小为 16 而不是 12 的字体。缩放因子 0.75你应用的然后会恢复这个。

关于latex - gnuplot pdfcairo 匹配 latex 字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50748415/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com