Is there a "glyph not found" character?
Asked Answered
J

8

36

Let's assume we have a text that contains a Unicode character that cannot be displayed because our font has no corresponding glyph. Usually, a placeholder is displayed instead, e.g. a rectangular block thingy (see screenshot).

Is there a "glyph not found" character that reliably produces this glyph? I'd like to write something like "If the following text contains <insert character here> then you need another font..." in a UI.

By the way, I am not talking about � (replacement character). This one is displayed when a Unicode character could not be correctly decoded from a data stream. It does not necessarily produce the same glyph:

enter image description here

Jonasjonathan answered 5/12, 2012 at 19:3 Comment(3)
The rectangle is the "glyph not found" glyph. Don't help.Pryer
While there are many great answers regarding the "glyph not found" glyph, that won't help you actually detect it, as the text string in code will still have the character regardless of the font used to render it. Some rendering libraries I think have the option to query the font but I have no idea how standard this is.Merriweather
While I don't think there is a Unicode code point for the "missing glyph", in TrueType and OpenType fonts this is guaranteed to be be at glyph ID 0. If you control conversion of unicode characters to glyphs in the font, you could, for example, map a code point in the private use area to glyph ID 0 and then use this.Roar
C
15

No, there is no “glyph not found” character. Different programs use different graphic presentations. An empty narrow rectangle is a common rendering, but not the only one. It could also be a rectangle with a question mark in it or with the code number of the character, in hexadecimal, in it.

So it is better to e.g. display a small image of the character along with the character itself, so that the reader can compare them.

Corkhill answered 5/12, 2012 at 20:26 Comment(1)
On several Android phones missing glyphs are drawn with just a few pixels of empty space. So it doesn't even have to be something that is visible.Genesisgenet
R
23

From the Unicode Spec:

U+25A1 □ WHITE SQUARE

  • may be used to represent a missing ideograph

  • U+20DE $⃞ combining enclosing square

Reedreedbird answered 1/10, 2015 at 23:20 Comment(2)
I have rolled back your edit to Jukka K. Korpela's answer. Please include that information in this answer and/or add a comment to the other answer.Jonasjonathan
Why not just include the information there and delete this answer?Reedreedbird
C
15

No, there is no “glyph not found” character. Different programs use different graphic presentations. An empty narrow rectangle is a common rendering, but not the only one. It could also be a rectangle with a question mark in it or with the code number of the character, in hexadecimal, in it.

So it is better to e.g. display a small image of the character along with the character itself, so that the reader can compare them.

Corkhill answered 5/12, 2012 at 20:26 Comment(1)
On several Android phones missing glyphs are drawn with just a few pixels of empty space. So it doesn't even have to be something that is visible.Genesisgenet
N
8

The glyph-not-found character is specified by the font engine and by the font; there is no fixed character for it.

Nolen answered 5/12, 2012 at 19:6 Comment(3)
The question clearly says that it is not about the replacement character, and REPLACEMENT CHARACTER U+FFFD is a fixed character (it does not have a fixed glyph, though fonts that contain it tend to use very similar glyphs).Corkhill
@Jukka: Except I'm not talking about U+FFFD either.Nolen
Then don’t use the phrase “replacement character”, because a) it’s not a character at all, and b) it’s specifically not the character with the Unicode name REPLACEMENT CHARACTER, and c) people easily get confused with issues like this.Corkhill
T
4

Unicode uses these terms:

  • replacement glyph
  • missing glyph
  • interpretable but unrenderable character

The Unicode Standard (10.0) does not define how they have to look, but it suggests in chapter 5.3 [PDF] that implementations display

[…] distinctive glyphs that give some general indication of their type […]

to distinguish them from "unassigned code points". They give some examples:

The Unicode glossary entry says:

It often is shown as an open or black rectangle.


tl;dr: There is no standardized look/glyph, it’s up to the implementation. To help users, implementations could display glyphs that indicate what type of character it is that can’t be displayed.

Thaler answered 20/10, 2017 at 19:51 Comment(0)
K
3

Use a non-character like U+10FFFF (at the very end of the Unicode space) which is 99.99% certain to not be found in the cmap table of any sane font. At least no known Windows system font maps that non-character to a glyph, and highly unlikely any Linux/Mac system font either. Even the all encompassing Last Resort font (http://www.unicode.org/policies/lastresortfont_eula.html) doesn't appear to map it. So while there is no official "glyph not found" character defined in Unicode that will map to the .notdef glyph, the above non-character is in practice guaranteed to display that glyph, whatever the glyph design is in that particular font. The .notdef glyph (glyph id 0 in OpenType) may be a simple hollow rectangle (standard), box with x, box with question mark, blank occasionally (which is bad practice), and sometimes bizarre things like spirals (in Palatino Linotype).

Kaifeng answered 5/7, 2013 at 22:49 Comment(0)
R
3

There is a notdef character that means the glyph is not found. But it has no charcode. You can use the charcodes of controll characters to insert a notdef character (like "", U+0002)

Rafi answered 20/10, 2018 at 15:34 Comment(1)
It looks like that character cannot be posted in stackoverflowRafi
C
2

Also, (from what I've heard) Japanese uses the GETA MARK 〓 U+3013

CJK Symbols and Punctuation

Cowman answered 15/2, 2016 at 8:2 Comment(0)
H
0

There are 3 possible characters for glyph not found.

Check in Microsoft specification, topic Shape of .notdef glyph, https://learn.microsoft.com/en-us/typography/opentype/otspec170/recom#shape-of-notdef-glyph

Hardspun answered 21/11, 2016 at 15:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.