PDF: import CJK patches and all languages use TCPDF (#8312).

Contributed Jun NAITOH.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5720 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA committed 2011-05-09 11:12:27 +00:00
1 parent 3b50809423
commit 29f6dd2a9e
5 files changed
+81 -93

No files matched your search

+26 -26
View File
@@ -85,7 +85,7 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
end
def GetStringWidth(s)
if(@CurrentFont['type']=='Type0')
if(@current_font['type']=='Type0')
return GetMBStringWidth(s)
else
return super(s)
@@ -95,7 +95,7 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
def GetMBStringWidth(s)
#Multi-byte version of GetStringWidth()
l=0
cw=@CurrentFont['cw']
cw=@current_font['cw']
nb=s.length
i=0
while(i<nb)
@@ -108,11 +108,11 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
i+=2
end
end
return l*@FontSize/1000
return l*@font_size/1000
end
def MultiCell(w,h,txt,border=0,align='L',fill=0)
if(@CurrentFont['type']=='Type0')
if(@current_font['type']=='Type0')
MBMultiCell(w,h,txt,border,align,fill)
else
super(w,h,txt,border,align,fill)
@@ -121,11 +121,11 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
#Multi-byte version of MultiCell()
cw=@CurrentFont['cw']
cw=@current_font['cw']
if(w==0)
w=@w-@rMargin-@x
w=@w-@r_margin-@x
end
wmax=(w-2*@cMargin)*1000/@FontSize
wmax=(w-2*@c_margin)*1000/@font_size
s=txt.gsub("\r",'')
nb=s.length
if(nb>0 and s[nb-1]=="\n")
@@ -202,11 +202,11 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
b+='B'
end
Cell(w,h,s[j,i-j],b,2,align,fill)
@x=@lMargin
@x=@l_margin
end
def Write(h,txt,link='')
if(@CurrentFont['type']=='Type0')
if(@current_font['type']=='Type0')
MBWrite(h,txt,link)
else
super(h,txt,link)
@@ -215,9 +215,9 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
def MBWrite(h,txt,link)
#Multi-byte version of Write()
cw=@CurrentFont['cw']
w=@w-@rMargin-@x
wmax=(w-2*@cMargin)*1000/@FontSize
cw=@current_font['cw']
w=@w-@r_margin-@x
wmax=(w-2*@c_margin)*1000/@font_size
s=txt.gsub("\r",'')
nb=s.length
sep=-1
@@ -238,9 +238,9 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
j=i
l=0
if(nl==1)
@x=@lMargin
w=@w-@rMargin-@x
wmax=(w-2*@cMargin)*1000/@FontSize
@x=@l_margin
w=@w-@r_margin-@x
wmax=(w-2*@c_margin)*1000/@font_size
end
nl+=1
next
@@ -252,12 +252,12 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
if(l>wmax)
#Automatic line break
if(sep==-1 or i==j)
if(@x>@lMargin)
if(@x>@l_margin)
#Move to next line
@x=@lMargin
@x=@l_margin
@y+=h
w=@w-@rMargin-@x
wmax=(w-2*@cMargin)*1000/@FontSize
w=@w-@r_margin-@x
wmax=(w-2*@c_margin)*1000/@font_size
i+=1
nl+=1
next
@@ -274,9 +274,9 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
j=i
l=0
if(nl==1)
@x=@lMargin
w=@w-@rMargin-@x
wmax=(w-2*@cMargin)*1000/@FontSize
@x=@l_margin
w=@w-@r_margin-@x
wmax=(w-2*@c_margin)*1000/@font_size
end
nl+=1
else
@@ -285,7 +285,7 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
end
#Last chunk
if(i!=j)
Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
Cell(l/1000*@font_size,h,s[j,i-j],0,0,'',0,link)
end
end
@@ -301,10 +301,10 @@ private
end
# mqr=get_magic_quotes_runtime()
# set_magic_quotes_runtime(0)
@FontFiles.each_pair do |file, info|
@font_files.each_pair do |file, info|
#Font file embedding
newobj()
@FontFiles[file]['n']=@n
@font_files[file]['n']=@n
if(defined('FPDF_FONTPATH'))
file=FPDF_FONTPATH+file
end
@@ -378,7 +378,7 @@ private
end
file=font['file']
if(file)
s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@FontFiles[file]['n']+' 0 R'
s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@font_files[file]['n']+' 0 R'
end
out(s+'>>')
out('endobj')