Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement stroke-linejoin attribute #152

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/prawn/svg/attributes/stroke.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Prawn::SVG::Attributes::Stroke
CAP_STYLE_TRANSLATIONS = {"butt" => :butt, "round" => :round, "square" => :projecting_square}
JOIN_STYLE_TRANSLATIONS = {"miter" => :miter, "round" => :round, "bevel" => :bevel}

def parse_stroke_attributes_and_call
if width_string = properties.stroke_width
Expand All @@ -11,6 +12,10 @@ def parse_stroke_attributes_and_call
if (linecap = properties.stroke_linecap) && linecap != 'inherit'
add_call('cap_style', CAP_STYLE_TRANSLATIONS.fetch(linecap, :butt))
end

if (linejoin = properties.stroke_linejoin) && linejoin != 'inherit'
add_call('join_style', JOIN_STYLE_TRANSLATIONS.fetch(linejoin, :miter))
end

if dasharray = properties.stroke_dasharray
case dasharray
Expand Down
2 changes: 0 additions & 2 deletions lib/prawn/svg/elements/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ def parse
end

def apply
add_call 'join_style', :bevel

apply_commands
apply_markers
end
Expand Down
1 change: 1 addition & 0 deletions lib/prawn/svg/properties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Prawn::SVG::Properties
"stroke" => Config.new("none", true, %w(inherit none currentColor)),
"stroke-dasharray" => Config.new("none", true, %w(inherit none)),
"stroke-linecap" => Config.new("butt", true, %w(inherit butt round square), true),
"stroke-linejoin" => Config.new("miter", true, %w(inherit miter round bevel), true),
"stroke-opacity" => Config.new("1", true),
"stroke-width" => Config.new("1", true),
"text-anchor" => Config.new("start", true, %w(inherit start middle end), true),
Expand Down