Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into adds_macos_arm_build
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjpfan committed Dec 5, 2023
2 parents f64ca3a + 963586e commit d27a8ab
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions wordcloud/wordcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class colormap_color_func(object):
"""
def __init__(self, colormap):
import matplotlib.pyplot as plt
self.colormap = plt.cm.get_cmap(colormap)
self.colormap = plt.get_cmap(colormap)

def __call__(self, word, font_size, position, orientation,
random_state=None, **kwargs):
Expand Down Expand Up @@ -499,6 +499,9 @@ def generate_from_frequencies(self, frequencies, max_font_size=None): # noqa: C
orientation = Image.ROTATE_90
tried_other_orientation = False
while True:
if font_size < self.min_font_size:
# font-size went too small
break
# try to find a position
font = ImageFont.truetype(self.font_path, font_size)
# transpose font optionally
Expand All @@ -510,8 +513,8 @@ def generate_from_frequencies(self, frequencies, max_font_size=None): # noqa: C
result = occupancy.sample_position(box_size[3] + self.margin,
box_size[2] + self.margin,
random_state)
if result is not None or font_size < self.min_font_size:
# either we found a place or font-size went too small
if result is not None:
# Found a place
break
# if we didn't find a place, make font smaller
# but first try to rotate!
Expand Down

0 comments on commit d27a8ab

Please sign in to comment.