PostScript - Generate text using uninstalled fonts - text

I want to generate text using postscript and some font file. I can convert the font to whatever needed font type necessary. The catch is, I can't install the font on the computer - there are certain limitations on the computer that would be way to long to explain, just know that the end result means that I can't install the font.
I am aware of the fact that t42 fonts are generated as a glorified eps file, however, I am not looking to simply append the font to the file - I have more than 1 font I am doing this to.
Are there hacky work arounds for the end goal?

Related

How to convert existing woff / ttf / otf files to a font file supported by report lab?

Understanding The Problem
I've run into a problem. I have a need to convert an svg file with multiple custom fonts into a png. This is supported by svglib. I actually was able to convert one of the fonts into a proper format for svglib to properly transform an svg to a png with the font. The problem is, I don't necessarily know what fonts are going to be "good" fonts and what fonts are going to be "bad" fonts (otf fonts that load for some reason and otf fonts that don't load for some reason), so ideally, I'd have a function in Python 3.x.x to convert all fonts to the same workable format. According to this google group on the subject, its a complicated beast (as of 2013). However, I could load any font (ttf / otf / woff) into this site and use it to get python to pump out a png file, just by having the font in the same directory as the svg file with the same name as the font file as the font family, with the proper results, but I couldn't get the converted font using Python's fonttools to work with the below provided code:
Code
from reportlab.graphics import renderPM
from svglib.svglib import svg2rlg
from fontTools import ttLib
from io import BytesIO
from PIL import Image
# Here I tried to take the font (which I had initially as a woff) and convert it to a ttf.
#woff2.decompress("./my_font.woff", "./my_font.ttf")
# Here I tried to take the original otf and convert it to a ttf
# font = ttLib.TTFont("my_font.otf")
# font.flavor = None
# font.save("my_font.ttf")
buff = BytesIO()
drawing = svg2rlg("./test.svg")
renderPM.drawToFile(drawing, buff, fmt="PNG")
img = Image.open(buff)
# l, w = image.size
# img = img.resize()
new_buff = BytesIO()
img.save("new_test.png", dpi=(600, 600))
Font For Minimal Reproduceable Example
I can upload a demo working font and the same font that is not working with the given format, but before I did that, I wanted to make sure that was part of the SO community guidelines to distribute potentially copyrighted (and other items of this nature with different licenses and EULAs) works - maybe a comment can confirm or deny this (I don't have the EULA, so I will probably find a link to a font that will be reproduceable). I think easiest is for me to find a link to a font online that I can reproduce the problem with, so I will get to looking and update the post with a link, but I mean... come on! I can't be the only person trying to solve this problem?!
Working font example
A non working font example - I could be wrong, but I think if you convert from a ttf to a woff back to a ttf using fonttools that you will be able to reproduce this issue. I'm still looking for an online example.
Problem Statement
So to make sure the problem statement is well articulated, the goal is to: Take any otf / ttf / or woff (even for simplicity sake - just a woff) file and convert it to a ttf file via Python that is supported by reportlab (which would mean it would be supported by svglib).
As unfortunate as it is, I couldn't supply a font to help with the "minimal, reproducible example clause", because finding a font online to replicate this with is very challenging (maybe I wasn't searching in the right place). However, I could convert the font in fontforge and opted for that. I could use the scripting portion of fontforge to accomplish this, so I can use this to convert fonts in bulk, and despite being GPL, after reaching out to the community from fontforge, they said:
We do not consider fonts created with FontForge or scripts run in FontForge to be derivative works of FontForge, which is standard practice for content creation tools and script interpreters. The FontForge license thus has no implication upon the ownership of those fonts and scripts or the owner's right to use and to distribute them. FontForge depends heavily upon a number of GPL libraries at the moment, and that is unlikely to change.
So for my purposes, I am content with this solution.

Eps to svg, special character not converted

I'm trying to convert an eps (created with Mathtype) to svg format.
I don't have any problems with math characteres, but I'm unable to get any special characters (aka àâä...)
I have tried on unix and windows, and none of those works.
The font used is Arial, and is installed properly(Default on Windows, manually added in fonts folder in unix)
I have oppened the Arial font in windows font manager and the non working character are in.
They just aren't converted.
Actually, to convert I use Inkscape (with ghostscript) like this :
inkscape -z -f in.eps -l out.svg
Thanks in advance,
Edit :
Added in.eps file
https://pastebin.com/vBtUVy69
The fact that you have installed Arial on your Windows box has little to do with the problem.
Does the EPS file include the embedded Arial font ? If not then you are dependent on font substitution. You should probably post a sample EPS file so that we can look at it.
My guess is that the Arial font is not embedded, so Ghostscript substittues Helvetica, and the Helvetica font doesn't have those glyphs, or they are not encoded at the character codes which the EPS file thinks they are.
[EDIT]
The EPS comments say DocumentNeededFonts: Arial-BoldMT", so the EPS does not include the font and you get font substitution.
I can't tell you immediately why the SVG says Arial. I can guess, but in the absence of a complete description as to how you are producing the SVG I can't (obviously) be sure.
Now... if the conversion path uses Ghostscript's pdfwrite device to create a PDF file from the EPS, and that PDF file is then somehow converted to Inkscape's internal format (or directly to SVG using something other than Ghostscript) then what is happening is that Ghostscript is substituting Helvetica for the missing Arial-BoldMT and when it produces the PDF file it embeds the Helvetica font, but calls it Arial-BoldMT (or whatever). That's a consequence of the font substitution, the font that gets substituted gets renamed to the expected name.
I think you can avoid that by setting -dEmbedAllFonts to false, though I haven't tested it. Even if you do, all that happens is that the PDF file then doesn't have the font, just the same as the EPS file. So the SVG creation will (presumably) have to use a substitute font instead. All you do is shove the problem further down.
The correct answer to this is 'always embed fonts'.
You can also make the Arial-BoldMT font available to Ghostscript by editing its fontmap.GS file in ghostpdl/Resource/Init for builds where the resources are not built into a ROM file system. For builds which do use a ROM file system (eg Windows) you must pick up a copy of the Resources (from the Ghostscript Git repository), modify the fontmap.GS file and then tell Ghostscript to use the modified resources by pointing to it with the -I switch.
This is still a hack, because its a TrueType font being used as a replacement for a PostScript font, so there's a certain amount of guesswork going on inside Ghostscript, but it usually works well enough, YMMV.

gnuplot gif not scalable with ttf font

After installing libgd on RedHat Linux, I found the path to .ttf fonts and used the full pathname to a DejaVu .ttf font (in 'set terminal gif font...") to create a .gif file from gnuplot. It looks good in a Firefox window, but when I change the size, it looks bad, as though the font is not scalable.
I am using the default binaries. Do I need to recompile gnuplot with different settings to make it scalable? I get no errors or msgs when the image is created from gnuplot (i.e. it finds and uses the .ttf file; I know because I tried several fonts and the image responded accordingly, with .pfa fonts also).
The gnuplot documentation says that TrueType fonts are fully scalable. Maybe I don't understand what scalable means. I had a similar problem with SUN OS, and my solution was to create a postscript (.eps) file from gnuplot and then convert it to .gif, and then it was scalable, but I don't have such a conversion utility on Linux (yet), and it seems like an unnecessary step.
I don't have the actual code/output in front of me, but I can add some if it would help. Also, I can't find any arial.ttf fonts on the system. Maybe that is a clue to the problem.
I heard good things about pngcairo (to avoid using gd), but 'set terminal' does not list it as an image type.
This is not a definitive answer, but it allows to show me a picture of the situation on my machine.
This plot was generated as gif using gnuplot 4.6p5 and Suse Linux 13.2.
The upper plot shows labels written in DejaVu, left using the full path to the TTF file, right using the name of the font. (DejaVu is an installed font here.)
The lower plot shows the same, the font is from the game Minecraft (i.e. very pixelated). I do not get any error message about missing fonts or similar, but gnuplot uses its default font here, but not what I want. More interesting: When I do not specify the font, I get Liberation Serif...
However, it seems my system ONLY uses fonts, regardless if referenced by name or path, when the font is correctly installed. Nevertheless, also the default font is smooth and scalable. (the gnuplot help says, gd has some not scalable build-in fonts, which may be used in your plot)

What is default fallback font of FoxIt Reader on linux

I'm making a PDF and I don't want to embed fonts inside it.
When I used Tahoma Foxit Reader substituted it for some default font on linux.
What is this font?
What font should I use so the Foxit Reader will not have to substitute font?
Installing fonts is not an option since the Client should be able to view this PDF on linux without having to install some fonts and stuff. Can't embed whole fonts since the PDF grows from 100KB to 1000KB then, can't also embed subset of font because used component doesn't allow it.
I want to know this font since I use EASTERN_EUROPEAN charset for special chars in PDF and when the font is substituted it falls back to some default charset and the special chars are trash. So I guess if I set the font to default fallback one + my charset, it should be ok.
Please someone tell me the default font that is used in Foxit Reader.
Thanks

pdftops eps font issue

I'm creating a pdf with Apache FOP in Linux
then I need to convert the pdf it into an eps.
I'm trying lot of ways, the only one that seems works is the pdftops.
But,
when I convert it into Linux in command line
pdftops file.pdf -eps file.eps
This command creates me the eps
but when I try to open it in Adobe Illustrator in Windows XP
It returns me the error
EAAFD+HelveticaNeueLTStd-MdCnO_99-Identify-H;
Font not found on the system; missing font has been substituted.
But
1: the fonts han not been substituted
2: the eps do not show words inside it is all blank instead of the images
I'm sure that in Windows XP I have all the fonts
becouse if I convert the pdf to an eps inside the Adobe Illustrator
all works fine and Adobe Illustrator do not show me the fonts issue.
Can you help me?
What I'm doing wrong?
If something is not working as intended, then that's a bug clear and simple: it needs to be debugged and fixed. Please could you file a bug-report at:
launchpad.net/ubuntu/+source/poppler/+filebug
along with a copy of the PDF file that is being generated, and the exact command that is being used for the conversion (particularly whether it is pdf2ps (part of GhostScript), or pdfteps (part of Poppler/Xpdf and found in the poppler-utils package).
(Note that this question has been asked in three other places, but not yet reported in the bug-tracker where it can be explored, pointed to the right people and hopefully fixed).
Without knowing much about your setup, it looks like you're asking FOP to draw your text using the Helvetica Neue font, which is not part of the standard set of PDF fonts (note that Helvetica is, but not Helvetica Neue).
It would seem to me that your two options are to either force FOP to use Helvetica instead of Helvetica Neue, or force it to embed Helvetica Neue into the PDF (pdf2ps should automatically embed it into the result EPS file). In the first instance, you shouldn't need embedding at all, while in the second case the file should be embedded.
More info on how FOP handles fonts is also available from the package's documentation—as you can see, Helvetica Neue is not listed here.

Resources