diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-01-01 11:45:12 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-01-01 11:45:12 +0000 |
commit | 2c830770cb39d962e12b072fdebffc35c457888b (patch) | |
tree | e418480a46fef426ee4f3a45679324081d9f96e4 /vendor | |
parent | 9748567452ccaf89e566622e2cf851da5dafc78d (diff) | |
download | redmine-2c830770cb39d962e12b072fdebffc35c457888b.tar.gz redmine-2c830770cb39d962e12b072fdebffc35c457888b.zip |
ruby1.9 compatibility
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4602 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb b/vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb index ad52e9e62..c41174f6a 100644 --- a/vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb +++ b/vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb @@ -378,13 +378,21 @@ class FPDF end @ColorFlag=(@FillColor!=@TextColor) end + + def GetCharWidth(widths, index) + if index.is_a?(String) + widths[index.ord] + else + widths[index] + end + end def GetStringWidth(s) # Get width of a string in the current font cw=@CurrentFont['cw'] w=0 s.each_byte do |c| - w=w+cw[c] + w=w+GetCharWidth(cw, c) end w*@FontSize/1000.0 end @@ -707,7 +715,7 @@ class FPDF ls=l ns=ns+1 end - l=l+cw[c[0]] + l=l+GetCharWidth(cw, c[0]) if l>wmax # Automatic line break if sep==-1 @@ -786,7 +794,7 @@ class FPDF sep=i ls=l end - l=l+cw[c]; + l=l+GetCharWidth(cw, c); if l>wmax # Automatic line break if sep==-1 @@ -1079,7 +1087,7 @@ class FPDF cw=font['cw'] s='[' 32.upto(255) do |i| - s << cw[i].to_s+' ' + s << GetCharWidth(cw, i).to_s + ' ' end out(s+']') out('endobj') |