Commit ce3cb7a2 authored by David Boddie's avatar David Boddie 💬
Browse files

Fit the document to the window width

parent 8e7bfdb0
Pipeline #42156 canceled with stages
...@@ -87,6 +87,10 @@ class Application(Gtk.Application): ...@@ -87,6 +87,10 @@ class Application(Gtk.Application):
rect = self.scroller.get_allocation() rect = self.scroller.get_allocation()
sw, sh = rect.width, rect.height sw, sh = rect.width, rect.height
w, h = page.get_size()
# Fit the width of the page in the scroller.
sh = int((h / w) * sw)
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, sw, sh) surface = cairo.ImageSurface(cairo.FORMAT_RGB24, sw, sh)
context = cairo.Context(surface) context = cairo.Context(surface)
...@@ -98,7 +102,6 @@ class Application(Gtk.Application): ...@@ -98,7 +102,6 @@ class Application(Gtk.Application):
context.paint() context.paint()
# Make the page fit the available size. # Make the page fit the available size.
w, h = page.get_size()
scale = min(sw / w, sh / h) scale = min(sw / w, sh / h)
x = (sw - (scale * w)) / 2 x = (sw - (scale * w)) / 2
y = (sh - (scale * h)) / 2 y = (sh - (scale * h)) / 2
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment