Fix Pango layout extents error in draw_year_markers

- Replace get_extents() with get_pixel_size() for correct text measurement
- Fixes ValueError: not enough values to unpack error
- get_pixel_size() returns (width, height) tuple directly in pixels
This commit is contained in:
Daniel Viegas 2025-11-28 22:23:28 +01:00
parent a94b01c4d8
commit d9c8bb8e34

View File

@ -542,9 +542,8 @@ class MyTimelineView(NavigationView):
) )
layout.set_text(str(year), -1) layout.set_text(str(year), -1)
(x_bearing, y_bearing, text_width, text_height, x_advance, y_advance) = layout.get_extents() # Get text size in pixels
text_width = text_width / Pango.SCALE text_width, text_height = layout.get_pixel_size()
text_height = text_height / Pango.SCALE
context.set_source_rgb(0.0, 0.0, 0.0) # Black context.set_source_rgb(0.0, 0.0, 0.0) # Black
context.move_to(timeline_x - 20 - text_width, y_pos - text_height / 2) context.move_to(timeline_x - 20 - text_width, y_pos - text_height / 2)