Problem showing a font with license restriction to pdf - pdf

I'm programming to convert a file to pdf on mac, file contains a Chinese text
using a font STFangsong which has license restriction and is not embeddable, I
tried many CMaps to encode it, but it seems the root cause is because pdf viewer(both
mac previewer and acrobat reader) does not recognize the font, as shown in the pdf
file properties, Actual Font Unknown and there is a pop message says can't find or
create the font.
The PDF 32000-1:2008 9.6.6.4 tells a guideline that when encoding truetype font,
the font program should be embedded, though no specific explanation, from my
understanding, embedding can guarantee the pdf is readable everywhere, but I do not
need this since the font is licensed, I just want it can be shown on my computer.
So my question here is does those pdf viewer has limitation on those CJK characters
when embedding is forbidden?
By the way, I used Microsoft word to write a text with the font and save word to
pdf, and it shows the font is embedded subset, does it mean Microsoft have bought the
license?

Related

open a PDF file with automatically replaced Fonts

I am not a programmer, but a normal user who uses Linux.
I want to use Ghostscript to DISPLAY Pdf files, not to CREATE Pdf files. (I have never used Ghostscript until now).
But I want Ghostscript to automatically replace all fonts with other fonts when I open the PDF. No matter if the fonts are embedded or not.
With which fonts should the fonts be replaced?
Answer: I want to create a list of fonts, that I want to be available for replacement.
But which of these fonts on the list should be used?
Answer: The one that best matches the metric of the font to be replaced.
Is it possible to do this somehow?
You can't get Ghostscript to do what you are asking. If a PDF file contains fonts Ghostscript will use those fonts, it will only substitute if it cannot find an embedded font.
The reason for this is simple; the font embedded in the PDF file is the correct font. It's Metrics are correct, and the mapping form character code to the appropriate glyph selector in the font will be correct.
It's also a non-trivial problem to select from a list of fonts the one which 'best matches the metrics of the font to be replaced'. What characteristics should be considered ? How should those be determined ?
When a font is not embedded then Ghostscript will consult its own list of fonts and CIDFonts. Both of these lists can be customised, the documentation is here
But since a substitute font is always going to be a compromise, you can't tell Ghostscript not to use the embedded fonts in a PDF. Well technically you could, by modifying the PDF interpreter, but you say you aren't a programmer, so I doubt you will want to try that.

How to get a font PostScript name?

