Skip to content

Underscore character does not exist for cmr10 font #16995

Closed

Description

@jrwrigh

Bug report

The bundled font cmr10 (and it's associated family) do not contain the underscore character. Instead, the unicode character for the underscore (according to this website anyways) is actually mappted to the overdot.

See this StackOverflow for details, but I'll repeat here.

Code for reproduction

import matplotlib.pyplot as plt
plt.rcParams.update({
            'font.family': 'serif',
            'font.serif': 'cmr10',
})

variable = range(5)
plt.plot(variable, variable, label='test_underscore')
plt.plot(variable, variable, label='escape\_underscore')
plt.plot(variable, variable, label=r'rawtest_underscore')
plt.plot(variable, variable, label=r'rawescape\_underscore')
_=plt.legend()

Actual outcome

image

Expected outcome

image

Matplotlib version

  • Operating system: Manjaro 19.0.2
  • Matplotlib version: 3.1.3
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.7.6

Other
cmr10 loaded into FontForge shows that:
A) the underscore character doesn't exist
B) the normal underscore character (005f) is replaced by the overdot
image

Activity

  1. anntzer commented on Apr 1, 2020

    @anntzer
    Contributor

    That's because there's, well, no underscore in the classic OT1 encoding (https://texfaq.org/FAQ-underscore). Consider e.g. downloading and using lmroman10-regular.ttf.

  2. jrwrigh commented on Apr 2, 2020

    @jrwrigh
    Author

    Huh. The more you know I guess. Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions