font: have Glyph return !ok for U+FFFD substitute

The other return values may still be non-zero, but this lets callers
identify when substitution happens.

"TODO: is falling back on the U+FFFD glyph the responsibility of the
Drawer or the Face?" was resolved. The answer is "the Face". For
kerning, the previous rune is unchanged (and not set to U+FFFD).

This also fixes an inconsistency in the basicfont.Face implementation,
where GlyphAdvance and GlyphBounds would unconditionally return a
non-zero advance, but Glyph could return a zero advance when the Face
doesn't have a U+FFFD entry.

Fixes golang/go#58252

Change-Id: Ie97e68e1d5e2efd13c9e84ad12db4495d83a5ca3
TryBot-Result: Gopher Robot <>
Reviewed-by: Dmitri Shuralyov <>
Reviewed-by: Nigel Tao (INACTIVE; USE INSTEAD) <>
Reviewed-by: Dmitri Shuralyov <>
Run-TryBot: Nigel Tao <>
3 files changed
tree: fc91c0c0b95ac72b0f1b3655925f96511f93105e
  1. bmp/
  2. ccitt/
  3. cmd/
  4. colornames/
  5. draw/
  6. example/
  7. font/
  8. math/
  9. riff/
  10. testdata/
  11. tiff/
  12. vector/
  13. vp8/
  14. vp8l/
  15. webp/
  16. .gitattributes
  17. .gitignore
  18. codereview.cfg
  20. go.mod
  21. go.sum

Go Images

Go Reference

This repository holds supplementary Go image libraries.


The easiest way to install is to run go get -u You can also manually git clone the repository to $GOPATH/src/

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see

The main issue tracker for the image repository is located at Prefix your issue with “x/image:” in the subject line, so it is easy to find.