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