This may be not a bug of gnuplot, but of cairo library.
Pdfcairo terminal of git version, 5.4.1, and so on, may make incorrect pdf file with cairo library 1.17.
We see error messages for such pdf file at viewing by xpdf command.
Attachment files:
t-cairo16-x.pdf: made by cairo-1.16.0 (correct)
t-cairo17-x.pdf: make by cairo-1.17.4 (incorrect)
These files are made by
set term pdfcairo
set out 't-cairoXX-x.pdf'
unset xtics
unset ytics
plot x
If we use "plot x not", i.e. no string in the file, the problem does not occur.
OS: FreeBSD 13, Gnuplot: gnuplot-5.4.1
Both files look identical when I view them here.
The only difference I can detect is that the cairo16 file contains an embedded font,
while the cairo17 file instead contains a reference to font DejaVuSans.
It is possible that your xpdf viewer is the problem, but my best guess is that the problem is that the DejaVuSans font is not found. Perhaps it is not installed or perhaps the search path used by xpdf does not match the font installation directory.
I suggest trying the test again using an explicit font that you know is present on your system.
Thanks for your sooner reply. I understand. I will try.
Above two files have few differences, FontName, Producer name (cairo 1.XX), and CreationDate only. FontName are:
t-cairo16-x.pdf: /FontName /FJLHRY+DejaVuSans
t-cairo17-x.pdf: /FontName /<86:0)+DejaVuSans
I think the font name of t-cairo17-x.pdf may be illegal, because I edit the font name from "/<86:0)" to "/FJLHRY" (attached file t-cairo17-x2.pdf) then xpdf program does not show any error messages for it, and pdffonts program says the font "FJLHRY+DejaVuSans" is embedded.
So, I think the problem may be that cairo-1.17 generates incorrect FontName prefix ("<86:0)").
Good detective work.
Nevertheless the pdf viewers I have tried here, including xpdf version 4.03, do not complain about that font name prefix. The file displays correctly with no error messages. Maybe you have a different version of xpdf?
I am using old, and light weight xpdf version 3.04 on FreeBSD. The pdffonts program included in xpdf-3.04 does not display the font name for t-cairo17-x.pdf, it show the same error messages as xpdf:
and I find the font name by less command directory.
By above error messages, xpdf does not interpret the font name "/<86:0)+DejaVuSans" correctly, and it tries to read in hex mode and fails.
According to the following, the prefix part of the name of embedded font should be 6 uppercase letters.
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
(p258 9.6.4 Font subsets)
So, the prefix "/<86:0)" of the font name in t-cairo17-x.pdf is incorrect. It may be the problem of cairo-1.17.4.
I find this is a bug of cairo-1.17.4 by using ldiv() function for negative value. The problem is already fixed in git version of cairo about 6 month ago:
https://gitlab.freedesktop.org/cairo/cairo/-/commit/a3b69a0215fdface0fd5730872a4b3242d979dca
cairo-1.17.4: "<86:0)" = ('A'-5, 'A'-9, 'A'-7, 'A'-17, 'A'-24)
cairo-1.16.0: "FJLHRY" = ('A'+5, 'A'+9, 'A'+7, 'A'+17, 'A'+24)
Until release the fixed version of cairo, I will use cairo-1.16.0 or modify it of cairo-1.17.4. Thanks.