From 55c17939fe956772edbeba836d806138d02b3d19 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 1 Oct 2018 19:12:45 +0200 Subject: Fix text flow in event boxes. Use the foreignObject tag to insert a small html-snippet with the text. --- room-schedule.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/room-schedule.rb b/room-schedule.rb index 40e94aa..bb6e677 100644 --- a/room-schedule.rb +++ b/room-schedule.rb @@ -73,14 +73,29 @@ module SVG bar_width = (x_end - x_start) * scale bar_start = x_start * scale - @graph.add_element( "rect", { + event = @graph.add_element( "rect", { "x" => bar_start.to_s, "y" => y.to_s, "width" => bar_width.to_s, "height" => subbar_height.to_s, "class" => "fill#{field_count+1}" }) - t = @graph.add_element("text", { + switch = @graph.add_element("switch") + fo = switch.add_element("foreignObject", { + "x" => (bar_start + @font_size / 2).to_s, + "y" => y.to_s, + "width" => bar_width.to_s, + "height" => subbar_height.to_s, + "requiredExtensions" => "http://www.w3.org/1999/xhtml", + }) + body = fo.add_element("body", { + "xmlns" => "http://www.w3.org/1999/xhtml", + }) + p = body.add_element("p", { + "class" => "event-title", + }) + p.add_text(entry.title) + t = switch.add_element("text", { "x" => (bar_start + @font_size / 2).to_s, "y" => (y + 2 * @font_size).to_s, }) @@ -165,6 +180,9 @@ module SVG stroke: none; stroke-width: 1px; } +.event-title { + font-size: 80%; +} EOL end -- cgit v1.2.3