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

Skip to content

Commit 12a3b4f

Browse files
authored
Merge pull request #10010 from jklymak/fix-check-fontsize
FIX: Check for fontsize smaller than 1 pt and round up
2 parents c46525a + 8d1f597 commit 12a3b4f

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
@@ -875,6 +875,10 @@ def set_size(self, size):
875875
+ ", ".join(map(str, font_scalings)))
876876
else:
877877
size = scale * FontManager.get_default_size()
878+
if size < 1.0:
879+
_log.info('Fontsize %1.2f < 1.0 pt not allowed by FreeType. '
880+
'Setting fontsize = 1 pt', size)
881+
size = 1.0
878882
self._size = size
879883

880884
def set_file(self, file):

0 commit comments

Comments
 (0)