Skip to content

Commit

Permalink
Fix Pango-Warning
Browse files Browse the repository at this point in the history
Invalid UTF-8 string is passed to pango_layout_set_text() is fixed
  • Loading branch information
Saumya-Mishra9129 authored and JuiP committed May 14, 2020
1 parent 83e334b commit 8c4b49f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ def draw_label(self, cr):
my_height = self.rect.height - self._margins[1] - self._margins[3]
for i in range(len(self.labels)):
pl = PangoCairo.create_layout(cr)
text = str(self.labels[i])
pl.set_text(text, len(text))
text = self.labels[i]
pl.set_text(text, -1)
self._fd.set_size(int(self._scale[i] * Pango.SCALE))
pl.set_font_description(self._fd)
w = pl.get_size()[0] / Pango.SCALE
Expand All @@ -390,7 +390,7 @@ def draw_label(self, cr):
j = len(self.labels[i]) - 1
while(w > my_width and j > 0):
text = "…" + self.labels[i][len(self.labels[i]) - j:]
pl.set_text(text, len(text))
pl.set_text(text, -1)
self._fd.set_size(int(self._scale[i] * Pango.SCALE))
pl.set_font_description(self._fd)
w = pl.get_size()[0] / Pango.SCALE
Expand Down Expand Up @@ -423,7 +423,7 @@ def label_width(self):
for i in range(len(self.labels)):
pl = cr.create_layout()
text = self.labels[i]
pl.set_text(text, len(text))
pl.set_text(text, -1)
self._fd.set_size(int(self._scale[i] * Pango.SCALE))
pl.set_font_description(self._fd)
w = pl.get_size()[0] / Pango.SCALE
Expand Down

0 comments on commit 8c4b49f

Please sign in to comment.