Chris@909
|
1 # Copyright (c) 2006 4ssoM LLC <www.4ssoM.com>
|
Chris@909
|
2 # 1.12 contributed by Ed Moss.
|
Chris@909
|
3 #
|
Chris@909
|
4 # The MIT License
|
Chris@909
|
5 #
|
Chris@909
|
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
|
Chris@909
|
7 # of this software and associated documentation files (the "Software"), to deal
|
Chris@909
|
8 # in the Software without restriction, including without limitation the rights
|
Chris@909
|
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
Chris@909
|
10 # copies of the Software, and to permit persons to whom the Software is
|
Chris@909
|
11 # furnished to do so, subject to the following conditions:
|
Chris@909
|
12 #
|
Chris@909
|
13 # The above copyright notice and this permission notice shall be included in
|
Chris@909
|
14 # all copies or substantial portions of the Software.
|
Chris@909
|
15 #
|
Chris@909
|
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
Chris@909
|
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
Chris@909
|
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
Chris@909
|
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
Chris@909
|
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
Chris@909
|
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
Chris@909
|
22 # THE SOFTWARE.
|
Chris@909
|
23 #
|
Chris@909
|
24 # This is direct port of korean.php
|
Chris@909
|
25 #
|
Chris@909
|
26 # Korean PDF support.
|
Chris@909
|
27 #
|
Chris@909
|
28 # Usage is as follows:
|
Chris@909
|
29 #
|
Chris@909
|
30 # require 'fpdf'
|
Chris@909
|
31 # require 'chinese'
|
Chris@909
|
32 # pdf = FPDF.new
|
Chris@909
|
33 # pdf.extend(PDF_Korean)
|
Chris@909
|
34 #
|
Chris@909
|
35 # This allows it to be combined with other extensions, such as the bookmark
|
Chris@909
|
36 # module.
|
Chris@909
|
37
|
Chris@909
|
38 module PDF_Korean
|
Chris@909
|
39
|
Chris@909
|
40 UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 916, '&' => 833, '\'' => 250,
|
Chris@909
|
41 '(' => 500, ')' => 500, '*' => 500, '+' => 833, ',' => 291, '-' => 833, '.' => 291, '/' => 375, '0' => 625, '1' => 625,
|
Chris@909
|
42 '2' => 625, '3' => 625, '4' => 625, '5' => 625, '6' => 625, '7' => 625, '8' => 625, '9' => 625, ':' => 333, ';' => 333,
|
Chris@909
|
43 '<' => 833, '=' => 833, '>' => 916, '?' => 500, '@' => 1000, 'A' => 791, 'B' => 708, 'C' => 708, 'D' => 750, 'E' => 708,
|
Chris@909
|
44 'F' => 666, 'G' => 750, 'H' => 791, 'I' => 375, 'J' => 500, 'K' => 791, 'L' => 666, 'M' => 916, 'N' => 791, 'O' => 750,
|
Chris@909
|
45 'P' => 666, 'Q' => 750, 'R' => 708, 'S' => 666, 'T' => 791, 'U' => 791, 'V' => 750, 'W' => 1000, 'X' => 708, 'Y' => 708,
|
Chris@909
|
46 'Z' => 666, '[' => 500, '\\' => 375, ']' => 500, '^' => 500, '_' => 500, '`' => 333, 'a' => 541, 'b' => 583, 'c' => 541,
|
Chris@909
|
47 'd' => 583, 'e' => 583, 'f' => 375, 'g' => 583, 'h' => 583, 'i' => 291, 'j' => 333, 'k' => 583, 'l' => 291, 'm' => 875,
|
Chris@909
|
48 'n' => 583, 'o' => 583, 'p' => 583, 'q' => 583, 'r' => 458, 's' => 541, 't' => 375, 'u' => 583, 'v' => 583, 'w' => 833,
|
Chris@909
|
49 'x' => 625, 'y' => 625, 'z' => 500, '{' => 583, '|' => 583, '}' => 583, '~' => 750}
|
Chris@909
|
50
|
Chris@909
|
51 def AddCIDFont(family,style,name,cw,cMap,registry)
|
Chris@909
|
52 fontkey=family.downcase+style.upcase
|
Chris@909
|
53 unless @fonts[fontkey].nil?
|
Chris@909
|
54 Error("Font already added: family style")
|
Chris@909
|
55 end
|
Chris@909
|
56 i=@fonts.length+1
|
Chris@909
|
57 name=name.gsub(' ','')
|
Chris@909
|
58 @fonts[fontkey]={'i'=>i,'type'=>'Type0','name'=>name,'up'=>-130,'ut'=>40,'cw'=>cw,
|
Chris@909
|
59 'CMap'=>cMap,'registry'=>registry}
|
Chris@909
|
60 end
|
Chris@909
|
61
|
Chris@909
|
62 def AddCIDFonts(family,name,cw,cMap,registry)
|
Chris@909
|
63 AddCIDFont(family,'',name,cw,cMap,registry)
|
Chris@909
|
64 AddCIDFont(family,'B',name+',Bold',cw,cMap,registry)
|
Chris@909
|
65 AddCIDFont(family,'I',name+',Italic',cw,cMap,registry)
|
Chris@909
|
66 AddCIDFont(family,'BI',name+',BoldItalic',cw,cMap,registry)
|
Chris@909
|
67 end
|
Chris@909
|
68
|
Chris@909
|
69 def AddUHCFont(family='UHC',name='HYSMyeongJoStd-Medium-Acro')
|
Chris@909
|
70 #Add UHC font with proportional Latin
|
Chris@909
|
71 cw=UHC_widths
|
Chris@909
|
72 cMap='KSCms-UHC-H'
|
Chris@909
|
73 registry={'ordering'=>'Korea1','supplement'=>1}
|
Chris@909
|
74 AddCIDFonts(family,name,cw,cMap,registry)
|
Chris@909
|
75 end
|
Chris@909
|
76
|
Chris@909
|
77 def AddUHChwFont(family='UHC-hw',name='HYSMyeongJoStd-Medium-Acro')
|
Chris@909
|
78 #Add UHC font with half-witdh Latin
|
Chris@909
|
79 32.upto(126) do |i|
|
Chris@909
|
80 cw[i.chr]=500
|
Chris@909
|
81 end
|
Chris@909
|
82 cMap='KSCms-UHC-HW-H'
|
Chris@909
|
83 registry={'ordering'=>'Korea1','supplement'=>1}
|
Chris@909
|
84 AddCIDFonts(family,name,cw,cMap,registry)
|
Chris@909
|
85 end
|
Chris@909
|
86
|
Chris@909
|
87 def GetStringWidth(s)
|
Chris@909
|
88 if(@current_font['type']=='Type0')
|
Chris@909
|
89 return GetMBStringWidth(s)
|
Chris@909
|
90 else
|
Chris@909
|
91 return super(s)
|
Chris@909
|
92 end
|
Chris@909
|
93 end
|
Chris@909
|
94
|
Chris@909
|
95 def GetMBStringWidth(s)
|
Chris@909
|
96 #Multi-byte version of GetStringWidth()
|
Chris@909
|
97 l=0
|
Chris@909
|
98 cw=@current_font['cw']
|
Chris@909
|
99 nb=s.length
|
Chris@909
|
100 i=0
|
Chris@909
|
101 while(i<nb)
|
Chris@909
|
102 c = s[i].is_a?(String) ? s[i].ord : s[i]
|
Chris@909
|
103 if(c<128)
|
Chris@909
|
104 l+=cw[c.chr] if cw[c.chr]
|
Chris@909
|
105 i+=1
|
Chris@909
|
106 else
|
Chris@909
|
107 l+=1000
|
Chris@909
|
108 i+=2
|
Chris@909
|
109 end
|
Chris@909
|
110 end
|
Chris@909
|
111 return l*@font_size/1000
|
Chris@909
|
112 end
|
Chris@909
|
113
|
Chris@909
|
114 def MultiCell(w,h,txt,border=0,align='L',fill=0,ln=1)
|
Chris@909
|
115 if(@current_font['type']=='Type0')
|
Chris@909
|
116 MBMultiCell(w,h,txt,border,align,fill,ln)
|
Chris@909
|
117 else
|
Chris@909
|
118 super(w,h,txt,border,align,fill,ln)
|
Chris@909
|
119 end
|
Chris@909
|
120 end
|
Chris@909
|
121
|
Chris@909
|
122 def MBMultiCell(w,h,txt,border=0,align='L',fill=0,ln=1)
|
Chris@909
|
123
|
Chris@909
|
124 # save current position
|
Chris@909
|
125 prevx = @x;
|
Chris@909
|
126 prevy = @y;
|
Chris@909
|
127
|
Chris@909
|
128 #Multi-byte version of MultiCell()
|
Chris@909
|
129 cw=@current_font['cw']
|
Chris@909
|
130 if(w==0)
|
Chris@909
|
131 w=@w-@r_margin-@x
|
Chris@909
|
132 end
|
Chris@909
|
133 wmax=(w-2*@c_margin)*1000/@font_size
|
Chris@909
|
134 s=txt.gsub("\r",'')
|
Chris@909
|
135 nb=s.length
|
Chris@909
|
136 if(nb>0 and s[nb-1]=="\n")
|
Chris@909
|
137 nb-=1
|
Chris@909
|
138 end
|
Chris@909
|
139 b=0
|
Chris@909
|
140 if(border)
|
Chris@909
|
141 if(border==1)
|
Chris@909
|
142 border='LTRB'
|
Chris@909
|
143 b='LRT'
|
Chris@909
|
144 b2='LR'
|
Chris@909
|
145 else
|
Chris@909
|
146 b2=''
|
Chris@909
|
147 b2='L' unless border.to_s.index('L').nil?
|
Chris@909
|
148 b2=b2+'R' unless border.to_s.index('R').nil?
|
Chris@909
|
149 b=(border.to_s.index('T')) ? (b2+'T') : b2
|
Chris@909
|
150 end
|
Chris@909
|
151 end
|
Chris@909
|
152 sep=-1
|
Chris@909
|
153 i=0
|
Chris@909
|
154 j=0
|
Chris@909
|
155 l=0
|
Chris@909
|
156 nl=1
|
Chris@909
|
157 while(i<nb)
|
Chris@909
|
158 #Get next character
|
Chris@909
|
159 c = s[i].is_a?(String) ? s[i].ord : s[i]
|
Chris@909
|
160 #Check if ASCII or MB
|
Chris@909
|
161 ascii=(c<128)
|
Chris@909
|
162 if(c.chr=="\n")
|
Chris@909
|
163 #Explicit line break
|
Chris@909
|
164 Cell(w,h,s[j,i-j],b,2,align,fill)
|
Chris@909
|
165 i+=1
|
Chris@909
|
166 sep=-1
|
Chris@909
|
167 j=i
|
Chris@909
|
168 l=0
|
Chris@909
|
169 nl+=1
|
Chris@909
|
170 if(border and nl==2)
|
Chris@909
|
171 b=b2
|
Chris@909
|
172 end
|
Chris@909
|
173 next
|
Chris@909
|
174 end
|
Chris@909
|
175 if(!ascii)
|
Chris@909
|
176 sep=i
|
Chris@909
|
177 ls=l
|
Chris@909
|
178 elsif(c.chr==' ')
|
Chris@909
|
179 sep=i
|
Chris@909
|
180 ls=l
|
Chris@909
|
181 end
|
Chris@909
|
182 l+=(ascii ? cw[c.chr] : 1000) || 0
|
Chris@909
|
183 if(l>wmax)
|
Chris@909
|
184 #Automatic line break
|
Chris@909
|
185 if(sep==-1 or i==j)
|
Chris@909
|
186 if(i==j)
|
Chris@909
|
187 i+=ascii ? 1 : 2
|
Chris@909
|
188 end
|
Chris@909
|
189 Cell(w,h,s[j,i-j],b,2,align,fill)
|
Chris@909
|
190 else
|
Chris@909
|
191 Cell(w,h,s[j,sep-j],b,2,align,fill)
|
Chris@909
|
192 i=(s[sep].chr==' ') ? sep+1 : sep
|
Chris@909
|
193 end
|
Chris@909
|
194 sep=-1
|
Chris@909
|
195 j=i
|
Chris@909
|
196 l=0
|
Chris@909
|
197 nl+=1
|
Chris@909
|
198 if(border and nl==2)
|
Chris@909
|
199 b=b2
|
Chris@909
|
200 end
|
Chris@909
|
201 else
|
Chris@909
|
202 i+=ascii ? 1 : 2
|
Chris@909
|
203 end
|
Chris@909
|
204 end
|
Chris@909
|
205 #Last chunk
|
Chris@909
|
206 if(border and not border.to_s.index('B').nil?)
|
Chris@909
|
207 b+='B'
|
Chris@909
|
208 end
|
Chris@909
|
209 Cell(w,h,s[j,i-j],b,2,align,fill)
|
Chris@909
|
210
|
Chris@909
|
211 # move cursor to specified position
|
Chris@909
|
212 if (ln == 1)
|
Chris@909
|
213 # go to the beginning of the next line
|
Chris@909
|
214 @x=@l_margin
|
Chris@909
|
215 elsif (ln == 0)
|
Chris@909
|
216 # go to the top-right of the cell
|
Chris@909
|
217 @y = prevy;
|
Chris@909
|
218 @x = prevx + w;
|
Chris@909
|
219 elsif (ln == 2)
|
Chris@909
|
220 # go to the bottom-left of the cell
|
Chris@909
|
221 @x = prevx;
|
Chris@909
|
222 end
|
Chris@909
|
223 end
|
Chris@909
|
224
|
Chris@909
|
225 def Write(h,txt,link='',fill=0)
|
Chris@909
|
226 if(@current_font['type']=='Type0')
|
Chris@909
|
227 MBWrite(h,txt,link,fill)
|
Chris@909
|
228 else
|
Chris@909
|
229 super(h,txt,link,fill)
|
Chris@909
|
230 end
|
Chris@909
|
231 end
|
Chris@909
|
232
|
Chris@909
|
233 def MBWrite(h,txt,link,fill=0)
|
Chris@909
|
234 #Multi-byte version of Write()
|
Chris@909
|
235 cw=@current_font['cw']
|
Chris@909
|
236 w=@w-@r_margin-@x
|
Chris@909
|
237 wmax=(w-2*@c_margin)*1000/@font_size
|
Chris@909
|
238 s=txt.gsub("\r",'')
|
Chris@909
|
239 nb=s.length
|
Chris@909
|
240 sep=-1
|
Chris@909
|
241 i=0
|
Chris@909
|
242 j=0
|
Chris@909
|
243 l=0
|
Chris@909
|
244 nl=1
|
Chris@909
|
245 while(i<nb)
|
Chris@909
|
246 #Get next character
|
Chris@909
|
247 c = s[i].is_a?(String) ? s[i].ord : s[i]
|
Chris@909
|
248 #Check if ASCII or MB
|
Chris@909
|
249 ascii=(c<128)
|
Chris@909
|
250 if(c.chr=="\n")
|
Chris@909
|
251 #Explicit line break
|
Chris@909
|
252 Cell(w,h,s[j,i-j],0,2,'',fill,link)
|
Chris@909
|
253 i+=1
|
Chris@909
|
254 sep=-1
|
Chris@909
|
255 j=i
|
Chris@909
|
256 l=0
|
Chris@909
|
257 if(nl==1)
|
Chris@909
|
258 @x=@l_margin
|
Chris@909
|
259 w=@w-@r_margin-@x
|
Chris@909
|
260 wmax=(w-2*@c_margin)*1000/@font_size
|
Chris@909
|
261 end
|
Chris@909
|
262 nl+=1
|
Chris@909
|
263 next
|
Chris@909
|
264 end
|
Chris@909
|
265 if(!ascii or c.chr==' ')
|
Chris@909
|
266 sep=i
|
Chris@909
|
267 end
|
Chris@909
|
268 l+=(ascii ? cw[c.chr] : 1000) || 0
|
Chris@909
|
269 if(l>wmax)
|
Chris@909
|
270 #Automatic line break
|
Chris@909
|
271 if(sep==-1 or i==j)
|
Chris@909
|
272 if(@x>@l_margin)
|
Chris@909
|
273 #Move to next line
|
Chris@909
|
274 @x=@l_margin
|
Chris@909
|
275 @y+=h
|
Chris@909
|
276 w=@w-@r_margin-@x
|
Chris@909
|
277 wmax=(w-2*@c_margin)*1000/@font_size
|
Chris@909
|
278 i+=1
|
Chris@909
|
279 nl+=1
|
Chris@909
|
280 next
|
Chris@909
|
281 end
|
Chris@909
|
282 if(i==j)
|
Chris@909
|
283 i+=ascii ? 1 : 2
|
Chris@909
|
284 end
|
Chris@909
|
285 Cell(w,h,s[j,i-j],0,2,'',fill,link)
|
Chris@909
|
286 else
|
Chris@909
|
287 Cell(w,h,s[j,sep-j],0,2,'',fill,link)
|
Chris@909
|
288 i=(s[sep].chr==' ') ? sep+1 : sep
|
Chris@909
|
289 end
|
Chris@909
|
290 sep=-1
|
Chris@909
|
291 j=i
|
Chris@909
|
292 l=0
|
Chris@909
|
293 if(nl==1)
|
Chris@909
|
294 @x=@l_margin
|
Chris@909
|
295 w=@w-@r_margin-@x
|
Chris@909
|
296 wmax=(w-2*@c_margin)*1000/@font_size
|
Chris@909
|
297 end
|
Chris@909
|
298 nl+=1
|
Chris@909
|
299 else
|
Chris@909
|
300 i+=ascii ? 1 : 2
|
Chris@909
|
301 end
|
Chris@909
|
302 end
|
Chris@909
|
303 #Last chunk
|
Chris@909
|
304 if(i!=j)
|
Chris@909
|
305 Cell(l*@font_size/1000.0,h,s[j,i-j],0,0,'',fill,link)
|
Chris@909
|
306 end
|
Chris@909
|
307 end
|
Chris@909
|
308
|
Chris@909
|
309 private
|
Chris@909
|
310
|
Chris@909
|
311 def putfonts()
|
Chris@909
|
312 nf=@n
|
Chris@909
|
313 @diffs.each do |diff|
|
Chris@909
|
314 #Encodings
|
Chris@909
|
315 newobj()
|
Chris@909
|
316 out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['+diff+']>>')
|
Chris@909
|
317 out('endobj')
|
Chris@909
|
318 end
|
Chris@909
|
319 # mqr=get_magic_quotes_runtime()
|
Chris@909
|
320 # set_magic_quotes_runtime(0)
|
Chris@909
|
321 @font_files.each_pair do |file, info|
|
Chris@909
|
322 #Font file embedding
|
Chris@909
|
323 newobj()
|
Chris@909
|
324 @font_files[file]['n']=@n
|
Chris@909
|
325 if(defined('FPDF_FONTPATH'))
|
Chris@909
|
326 file=FPDF_FONTPATH+file
|
Chris@909
|
327 end
|
Chris@909
|
328 size=filesize(file)
|
Chris@909
|
329 if(!size)
|
Chris@909
|
330 Error('Font file not found')
|
Chris@909
|
331 end
|
Chris@909
|
332 out('<</Length '+size)
|
Chris@909
|
333 if(file[-2]=='.z')
|
Chris@909
|
334 out('/Filter /FlateDecode')
|
Chris@909
|
335 end
|
Chris@909
|
336 out('/Length1 '+info['length1'])
|
Chris@909
|
337 if(not info['length2'].nil?)
|
Chris@909
|
338 out('/Length2 '+info['length2']+' /Length3 0')
|
Chris@909
|
339 end
|
Chris@909
|
340 out('>>')
|
Chris@909
|
341 f=fopen(file,'rb')
|
Chris@909
|
342 putstream(fread(f,size))
|
Chris@909
|
343 fclose(f)
|
Chris@909
|
344 out('endobj')
|
Chris@909
|
345 end
|
Chris@909
|
346 # set_magic_quotes_runtime(mqr)
|
Chris@909
|
347 @fonts.each_pair do |k, font|
|
Chris@909
|
348 #Font objects
|
Chris@909
|
349 newobj()
|
Chris@909
|
350 @fonts[k]['n']=@n
|
Chris@909
|
351 out('<</Type /Font')
|
Chris@909
|
352 if(font['type']=='Type0')
|
Chris@909
|
353 putType0(font)
|
Chris@909
|
354 else
|
Chris@909
|
355 name=font['name']
|
Chris@909
|
356 out('/BaseFont /'+name)
|
Chris@909
|
357 if(font['type']=='core')
|
Chris@909
|
358 #Standard font
|
Chris@909
|
359 out('/Subtype /Type1')
|
Chris@909
|
360 if(name!='Symbol' and name!='ZapfDingbats')
|
Chris@909
|
361 out('/Encoding /WinAnsiEncoding')
|
Chris@909
|
362 end
|
Chris@909
|
363 else
|
Chris@909
|
364 #Additional font
|
Chris@909
|
365 out('/Subtype /'+font['type'])
|
Chris@909
|
366 out('/FirstChar 32')
|
Chris@909
|
367 out('/LastChar 255')
|
Chris@909
|
368 out('/Widths '+(@n+1)+' 0 R')
|
Chris@909
|
369 out('/FontDescriptor '+(@n+2)+' 0 R')
|
Chris@909
|
370 if(font['enc'])
|
Chris@909
|
371 if(not font['diff'].nil?)
|
Chris@909
|
372 out('/Encoding '+(nf+font['diff'])+' 0 R')
|
Chris@909
|
373 else
|
Chris@909
|
374 out('/Encoding /WinAnsiEncoding')
|
Chris@909
|
375 end
|
Chris@909
|
376 end
|
Chris@909
|
377 end
|
Chris@909
|
378 out('>>')
|
Chris@909
|
379 out('endobj')
|
Chris@909
|
380 if(font['type']!='core')
|
Chris@909
|
381 #Widths
|
Chris@909
|
382 newobj()
|
Chris@909
|
383 cw=font['cw']
|
Chris@909
|
384 s='['
|
Chris@909
|
385 32.upto(255) do |i|
|
Chris@909
|
386 s+=cw[i.chr]+' '
|
Chris@909
|
387 end
|
Chris@909
|
388 out(s+']')
|
Chris@909
|
389 out('endobj')
|
Chris@909
|
390 #Descriptor
|
Chris@909
|
391 newobj()
|
Chris@909
|
392 s='<</Type /FontDescriptor /FontName /'+name
|
Chris@909
|
393 font['desc'].each_pair do |k, v|
|
Chris@909
|
394 s+=' /'+k+' '+v
|
Chris@909
|
395 end
|
Chris@909
|
396 file=font['file']
|
Chris@909
|
397 if(file)
|
Chris@909
|
398 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@font_files[file]['n']+' 0 R'
|
Chris@909
|
399 end
|
Chris@909
|
400 out(s+'>>')
|
Chris@909
|
401 out('endobj')
|
Chris@909
|
402 end
|
Chris@909
|
403 end
|
Chris@909
|
404 end
|
Chris@909
|
405 end
|
Chris@909
|
406
|
Chris@909
|
407 def putType0(font)
|
Chris@909
|
408 #Type0
|
Chris@909
|
409 out('/Subtype /Type0')
|
Chris@909
|
410 out('/BaseFont /'+font['name']+'-'+font['CMap'])
|
Chris@909
|
411 out('/Encoding /'+font['CMap'])
|
Chris@909
|
412 out('/DescendantFonts ['+(@n+1).to_s+' 0 R]')
|
Chris@909
|
413 out('>>')
|
Chris@909
|
414 out('endobj')
|
Chris@909
|
415 #CIDFont
|
Chris@909
|
416 newobj()
|
Chris@909
|
417 out('<</Type /Font')
|
Chris@909
|
418 out('/Subtype /CIDFontType0')
|
Chris@909
|
419 out('/BaseFont /'+font['name'])
|
Chris@909
|
420 out('/CIDSystemInfo <</Registry (Adobe) /Ordering ('+font['registry']['ordering']+') /Supplement '+font['registry']['supplement'].to_s+'>>')
|
Chris@909
|
421 out('/FontDescriptor '+(@n+1).to_s+' 0 R')
|
Chris@909
|
422 if(font['CMap']=='KSCms-UHC-HW-H')
|
Chris@909
|
423 w='8094 8190 500'
|
Chris@909
|
424 else
|
Chris@909
|
425 w='1 ['
|
Chris@909
|
426 font['cw'].keys.sort.each {|key|
|
Chris@909
|
427 w+=font['cw'][key].to_s + " "
|
Chris@909
|
428 # ActionController::Base::logger.debug key.to_s
|
Chris@909
|
429 # ActionController::Base::logger.debug font['cw'][key].to_s
|
Chris@909
|
430 }
|
Chris@909
|
431 w +=']'
|
Chris@909
|
432 end
|
Chris@909
|
433 out('/W ['+w+']>>')
|
Chris@909
|
434 out('endobj')
|
Chris@909
|
435 #Font descriptor
|
Chris@909
|
436 newobj()
|
Chris@909
|
437 out('<</Type /FontDescriptor')
|
Chris@909
|
438 out('/FontName /'+font['name'])
|
Chris@909
|
439 out('/Flags 6')
|
Chris@909
|
440 out('/FontBBox [0 -200 1000 900]')
|
Chris@909
|
441 out('/ItalicAngle 0')
|
Chris@909
|
442 out('/Ascent 800')
|
Chris@909
|
443 out('/Descent -200')
|
Chris@909
|
444 out('/CapHeight 800')
|
Chris@909
|
445 out('/StemV 50')
|
Chris@909
|
446 out('>>')
|
Chris@909
|
447 out('endobj')
|
Chris@909
|
448 end
|
Chris@909
|
449 end
|