japanese.rb_rfpdf115.patch

Jun NAITOH, 2011-03-27 09:34

Download (2.02 KB)

View differences:

rfpdf/lib/fpdf/japanese.rb 2011-03-23 17:46:19.000000000 -0400
103 103
  		o=s[i]
104 104
  		if(o<128)
105 105
  			#ASCII
106
  			l+=cw[o.chr]
106
  			l+=cw[o.chr] if cw[o.chr]
107 107
  			i+=1
108 108
  		elsif(o>=161 and o<=223)
109 109
  			#Half-width katakana
......
146 146
  			b2='LR'
147 147
  		else
148 148
  			b2=''
149
  			if(border.index('L').nil?)
150
  				b2+='L'
151
      	end  
152
  			if(border.index('R').nil?)
153
  				b2+='R'
154
      	end  
155
  			b=border.index('T').nil? ? b2+'T' : b2
149
  			b2='L' unless border.to_s.index('L').nil?
150
  			b2=b2+'R' unless border.to_s.index('R').nil?
151
  			b=(border.to_s.index('T')) ? (b2+'T') : b2
156 152
  		end
157 153
  	end
158 154
  	sep=-1
......
163 159
  	while(i<nb)
164 160
  		#Get next character
165 161
  		c=s[i]
166
  		o=ord(c)
162
  		o=c #o=ord(c)
167 163
  		if(o==10)
168 164
  			#Explicit line break
169 165
  			Cell(w,h,s[j,i-j],b,2,align,fill)
......
179 175
  		end
180 176
  		if(o<128)
181 177
  			#ASCII
182
  			l+=cw[c.chr]
178
  			l+=cw[c.chr] || 0
183 179
  			n=1
184 180
  			if(o==32)
185 181
  				sep=i
......
204 200
  				Cell(w,h,s[j,i-j],b,2,align,fill)
205 201
  			else
206 202
  				Cell(w,h,s[j,sep-j],b,2,align,fill)
207
  				i=(s[sep]==' ') ? sep+1 : sep
203
  				i=(s[sep].chr==' ') ? sep+1 : sep
208 204
  			end
209 205
  			sep=-1
210 206
  			j=i
......
221 217
  		end
222 218
  	end
223 219
  	#Last chunk
224
  	if(border and not border.index('B').nil?)
220
  	if(border and not border.to_s.index('B').nil?)
225 221
  		b+='B'
226 222
  	end  
227 223
  	Cell(w,h,s[j,i-j],b,2,align,fill)
......
230 226

  
231 227
  def Write(h,txt,link='')
232 228
  	if(@CurrentFont['type']=='Type0')
233
  		SJISWrite(h,txt,link)
234
  	else
235
  		super(h,txt,link)
229
 		SJISWrite(h,txt,link)
230
 	else
231
 		super(h,txt,link)
236 232
  	end  
237 233
  end
238 234

  
......
270 266
  		end
271 267
  		if(o<128)
272 268
  			#ASCII
273
  			l+=cw[c.chr]
269
  			l+=cw[c.chr] || 0
274 270
  			n=1
275 271
  			if(o==32)
276 272
  				sep=i
......
305 301
  				Cell(w,h,s[j,i-j],0,2,'',0,link)
306 302
  			else
307 303
  				Cell(w,h,s[j,sep-j],0,2,'',0,link)
308
  				i=(s[sep]==' ') ? sep+1 : sep
304
  				i=(s[sep].chr==' ') ? sep+1 : sep
309 305
  			end
310 306
  			sep=-1
311 307
  			j=i