簡體   English   中英

gnuplot pdfcairo匹配乳膠字體大小

[英]gnuplot pdfcairo matches latex font size

我使用gnuplot 5.0和pdfcairo終端繪制pdf圖,然后使用latex將此圖插入到pdf文件中。 但是,我發現gunplot中的字體大小與latex中的字體大小不同,盡管我將它們設置為相同。

為了使字體大小在gnuplot和latex中保持一致,我必須將gnuplot中的fontscale設置為0.75,如下面的代碼所示。

gnuplot代碼:用藍色繪制'A'(Helvetica,大小12,fontscale 0.75)。

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

膠乳代碼:以原始大小插入上一個數字,並在前一個'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}

你可以在這里看到最終的pdf文件。 現在我們可以看到這兩個'A'在gnuplot設置'fontscale 0.75'下的大小完全相同。 我不明白為什么'fontscale 0.75'應該用在gnuplot中,而不是'fontscale 1'? 這是開羅的問題嗎? 有沒有優雅的方法來處理這個字體大小問題?


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

注意:出於同樣的原因,如果使用pngcairo,還應使用'fontscale 0.75'來獲得正確的字體大小。

替代解決方案:cairolatex。 @ user8153

我認為這可能是由於cairo渲染。 為了設置字體大小,Gnuplot使用提供的大小調用函數pango_font_description_set_size ,即在您的情況下為12。 然而,這被翻譯成cairo單位:

以磅為單位的字體大小,按PANGO_SCALE縮放。 (也就是說,10 * PANGO_SCALE的大小值是10磅字體。點和設備單位之間的轉換因子取決於系統配置和輸出設備。對於屏幕顯示,邏輯DPI為96是常見的,在這種情況下, 10點字體對應於10 *(96/72)= 13.3像素字體。

Moreveor,來自函數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然后將恢復這個。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM