@@ -378,13 +378,21 class FPDF | |||||
378 | end |
|
378 | end | |
379 | @ColorFlag=(@FillColor!=@TextColor) |
|
379 | @ColorFlag=(@FillColor!=@TextColor) | |
380 | end |
|
380 | end | |
|
381 | ||||
|
382 | def GetCharWidth(widths, index) | |||
|
383 | if index.is_a?(String) | |||
|
384 | widths[index.ord] | |||
|
385 | else | |||
|
386 | widths[index] | |||
|
387 | end | |||
|
388 | end | |||
381 |
|
389 | |||
382 | def GetStringWidth(s) |
|
390 | def GetStringWidth(s) | |
383 | # Get width of a string in the current font |
|
391 | # Get width of a string in the current font | |
384 | cw=@CurrentFont['cw'] |
|
392 | cw=@CurrentFont['cw'] | |
385 | w=0 |
|
393 | w=0 | |
386 | s.each_byte do |c| |
|
394 | s.each_byte do |c| | |
387 |
w=w+cw |
|
395 | w=w+GetCharWidth(cw, c) | |
388 | end |
|
396 | end | |
389 | w*@FontSize/1000.0 |
|
397 | w*@FontSize/1000.0 | |
390 | end |
|
398 | end | |
@@ -707,7 +715,7 class FPDF | |||||
707 | ls=l |
|
715 | ls=l | |
708 | ns=ns+1 |
|
716 | ns=ns+1 | |
709 | end |
|
717 | end | |
710 |
l=l+cw |
|
718 | l=l+GetCharWidth(cw, c[0]) | |
711 | if l>wmax |
|
719 | if l>wmax | |
712 | # Automatic line break |
|
720 | # Automatic line break | |
713 | if sep==-1 |
|
721 | if sep==-1 | |
@@ -786,7 +794,7 class FPDF | |||||
786 | sep=i |
|
794 | sep=i | |
787 | ls=l |
|
795 | ls=l | |
788 | end |
|
796 | end | |
789 |
l=l+cw |
|
797 | l=l+GetCharWidth(cw, c); | |
790 | if l>wmax |
|
798 | if l>wmax | |
791 | # Automatic line break |
|
799 | # Automatic line break | |
792 | if sep==-1 |
|
800 | if sep==-1 | |
@@ -1079,7 +1087,7 class FPDF | |||||
1079 | cw=font['cw'] |
|
1087 | cw=font['cw'] | |
1080 | s='[' |
|
1088 | s='[' | |
1081 | 32.upto(255) do |i| |
|
1089 | 32.upto(255) do |i| | |
1082 |
s << cw |
|
1090 | s << GetCharWidth(cw, i).to_s + ' ' | |
1083 | end |
|
1091 | end | |
1084 | out(s+']') |
|
1092 | out(s+']') | |
1085 | out('endobj') |
|
1093 | out('endobj') |
General Comments 0
You need to be logged in to leave comments.
Login now