Skip to content

Commit 442c737

Browse files
committed
gtk4: add support for rendering SVG
1 parent 9696809 commit 442c737

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/rabbit/renderer/scene.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,23 @@ def draw_arc_by_radius(filled,
443443
end
444444
end
445445

446+
def draw_rsvg_handle(handle, x, y, params={})
447+
x, y = adjust_xy(x, y)
448+
dim = handle.dimensions
449+
w = dim.width
450+
h = dim.height
451+
width = (params[:width] || w).to_f
452+
height = (params[:height] || h).to_f
453+
454+
snapshot = current_snapshot
455+
snapshot.save do
456+
# TODO: clip
457+
snapshot.scale(width / w, height / h)
458+
context = snapshot.append_cairo([x, y, w, h])
459+
context.render_rsvg_handle(handle)
460+
end
461+
end
462+
446463
def draw_poppler_page(page, x, y, params={})
447464
x, y = adjust_xy(x, y)
448465
w, h = page.size

0 commit comments

Comments
 (0)