Respect DPI settings in text, add pt unit
This has the compatibility impact that all font sizes should be divided by 3 to maintain their same sizes. Based on PR #225. Thanks @felixleong!! Conflicts: bin/squib lib/squib/graphics/text.rb
This commit is contained in:
committed by
Andy Meneely
parent
06970b77a6
commit
f800c131ff
@@ -14,6 +14,16 @@ describe Squib::Deck do
|
||||
end
|
||||
end
|
||||
|
||||
context '#pt' do
|
||||
it 'converts inches properly' do
|
||||
expect(deck.points(1)).to eq 4.166666666666667
|
||||
end
|
||||
|
||||
it 'handles strings too' do
|
||||
expect(deck.points('1')).to eq 4.166666666666667
|
||||
end
|
||||
end
|
||||
|
||||
context '#cm' do
|
||||
it 'converts inches properly' do
|
||||
expect(deck.cm(1)).to eq 118.1102361
|
||||
|
||||
@@ -15,6 +15,11 @@ describe Squib::Args::UnitConversion do
|
||||
expect(subject.parse('1 in')).to eq(300)
|
||||
end
|
||||
|
||||
it 'does pt' do
|
||||
expect(subject.parse('1pt')).to eq(4.166666666666667)
|
||||
expect(subject.parse('1pt ')).to eq(4.166666666666667)
|
||||
end
|
||||
|
||||
it 'does cm' do
|
||||
expect(subject.parse('1cm')).to eq(118.1102361)
|
||||
expect(subject.parse('1cm ')).to eq(118.1102361)
|
||||
|
||||
@@ -60,7 +60,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([10, 10])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([32768])
|
||||
pango font: size=([10915.84])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Short & Big"])
|
||||
pango: width=([286720])
|
||||
@@ -82,7 +82,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([10, 10])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([18432])
|
||||
pango font: size=([6144])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Medium Length & Size"])
|
||||
pango: width=([286720])
|
||||
@@ -104,7 +104,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([10, 10])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([12288])
|
||||
pango font: size=([4096])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Super duper long string here, therefore a smaller font."])
|
||||
pango: width=([286720])
|
||||
|
||||
@@ -348,7 +348,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([0, 0])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([18432])
|
||||
pango font: size=([6144])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Take 1 :tool: and gain 2 :health:."])
|
||||
pango: width=([184320])
|
||||
@@ -372,7 +372,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([0, 0])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([26624])
|
||||
pango font: size=([8704.0])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Take 1 :tool: and gain 2 :health:."])
|
||||
pango: width=([184320])
|
||||
@@ -396,7 +396,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([0, 0])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([35840])
|
||||
pango font: size=([11776.0])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Take 1 :tool: and gain 2 :health:."])
|
||||
pango: width=([184320])
|
||||
|
||||
@@ -282,7 +282,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([65, 350])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([16384])
|
||||
pango font: size=([5120])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Font string sizes can be overridden per card."])
|
||||
pango: wrap=([#<Pango::WrapMode word-char>])
|
||||
@@ -298,7 +298,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([65, 350])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([20480])
|
||||
pango font: size=([7168])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Font string sizes can be overridden per card."])
|
||||
pango: wrap=([#<Pango::WrapMode word-char>])
|
||||
@@ -314,7 +314,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([65, 350])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([24576])
|
||||
pango font: size=([8192])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Font string sizes can be overridden per card."])
|
||||
pango: wrap=([#<Pango::WrapMode word-char>])
|
||||
@@ -393,7 +393,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([65, 550])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([16384])
|
||||
pango font: size=([5120])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Ink extent return value"])
|
||||
pango: wrap=([#<Pango::WrapMode word-char>])
|
||||
@@ -409,7 +409,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([65, 550])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([20480])
|
||||
pango font: size=([7168])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Ink extent return value"])
|
||||
pango: wrap=([#<Pango::WrapMode word-char>])
|
||||
@@ -425,7 +425,7 @@ cairo: set_source_color(["black"])
|
||||
cairo: translate([65, 550])
|
||||
cairo: rotate([0])
|
||||
cairo: move_to([0, 0])
|
||||
pango font: size=([24576])
|
||||
pango font: size=([8192])
|
||||
pango: font_description=([MockDouble])
|
||||
pango: text=(["Ink extent return value"])
|
||||
pango: wrap=([#<Pango::WrapMode word-char>])
|
||||
|
||||
@@ -115,6 +115,7 @@ def mock_cairo(strio)
|
||||
allow(pango).to receive(:attributes).and_return(nil)
|
||||
allow(pango_cxt).to receive(:set_shape_renderer)
|
||||
allow(pango_cxt).to receive(:font_options=)
|
||||
allow(pango_cxt).to receive(:resolution=)
|
||||
allow(iter).to receive(:next_char!).and_return(false)
|
||||
allow(iter).to receive(:char_extents).and_return(Pango::Rectangle.new(5, 5, 5, 5))
|
||||
allow(iter).to receive(:index).and_return(1000)
|
||||
|
||||
Reference in New Issue
Block a user