Ghostscript - Can't find (or can't open) font file - ghostscript

I try to create a image from a pdf in php (imagemagic). On the image text is missing.
To debug this problem i went to the CLI and use the folowing command:
gs -sDevice=png16m -sOutputFile="test.png" test.pdf
Now I get:
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Querying operating system for font files...
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Loading ArialMT font from /usr/share/fonts/truetype/msttcorefonts/Arial.ttf... 4395876 2792289 6087360 4693359 4 done.
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/Arial-BoldMT.
Can't find (or can't open) font file Arial-BoldMT.
Loading Arial-BoldMT font from /usr/share/fonts/truetype/msttcorefonts/arialbd.ttf... 4395876 2792684 6897144 5444610 4 done.
Can't find CID font "Arial".
Attempting to substitute CID font /Adobe-Identity for /Arial, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. attempting to use fallback CIDFont.See doc/Use.htm#CIDFontSubstitution.
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font Adobe-Identity ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
Warning: falling back to Identity ordering
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font CIDFallBack ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
**** Error: can't process embedded font stream,
attempting to load the font using its name.
Output may be incorrect.
Can't find CID font "Arial".
Attempting to substitute CID font /Adobe-Identity for /Arial, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. attempting to use fallback CIDFont.See doc/Use.htm#CIDFontSubstitution.
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font Adobe-Identity ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
Warning: falling back to Identity ordering
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font CIDFallBack ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
**** Error reading a content stream. The page may be incomplete.
Output may be incorrect.
**** Error: File did not complete the page properly and may be damaged.
Output may be incorrect.
%%BoundingBox: 85 470 562 757
%%HiResBoundingBox: 85.491068 470.681986 561.761983 756.827977
I found a lot of topics and tried a lot but I can't fix the problem. I think the problem is the CID font but I'm not sure.
Can someone give me some tips how I can solve this problem?
Server: Debian GNU/Linux 9 (stretch)
Ghostscript: GPL Ghostscript 9.26 (2018-11-20)

You appear to have several problems. It's hard to say for certain because you haven't supplied the PDF file to inspect.
Firstly your PDF file appears to be trying to use a CIDFont called 'Arial' which it does not embed in the PDF file. It also doesn't contain the regular fonts ArialMT and Arial-BoldMT but you appear to have substitute fonts available either from fontmap.GS or via fontconfig (if your build includes that) for those.
Failing to embed fonts is poor practice, failing to embed CIDFonts is specifically frowned upon in the PDF specification.
Ghostscript tries its fallback approaches to define a substitute CIDFont for the missing Arial CIDFont. Firstly it tries the fallback font Adobe-Identity (the name is derived from the CIDSystemInfo) but that CIDFont is also not available. So it drops back to the next attempt, which is to use DroidSansFallback.
However that fails because, in order to produce a satisfactory substitute, Ghostscript needs a CMap, in order to build a CIDDecoding resource. It seems that your installation is missing the relevant CMap.
It looks like your distribution has packaged Ghostscript so that it does not use a ROM file system. Instead it 'looks like' all the files are installed on disk under /usr/share/ghostscript/9.26
You should look for the directory /usr/share/ghostscript/9.26/Resource/CMap and see if there is a file there called Identity-UTF16-H.
I'm going to guess there isn't, and this will be due to a decision made by your package maintainer. I have no idea why they would choose not to include that file but without it (and the other files in that folder) the CIDFont support will be hampered.
If it's not present I'd suggest you take it up with the Debian package maintainer. As Ghostscript is licensed under the AGPL the source code (including all the support files) is of course available from the Ghostscript Git repository and the Ghostscript web site. You could pick up the missing file(s) from there.
Note that the current version is 9.27 and I would recommend upgrading.

Related

Ghostscript PDF fonts becomes boxes in Adobe Illustrator where as its output is fine when opened in Adobe Acrobat

