Bug 689198 - Handling of missing glyphs in fonts
Summary: Handling of missing glyphs in fonts
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Font API (show other bugs)
Version: master
Hardware: All All
: P4 normal
Assignee: Ken Sharp
URL:
Keywords: bountiable
Depends on:
Blocks:
 
Reported: 2007-04-29 10:14 UTC by Till Kamppeter
Modified: 2009-02-07 01:34 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2007-04-29 10:14:57 UTC
In ESP GhostScript Mike Sweet has introduced an espgsMissingChar character to
substitute missing Glyphs in fonts. As I asked on trhe gs-devel list whether I
shouyld port this to GPL GhostScript Mike told that the better solution is to
look at first whether the font contains a "space" character and use that. If no
"space" is available use .notdef, or better let .notdef not display a box.
Comment 1 Ray Johnston 2007-05-01 09:41:34 UTC
If we do add support for this non standard behavior, it should ONLY be
done when an option is specified for "ESP" like behavior. Changing the
glyph shown for undefined glyphs is not backward compatible.
Comment 2 Hin-Tak Leung 2007-05-03 06:46:21 UTC
I was in the discussion (on cups-devel or somewhere?) with Mike Sweet, and 
as far as my impression of what the PS font-related specs says, .notdef is 
the one-and-only recommendation when a glyph is not found. What .notdef looks 
like differs of course on a font-by-font basis. I am still of the opinion that
missing glyph should be replaced by .notdef first (or only), and maybe space 
or other after... 
Comment 3 Ken Sharp 2009-02-06 03:13:27 UTC
Hmm, I'm coming into this thread with no background, could Till or Hin-Tak help
me out here please ?

Are we referring to PostScript (type 1, type 3, CID etc) or TrueType fonts ?
From my understanding of the spec(s), a font *must* contain a .notdef as the
bare minimum, precisely to handle the condition of missing glyphs. A font which
does not contain a .notdef is an invalid font.

If I remember correctly, the equivalent in a TrueType font is the glyph whose ID
is 0.

When a glyph is missing in a font, it must be replaced by the .notdef glyph (GID
0 for TT).

As Hin-Tak says, what a .notdef looks like is entirely up to the font designer,
most PostScript fonts use a glyph which draws nothing, most TrueType fonts use a
hollow rectangle (which is a common cause of complaint about glyphs being
replaced with squares). There are exceptions to both these cases.

From Till's original comment, I infer that what we have here is a discussion
about TrueType fonts, where glyph 0 is the 'hollow rectangle', the common case.
I'm assuming that there are complaints because the missing glyph is substituted
by the rectangle, and that Acrobat just shows an empty space. I've tried in the
past to decipher what rules Acrobat uses for this, and failed. Sometimes it
shows GID 0, sometimes it draws nothing.

If this is the problem, then one possible proposal is to add a new contrl (eg
UseTrueTypeNotDef) which defaults to true and causes GS to use the glyph at ID 0
for missing TrueType glyphs. When the control is false, GS simply elides the
glyph, and moves the current point, effectively replacing with a space.

Comments, opinions ? Did I completely misunderstand the problem ?
Comment 4 Ken Sharp 2009-02-06 07:31:16 UTC
<sigh> And indeed there already exists a control for rendering of TrueType
.notdef glyphs. Its called 'RenderTTNotdef' and if true the .notdef is rendered,
if false it isn't.

Which I should have remembered, because I added it <blush>

Till, Hin-Tak, could you look at this and see if you think it is sufficient to
resolve this issue please ?

For your reference the change was made in revision 8631 to fix bug #689757,
which was opened as a PDF writer problem. There is more information in the log
accompanying revision 8631.

Comment 5 Till Kamppeter 2009-02-06 09:01:39 UTC
I think this is OK, so you can switch between whether a hollow rectangle should
appear or simply blank space. I would say that's it.
Comment 6 Hin-Tak Leung 2009-02-06 13:54:21 UTC
The original motivation was that some cups customers complains of seeing
unsighty squares. (IMHO, despite it being the "correct" behavior according to
spec - it is just .notdef and .notdef could be anything the font vendor
decides). So the desired behavior - though considered off-spec - is to ignore
the presence of .notdef and uses "space" (if it is a text font). 

That's my understanding of the problem.
Comment 7 Ken Sharp 2009-02-07 01:34:35 UTC
Till, Hin-Tak, thanks for your input. It seems certain that the RenderTTNotdef
switch does do what is required here, so I'll close this issue.

For the record, this switch is documented in /gs/doc/Use.htm, defaults to true
for PostScript and false for PDF files.