]> source.dussan.org Git - redmine.git/commitdiff
PDF: import Korean rfpdf patch for textilized PDF (#69).
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 30 Jun 2011 03:47:56 +0000 (03:47 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 30 Jun 2011 03:47:56 +0000 (03:47 +0000)
Contributed by Jun NAITOH.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6132 e93f8b46-1217-0410-a6f0-8f06a7374b81

vendor/plugins/rfpdf/lib/fpdf/korean.rb

index 11df9ffb0ea604f0082ed59c20bbd10a60147f5c..8fbf129092e40f7cc176ad36f5503fa0a0219641 100644 (file)
@@ -111,15 +111,20 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
        return l*@font_size/1000\r
   end\r
 \r
-  def MultiCell(w,h,txt,border=0,align='L',fill=0)\r
+  def MultiCell(w,h,txt,border=0,align='L',fill=0,ln=1)\r
        if(@current_font['type']=='Type0')\r
-               MBMultiCell(w,h,txt,border,align,fill)\r
+               MBMultiCell(w,h,txt,border,align,fill,ln)\r
        else\r
-               super(w,h,txt,border,align,fill)\r
+               super(w,h,txt,border,align,fill,ln)\r
     end\r
   end\r
 \r
-  def MBMultiCell(w,h,txt,border=0,align='L',fill=0)\r
+  def MBMultiCell(w,h,txt,border=0,align='L',fill=0,ln=1)\r
+\r
+       # save current position\r
+       prevx = @x;\r
+       prevy = @y;\r
+\r
        #Multi-byte version of MultiCell()\r
        cw=@current_font['cw']\r
        if(w==0)\r
@@ -202,18 +207,30 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
                b+='B'\r
     end\r
        Cell(w,h,s[j,i-j],b,2,align,fill)\r
-       @x=@l_margin\r
+\r
+       # move cursor to specified position\r
+       if (ln == 1)\r
+               # go to the beginning of the next line\r
+               @x=@l_margin\r
+       elsif (ln == 0)\r
+               # go to the top-right of the cell\r
+               @y = prevy;\r
+               @x = prevx + w;\r
+       elsif (ln == 2)\r
+               # go to the bottom-left of the cell\r
+               @x = prevx;\r
+    end\r
   end\r
 \r
-  def Write(h,txt,link='')\r
+  def Write(h,txt,link='',fill=0)\r
        if(@current_font['type']=='Type0')\r
-               MBWrite(h,txt,link)\r
+               MBWrite(h,txt,link,fill)\r
        else\r
-               super(h,txt,link)\r
+               super(h,txt,link,fill)\r
     end\r
   end\r
 \r
-  def MBWrite(h,txt,link)\r
+  def MBWrite(h,txt,link,fill=0)\r
        #Multi-byte version of Write()\r
        cw=@current_font['cw']\r
        w=@w-@r_margin-@x\r
@@ -232,7 +249,7 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
                ascii=(c<128)\r
                if(c.chr=="\n")\r
                        #Explicit line break\r
-                       Cell(w,h,s[j,i-j],0,2,'',0,link)\r
+                       Cell(w,h,s[j,i-j],0,2,'',fill,link)\r
                        i+=1\r
                        sep=-1\r
                        j=i\r
@@ -265,9 +282,9 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
                                if(i==j)\r
                                        i+=ascii ? 1 : 2\r
           end\r
-                               Cell(w,h,s[j,i-j],0,2,'',0,link)\r
+                               Cell(w,h,s[j,i-j],0,2,'',fill,link)\r
                        else\r
-                               Cell(w,h,s[j,sep-j],0,2,'',0,link)\r
+                               Cell(w,h,s[j,sep-j],0,2,'',fill,link)\r
                                i=(s[sep].chr==' ') ? sep+1 : sep\r
                        end\r
                        sep=-1\r
@@ -285,7 +302,7 @@ UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 9
        end\r
        #Last chunk\r
        if(i!=j)\r
-               Cell(l/1000*@font_size,h,s[j,i-j],0,0,'',0,link)\r
+               Cell(l*@font_size/1000.0,h,s[j,i-j],0,0,'',fill,link)\r
     end\r
   end\r
 \r