I need to convert the PDF of RGB color space to Grayscale using commandline tool supporting for Windows and Linux.
When i used Ghostscript the conversion is happening but when the output is opened in illustrator the fonts were shown as boxes.
Is there any solution option available in Ghostscript to overcome this font issue.
Is there any other commandline tool available for this conversion.
The font encoding is always built in is there any ways available to change it as ANSI encoding.Screenshot of font issue on illustrator VS the working scenario on acrobat
Pictures of the problem really don't help. You need to provide the following:
The version of Ghostscript you are using, and the platform (Linux, Windows etc), the word size of the version of Ghostscript and where you sourced this version of Ghostscript from (official Ghostscript download page, package, self-built binary).
An example file to reproduce the problem
The exact command line you used to reproduce the problem, and any supporting files required.
I suspect that your problem is that the original PDF file does not include the fonts that it uses, and that you have left SubsetFonts as true, and have left the AlwaysEmbed and NeverEmbed arrays untouched. This will mean that the new PDF file also does not include the fonts, which means that any PDF consumer must use a substitute font. The 'boxes' you refer to are /.notdef glyphs which are used when the font does not contain the glyph being requested.
Having the Encoding 'built-in' doesn't help with anything at all, it's the presence or absence of the fonts which matters. No, you can't change the encoding to 'ANSI', if you do that (assuming it isn't already WinAnsiEncoding) you'll see very similar problems to the ones you are complaining of here. You would also need to change the text character codes in the PDF file to be able to change the Encoding.
You could also raise this as a bug at https://bugs.ghostscript.com, where you will also have to supply an example file (as simple as possible) and all the other information listed above.

Why are my TrueType hints ignored?

