Skip to content

Fallback font doesn't work on windows? #5929

@jankatins

Description

@jankatins

This is a test failure matplotlib.tests.test_text.test_font_styles.test which results in an image without any text on it (found as part of #5922)

import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
from matplotlib import _get_data_path
data_path = _get_data_path()

from matplotlib.font_manager import FontProperties, findfont

normalFont = dict(
    family="sans-serif",
    style="normal",
    variant="normal",
    size=14)

prop = FontProperties(**normalFont)
path = findfont(prop, directory=data_path)
print(path)
fp = FontProperties(fname=path)

plt.figure()
ax = plt.subplot(1, 1, 1)

ax.annotate(
    "Normal Font",
    (0.1, 0.1),
    xycoords='axes fraction',
    fontproperties=fp)

ax.set_xticks([])
ax.set_yticks([])

This results in the following output:

C:\portabel\miniconda\envs\matplotlib_build\lib\site-packages\matplotlib-1.5.1+1064.g4f14fc8-py3.5-win-amd64.egg\matplotlib\mpl-data\fonts\ttf\STIXSizOneSymBol.ttf
c:\data\external\pydata\matplotlib\lib\matplotlib\font_manager.py:1314: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans
  (prop.get_family(), self.defaultFamily[fontext]))
c:\data\external\pydata\matplotlib\lib\matplotlib\font_manager.py:1324: UserWarning: findfont: Could not match :family=DejaVu Sans:style=normal:variant=normal:weight=400:stretch=normal:size=14.0. Returning C:\portabel\miniconda\envs\matplotlib_build\lib\site-packages\matplotlib-1.5.1+1064.g4f14fc8-py3.5-win-amd64.egg\matplotlib\mpl-data\fonts\ttf\STIXSizOneSymBol.ttf
  UserWarning)
Out[14]: []

The produces image has not text on it :-(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy