Skip to content

Commit

Permalink
Force normal style and weight for text used in labels and other annot…
Browse files Browse the repository at this point in the history
…ations.
  • Loading branch information
rmagick committed Jan 3, 2009
1 parent 95bba79 commit 843e153
Show file tree
Hide file tree
Showing 41 changed files with 92 additions and 34 deletions.
2 changes: 1 addition & 1 deletion doc/ex/InitialCoords.rb
Expand Up @@ -12,7 +12,7 @@
grp.rect(3, 3, 297, 0)
grp.rect(3, 3, 0, 97)
end
canvas.g.styles(:font_size=>14, :font_family=>'Verdana') do |grp|
canvas.g.styles(:font_size=>14, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal') do |grp|
grp.text(10, 20, '(0,0)')
grp.text(240, 20, '(300,0)')
grp.text(10, 90, '(0,100)')
Expand Down
4 changes: 2 additions & 2 deletions doc/ex/NewCoordSys.rb
Expand Up @@ -10,7 +10,7 @@
end

canvas.g do |grp|
grp.text(30, 30, 'ABC (orig coord system)').styles(:font_size=>20, :font_family=>'Verdana')
grp.text(30, 30, 'ABC (orig coord system)').styles(:font_size=>20, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
end

# Establish a new coordinate system, which is
Expand All @@ -23,7 +23,7 @@
grp2.line(0, 0, 50, 0)
grp2.line(0, 0, 0, 50)
end
grp.text(30, 30, 'ABC (translated coord system)').styles(:font_size=>20, :font_family=>'Verdana')
grp.text(30, 30, 'ABC (translated coord system)').styles(:font_size=>20, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
end

end
Expand Down
2 changes: 1 addition & 1 deletion doc/ex/OrigCoordSys.rb
Expand Up @@ -10,7 +10,7 @@
grp.line(1.5, 0, 1.5, 150)
end

canvas.text(30, 30, 'ABC (orig coord system)').styles(:font_size=>20, :font_family=>'Verdana')
canvas.text(30, 30, 'ABC (orig coord system)').styles(:font_size=>20, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')

end

Expand Down
4 changes: 2 additions & 2 deletions doc/ex/RotateScale.rb
Expand Up @@ -16,7 +16,7 @@
grp3.line(0, 0, 50, 0)
grp3.line(0, 0, 0, 50)
end
grp2.text(0, 0, "ABC (rotate)").styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana')
grp2.text(0, 0, "ABC (rotate)").styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
end
end

Expand All @@ -28,7 +28,7 @@
grp3.line(0, 0, 50, 0)
grp3.line(0, 0, 0, 50)
end
grp2.text(0, 0, "ABC (scale)").styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana')
grp2.text(0, 0, "ABC (scale)").styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions doc/ex/Skew.rb
Expand Up @@ -18,7 +18,7 @@
grp3.line(0, 0, 50, 0)
grp3.line(0, 0, 0, 50)
end
grp.text(0, 0, 'ABC (skewX)').styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana')
grp.text(0, 0, 'ABC (skewX)').styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
end
end

Expand All @@ -30,7 +30,7 @@
grp3.line(0, 0, 50, 0)
grp3.line(0, 0, 0, 50)
end
grp.text(0, 0, 'ABC (skewY)').styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana')
grp.text(0, 0, 'ABC (skewY)').styles(:font_size=>20, :fill=>'blue', :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion doc/ex/ViewBox.rb
Expand Up @@ -22,7 +22,7 @@ def example(cols, rows)
canvas.path("M 750,100 L 250,900 L 1250,900 z").styles(:fill=>'red')

# A text string that spans most of the viewport
canvas.text(100, 600, 'Stretch to fit').styles(:font_size=>200, :font_family=>'Verdana')
canvas.text(100, 600, 'Stretch to fit').styles(:font_size=>200, :font_style=>'normal', :font_weight=>'normal', :font_family=>'Verdana')

end
return rvg.draw
Expand Down
6 changes: 4 additions & 2 deletions doc/ex/arc.rb
Expand Up @@ -18,14 +18,16 @@
gc.circle(146, 50, 146+3, 50)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.stroke('transparent')
gc.fill("black")
gc.fill_opacity(1)

# xMagick recognizes the braces as delimiters.
gc.gravity(Magick::NorthWestGravity)
gc.text(43, 45, "{40, 50}")
gc.text(195, 118, "{0 degrees}")
gc.text(42, 37, "{40, 50}")
gc.text(188, 108, "{0 degrees}")

gc.gravity(Magick::SouthEastGravity)
gc.text(300-250, 220-195, "{250, 180}")
Expand Down
2 changes: 1 addition & 1 deletion doc/ex/arcs02.rb
Expand Up @@ -23,7 +23,7 @@

canvas.rect(1196, 522, 1, 1).styles(:fill=>'none', :stroke=>'blue', :stroke_width=>1)

canvas.g.styles(:font_size=>30, :font_family=>'Verdana') do |grp|
canvas.g.styles(:font_size=>30, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal') do |grp|

grp.use(base_ellipses)

Expand Down
3 changes: 3 additions & 0 deletions doc/ex/bounding_box.rb
Expand Up @@ -29,6 +29,9 @@

gc.fill("black")
gc.stroke("transparent")
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.pointsize(9)
gc.text(bb.x-15, bb.y-5, "\'#{bb.x},#{bb.y}\'")
gc.text(bb.x+bb.width-15, bb.y-5, "\'#{bb.x+bb.width},#{bb.y}\'")
gc.text(bb.x-15, bb.y+bb.height+15, "\'#{bb.x},#{bb.y+bb.height}\'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/cbezier1.rb
Expand Up @@ -26,6 +26,8 @@
gc.circle(320,20, 323,23)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(27,120, "'20,120'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/cbezier2.rb
Expand Up @@ -26,6 +26,8 @@
gc.circle(400,25, 403,28)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(34,125, "'25,125'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/cbezier3.rb
Expand Up @@ -26,6 +26,8 @@
gc.circle(475,50, 478,53)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(107,150, "'100,150'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/cbezier4.rb
Expand Up @@ -26,6 +26,8 @@
gc.circle(320,330, 323,333)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(29,180, "'20,180'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/cbezier5.rb
Expand Up @@ -26,6 +26,8 @@
gc.circle(245,20, 248,23)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(29,120, "'20,120'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/cbezier6.rb
Expand Up @@ -34,6 +34,8 @@
gc.line(350,150, 350,250)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(30,170, "'50,150'")
Expand Down
1 change: 1 addition & 0 deletions doc/ex/channel.rb
Expand Up @@ -18,6 +18,7 @@
self.background_color = 'black'
self.stroke = 'transparent'
self.fill = 'white'
self.pointsize =9
self.geometry = Magick::Geometry.new(img.columns/2, img.rows/2, 5, 5)
}

Expand Down
2 changes: 2 additions & 0 deletions doc/ex/circle.rb
Expand Up @@ -21,6 +21,8 @@
gc.circle(125,125, 128,128)

# Annotate the dots
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(132,125, "'125,125'")
Expand Down
2 changes: 1 addition & 1 deletion doc/ex/cubic01.rb
Expand Up @@ -8,7 +8,7 @@
EndPoint = {:fill=>'none', :stroke=>'#888', :stroke_width=>2}
CtlPoint = {:fill=>'#888', :stroke=>'none'}
AutoCtlPoint = {:fill=>'none', :stroke=>'blue', :stroke_width=>4}
Label = {:font_size=>22, :font_family=>'Verdana'}
Label = {:font_size=>22, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal'}

rvg = Magick::RVG.new(5.cm, 4.cm).viewbox(0, 0, 500, 400) do |canvas|
canvas.title = "Example cubic01 - cubic Bezier commands in path data"
Expand Down
2 changes: 1 addition & 1 deletion doc/ex/cubic02.rb
Expand Up @@ -8,7 +8,7 @@
EndPoint = { :fill=>'none', :stroke=>'#888888', :stroke_width=>2 }
CtlPoint = { :fill=>'#888888', :stroke=>'none' }
AutoCtlPoint = { :fill=>'none', :stroke=>'blue', :stroke_width=>4 }
Label = { :text_anchor=>'middle', :font_size=>22, :font_family=>'Verdana' }
Label = { :text_anchor=>'middle', :font_size=>22, :font_family=>'Verdana', :font_weight=>'normal', :font_style=>'normal' }

rvg = Magick::RVG.new(10.cm, 10.cm).viewbox(0, 0, 1000, 1000) do |canvas|
canvas.title = 'Example cubic02 - cubic Bezier commands in path data'
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/ellipse.rb
Expand Up @@ -27,6 +27,8 @@
gc.circle(180, 125-75, 180+3, 125-75+3)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill_opacity(1)
gc.circle(180,125, 183,128)
gc.fill('black')
Expand Down
22 changes: 12 additions & 10 deletions doc/ex/font_styles.rb
Expand Up @@ -6,18 +6,20 @@
canvas.background_fill = 'white'

canvas.g do |grp|
grp.text(10, 30, "default size")
grp.text(10, 50, ":font_size=>14").styles(:font_size=>14)
grp.text(10, 70, ":font_size=>16").styles(:font_size=>16)
grp.text(10,100, ":font_size=>24").styles(:font_size=>24)
grp.g.styles(:font_weight=>'normal', :font_style=>'normal') do |grp2|
grp2.text(10, 30, "default size")
grp2.text(10, 50, ":font_size=>14").styles(:font_size=>14)
grp2.text(10, 70, ":font_size=>16").styles(:font_size=>16)
grp2.text(10,100, ":font_size=>24").styles(:font_size=>24)
end
end

canvas.g.styles(:font_size=>14) do |grp|
if RUBY_PLATFORM =~ /mswin32/
grp.text( 8, 120, ":font_family=>'Courier-New'").styles(:font_family=>'Courier-New')
else
grp.text( 8, 120, ":font_family=>'Courier'").styles(:font_family=>'Courier')
end
canvas.g.styles(:font_size=>14, :font_weight=>'normal', :font_style=>'normal') do |grp|
if RUBY_PLATFORM =~ /mswin32/
grp.text( 8, 120, ":font_family=>'Courier-New'").styles(:font_family=>'Courier-New')
else
grp.text( 8, 120, ":font_family=>'Courier'").styles(:font_family=>'Courier')
end
grp.text(10, 140, ":font_weight=>'bold'").styles(:font_weight=>'bold')
grp.text(10, 160, ":font_stretch=>'normal'").styles(:font_stretch=>'normal')
grp.text(10, 180, ":font_stretch=>'condensed'").styles(:font_stretch=>'condensed')
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/get_type_metrics.rb
Expand Up @@ -130,6 +130,8 @@ def brace(w, h)
gc.pop

# Add labels
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.stroke('none')
gc.fill('black')
gc.text(metrics.width+40, -(metrics.ascent/2)+4, 'ascent')
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/grav.rb
Expand Up @@ -15,6 +15,8 @@
gc.line(20,100, 380,100)

# Draw text at all 9 compass points.
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.stroke('transparent')
gc.fill('black')
gc.gravity(Magick::NorthWestGravity)
Expand Down
2 changes: 1 addition & 1 deletion doc/ex/image.rb
Expand Up @@ -31,7 +31,7 @@
canvas.line(345, 20, 500, 20)
canvas.line(150, 250, 305, 250)
canvas.line(340, 250, 500, 250)
canvas.g.styles(:stroke=>'none') do |t|
canvas.g.styles(:stroke=>'none', :font_weight=>'normal', :font_style=>'normal') do |t|
t.text(310, 23, 'meet')
t.text(60, 140, 'none')
t.text(170, 140, 'xMinYMin')
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/line.rb
Expand Up @@ -27,6 +27,8 @@
gc.circle(200,200, 203,203)

# Annotate the endpoints
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(30,40, "'50,50'")
Expand Down
10 changes: 6 additions & 4 deletions doc/ex/opacity.rb
Expand Up @@ -22,13 +22,15 @@
gc.opacity(1)
gc.roundrectangle(200,20, 240,90, 5,5)

gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.stroke('transparent')
gc.fill('black')
gc.gravity(Magick::SouthGravity)
gc.text(-90,20, '"25%%"')
gc.text(-30,20, '"50%%"')
gc.text( 30,20, '"75%%"')
gc.text( 90,20, '"100%%"')
gc.text(-90,15, '"25%"')
gc.text(-30,15, '"50%"')
gc.text( 30,15, '"75%"')
gc.text( 90,15, '"100%"')

gc.draw(canvas)

Expand Down
2 changes: 2 additions & 0 deletions doc/ex/path.rb
Expand Up @@ -39,6 +39,8 @@
gc.circle 170,220, 173,223

# Add labels
gc.font_weight Magick::NormalWeight
gc.font_style Magick::NormalStyle
gc.stroke "none" # unset stroke color
gc.fill 'black'

Expand Down
2 changes: 2 additions & 0 deletions doc/ex/polaroid.rb
Expand Up @@ -9,6 +9,8 @@

begin
picture = img.polaroid do
self.font_weight = Magick::NormalWeight
self.font_style = Magick::NormalStyle
self.gravity = Magick::CenterGravity
self.border_color = "#f0f0f8"
end
Expand Down
3 changes: 3 additions & 0 deletions doc/ex/qbezierpath.rb
Expand Up @@ -33,6 +33,9 @@
gc.line 320,275, 420,150

# Add labels
gc.font_weight Magick::NormalWeight
gc.font_style Magick::NormalStyle

# Add end point labels
gc.text 30,155, "'20,150'"
gc.text 230,155, "'220,150'"
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/rectangle.rb
Expand Up @@ -20,6 +20,8 @@
gc.circle(280, 180, 283, 183)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(30,35, "'20,20'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/rotate.rb
Expand Up @@ -28,6 +28,8 @@
gc.line( max_x, 0, max_x-10, 10)

# Add labels
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')

Expand Down
2 changes: 2 additions & 0 deletions doc/ex/roundrect.rb
Expand Up @@ -20,6 +20,8 @@
gc.circle(280,180, 283,183)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(30,35, "'20,20'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/skewx.rb
Expand Up @@ -34,6 +34,8 @@
# Add labels using "normal" skew
gc = Magick::Draw.new
gc.pointsize(14)
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.stroke('transparent')
gc.gravity(Magick::CenterGravity)
gc.text(10, -10, "'0,0'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/skewy.rb
Expand Up @@ -32,6 +32,8 @@
# Add labels
gc = Magick::Draw.new
gc.pointsize(14)
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.stroke('transparent')
gc.gravity(Magick::CenterGravity)
gc.text(15, 0, "'0,0'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/stroke_dasharray.rb
Expand Up @@ -25,6 +25,8 @@

gc.fill('black')
gc.stroke('transparent')
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)

gc.gravity(Magick::CenterGravity)
gc.text( 0, -60, "'gc.stroke_dasharray(30, 10, 10, 10)'")
Expand Down
2 changes: 2 additions & 0 deletions doc/ex/stroke_width.rb
Expand Up @@ -33,6 +33,8 @@
gc.line(10,30,490,30)

# Annotate
gc.font_weight(Magick::NormalWeight)
gc.font_style(Magick::NormalStyle)
gc.fill('black')
gc.stroke('transparent')
gc.text(60,70,"'5'")
Expand Down

0 comments on commit 843e153

Please sign in to comment.