I'm adding the possibility to embed Truetype fonts in the PDFs generated by my application, but the fonts "Sitka Text" (and it's variants "Sitka Banner", "Sitka small" and etc) and "Meiryo" don't embed.
I believe it is because I'm using the name from the LOGFONT object and to these fonts I should be using the PostScript name.
How can I obtain the Postscript name?
I obtained the 'name' table with GetFontData but the result didn't return any name I could use.
Is there any method on WINAPI that gives me that name?
Edit: I only show to my users fonts with the embedding permissions "Editable" and "Installable" which I obtain with the methods EnumFontFamiliesEx and it's CALLBACK function.
I also checked the NEWTEXTMETRIC ntmFlags that shows all my fonts are NTM_TT_OPENTYPE.
Edit2: By don't embed I mean that the PDF readers don't show my font as embedded (and Acrobat doesn't show any text)
An example of the error.
SOLVED
first, I'd like to thanks Michael Mckeough and mkl, You guys are Awesome and helped me a lot, I checked my original font and it wasn't damaged and I didn't change the font bytes, but then I finally noticed that if you call GetFontData to a (.ttc) file it will crop the ttcf part and no PDF reader will be able to understand what font it was.
Ideally, you would find this in the "name" table of the font. It would be nameId 0x0006, in a form useful for your platform. The format of the name table is a part of the TrueType and OpenType specifications. (You can find a copy here Microsoft Typography OpenType spec Name). There can be an awful lot of entries in the table, or there may be few. In particular, the Postscript name may or may not be present in any given font. You will need to look through the table for nameID of 0x0006, and a form (language, platform, encoding) that you can use. For postscript names, you most likely want them to be English, ASCII encoded, for any platform.
However, it is unlikely that the font is not embedding for this reason! A more common reason is that it is not legal to embed this font. In the Microsoft Typography OpenType Spec OS/2 you will see a field named fsType. This field contains flags indicating under what circumstances this font is licensed to be embedded. No Reputable tool will embed or subset this font is these flags indicate is it not licensed to be embedded.
I see that "Sitka Text" is a MS Windows 10 font, freely distributed by windows. It seems unlikely that It would not be licensed for embedding. Interestingly, the tool I usually use for "looking at" a font quickly (Font Validator, which used to be available from Microsoft Typography, but appears to no longer be) tells me that the OS/2 record is invalid. That it specifies a type of 5, and the spec says that type 4 is the latest. The correct response to a request to embed would require access to the fsType field, and if the record format was unknown, it should "fail safe", and refuse to embed the font.
So this is the most likely reason that the font will not embed for you.

PDF cannot display Chinese fonts in table of contents

I made a PDF file from Latex (using TexMaker).
Acrobat Reader is able to display BOTH the text and the table of contents in Linux.
But Acrobat Reader is unable to display the table of contents in Windows XP (the Chinese characters came out as boxes). However, the text is displayed correctly.
I tried to embed the fonts into the PDF but the various methods are not 100% successful, so I'm not sure if the fonts are embedded correctly or not. Anyway, the table of contents remain unreadable in Windows.
I wonder if it is really an font embedding problem? Or do I need to install these "Adobe Reader X Font Packs":
https://www.adobe.com/support/downloads/detail.jsp?ftpID=4883
My concern is that I'd like my PDF to be readable in Windows, including the table of contents (and preferably without further installations). If this is possible...
I suspect you are talking about "bookmarks" and not saying part of the text in the document is ok and part is not. PDF Bookmarks are part of the UI of the application and are not selected from embedded fonts. Therefore, the system you are running on needs to know how to handle fonts in the language(s) of choice.
See https://forums.adobe.com/thread/1144972?start=0&tstart=0
Embedding the fonts will have no effect on the bookmarks.

Which Chinese font is commonly supported by PDF readers of Chinese people?

I am generating PDF files which contain English and Chinese characters (using the Ruby Prawn library). I don't want to embed a Chinese font file in the generated PDF files, because these files need to stay small. So I'm wondering if I could just mentioning a Chinese font name in my PDF files, and have the PDF readers correctly rendering the Chinese characters because the PDF readers would already have the Chinese font file.
Is that something sensible? If so is there any commonly used Chinese font that one can expect to be installed in most of the PDF readers used by Chinese people?
The best way to ensure that a PDF file can be displayed on a any reader, is to use partially embedded fonts (also known as font subset). In PDF, you don't need to include the whole font with your document, having a subset with just the glyphs that were used in the file is enough for the file to be portable.

Possible to edit PDF without embedded font installed?

I have a PDF and need to edit its text.
It has an embedded font and I'm not able to find the font to install. Is it possible to edit the text and maintain its embedded font when I don't have the font installed?
I'm editing with Acrobat X and its warning me that I don't have the font and forcing me to change the font of the text I want to edit to one that I have installed. I've Googled for a couple hours and found the font family, but not the variation that's embedded. Because the font is already in the document, I would have thought Acrobat or another software program could tap it to allow me to edit, though I'm guessing I'm missing something.
It depends...
1.
Most likely, your embedded font is a subset of the full font. That means that it contains only these glyphs (shapes that represent printable characters) which were required as representations for characters used by the original PDF.
If your edit wants to insert a character that wasn't present in the original PDF, Acrobat (or any other editing method) has to use a different font. The font embedded in the PDF simply doesn't have glyph that is suitable for your edit!
Also, your subsetted font's name is not exactly like the full set font's name: it uses has a randomly composed 6 uppercase character prefix with a +-sign to build the used font name, like ABCXYZ+Arial.
You could employ the free (as in beer) Acrobat Plugin FontReporter to generate a list of all glyphs contained in your font.
You can also use this answer:
"How can I extract embedded fonts from a PDF as valid font files?"
to extract the font in question.
Then open the extracted font (which will be the subset variant, mind you!) in FontForgehttp://fontforge.github.io/en-US/), and there check two things:
the original font's license
the original font's creator
With that knowledge you could then definitely find the variant of the family that is embedded (or rather: that was present when the PDF generating and font embedding software created the subset).
2.
If the (subsetted) font you are looking at uses a so called "custom encoding", it may be almost impossible to edit the PDF file with standard tools (even if you have the same font locally installed that was used to create the PDF file).