Skip to content

Commit

Permalink
improved canvas if monospace font not present
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokse22 committed Jun 15, 2024
1 parent 4222eb7 commit e7a8622
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,21 @@ def drawing_function(self, area, cr, width, height, data):
cr.set_source_rgb(self.color, self.color, self.color)
cr.select_font_face("monospace")
cr.set_font_size(20 * self.scale_factor)
for index, line in enumerate(self.drawing):
cr.move_to (0, (index + 1) * self.y_mul * self.scale_factor - 5)
cr.show_text(''.join(w if w != "" else " " for w in line))

# for y, line in enumerate(self.drawing):
# for x, char in enumerate(line):
# cr.move_to(x * self.x_mul, (y + 1) * self.y_mul * self.scale_factor - 5)
# cr.show_text(char)
for y, line in enumerate(self.drawing):
for x, char in enumerate(line):
cr.move_to(x * self.x_mul, (y + 1) * self.y_mul * self.scale_factor - 5)
cr.show_text(char)

def preview_drawing_function(self, area, cr, width, height, data):
cr.set_source_rgb(self.color, self.color, self.color)
cr.select_font_face("monospace")
cr.set_font_size(20 * self.scale_factor)
for index, line in enumerate(self.preview):
cr.move_to (0, (index + 1) * self.y_mul * self.scale_factor - 5)
cr.show_text(''.join(w if w != "" else " " for w in line))

for y, line in enumerate(self.preview):
for x, char in enumerate(line):
cr.move_to(x * self.x_mul, (y + 1) * self.y_mul * self.scale_factor - 5)
cr.show_text(char)

def update(self):
self.draw_drawing_area.queue_draw()
Expand Down

0 comments on commit e7a8622

Please sign in to comment.