Unicode Replacement Character in Standard TeX

Is there a font, available to -all- TeX users, that includes a glyph that can be recognized as the Unicode Replacement Character? I realize I can use XeTeX with a U+FFFD (or maybe any character not in the font), but I'm interested in using standard pdfTeX with standard LaTeX 2e and a pure ASCII input file.

The glyph typically looks like a filled black diamond with a white question mark inside it:

If no such font is available, what's the best robust strategy for getting such a glyph into a standard pdfTeX document (one whose input file has no Unicode or non-ASCII UTF-8 byte sequences in it) without using XeTeX or similar? Inserting TikZ commands? Raw PostScript?

Right now, for lack of a better solution, I'm using a \textbullet, simply because it's the boldest/blackest glyph I can think of, and it's available in most standard fonts.

Creating a custom font with one glyph in it is not really viable, or if it is it's a strategy of last resort, unless (perhaps) it can be done automatically and on the fly when processing the document each time.

(Reposted from the texhax mailing list: http://tug.org/pipermail/texhax/2015-January/021519.html; originally posed by Doug McKenna)

• Should it be inserted manually or automatically in some way? In the latter case, under what circumstances? – egreg Jan 14 '15 at 21:46
• my inclination would be to find such an image on a web page, save it as a graphic, and drop it in with \includegraphics. – barbara beeton Jan 14 '15 at 21:52

Of course, this is LaTeX, not standard TeX. This takes \blacksquare and rotates it 45 degree for the black diamond. Then it insets a white \sffamily\small ? atop it, centered left/right, and .2pt below vertical center. It then uses a \scalebox to make the composite symbol 2x as large (or however large or small you desire).

\documentclass{article}
\usepackage{amssymb,graphicx,stackengine,xcolor}
\def\ucr{\scalebox{2}{\stackinset{c}{}{c}{-.2pt}{%
\textcolor{white}{\sffamily\bfseries\small ?}}{%
\rotatebox{45}{$\blacksquare$}}}}
\begin{document}
\ucr
\end{document}

• This seems to work well and answers the question, because it doesn't depend on any other (included) file. Also the graphicx and xcolor packages don't appear necessary for this example to work. – jsbox Jan 15 '15 at 4:58
• @jsbox The xcolor and graphicx packages are required; however, if you are also loading tikz, they will be automatically loaded by that package. – Steven B. Segletes Jan 15 '15 at 5:02
• @jsbox I marked this solution as the answer. Sorry to take your karma on this one (mwhahaha),but I am real glad to see you on StackExchange! – Justin Bailey Jan 15 '15 at 21:27

I would say that no such font exists, so I propose another kind of approach.

You can pick up your favorite font and extract the glyph as en eps file, and then include it.

You can refer to an answer where I explain how I managed to do such a thing.

Alternatively,

MWE:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{repchar.eps}
%%Creator: cairo 1.12.8 (http://cairographics.org)
%%CreationDate: Thu Jan 15 01:23:35 2015
%%Pages: 1
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%BoundingBox: 0 -1 192 192
%%BeginProlog
save
50 dict begin
/q { gsave } bind def
/Q { grestore } bind def
/cm { 6 array astore concat } bind def
/w { setlinewidth } bind def
/J { setlinecap } bind def
/j { setlinejoin } bind def
/M { setmiterlimit } bind def
/d { setdash } bind def
/m { moveto } bind def
/l { lineto } bind def
/c { curveto } bind def
/h { closepath } bind def
/re { exch dup neg 3 1 roll 5 3 roll moveto 0 rlineto
0 exch rlineto 0 rlineto closepath } bind def
/S { stroke } bind def
/f { fill } bind def
/f* { eofill } bind def
/n { newpath } bind def
/W { clip } bind def
/W* { eoclip } bind def
/BT { } bind def
/ET { } bind def
/pdfmark where { pop globaldict /?pdfmark /exec load put }
{ globaldict begin /?pdfmark /pop load def /pdfmark
/cleartomark load def end } ifelse
/BDC { mark 3 1 roll /BDC pdfmark } bind def
/EMC { mark /EMC pdfmark } bind def
/cairo_store_point { /cairo_point_y exch def /cairo_point_x exch def } def
/Tj { show currentpoint cairo_store_point } bind def
/TJ {
{
dup
type /stringtype eq
{ show } { -0.001 mul 0 cairo_font_matrix dtransform rmoveto } ifelse
} forall
currentpoint cairo_store_point
} bind def
/cairo_selectfont { cairo_font_matrix aload pop pop pop 0 0 6 array astore
cairo_font exch selectfont cairo_point_x cairo_point_y moveto } bind def
/Tf { pop /cairo_font exch def /cairo_font_matrix where
{ pop cairo_selectfont } if } bind def
/Td { matrix translate cairo_font_matrix matrix concatmatrix dup
/cairo_font_matrix exch def dup 4 get exch 5 get cairo_store_point
/cairo_font where { pop cairo_selectfont } if } bind def
/Tm { 2 copy 8 2 roll 6 array astore /cairo_font_matrix exch def
cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind def
/g { setgray } bind def
/rg { setrgbcolor } bind def
/d1 { setcachedevice } bind def
%%EndProlog
%%Page: 1 1
%%BeginPageSetup
%%PageBoundingBox: 0 -1 192 192
%%EndPageSetup
q 0 -1 192 193 rectclip q
0 g
191.25 95.625 m 95.625 -0 l 0 95.625 l 95.625 191.25 l h
129.711 119.812 m 129.711 128.437 126.523 135.617 120.148 141.355 c 113.773
147.094 106.012 149.961 96.863 149.961 c 85.836 149.961 76.238 148.273
68.062 144.898 c 66.039 124.762 l 72.262 128.738 79.125 130.726 86.625 130.726
c 92.25 130.726 96.898 129.187 100.574 126.113 c 104.25 123.039 106.086
118.988 106.086 113.961 c 106.086 108.488 102.918 101.57 96.582 93.207
c 90.242 84.844 87.074 76.312 87.074 67.613 c 104.176 67.613 l 104.176 71.664
106.387 76.426 110.812 81.898 c 118.312 91.199 122.398 96.414 123.074 97.539
c 127.5 104.586 129.711 112.012 129.711 119.812 c h
108.676 31.726 m 108.676 55.351 l 82.574 55.351 l 82.574 31.726 l h
f
Q Q
showpage
\end{filecontents*}
\begin{document}
\includegraphics[height=\fontcharht\fontX]{repchar.eps}
\end{document}

Note that the "[height=\fontcharht\fontX]" option makes that your character the size of a captital X, following this post.

• Note that this technics makes your tex file self-contained: no need to always include the eps file, as it will always be re-created on the fly, when you compile your source code. – Clément Jan 15 '15 at 0:40
• The shape doesn't seem very difficult to obtain with a Metapost program; this would have a benefit: the PostScript output is directly readable also by pdflatex. – egreg Jan 15 '15 at 10:19