##// END OF EJS Templates
Added chinese simplified translation (Andy Wu)...
Jean-Philippe Lang -
r390:2a00565bc445
parent child
Show More
@@ -0,0 +1,6
1 <%= @added_to %>
2 <%= @attachments.size %> files(s) added.
3 <% @attachments.each do |attachment | %>
4 - <%= attachment.filename %><% end %>
5
6 <%= @url %> No newline at end of file
@@ -0,0 +1,4
1 A document has been added to <%= @document.project.name %> (<%= @document.category.name %>):
2 <%= l(:field_title) %>: <%= @document.title %>
3
4 http://<%= Setting.host_name %>/documents/show/<%= @document.id %> No newline at end of file
@@ -0,0 +1,3
1 Issue #<%= @issue.id %> has been reported.
2 ----------------------------------------
3 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file
@@ -0,0 +1,8
1 Issue #<%= @issue.id %> has been updated.
2 <%= @journal.user.name %>
3 <% for detail in @journal.details %>
4 <%= show_detail(detail, true) %>
5 <% end %>
6 <%= @journal.notes if @journal.notes? %>
7 ----------------------------------------
8 <%= render :file => "_issue", :use_full_path => true, :locals => { :issue => @issue } %> No newline at end of file
@@ -0,0 +1,3
1 To change your password, use the following link:
2
3 http://<%= Setting.host_name %>/account/lost_password?token=<%= @token.value %> No newline at end of file
@@ -0,0 +1,3
1 To activate your redMine account, use the following link:
2
3 http://<%= Setting.host_name %>/account/register?token=<%= @token.value %> No newline at end of file
@@ -0,0 +1,424
1 # translated by andy wu
2 # email:andywu.zh@gmail.com
3
4 _gloc_rule_default: '|n| n==1 ? "" : "_plural" '
5
6 actionview_datehelper_select_day_prefix:
7 actionview_datehelper_select_month_names: 一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月
8 actionview_datehelper_select_month_names_abbr: 一,二,三,四,五,六,七,八,九,十,十一,十二
9 actionview_datehelper_select_month_prefix:
10 actionview_datehelper_select_year_prefix:
11 actionview_datehelper_time_in_words_day: 1 天
12 actionview_datehelper_time_in_words_day_plural: %d 天
13 actionview_datehelper_time_in_words_hour_about: 约1小时
14 actionview_datehelper_time_in_words_hour_about_plural: 约 %d 小时
15 actionview_datehelper_time_in_words_hour_about_single: 约1小时
16 actionview_datehelper_time_in_words_minute: 1分钟
17 actionview_datehelper_time_in_words_minute_half: 半分钟
18 actionview_datehelper_time_in_words_minute_less_than: 1分钟以内
19 actionview_datehelper_time_in_words_minute_plural: %d 分钟
20 actionview_datehelper_time_in_words_minute_single: 1分钟
21 actionview_datehelper_time_in_words_second_less_than: 1秒以内
22 actionview_datehelper_time_in_words_second_less_than_plural: %d 秒以内
23 actionview_instancetag_blank_option: 请选择
24
25 activerecord_error_inclusion: 未包含在列表中
26 activerecord_error_exclusion: 保留的
27 activerecord_error_invalid: 无效的
28 activerecord_error_confirmation: 和确认输入不匹配
29 activerecord_error_accepted: 必需被接受
30 activerecord_error_empty: 不能为空
31 activerecord_error_blank: 不能是空格
32 activerecord_error_too_long: 太长
33 activerecord_error_too_short: 太短
34 activerecord_error_wrong_length: 长度有问题
35 activerecord_error_taken: has already been taken
36 activerecord_error_not_a_number: 不是数字
37 activerecord_error_not_a_date: 不是有效的日期
38 activerecord_error_greater_than_start_date: 必需大于开始日期
39
40 general_fmt_age: %d yr
41 general_fmt_age_plural: %d yrs
42 general_fmt_date: %%m/%%d/%%Y
43 general_fmt_datetime: %%m/%%d/%%Y %%I:%%M %%p
44 general_fmt_datetime_short: %%b %%d, %%I:%%M %%p
45 general_fmt_time: %%I:%%M %%p
46 general_text_No: '否'
47 general_text_Yes: '是'
48 general_text_no: '否'
49 general_text_yes: '是'
50 general_lang_zh: 'Chinese (简体中文)'
51 general_csv_separator: ','
52 general_csv_encoding: gb2312
53 general_pdf_encoding: Big5
54 general_day_names: 一,二,三,四,五,六,日
55
56 notice_account_updated: 帐户更新成功。
57 notice_account_invalid_creditentials: 用户名或密码不正确
58 notice_account_password_updated: 成功更新口令
59 notice_account_wrong_password: 错误的口令
60 notice_account_register_done: 帐户已创建成功
61 notice_account_unknown_email: 未知用户
62 notice_can_t_change_password: 该帐户使用了外部认证。无法更改口令。
63 notice_account_lost_email_sent: 邮件已被发送,邮件中有关于选择新口令的指导
64 notice_account_activated: 您的帐号已被激活。您现在可以登录了。
65 notice_successful_create: 创建成功
66 notice_successful_update: 更新成功
67 notice_successful_delete: 删除成功
68 notice_successful_connection: 连接成功
69 notice_file_not_found: 您访问的页面不存在或已被删除。
70 notice_locking_conflict: 数据已被另一个用户更新
71 notice_scm_error: 在版本库中不存在该条目或修订
72
73 mail_subject_lost_password: 您的redMine口令
74 mail_subject_register: redMine帐户激活
75
76 gui_validation_error: 1 个错误
77 gui_validation_error_plural: %d 个错误
78
79 field_name: 名称
80 field_description: 描述
81 field_summary: 摘要
82 field_is_required: 必填
83 field_firstname: 名字
84 field_lastname:
85 field_mail: 邮件地址
86 field_filename: 文件
87 field_filesize: 大小
88 field_downloads: 下载次数
89 field_author: 作者
90 field_created_on: 创建于
91 field_updated_on: 更新于
92 field_field_format: 格式
93 field_is_for_all: 应用于所有项目
94 field_possible_values: 可能的值
95 field_regexp: 正则表达式
96 field_min_length: 最小长度
97 field_max_length: 最大长度
98 field_value:
99 field_category: 分类
100 field_title: 标题
101 field_project: 项目
102 field_issue: 任务
103 field_status: 状态
104 field_notes: 说明
105 field_is_closed: 已关闭的任务
106 field_is_default: 默认状态
107 field_html_color: 颜色
108 field_tracker: 跟踪
109 field_subject: 主题
110 field_due_date: 到期日
111 field_assigned_to: 指派
112 field_priority: 优先级
113 field_fixed_version: 修订版本
114 field_user: 用户
115 field_role: 角色
116 field_homepage: 主页
117 field_is_public: 公开
118 field_parent: 上级项目
119 field_is_in_chlog: 在更新日志中显示任务
120 field_is_in_roadmap: 在路线图中显示任务
121 field_login: 登录名
122 field_mail_notification: 邮件通知
123 field_admin: 管理员
124 field_last_login_on: 最后登录
125 field_language: 语言
126 field_effective_date: 日期
127 field_password: 口令
128 field_new_password: 新口令
129 field_password_confirmation: 确认
130 field_version: 版本
131 field_type: 类别
132 field_host: 主机
133 field_port: 端口
134 field_account: 帐号
135 field_base_dn: Base DN
136 field_attr_login: 登录名属性
137 field_attr_firstname: 名字属性
138 field_attr_lastname: 姓属性
139 field_attr_mail: 邮件属性
140 field_onthefly: On-the-fly user creation
141 field_start_date: 开始
142 field_done_ratio: %% 完成
143 field_auth_source: 认证模式
144 field_hide_mail: 隐藏我的邮件
145 field_comment: 注释
146 field_url: URL
147 field_start_page: 起始页
148 field_subproject: 子项目
149 field_hours: Hours
150 field_activity: 活动
151 field_spent_on: 日期
152
153 setting_app_title: 应用程序标题
154 setting_app_subtitle: 应用程序子标题
155 setting_welcome_text: 欢迎文字
156 setting_default_language: 默认语言
157 setting_login_required: 要求认证
158 setting_self_registration: 允许自注册
159 setting_attachment_max_size: 附件最大尺寸
160 setting_issues_export_limit: Issues export limit
161 setting_mail_from: Emission mail address
162 setting_host_name: 主机名称
163 setting_text_formatting: 文本格式
164 setting_wiki_compression: Wiki history compression
165 setting_feeds_limit: Feed content limit
166 setting_autofetch_changesets: Autofetch SVN commits
167
168 label_user: 用户
169 label_user_plural: 用户列表
170 label_user_new: 新建用户
171 label_project: 项目
172 label_project_new: 新建项目
173 label_project_plural: 项目列表
174 label_project_latest: 最近的项目列表
175 label_issue: 任务
176 label_issue_new: 新建任务
177 label_issue_plural: 任务列表
178 label_issue_view_all: 查看所有任务
179 label_document: 文档
180 label_document_new: 新建文档
181 label_document_plural: 文档列表
182 label_role: 角色
183 label_role_plural: 角色列表
184 label_role_new: 新建角色
185 label_role_and_permissions: 角色和权限
186 label_member: 成员
187 label_member_new: 新建成员
188 label_member_plural: 成员列表
189 label_tracker: 跟踪标签
190 label_tracker_plural: 跟踪标签列表
191 label_tracker_new: 新建跟踪标签
192 label_workflow: 工作流
193 label_issue_status: 任务状态列表
194 label_issue_status_plural: 任务状态列表
195 label_issue_status_new: 新建任务状态列表
196 label_issue_category: 任务类别
197 label_issue_category_plural: 任务类别列表
198 label_issue_category_new: 新建任务类别
199 label_custom_field: 自定义字段
200 label_custom_field_plural: 自定义字段列表
201 label_custom_field_new: 新建自定义字段
202 label_enumerations: 枚举列表
203 label_enumeration_new: 新建枚举值
204 label_information: 信息
205 label_information_plural: 信息
206 label_please_login: 请登录
207 label_register: 注册
208 label_password_lost: 忘记口令
209 label_home: 主页
210 label_my_page: 我的工作台
211 label_my_account: 我的帐号
212 label_my_projects: 我的项目列表
213 label_administration: 管理
214 label_login: 登录
215 label_logout: 退出
216 label_help: 帮助
217 label_reported_issues: 已报告的问题
218 label_assigned_to_me_issues: 分配给我的任务
219 label_last_login: 最后登录
220 label_last_updates: 最后更新
221 label_last_updates_plural: %d 最后更新
222 label_registered_on: 注册于
223 label_activity: 活动
224 label_new: 新建
225 label_logged_as: 登录为
226 label_environment: 环境
227 label_authentication: 认证
228 label_auth_source: 认证模式
229 label_auth_source_new: 新建认证模式
230 label_auth_source_plural: 认证模式列表
231 label_subproject_plural: 子项目列表
232 label_min_max_length: 最小 - 最大 长度
233 label_list: list
234 label_date: Date
235 label_integer: Integer
236 label_boolean: Boolean
237 label_string: Text
238 label_text: Long text
239 label_attribute: 属性
240 label_attribute_plural: 属性
241 label_download: %d 个下载次数
242 label_download_plural: %d 个下载次数
243 label_no_data: 没有数据用于显示
244 label_change_status: 改变状态
245 label_history: 历史记录
246 label_attachment: 文件
247 label_attachment_new: 新建文件
248 label_attachment_delete: 删除文件
249 label_attachment_plural: 文件列表
250 label_report: 报表
251 label_report_plural: 报表列表
252 label_news: 新闻
253 label_news_new: 增加新闻
254 label_news_plural: 新闻列表
255 label_news_latest: 最近的新闻
256 label_news_view_all: 查看所有新闻
257 label_change_log: 更新日志
258 label_settings: 配置
259 label_overview: 概述
260 label_version: 版本
261 label_version_new: 新建版本
262 label_version_plural: 版本列表
263 label_confirmation: 确认
264 label_export_to: 导出
265 label_read: 读取...
266 label_public_projects: 公开的项目列表
267 label_open_issues: 打开
268 label_open_issues_plural: 打开
269 label_closed_issues: 已关闭
270 label_closed_issues_plural: 已关闭
271 label_total: 合计
272 label_permissions: 权限列表
273 label_current_status: 当前状态
274 label_new_statuses_allowed: New statuses allowed
275 label_all: 全部
276 label_none:
277 label_next: 下一个
278 label_previous: 上一个
279 label_used_by: 使用中
280 label_details: 详情...
281 label_add_note: 添加说明
282 label_per_page: 每面
283 label_calendar: 日历
284 label_months_from: months from
285 label_gantt: 甘特图(Gantt)
286 label_internal: 内部
287 label_last_changes: 最近的 %d 次更改
288 label_change_view_all: 查看所有更改
289 label_personalize_page: 个性化定制本页
290 label_comment: 注释
291 label_comment_plural: 注释列表
292 label_comment_add: 添加注释
293 label_comment_added: 已加入注释
294 label_comment_delete: 删除注释
295 label_query: 自定义查询
296 label_query_plural: 自定义查询列表
297 label_query_new: 新建查询
298 label_filter_add: 增加过滤器
299 label_filter_plural: 过滤器列表
300 label_equals: 等于
301 label_not_equals: 不等于
302 label_in_less_than: 剩余天数小于
303 label_in_more_than: 剩余天数大于
304 label_in: 剩余天数
305 label_today: 今天
306 label_less_than_ago: 之前天数少于
307 label_more_than_ago: 之前天数大于
308 label_ago: 之前天数
309 label_contains: 包含
310 label_not_contains: 不包含
311 label_day_plural: 天数
312 label_repository: SVN 版本库
313 label_browse: 浏览
314 label_modification: %d 个更新
315 label_modification_plural: %d 个更新
316 label_revision: 修订
317 label_revision_plural: 修订
318 label_added: 已增加
319 label_modified: 已修改
320 label_deleted: 已删除
321 label_latest_revision: 最近的版本
322 label_latest_revision_plural: 最近的版本列表
323 label_view_revisions: 查看修订列表
324 label_max_size: 最大尺寸
325 label_on: 'on'
326 label_sort_highest: 置顶
327 label_sort_higher: 上移
328 label_sort_lower: 下移
329 label_sort_lowest: 置底
330 label_roadmap: 路线图
331 label_roadmap_due_in: Due in
332 label_roadmap_no_issues: 该版本没有任务
333 label_search: 查找
334 label_result: %d 个结果
335 label_result_plural: %d 个结果
336 label_all_words: 所有单词
337 label_wiki: Wiki
338 label_wiki_edit: Wiki edit
339 label_wiki_edit_plural: Wiki edits
340 label_page_index: 索引
341 label_current_version: 当前版本
342 label_preview: 预览
343 label_feed_plural: Feeds
344 label_changes_details: 所有更改的详情
345 label_issue_tracking: 任务跟踪
346 label_spent_time: 耗时
347 label_f_hour: %.2f 小时
348 label_f_hour_plural: %.2f 小时
349 label_time_tracking: 时间跟踪
350 label_change_plural: 更改列表
351 label_statistics: 统计
352 label_commits_per_month: Commits per month
353 label_commits_per_author: Commits per author
354 label_view_diff: View differences
355 label_diff_inline: inline
356 label_diff_side_by_side: side by side
357
358 button_login: 登录
359 button_submit: 提交
360 button_save: 保存
361 button_check_all: 全选
362 button_uncheck_all: 清除
363 button_delete: 删除
364 button_create: 创建
365 button_test: 测试
366 button_edit: 编辑
367 button_add: 新增
368 button_change: 修改
369 button_apply: 应用
370 button_clear: 清除
371 button_lock: 锁定
372 button_unlock: 解锁
373 button_download: 下载
374 button_list: 列表
375 button_view: 查看
376 button_move: 移动
377 button_back: 返回
378 button_cancel: 取消
379 button_activate: 激活
380 button_sort: 排序
381 button_log_time: 登记工时
382
383 status_active: 激活
384 status_registered: 已注册
385 status_locked: 已锁定
386
387 text_select_mail_notifications: 选择需要发送邮件通知的动作。
388 text_regexp_info: eg. ^[A-Z0-9]+$
389 text_min_max_length_info: 0 表示没有限制
390 text_project_destroy_confirmation: 您确信要删除这个项目以及所有相关的数据吗?
391 text_workflow_edit: 选择一个角色和跟踪标签来编辑这个工作流
392 text_are_you_sure: 您确定?
393 text_journal_changed: 从 %s 更改为 %s
394 text_journal_set_to: 设置为 %s
395 text_journal_deleted: 已删除
396 text_tip_task_begin_day: 开始于此
397 text_tip_task_end_day: 在此结束
398 text_tip_task_begin_end_day: 开始并结束于此
399
400 default_role_manager: 管理员
401 default_role_developper: 开发人员
402 default_role_reporter: 报告人员
403 default_tracker_bug: 问题
404 default_tracker_feature: 功能
405 default_tracker_support: 支持
406 default_issue_status_new: 新建
407 default_issue_status_assigned: 已分配
408 default_issue_status_resolved: 已解决
409 default_issue_status_feedback: 回复
410 default_issue_status_closed: 已关闭
411 default_issue_status_rejected: 已打回
412 default_doc_category_user: 用户文档
413 default_doc_category_tech: 技术文档
414 default_priority_low:
415 default_priority_normal: 普通
416 default_priority_high:
417 default_priority_urgent: 紧急
418 default_priority_immediate: 立刻
419 default_activity_design: 设计
420 default_activity_development: 开发
421
422 enumeration_issue_priorities: 任务优先级
423 enumeration_doc_categories: 文档类别
424 enumeration_activities: Activities (time tracking)
@@ -1,70 +1,75
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require 'iconv'
18 require 'iconv'
19 require 'rfpdf/chinese'
19 require 'rfpdf/chinese'
20
20
21 module IfpdfHelper
21 module IfpdfHelper
22
22
23 class IFPDF < FPDF
23 class IFPDF < FPDF
24 include GLoc
24 include GLoc
25 attr_accessor :footer_date
25 attr_accessor :footer_date
26
26
27 def initialize(lang)
27 def initialize(lang)
28 super()
28 super()
29 set_language_if_valid lang
29 set_language_if_valid lang
30 case current_language
30 case current_language
31 when :ja
31 when :ja
32 extend(PDF_Japanese)
32 extend(PDF_Japanese)
33 AddSJISFont()
33 AddSJISFont()
34 @font_for_content = 'SJIS'
34 @font_for_content = 'SJIS'
35 @font_for_footer = 'SJIS'
35 @font_for_footer = 'SJIS'
36 when :zh
37 extend(PDF_Chinese)
38 AddBig5Font()
39 @font_for_content = 'Big5'
40 @font_for_footer = 'Big5'
36 else
41 else
37 @font_for_content = 'Arial'
42 @font_for_content = 'Arial'
38 @font_for_footer = 'Helvetica'
43 @font_for_footer = 'Helvetica'
39 end
44 end
40 SetCreator("redMine #{Redmine::VERSION}")
45 SetCreator("redMine #{Redmine::VERSION}")
41 SetFont(@font_for_content)
46 SetFont(@font_for_content)
42 end
47 end
43
48
44 def SetFontStyle(style, size)
49 def SetFontStyle(style, size)
45 SetFont(@font_for_content, style, size)
50 SetFont(@font_for_content, style, size)
46 end
51 end
47
52
48 def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
53 def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
49 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
54 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
50 txt = begin
55 txt = begin
51 @ic.iconv(txt)
56 @ic.iconv(txt)
52 rescue
57 rescue
53 txt
58 txt
54 end
59 end
55 super w,h,txt,border,ln,align,fill,link
60 super w,h,txt,border,ln,align,fill,link
56 end
61 end
57
62
58 def Footer
63 def Footer
59 SetFont(@font_for_footer, 'I', 8)
64 SetFont(@font_for_footer, 'I', 8)
60 SetY(-15)
65 SetY(-15)
61 SetX(15)
66 SetX(15)
62 Cell(0, 5, @footer_date, 0, 0, 'L')
67 Cell(0, 5, @footer_date, 0, 0, 'L')
63 SetY(-15)
68 SetY(-15)
64 SetX(-30)
69 SetX(-30)
65 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
70 Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
66 end
71 end
67
72
68 end
73 end
69
74
70 end
75 end
@@ -1,38 +1,38
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19 require 'application'
19 require 'application'
20
20
21 # Re-raise errors caught by the controller.
21 # Re-raise errors caught by the controller.
22 class ApplicationController; def rescue_action(e) raise e end; end
22 class ApplicationController; def rescue_action(e) raise e end; end
23
23
24 class ApplicationControllerTest < Test::Unit::TestCase
24 class ApplicationControllerTest < Test::Unit::TestCase
25 def setup
25 def setup
26 @controller = ApplicationController.new
26 @controller = ApplicationController.new
27 @request = ActionController::TestRequest.new
27 @request = ActionController::TestRequest.new
28 @response = ActionController::TestResponse.new
28 @response = ActionController::TestResponse.new
29 end
29 end
30
30
31 # check that all 6 supported languages are valid
31 # check that all 6 supported languages are valid
32 def test_localization
32 def test_localization
33 assert_equal 6, GLoc.valid_languages.size
33 assert_equal 7, GLoc.valid_languages.size
34 GLoc.valid_languages.each do |lang|
34 GLoc.valid_languages.each do |lang|
35 assert set_language_if_valid(lang)
35 assert set_language_if_valid(lang)
36 end
36 end
37 end
37 end
38 end
38 end
@@ -1,473 +1,473
1 # Copyright (c) 2006 4ssoM LLC <www.4ssoM.com>
1 # Copyright (c) 2006 4ssoM LLC <www.4ssoM.com>
2 # 1.12 contributed by Ed Moss.
2 # 1.12 contributed by Ed Moss.
3 #
3 #
4 # The MIT License
4 # The MIT License
5 #
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
11 # furnished to do so, subject to the following conditions:
12 #
12 #
13 # The above copyright notice and this permission notice shall be included in
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
14 # all copies or substantial portions of the Software.
15 #
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
22 # THE SOFTWARE.
23 #
23 #
24 # This is direct port of chinese.php
24 # This is direct port of chinese.php
25 #
25 #
26 # Chinese PDF support.
26 # Chinese PDF support.
27 #
27 #
28 # Usage is as follows:
28 # Usage is as follows:
29 #
29 #
30 # require 'fpdf'
30 # require 'fpdf'
31 # require 'chinese'
31 # require 'chinese'
32 # pdf = FPDF.new
32 # pdf = FPDF.new
33 # pdf.extend(PDF_Chinese)
33 # pdf.extend(PDF_Chinese)
34 #
34 #
35 # This allows it to be combined with other extensions, such as the bookmark
35 # This allows it to be combined with other extensions, such as the bookmark
36 # module.
36 # module.
37
37
38 module PDF_Chinese
38 module PDF_Chinese
39
39
40 Big5_widths={' '=>250,'!'=>250,'"'=>408,'#'=>668,''=>490,'%'=>875,'&'=>698,'\''=>250,
40 Big5_widths={' '=>250,'!'=>250,'"'=>408,'#'=>668,''=>490,'%'=>875,'&'=>698,'\''=>250,
41 '('=>240,')'=>240,'*'=>417,'+'=>667,','=>250,'-'=>313,'.'=>250,'/'=>520,'0'=>500,'1'=>500,
41 '('=>240,')'=>240,'*'=>417,'+'=>667,','=>250,'-'=>313,'.'=>250,'/'=>520,'0'=>500,'1'=>500,
42 '2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>250,''=>250,
42 '2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>250,''=>250,
43 '<'=>667,'='=>667,'>'=>667,'?'=>396,'@'=>921,'A'=>677,'B'=>615,'C'=>719,'D'=>760,'E'=>625,
43 '<'=>667,'='=>667,'>'=>667,'?'=>396,'@'=>921,'A'=>677,'B'=>615,'C'=>719,'D'=>760,'E'=>625,
44 'F'=>552,'G'=>771,'H'=>802,'I'=>354,'J'=>354,'K'=>781,'L'=>604,'M'=>927,'N'=>750,'O'=>823,
44 'F'=>552,'G'=>771,'H'=>802,'I'=>354,'J'=>354,'K'=>781,'L'=>604,'M'=>927,'N'=>750,'O'=>823,
45 'P'=>563,'Q'=>823,'R'=>729,'S'=>542,'T'=>698,'U'=>771,'V'=>729,'W'=>948,'X'=>771,'Y'=>677,
45 'P'=>563,'Q'=>823,'R'=>729,'S'=>542,'T'=>698,'U'=>771,'V'=>729,'W'=>948,'X'=>771,'Y'=>677,
46 'Z'=>635,'['=>344,'\\'=>520,']'=>344,'^'=>469,'_'=>500,'`'=>250,'a'=>469,'b'=>521,'c'=>427,
46 'Z'=>635,'['=>344,'\\'=>520,']'=>344,'^'=>469,'_'=>500,'`'=>250,'a'=>469,'b'=>521,'c'=>427,
47 'd'=>521,'e'=>438,'f'=>271,'g'=>469,'h'=>531,'i'=>250,'j'=>250,'k'=>458,'l'=>240,'m'=>802,
47 'd'=>521,'e'=>438,'f'=>271,'g'=>469,'h'=>531,'i'=>250,'j'=>250,'k'=>458,'l'=>240,'m'=>802,
48 'n'=>531,'o'=>500,'p'=>521,'q'=>521,'r'=>365,'s'=>333,'t'=>292,'u'=>521,'v'=>458,'w'=>677,
48 'n'=>531,'o'=>500,'p'=>521,'q'=>521,'r'=>365,'s'=>333,'t'=>292,'u'=>521,'v'=>458,'w'=>677,
49 'x'=>479,'y'=>458,'z'=>427,'{'=>480,'|'=>496,'end'=>480,'~'=>667}
49 'x'=>479,'y'=>458,'z'=>427,'{'=>480,'|'=>496,'end'=>480,'~'=>667}
50
50
51 GB_widths={' '=>207,'!'=>270,'"'=>342,'#'=>467,''=>462,'%'=>797,'&'=>710,'\''=>239,
51 GB_widths={' '=>207,'!'=>270,'"'=>342,'#'=>467,''=>462,'%'=>797,'&'=>710,'\''=>239,
52 '('=>374,')'=>374,'*'=>423,'+'=>605,','=>238,'-'=>375,'.'=>238,'/'=>334,'0'=>462,'1'=>462,
52 '('=>374,')'=>374,'*'=>423,'+'=>605,','=>238,'-'=>375,'.'=>238,'/'=>334,'0'=>462,'1'=>462,
53 '2'=>462,'3'=>462,'4'=>462,'5'=>462,'6'=>462,'7'=>462,'8'=>462,'9'=>462,':'=>238,''=>238,
53 '2'=>462,'3'=>462,'4'=>462,'5'=>462,'6'=>462,'7'=>462,'8'=>462,'9'=>462,':'=>238,''=>238,
54 '<'=>605,'='=>605,'>'=>605,'?'=>344,'@'=>748,'A'=>684,'B'=>560,'C'=>695,'D'=>739,'E'=>563,
54 '<'=>605,'='=>605,'>'=>605,'?'=>344,'@'=>748,'A'=>684,'B'=>560,'C'=>695,'D'=>739,'E'=>563,
55 'F'=>511,'G'=>729,'H'=>793,'I'=>318,'J'=>312,'K'=>666,'L'=>526,'M'=>896,'N'=>758,'O'=>772,
55 'F'=>511,'G'=>729,'H'=>793,'I'=>318,'J'=>312,'K'=>666,'L'=>526,'M'=>896,'N'=>758,'O'=>772,
56 'P'=>544,'Q'=>772,'R'=>628,'S'=>465,'T'=>607,'U'=>753,'V'=>711,'W'=>972,'X'=>647,'Y'=>620,
56 'P'=>544,'Q'=>772,'R'=>628,'S'=>465,'T'=>607,'U'=>753,'V'=>711,'W'=>972,'X'=>647,'Y'=>620,
57 'Z'=>607,'['=>374,'\\'=>333,']'=>374,'^'=>606,'_'=>500,'`'=>239,'a'=>417,'b'=>503,'c'=>427,
57 'Z'=>607,'['=>374,'\\'=>333,']'=>374,'^'=>606,'_'=>500,'`'=>239,'a'=>417,'b'=>503,'c'=>427,
58 'd'=>529,'e'=>415,'f'=>264,'g'=>444,'h'=>518,'i'=>241,'j'=>230,'k'=>495,'l'=>228,'m'=>793,
58 'd'=>529,'e'=>415,'f'=>264,'g'=>444,'h'=>518,'i'=>241,'j'=>230,'k'=>495,'l'=>228,'m'=>793,
59 'n'=>527,'o'=>524,'p'=>524,'q'=>504,'r'=>338,'s'=>336,'t'=>277,'u'=>517,'v'=>450,'w'=>652,
59 'n'=>527,'o'=>524,'p'=>524,'q'=>504,'r'=>338,'s'=>336,'t'=>277,'u'=>517,'v'=>450,'w'=>652,
60 'x'=>466,'y'=>452,'z'=>407,'{'=>370,'|'=>258,'end'=>370,'~'=>605}
60 'x'=>466,'y'=>452,'z'=>407,'{'=>370,'|'=>258,'end'=>370,'~'=>605}
61
61
62 def AddCIDFont(family,style,name,cw,cMap,registry)
62 def AddCIDFont(family,style,name,cw,cMap,registry)
63 #ActionController::Base::logger.debug registry.to_a.join(":").to_s
63 #ActionController::Base::logger.debug registry.to_a.join(":").to_s
64 fontkey=family.downcase+style.upcase
64 fontkey=family.downcase+style.upcase
65 unless @fonts[fontkey].nil?
65 unless @fonts[fontkey].nil?
66 Error("Font already added: family style")
66 Error("Font already added: family style")
67 end
67 end
68 i=@fonts.length+1
68 i=@fonts.length+1
69 name=name.gsub(' ','')
69 name=name.gsub(' ','')
70 @fonts[fontkey]={'i'=>i,'type'=>'Type0','name'=>name,'up'=>-130,'ut'=>40,'cw'=>cw, 'CMap'=>cMap,'registry'=>registry}
70 @fonts[fontkey]={'i'=>i,'type'=>'Type0','name'=>name,'up'=>-130,'ut'=>40,'cw'=>cw, 'CMap'=>cMap,'registry'=>registry}
71 end
71 end
72
72
73 def AddCIDFonts(family,name,cw,cMap,registry)
73 def AddCIDFonts(family,name,cw,cMap,registry)
74 AddCIDFont(family,'',name,cw,cMap,registry)
74 AddCIDFont(family,'',name,cw,cMap,registry)
75 AddCIDFont(family,'B',name+',Bold',cw,cMap,registry)
75 AddCIDFont(family,'B',name+',Bold',cw,cMap,registry)
76 AddCIDFont(family,'I',name+',Italic',cw,cMap,registry)
76 AddCIDFont(family,'I',name+',Italic',cw,cMap,registry)
77 AddCIDFont(family,'BI',name+',BoldItalic',cw,cMap,registry)
77 AddCIDFont(family,'BI',name+',BoldItalic',cw,cMap,registry)
78 end
78 end
79
79
80 def AddBig5Font(family='Big5',name='MSungStd-Light-Acro')
80 def AddBig5Font(family='Big5',name='MSungStd-Light-Acro')
81 #Add Big5 font with proportional Latin
81 #Add Big5 font with proportional Latin
82 cw=Big5_widths
82 cw=Big5_widths
83 cMap='ETenms-B5-H'
83 cMap='ETenms-B5-H'
84 registry={'ordering'=>'CNS1','supplement'=>0}
84 registry={'ordering'=>'CNS1','supplement'=>0}
85 #ActionController::Base::logger.debug registry.to_a.join(":").to_s
85 #ActionController::Base::logger.debug registry.to_a.join(":").to_s
86 AddCIDFonts(family,name,cw,cMap,registry)
86 AddCIDFonts(family,name,cw,cMap,registry)
87 end
87 end
88
88
89 def AddBig5hwFont(family='Big5-hw',name='MSungStd-Light-Acro')
89 def AddBig5hwFont(family='Big5-hw',name='MSungStd-Light-Acro')
90 #Add Big5 font with half-witdh Latin
90 #Add Big5 font with half-witdh Latin
91 cw = {}
91 cw = {}
92 32.upto(126) do |i|
92 32.upto(126) do |i|
93 cw[i.chr]=500
93 cw[i.chr]=500
94 end
94 end
95 cMap='ETen-B5-H'
95 cMap='ETen-B5-H'
96 registry={'ordering'=>'CNS1','supplement'=>0}
96 registry={'ordering'=>'CNS1','supplement'=>0}
97 AddCIDFonts(family,name,cw,cMap,registry)
97 AddCIDFonts(family,name,cw,cMap,registry)
98 end
98 end
99
99
100 def AddGBFont(family='GB',name='STSongStd-Light-Acro')
100 def AddGBFont(family='GB',name='STSongStd-Light-Acro')
101 #Add GB font with proportional Latin
101 #Add GB font with proportional Latin
102 cw=GB_widths
102 cw=GB_widths
103 cMap='GBKp-EUC-H'
103 cMap='GBKp-EUC-H'
104 registry={'ordering'=>'GB1','supplement'=>2}
104 registry={'ordering'=>'GB1','supplement'=>2}
105 AddCIDFonts(family,name,cw,cMap,registry)
105 AddCIDFonts(family,name,cw,cMap,registry)
106 end
106 end
107
107
108 def AddGBhwFont(family='GB-hw',name='STSongStd-Light-Acro')
108 def AddGBhwFont(family='GB-hw',name='STSongStd-Light-Acro')
109 #Add GB font with half-width Latin
109 #Add GB font with half-width Latin
110 32.upto(126) do |i|
110 32.upto(126) do |i|
111 cw[i.chr]=500
111 cw[i.chr]=500
112 end
112 end
113 cMap='GBK-EUC-H'
113 cMap='GBK-EUC-H'
114 registry={'ordering'=>'GB1','supplement'=>2}
114 registry={'ordering'=>'GB1','supplement'=>2}
115 AddCIDFonts(family,name,cw,cMap,registry)
115 AddCIDFonts(family,name,cw,cMap,registry)
116 end
116 end
117
117
118 def GetStringWidth(s)
118 def GetStringWidth(s)
119 if(@CurrentFont['type']=='Type0')
119 if(@CurrentFont['type']=='Type0')
120 return GetMBStringWidth(s)
120 return GetMBStringWidth(s)
121 else
121 else
122 return super(s)
122 return super(s)
123 end
123 end
124 end
124 end
125
125
126 def GetMBStringWidth(s)
126 def GetMBStringWidth(s)
127 #Multi-byte version of GetStringWidth()
127 #Multi-byte version of GetStringWidth()
128 l=0
128 l=0
129 cw=@CurrentFont['cw']
129 cw=@CurrentFont['cw']
130 nb=s.length
130 nb=s.length
131 i=0
131 i=0
132 while(i<nb)
132 while(i<nb)
133 c=s[i]
133 c=s[i]
134 if(c<128)
134 if(c<128)
135 l+=cw[c.chr]
135 l+=cw[c.chr] if cw[c.chr]
136 i+=1
136 i+=1
137 else
137 else
138 l+=1000
138 l+=1000
139 i+=2
139 i+=2
140 end
140 end
141 end
141 end
142 return l*@FontSize/1000
142 return l*@FontSize/1000
143 end
143 end
144
144
145 def MultiCell(w,h,txt,border=0,align='L',fill=0)
145 def MultiCell(w,h,txt,border=0,align='L',fill=0)
146 if(@CurrentFont['type']=='Type0')
146 if(@CurrentFont['type']=='Type0')
147 MBMultiCell(w,h,txt,border,align,fill)
147 MBMultiCell(w,h,txt,border,align,fill)
148 else
148 else
149 super(w,h,txt,border,align,fill)
149 super(w,h,txt,border,align,fill)
150 end
150 end
151 end
151 end
152
152
153 def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
153 def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
154 #Multi-byte version of MultiCell()
154 #Multi-byte version of MultiCell()
155 cw=@CurrentFont['cw']
155 cw=@CurrentFont['cw']
156 if(w==0)
156 if(w==0)
157 w=@w-@rMargin-@x
157 w=@w-@rMargin-@x
158 end
158 end
159 wmax=(w-2*@cMargin)*1000/@FontSize
159 wmax=(w-2*@cMargin)*1000/@FontSize
160 s=txt.gsub("\r",'')
160 s=txt.gsub("\r",'')
161 nb=s.length
161 nb=s.length
162 if(nb>0 and s[nb-1]=="\n")
162 if(nb>0 and s[nb-1]=="\n")
163 nb-=1
163 nb-=1
164 end
164 end
165 b=0
165 b=0
166 if(border)
166 if(border)
167 if(border==1)
167 if(border==1)
168 border='LTRB'
168 border='LTRB'
169 b='LRT'
169 b='LRT'
170 b2='LR'
170 b2='LR'
171 else
171 else
172 b2=''
172 b2=''
173 if(border.index('L').nil?)
173 if(border.to_s.index('L'))
174 b2+='L'
174 b2+='L'
175 end
175 end
176 if(border.index('R').nil?)
176 if(border.to_s.index('R'))
177 b2+='R'
177 b2+='R'
178 end
178 end
179 b=border.index('T').nil? ? b2+'T' : b2
179 b=border.to_s.index('T') ? b2+'T' : b2
180 end
180 end
181 end
181 end
182 sep=-1
182 sep=-1
183 i=0
183 i=0
184 j=0
184 j=0
185 l=0
185 l=0
186 nl=1
186 nl=1
187 while(i<nb)
187 while(i<nb)
188 #Get next character
188 #Get next character
189 c=s[i]
189 c=s[i]
190 #Check if ASCII or MB
190 #Check if ASCII or MB
191 ascii=(c<128)
191 ascii=(c<128)
192 if(c=="\n")
192 if(c=="\n")
193 #Explicit line break
193 #Explicit line break
194 Cell(w,h,s[j,i-j],b,2,align,fill)
194 Cell(w,h,s[j,i-j],b,2,align,fill)
195 i+=1
195 i+=1
196 sep=-1
196 sep=-1
197 j=i
197 j=i
198 l=0
198 l=0
199 nl+=1
199 nl+=1
200 if(border and nl==2)
200 if(border and nl==2)
201 b=b2
201 b=b2
202 end
202 end
203 next
203 next
204 end
204 end
205 if(!ascii)
205 if(!ascii)
206 sep=i
206 sep=i
207 ls=l
207 ls=l
208 elsif(c==' ')
208 elsif(c==' ')
209 sep=i
209 sep=i
210 ls=l
210 ls=l
211 end
211 end
212 l+=ascii ? cw[c.chr] : 1000
212 l+=ascii ? (cw[c.chr] || 0) : 1000
213 if(l>wmax)
213 if(l>wmax)
214 #Automatic line break
214 #Automatic line break
215 if(sep==-1 or i==j)
215 if(sep==-1 or i==j)
216 if(i==j)
216 if(i==j)
217 i+=ascii ? 1 : 2
217 i+=ascii ? 1 : 2
218 end
218 end
219 Cell(w,h,s[j,i-j],b,2,align,fill)
219 Cell(w,h,s[j,i-j],b,2,align,fill)
220 else
220 else
221 Cell(w,h,s[j,sep-j],b,2,align,fill)
221 Cell(w,h,s[j,sep-j],b,2,align,fill)
222 i=(s[sep]==' ') ? sep+1 : sep
222 i=(s[sep]==' ') ? sep+1 : sep
223 end
223 end
224 sep=-1
224 sep=-1
225 j=i
225 j=i
226 l=0
226 l=0
227 # nl+=1
227 # nl+=1
228 if(border and nl==2)
228 if(border and nl==2)
229 b=b2
229 b=b2
230 end
230 end
231 else
231 else
232 i+=ascii ? 1 : 2
232 i+=ascii ? 1 : 2
233 end
233 end
234 end
234 end
235 #Last chunk
235 #Last chunk
236 if(border and not border.index('B').nil?)
236 if(border and not border.to_s.index('B').nil?)
237 b+='B'
237 b+='B'
238 end
238 end
239 Cell(w,h,s[j,i-j],b,2,align,fill)
239 Cell(w,h,s[j,i-j],b,2,align,fill)
240 @x=@lMargin
240 @x=@lMargin
241 end
241 end
242
242
243 def Write(h,txt,link='')
243 def Write(h,txt,link='')
244 if(@CurrentFont['type']=='Type0')
244 if(@CurrentFont['type']=='Type0')
245 MBWrite(h,txt,link)
245 MBWrite(h,txt,link)
246 else
246 else
247 super(h,txt,link)
247 super(h,txt,link)
248 end
248 end
249 end
249 end
250
250
251 def MBWrite(h,txt,link)
251 def MBWrite(h,txt,link)
252 #Multi-byte version of Write()
252 #Multi-byte version of Write()
253 cw=@CurrentFont['cw']
253 cw=@CurrentFont['cw']
254 w=@w-@rMargin-@x
254 w=@w-@rMargin-@x
255 wmax=(w-2*@cMargin)*1000/@FontSize
255 wmax=(w-2*@cMargin)*1000/@FontSize
256 s=txt.gsub("\r",'')
256 s=txt.gsub("\r",'')
257 nb=s.length
257 nb=s.length
258 sep=-1
258 sep=-1
259 i=0
259 i=0
260 j=0
260 j=0
261 l=0
261 l=0
262 nl=1
262 nl=1
263 while(i<nb)
263 while(i<nb)
264 #Get next character
264 #Get next character
265 c=s[i]
265 c=s[i]
266 #Check if ASCII or MB
266 #Check if ASCII or MB
267 ascii=(c<128)
267 ascii=(c<128)
268 if(c=="\n")
268 if(c=="\n")
269 #Explicit line break
269 #Explicit line break
270 Cell(w,h,s[j,i-j],0,2,'',0,link)
270 Cell(w,h,s[j,i-j],0,2,'',0,link)
271 i+=1
271 i+=1
272 sep=-1
272 sep=-1
273 j=i
273 j=i
274 l=0
274 l=0
275 if(nl==1)
275 if(nl==1)
276 @x=@lMargin
276 @x=@lMargin
277 w=@w-@rMargin-@x
277 w=@w-@rMargin-@x
278 wmax=(w-2*@cMargin)*1000/@FontSize
278 wmax=(w-2*@cMargin)*1000/@FontSize
279 end
279 end
280 nl+=1
280 nl+=1
281 next
281 next
282 end
282 end
283 if(!ascii or c==' ')
283 if(!ascii or c==' ')
284 sep=i
284 sep=i
285 end
285 end
286 l+=ascii ? cw[c.chr] : 1000
286 l+=ascii ? cw[c.chr] : 1000
287 if(l>wmax)
287 if(l>wmax)
288 #Automatic line break
288 #Automatic line break
289 if(sep==-1 or i==j)
289 if(sep==-1 or i==j)
290 if(@x>@lMargin)
290 if(@x>@lMargin)
291 #Move to next line
291 #Move to next line
292 @x=@lMargin
292 @x=@lMargin
293 @y+=h
293 @y+=h
294 w=@w-@rMargin-@x
294 w=@w-@rMargin-@x
295 wmax=(w-2*@cMargin)*1000/@FontSize
295 wmax=(w-2*@cMargin)*1000/@FontSize
296 i+=1
296 i+=1
297 nl+=1
297 nl+=1
298 next
298 next
299 end
299 end
300 if(i==j)
300 if(i==j)
301 i+=ascii ? 1 : 2
301 i+=ascii ? 1 : 2
302 end
302 end
303 Cell(w,h,s[j,i-j],0,2,'',0,link)
303 Cell(w,h,s[j,i-j],0,2,'',0,link)
304 else
304 else
305 Cell(w,h,s[j,sep-j],0,2,'',0,link)
305 Cell(w,h,s[j,sep-j],0,2,'',0,link)
306 i=(s[sep]==' ') ? sep+1 : sep
306 i=(s[sep]==' ') ? sep+1 : sep
307 end
307 end
308 sep=-1
308 sep=-1
309 j=i
309 j=i
310 l=0
310 l=0
311 if(nl==1)
311 if(nl==1)
312 @x=@lMargin
312 @x=@lMargin
313 w=@w-@rMargin-@x
313 w=@w-@rMargin-@x
314 wmax=(w-2*@cMargin)*1000/@FontSize
314 wmax=(w-2*@cMargin)*1000/@FontSize
315 end
315 end
316 nl+=1
316 nl+=1
317 else
317 else
318 i+=ascii ? 1 : 2
318 i+=ascii ? 1 : 2
319 end
319 end
320 end
320 end
321 #Last chunk
321 #Last chunk
322 if(i!=j)
322 if(i!=j)
323 Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
323 Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
324 end
324 end
325 end
325 end
326
326
327 private
327 private
328
328
329 def putfonts()
329 def putfonts()
330 nf=@n
330 nf=@n
331 @diffs.each do |diff|
331 @diffs.each do |diff|
332 #Encodings
332 #Encodings
333 newobj()
333 newobj()
334 out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['+diff+']>>')
334 out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['+diff+']>>')
335 out('endobj')
335 out('endobj')
336 end
336 end
337 # mqr=get_magic_quotes_runtime()
337 # mqr=get_magic_quotes_runtime()
338 # set_magic_quotes_runtime(0)
338 # set_magic_quotes_runtime(0)
339 @FontFiles.each_pair do |file, info|
339 @FontFiles.each_pair do |file, info|
340 #Font file embedding
340 #Font file embedding
341 newobj()
341 newobj()
342 @FontFiles[file]['n']=@n
342 @FontFiles[file]['n']=@n
343 if(defined('FPDF_FONTPATH'))
343 if(defined('FPDF_FONTPATH'))
344 file=FPDF_FONTPATH+file
344 file=FPDF_FONTPATH+file
345 end
345 end
346 size=filesize(file)
346 size=filesize(file)
347 if(!size)
347 if(!size)
348 Error('Font file not found')
348 Error('Font file not found')
349 end
349 end
350 out('<</Length '+size)
350 out('<</Length '+size)
351 if(file[-2]=='.z')
351 if(file[-2]=='.z')
352 out('/Filter /FlateDecode')
352 out('/Filter /FlateDecode')
353 end
353 end
354 out('/Length1 '+info['length1'])
354 out('/Length1 '+info['length1'])
355 unless info['length2'].nil?
355 unless info['length2'].nil?
356 out('/Length2 '+info['length2']+' /Length3 0')
356 out('/Length2 '+info['length2']+' /Length3 0')
357 end
357 end
358 out('>>')
358 out('>>')
359 f=fopen(file,'rb')
359 f=fopen(file,'rb')
360 putstream(fread(f,size))
360 putstream(fread(f,size))
361 fclose(f)
361 fclose(f)
362 out('endobj')
362 out('endobj')
363 end
363 end
364 #
364 #
365 # set_magic_quotes_runtime(mqr)
365 # set_magic_quotes_runtime(mqr)
366 #
366 #
367 @fonts.each_pair do |k, font|
367 @fonts.each_pair do |k, font|
368 #Font objects
368 #Font objects
369 newobj()
369 newobj()
370 @fonts[k]['n']=@n
370 @fonts[k]['n']=@n
371 out('<</Type /Font')
371 out('<</Type /Font')
372 if(font['type']=='Type0')
372 if(font['type']=='Type0')
373 putType0(font)
373 putType0(font)
374 else
374 else
375 name=font['name']
375 name=font['name']
376 out('/BaseFont /'+name)
376 out('/BaseFont /'+name)
377 if(font['type']=='core')
377 if(font['type']=='core')
378 #Standard font
378 #Standard font
379 out('/Subtype /Type1')
379 out('/Subtype /Type1')
380 if(name!='Symbol' and name!='ZapfDingbats')
380 if(name!='Symbol' and name!='ZapfDingbats')
381 out('/Encoding /WinAnsiEncoding')
381 out('/Encoding /WinAnsiEncoding')
382 end
382 end
383 else
383 else
384 #Additional font
384 #Additional font
385 out('/Subtype /'+font['type'])
385 out('/Subtype /'+font['type'])
386 out('/FirstChar 32')
386 out('/FirstChar 32')
387 out('/LastChar 255')
387 out('/LastChar 255')
388 out('/Widths '+(@n+1)+' 0 R')
388 out('/Widths '+(@n+1)+' 0 R')
389 out('/FontDescriptor '+(@n+2)+' 0 R')
389 out('/FontDescriptor '+(@n+2)+' 0 R')
390 if(font['enc'])
390 if(font['enc'])
391 if !font['diff'].nil?
391 if !font['diff'].nil?
392 out('/Encoding '+(nf+font['diff'])+' 0 R')
392 out('/Encoding '+(nf+font['diff'])+' 0 R')
393 else
393 else
394 out('/Encoding /WinAnsiEncoding')
394 out('/Encoding /WinAnsiEncoding')
395 end
395 end
396 end
396 end
397 end
397 end
398 out('>>')
398 out('>>')
399 out('endobj')
399 out('endobj')
400 if(font['type']!='core')
400 if(font['type']!='core')
401 #Widths
401 #Widths
402 newobj()
402 newobj()
403 cw=font['cw']
403 cw=font['cw']
404 s='['
404 s='['
405 32.upto(255) do |i|
405 32.upto(255) do |i|
406 s+=cw[i.chr]+' '
406 s+=cw[i.chr]+' '
407 end
407 end
408 out(s+']')
408 out(s+']')
409 out('endobj')
409 out('endobj')
410 #Descriptor
410 #Descriptor
411 newobj()
411 newobj()
412 s='<</Type /FontDescriptor /FontName /'+name
412 s='<</Type /FontDescriptor /FontName /'+name
413 font['desc'].each_pair do |k, v|
413 font['desc'].each_pair do |k, v|
414 s+=' /'+k+' '+v
414 s+=' /'+k+' '+v
415 end
415 end
416 file=font['file']
416 file=font['file']
417 if(file)
417 if(file)
418 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@FontFiles[file]['n']+' 0 R'
418 s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@FontFiles[file]['n']+' 0 R'
419 end
419 end
420 out(s+'>>')
420 out(s+'>>')
421 out('endobj')
421 out('endobj')
422 end
422 end
423 end
423 end
424 end
424 end
425 end
425 end
426
426
427 def putType0(font)
427 def putType0(font)
428 #Type0
428 #Type0
429 out('/Subtype /Type0')
429 out('/Subtype /Type0')
430 out('/BaseFont /'+font['name']+'-'+font['CMap'])
430 out('/BaseFont /'+font['name']+'-'+font['CMap'])
431 out('/Encoding /'+font['CMap'])
431 out('/Encoding /'+font['CMap'])
432 out('/DescendantFonts ['+(@n+1).to_s+' 0 R]')
432 out('/DescendantFonts ['+(@n+1).to_s+' 0 R]')
433 out('>>')
433 out('>>')
434 out('endobj')
434 out('endobj')
435 #CIDFont
435 #CIDFont
436 newobj()
436 newobj()
437 out('<</Type /Font')
437 out('<</Type /Font')
438 out('/Subtype /CIDFontType0')
438 out('/Subtype /CIDFontType0')
439 out('/BaseFont /'+font['name'])
439 out('/BaseFont /'+font['name'])
440 out('/CIDSystemInfo <</Registry '+textstring('Adobe')+' /Ordering '+textstring(font['registry']['ordering'])+' /Supplement '+font['registry']['supplement'].to_s+'>>')
440 out('/CIDSystemInfo <</Registry '+textstring('Adobe')+' /Ordering '+textstring(font['registry']['ordering'])+' /Supplement '+font['registry']['supplement'].to_s+'>>')
441 out('/FontDescriptor '+(@n+1).to_s+' 0 R')
441 out('/FontDescriptor '+(@n+1).to_s+' 0 R')
442 if(font['CMap']=='ETen-B5-H')
442 if(font['CMap']=='ETen-B5-H')
443 w='13648 13742 500'
443 w='13648 13742 500'
444 elsif(font['CMap']=='GBK-EUC-H')
444 elsif(font['CMap']=='GBK-EUC-H')
445 w='814 907 500 7716 [500]'
445 w='814 907 500 7716 [500]'
446 else
446 else
447 # ActionController::Base::logger.debug font['cw'].keys.sort.join(' ').to_s
447 # ActionController::Base::logger.debug font['cw'].keys.sort.join(' ').to_s
448 # ActionController::Base::logger.debug font['cw'].values.join(' ').to_s
448 # ActionController::Base::logger.debug font['cw'].values.join(' ').to_s
449 w='1 ['
449 w='1 ['
450 font['cw'].keys.sort.each {|key|
450 font['cw'].keys.sort.each {|key|
451 w+=font['cw'][key].to_s + " "
451 w+=font['cw'][key].to_s + " "
452 # ActionController::Base::logger.debug key.to_s
452 # ActionController::Base::logger.debug key.to_s
453 # ActionController::Base::logger.debug font['cw'][key].to_s
453 # ActionController::Base::logger.debug font['cw'][key].to_s
454 }
454 }
455 w +=']'
455 w +=']'
456 end
456 end
457 out('/W ['+w+']>>')
457 out('/W ['+w+']>>')
458 out('endobj')
458 out('endobj')
459 #Font descriptor
459 #Font descriptor
460 newobj()
460 newobj()
461 out('<</Type /FontDescriptor')
461 out('<</Type /FontDescriptor')
462 out('/FontName /'+font['name'])
462 out('/FontName /'+font['name'])
463 out('/Flags 6')
463 out('/Flags 6')
464 out('/FontBBox [0 -200 1000 900]')
464 out('/FontBBox [0 -200 1000 900]')
465 out('/ItalicAngle 0')
465 out('/ItalicAngle 0')
466 out('/Ascent 800')
466 out('/Ascent 800')
467 out('/Descent -200')
467 out('/Descent -200')
468 out('/CapHeight 800')
468 out('/CapHeight 800')
469 out('/StemV 50')
469 out('/StemV 50')
470 out('>>')
470 out('>>')
471 out('endobj')
471 out('endobj')
472 end
472 end
473 end
473 end
General Comments 0
You need to be logged in to leave comments. Login now