ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

patch

patch to fix bug of generating cjk pdf - Yu-Chun Huang, 2012-03-29 08:35 am

Download (3.1 kB)

 
1
diff --git a/files/delete.me b/files/delete.me
2
old mode 100644
3
new mode 100755
4
diff --git a/log/delete.me b/log/delete.me
5
old mode 100644
6
new mode 100755
7
diff --git a/tmp/test/empty b/tmp/test/empty
8
old mode 100644
9
new mode 100755
10
diff --git a/vendor/plugins/rfpdf/lib/fpdf/chinese.rb b/vendor/plugins/rfpdf/lib/fpdf/chinese.rb
11
index 5cdb0da..a9a222a 100644
12
--- a/vendor/plugins/rfpdf/lib/fpdf/chinese.rb
13
+++ b/vendor/plugins/rfpdf/lib/fpdf/chinese.rb
14
@@ -132,7 +132,7 @@ module PDF_Chinese
15
   	i=0
16
   	while(i<nb)
17
   		c=s[i]
18
-  		if(c<128)
19
+  		if(c.to_i<128)
20
   			l+=cw[c.chr] if cw[c.chr]
21
   			i+=1
22
   		else
23
@@ -185,7 +185,7 @@ module PDF_Chinese
24
   		#Get next character
25
   		c=s[i]
26
   		#Check if ASCII or MB
27
-  		ascii=(c<128)
28
+  		ascii=(c.to_i<128)
29
   		if(c.chr=="\n")
30
   			#Explicit line break
31
   			Cell(w,h,s[j,i-j],b,2,align,fill)
32
@@ -261,7 +261,7 @@ module PDF_Chinese
33
   		#Get next character
34
   		c=s[i]
35
   		#Check if ASCII or MB
36
-  		ascii=(c<128)
37
+  		ascii=(c.to_i<128)
38
   		if(c.chr=="\n")
39
   			#Explicit line break
40
   			Cell(w,h,s[j,i-j],0,2,'',0,link)
41
diff --git a/vendor/plugins/rfpdf/lib/fpdf/japanese.rb b/vendor/plugins/rfpdf/lib/fpdf/japanese.rb
42
index 8fce75f..72d3672 100644
43
--- a/vendor/plugins/rfpdf/lib/fpdf/japanese.rb
44
+++ b/vendor/plugins/rfpdf/lib/fpdf/japanese.rb
45
@@ -102,7 +102,7 @@ module PDF_Japanese
46
   	i=0
47
   	while(i<nb)
48
   		o=s[i]
49
-  		if(o<128)
50
+  		if(o.to_i<128)
51
   			#ASCII
52
   			l+=cw[o.chr] if cw[o.chr]
53
   			i+=1
54
@@ -174,7 +174,7 @@ module PDF_Japanese
55
       	end  
56
   			next
57
   		end
58
-  		if(o<128)
59
+  		if(o.to_i<128)
60
   			#ASCII
61
   			l+=cw[c.chr] || 0
62
   			n=1
63
@@ -212,7 +212,7 @@ module PDF_Japanese
64
       	end  
65
   		else
66
   			i+=n
67
-  			if(o>=128)
68
+  			if(o.to_i>=128)
69
   				sep=i
70
   			end
71
   		end
72
@@ -265,7 +265,7 @@ module PDF_Japanese
73
   			nl+=1
74
   			next
75
   		end
76
-  		if(o<128)
77
+  		if(o.to_i<128)
78
   			#ASCII
79
   			l+=cw[c.chr] || 0
80
   			n=1
81
@@ -315,7 +315,7 @@ module PDF_Japanese
82
   			nl+=1
83
   		else
84
   			i+=n
85
-  			if(o>=128)
86
+  			if(o.to_i>=128)
87
   				sep=i
88
       	end  
89
   		end
90
diff --git a/vendor/plugins/rfpdf/lib/fpdf/makefont.rb b/vendor/plugins/rfpdf/lib/fpdf/makefont.rb
91
index 91aa69d..8900deb 100644
92
--- a/vendor/plugins/rfpdf/lib/fpdf/makefont.rb
93
+++ b/vendor/plugins/rfpdf/lib/fpdf/makefont.rb
94
@@ -1721,7 +1721,7 @@ def MakeFont(fontfile, afmfile, enc = 'cp1252', patch = {}, type = 'TrueType')
95
 
96
         if type == 'Type1' then
97
             # Find first two sections and discard third one
98
-            header = file[0] == 128
99
+            header = file[0].to_i == 128
100
             file = file[6, file.length - 6] if header
101
 
102
             pos = file.index('eexec')
103
@@ -1729,7 +1729,7 @@ def MakeFont(fontfile, afmfile, enc = 'cp1252', patch = {}, type = 'TrueType')
104
 
105
             size1 = pos + 6
106
 
107
-            file = file[0, size1] + file[size1 + 6, file.length - (size1 + 6)] if header && file[size1] == 128
108
+            file = file[0, size1] + file[size1 + 6, file.length - (size1 + 6)] if header && file[size1].to_i == 128
109
 
110
             pos = file.index('00000000')
111
             raise 'Error: font file does not seem to be valid Type1' if pos == nil