Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a6e4f8

Browse files
committed
FIX: Check for fontsize smaller than 1 pt
1 parent cfb648f commit 8a6e4f8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Fontsizes less than 1 pt are clipped to be 1 pt.
2+
------------------------------------------------
3+
4+
FreeType doesn't allow fonts to get smaller than 1 pt, so all Agg
5+
backends were silently rounding up to 1 pt. PDF (other vector
6+
backends?) were letting us write fonts that were less than 1 pt, but
7+
they could not be placed properly because position information comes from
8+
FreeType. This change makes it so no backends can use fonts smaller than
9+
1 pt, consistent with FreeType and ensuring more consistent results across
10+
backends.

lib/matplotlib/font_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,10 @@ def set_size(self, size):
878878
+ ", ".join(map(str, font_scalings)))
879879
else:
880880
size = scale * FontManager.get_default_size()
881+
if size < 1.0:
882+
_log.info('Fontsize %1.2f < 1.0 pt not allowed by FreeType. '
883+
'Setting fontsize = 1 pt' % size)
884+
size = 1.0
881885
self._size = size
882886

883887
def set_file(self, file):

0 commit comments

Comments
 (0)