I have integrated some hints (a prep handler to update the cvt and glyph instructions (simple MIAPs to copy the cvt values to specific points) into a custom TTF font.
I changed the fonts via Python fontTools.ttx
The font and the hints work perfectly when I test the font in TrueTypeViewerQt.
The font (and the hints) work also in PIL.
I can also see the hints in FontForge (for prep and the glyphs), but debugging them just shows "".
I also get this message in the console window:
SplineFontPieceMeal() going unhinted...
When I now use the font from a PDF file (written via reportlab), the font is used, but my hints seem to be ignored by Acrobat Reader, Ghostscript, mudraw, Chrome Web Browser (integrated PDF view), or an own application based on PDFium.
Then font exported from the PDF (via mutool) still contains the hints which work in TrueTypeViewerQt.
PDF: https://www.dropbox.com/s/qn3iooazsq1z2w5/d85.pdf?dl=0
Font: https://www.dropbox.com/s/p6qwug9h6vcgps0/testbar.ttf?dl=0
Any ideas?

Opentype font not being used in Silverlight Windows Phone 7 app on deploy

Is there a way to use an OpenType font on Windows Phone 7 Silverlight application? I want to use Lobster which is only available AFAIK in OpenType format. It renders in Blend but not when I deploy to the emulator.
I have included the .otf file in my project and set the Properties to 'Content' and 'Copy If Newer'.
This website found a solution for .ttf fonts, but the technique specified does not work for OpenType. Is OpenType not supported by Windows Phone? I find this hard to believe given that MS part invented the format!
Windows Phone requires your fonts to be TrueType (.ttf). OpenType (.otf) is not supported.
There may be some confusion on the term "OpenType". OpenType is a broad description of the format which actually includes 2 "flavors" for describing the font's outlines: TrueType and CFF (A form of Adobe PostScript).
A font with a .otf extension is most definitely an OpenType font, and usually means that it includes CFF outlines.
But a TrueType font is, in most cases, generally considered an OpenType font as well, since the OpenType format is actually a superset of both TrueType and CFF flavors.
Regarding Lobster in particular: as a test, I added that font to my Google Webfonts collection, and clicked "Download Collection". The resulting file was a .ttf, and as such, should be usable in Windows Phone as Den Delimarsky's answer points out. How are you getting a .otf version of this file? And is it truly a CFF file, or just a TrueType file with a .otf extension?
Also note that you may be able to obtain the TrueType/.TTF directly from the Google Font Directory though doing so through a browser currently seems to be a bit wonky.
you need to add it to the project, set build action to content and enter a uri that links to it in the FontFamily property with the hash tag:
Example of FontFamily:
FontFamily="fonts/Lobster.ttf#Lobster"

Cannot extract the embedded font - Code Igniter and dompdf

Following the instruction in this link ( https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf ), I always encounter an error when opening the pdf file created. The error message is:"Cannot extract embedded font 'TradeGothicLT-CondEighteen'.Some characters may not display or print correctly. " and when i click OK, the pdf displays black background and when i start highlighting the body, it captures the text but text are in black font-color. what should I do to get rid of this error?
There may be something wrong with your font cache, located at dompdf/lib/fonts/dompdf_font_family_cache.php (though the exact file name depends on your release and whether you have loaded fonts). This file tells dompdf what fonts are available for use in the PDF. If this file references a font that isn't actually available you can run into major issues on viewing. You may need to re-load your font files. Take a look at the Unicode how-to for an overview of using embedded fonts. This document hasn't been updated to reflect changes implemented in dompdf 0.6.0 beta 3, but the information is still pertinent.

On iOS, can I access the system-provided font's TTF file

I'm trying out FTGLES to dynamically display text in arbitrary fonts on OpenGL-ES on iOS (cf. my SO question here). That library seems to require direct access to the TTF file to use the font. Using kosher methods, can one directly access -- by path -- the system font files on iOS? I've RTFM'd and couldn't find anything.
Barring that, does anyone know if it is Apple-approved to copy the system fonts into your app (before submission).
My solution was inspired by skia.
Though cannot access system built-in font files directly, we still have an indirect way:
Create a CGFont with your wanted font name, all contents of SFNT table of this CGFont can be accessed by simply calling CGFontCopyTableTags() and CGFontCopyTableForTag().
A ttf/otf font data can then be constructed by using these tables, save the new created font to disk, you can use it in FTGL ES later.
No, you can't access the system installed TTF files on iOS devices. So you'll have to embed the typefaces you'd like to use.
Disclaimer: I'm not a lawyer, and the acceptability of using Apple supplied system fonts in an iOS app is a legal question about interpreting software licenses, so you may want to seek professional advice.
You wish to embed an Apple supplied font in your app. The definition of "embed" is a bit nebulous, so adding the font to an iOS app may or may not fit within the copyright holder's definition of "embed". Some type houses define "embed" to mean just viewing predetermined content in the included font; other mean viewing and editing content in that font. Displaying content that changes during the running of your app is somewhere between these two cases.
According to the Mac OS X Lion 10.7.2 ELUA:
F. Fonts. Subject to the terms and conditions of this License, you may
use the fonts included with the Apple Software to display and print
content while running the Apple Software; however, you may only embed
fonts in content if that is permitted by the embedding restrictions
accompanying the font in question. These embedding restrictions can be
found in the Font Book/Preview/Show Font Info panel.
If using the fonts in an iOS app is indeed "embedding", you just need to check the particular fonts you wish to use in Font Book.
In this situation I would find a font or set of fonts where I had explicit permission to include the fonts in the iOS app. I would start by shopping around the various type houses for a licensing scheme that explicitly allowed this use. This may get expensive, so another tack would be to seek out open source typefaces with a license that would allow this use. Or, for a very limited set of characters (e.g. only numbers) I would even consider drawing my own typeface.
No. Your app cannot access files outside the sandbox of your app. Period (well, unless it's jailbroken ;). But you can indeed bundle the font file. Now, I see no reason why Apple would reject your app, as it's using a file already available on the device, and you're just including your local file to it. In terms of copyright, Apple already has that permission to use it on their device, so your inclusion of it should be no problem.
I say should because I haven't needed this capability and haven't tested it with a submission of my own, but based on legal instinct and font copyright issues I've seen in the past, I'd expect that it wouldn't be a problem.

Resources