diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 589b054..405c5bf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -298,7 +298,7 @@ module ApplicationHelper # source:some/file#L120 -> Link to line 120 of the file # source:some/file@52#L120 -> Link to line 120 of the file's revision 52 # export:some/file -> Force the download of the file - text = text.gsub(%r{([\s\(,-^])(!)?(attachment|document|version|commit|source|export)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*|"[^"]+"))(?=[[:punct:]]|\s|<|$)}) do |m| + text = text.gsub(%r{([\s\(,\-\>]|^)(!)?(attachment|document|version|commit|source|export)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*|"[^"]+"))(?=[[:punct:]]|\s|<|$)}) do |m| leading, esc, prefix, sep, oid = $1, $2, $3, $5 || $7, $6 || $8 link = nil if esc.nil? diff --git a/app/views/issues/index.rhtml b/app/views/issues/index.rhtml index 027f3f0..973f3eb 100644 --- a/app/views/issues/index.rhtml +++ b/app/views/issues/index.rhtml @@ -45,7 +45,7 @@

<%= l(:label_export_to) %> -<%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> +<%= link_to 'Atom', {:query_id => @query, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %> <%= link_to 'CSV', {:format => 'csv'}, :class => 'csv' %> <%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %>

diff --git a/app/views/messages/show.rhtml b/app/views/messages/show.rhtml index 251b7c7..c04c409 100644 --- a/app/views/messages/show.rhtml +++ b/app/views/messages/show.rhtml @@ -17,6 +17,7 @@
+<% unless @replies.empty? %>

<%= l(:label_reply_plural) %>

<% @replies.each do |message| %> "> @@ -30,6 +31,7 @@ <%= link_to_attachments message.attachments, :no_author => true %> <% end %> +<% end %> <% if !@topic.locked? && authorize_for('messages', 'reply') %>

<%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %>

diff --git a/lang/hu.yml b/lang/hu.yml index c3feaf1..2a399bc 100644 --- a/lang/hu.yml +++ b/lang/hu.yml @@ -620,3 +620,7 @@ default_activity_development: Fejlesztés enumeration_issue_priorities: Feladat prioritások enumeration_doc_categories: Dokumentum kategóriák enumeration_activities: Tevékenységek (idő rögzítés) +mail_body_reminder: "%d neked kiosztott feladat határidős az elkövetkező %d napban:" +mail_subject_reminder: "%d feladat határidős az elkövetkező napokban" +text_user_wrote: '%s írta:' +label_duplicated_by: duplikálta diff --git a/lang/no.yml b/lang/no.yml index 13fcd24..a31751d 100644 --- a/lang/no.yml +++ b/lang/no.yml @@ -91,6 +91,8 @@ mail_body_account_information_external: Du kan bruke din "%s"-konto for å logge mail_body_account_information: Informasjon om din konto mail_subject_account_activation_request: %s kontoaktivering mail_body_account_activation_request: 'En ny bruker (%s) er registrert, og avventer din godkjenning:' +mail_subject_reminder: "%d sak(er) har frist de kommende dagene" +mail_body_reminder: "%d sak(er) som er tildelt deg har frist de kommende %d dager:" gui_validation_error: 1 feil gui_validation_error_plural: %d feil @@ -445,7 +447,8 @@ label_loading: Laster... label_relation_new: Ny relasjon label_relation_delete: Slett relasjon label_relates_to: relatert til -label_duplicates: duplikater +label_duplicates: dupliserer +label_duplicated_by: duplisert av label_blocks: blokkerer label_blocked_by: blokkert av label_precedes: kommer før @@ -594,6 +597,7 @@ text_destroy_time_entries_question: %.02f timer er ført på sakene du er i ferd text_destroy_time_entries: Slett førte timer text_assign_time_entries_to_project: Overfør førte timer til prosjektet text_reassign_time_entries: 'Overfør førte timer til denne saken:' +text_user_wrote: '%s skrev:' default_role_manager: Leder default_role_developper: Utvikler diff --git a/lang/ru.yml b/lang/ru.yml index f690098..37f2aef 100644 --- a/lang/ru.yml +++ b/lang/ru.yml @@ -332,7 +332,7 @@ label_internal: Внутренний label_last_changes: менее %d изменений label_change_view_all: Просмотреть все изменения label_personalize_page: Персонализировать данную страницу -label_comment: Комментировать +label_comment: комментарий label_comment_plural: Комментарии label_comment_add: Оставить комментарий label_comment_added: Добавленный комментарий @@ -621,4 +621,9 @@ label_overall_activity: Сводная активность setting_default_projects_public: Новые проекты являются публичными error_scm_annotate: "Данные отсутствуют или не могут быть подписаны." label_planning: Планирование -text_subprojects_destroy_warning: 'Its subproject(s): %s will be also deleted.' +text_subprojects_destroy_warning: 'Подпроекты: %s также будут удалены.' +label_and_its_subprojects: %s и все подпроекты +mail_body_reminder: "%d назначенных на вас задач на следующие %d дней:" +mail_subject_reminder: "%d назначенных на вас задач в ближайшие дни" +text_user_wrote: '%s написал:' +label_duplicated_by: duplicated by diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml index 1bdc7d7..c3cd096 100644 --- a/lang/zh-tw.yml +++ b/lang/zh-tw.yml @@ -91,6 +91,8 @@ mail_body_account_information_external: 您可以使用 "%s" 帳號登入 Redmin mail_body_account_information: 您的 Redmine 帳號資訊 mail_subject_account_activation_request: Redmine 帳號啟用需求通知 mail_body_account_activation_request: '有位新用戶 (%s) 已經完成註冊,正等候您的審核:' +mail_subject_reminder: "您有 %d 個項目即將到期" +mail_body_reminder: "%d 個指派給您的項目,將於 %d 天之內到期:" gui_validation_error: 1 個錯誤 gui_validation_error_plural: %d 個錯誤 @@ -446,6 +448,7 @@ label_relation_new: 建立新關聯 label_relation_delete: 刪除關聯 label_relates_to: 關聯至 label_duplicates: 已重複 +label_duplicated_by: 與後面所列項目重複 label_blocks: 阻擋 label_blocked_by: 被阻擋 label_precedes: 優先於 @@ -594,6 +597,7 @@ text_destroy_time_entries_question: 您即將刪除的項目已報工 %.02f 小 text_destroy_time_entries: 刪除已報工的時數 text_assign_time_entries_to_project: 指定已報工的時數至專案中 text_reassign_time_entries: '重新指定已報工的時數至此項目:' +text_user_wrote: '%s 先前提到:' default_role_manager: 管理人員 default_role_developper: 開發人員 diff --git a/lang/zh.yml b/lang/zh.yml index 55516e0..9e22e68 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -91,6 +91,8 @@ mail_body_account_information_external: 您可以使用您的 "%s" 帐号来登 mail_body_account_information: 您的帐号信息 mail_subject_account_activation_request: %s帐号激活请求 mail_body_account_activation_request: '新用户(%s)已完成注册,正在等候您的审核:' +mail_subject_reminder: "%d 个问题需要尽快解决" +mail_body_reminder: "指派给您的 %d 个问题需要在 %d 天内完成:" gui_validation_error: 1 个错误 gui_validation_error_plural: %d 个错误 @@ -594,6 +596,7 @@ text_destroy_time_entries_question: 您要删除的问题已经上报了 %.02f text_destroy_time_entries: 删除上报的工作量 text_assign_time_entries_to_project: 将已上报的工作量提交到项目中 text_reassign_time_entries: '将已上报的工作量指定到此问题:' +text_user_wrote: '%s 写到:' default_role_manager: 管理人员 default_role_developper: 开发人员 @@ -620,5 +623,4 @@ default_activity_development: 开发 enumeration_issue_priorities: 问题优先级 enumeration_doc_categories: 文档类别 enumeration_activities: 活动(时间跟踪) -mail_subject_reminder: "%d issue(s) due in the next days" -mail_body_reminder: "%d issue(s) that are assigned to you are due in the next %d days:" +label_duplicated_by: duplicated by diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 8fbae9f..9563ed8 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -118,7 +118,7 @@ module Redmine def logger RAILS_DEFAULT_LOGGER end - + def shellout(cmd, &block) logger.debug "Shelling out: #{cmd}" if logger && logger.debug? begin @@ -127,11 +127,22 @@ module Redmine block.call(io) if block_given? end rescue Errno::ENOENT => e + msg = strip_credential(e.message) # The command failed, log it and re-raise - logger.error("SCM command failed: #{cmd}\n with: #{e.message}") - raise CommandFailed.new(e.message) + logger.error("SCM command failed: #{strip_credential(cmd)}\n with: #{msg}") + raise CommandFailed.new(msg) end end + + # Hides username/password in a given command + def self.hide_credential(cmd) + q = (RUBY_PLATFORM =~ /mswin/ ? '"' : "'") + cmd.to_s.gsub(/(\-\-(password|username))\s+(#{q}[^#{q}]+#{q}|[^#{q}]\S+)/, '\\1 xxxx') + end + + def strip_credential(cmd) + self.class.hide_credential(cmd) + end end class Entries < Array diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake index 5341fa1..8d5a35f 100644 --- a/lib/tasks/migrate_from_trac.rake +++ b/lib/tasks/migrate_from_trac.rake @@ -237,7 +237,8 @@ namespace :redmine do text = text.gsub(/\[\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"} text = text.gsub(/\[wiki:\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"} text = text.gsub(/\[wiki:\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"} - text = text.gsub(/\[wiki:([^\s\]]+).*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"} + text = text.gsub(/\[wiki:([^\s\]]+)\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"} + text = text.gsub(/\[wiki:([^\s\]]+)\s(.*)\]/) {|s| "[[#{$1.delete(',./?;|:')}|#{$2.delete(',./?;|:')}]]"} # Links to pages UsingJustWikiCaps text = text.gsub(/([^!]|^)(^| )([A-Z][a-z]+[A-Z][a-zA-Z]+)/, '\\1\\2[[\3]]') diff --git a/public/javascripts/calendar/lang/calendar-zh-tw.js b/public/javascripts/calendar/lang/calendar-zh-tw.js index c48d25b..1e759db 100644 --- a/public/javascripts/calendar/lang/calendar-zh-tw.js +++ b/public/javascripts/calendar/lang/calendar-zh-tw.js @@ -84,13 +84,13 @@ Calendar._TT["INFO"] = "關於 calendar"; Calendar._TT["ABOUT"] = "DHTML 日期/時間 選擇器\n" + "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-) -"最For latest version visit: http://www.dynarch.com/projects/calendar/\n" + -"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." + +"最新版本取得位址: http://www.dynarch.com/projects/calendar/\n" + +"使用 GNU LGPL 發行. 參考 http://gnu.org/licenses/lgpl.html 以取得更多關於 LGPL 之細節。" + "\n\n" + -"Date selection:\n" + -"- Use the \xab, \xbb buttons to select year\n" + -"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" + -"- Hold mouse button on any of the above buttons for faster selection."; +"日期選擇方式:\n" + +"- 使用滑鼠點擊 \xab 、 \xbb 按鈕選擇年份\n" + +"- 使用滑鼠點擊 " + String.fromCharCode(0x2039) + " 、 " + String.fromCharCode(0x203a) + " 按鈕選擇月份\n" + +"- 使用滑鼠點擊上述按鈕並按住不放,可開啟快速選單。"; Calendar._TT["ABOUT_TIME"] = "\n\n" + "時間選擇方式:\n" + "- 「單擊」時分秒為遞增\n" + diff --git a/public/javascripts/calendar/lang/calendar-zh.js b/public/javascripts/calendar/lang/calendar-zh.js index ddb092b..121653f 100644 --- a/public/javascripts/calendar/lang/calendar-zh.js +++ b/public/javascripts/calendar/lang/calendar-zh.js @@ -82,33 +82,33 @@ Calendar._TT = {}; Calendar._TT["INFO"] = "关于日历"; Calendar._TT["ABOUT"] = -"DHTML Date/Time Selector\n" + +"DHTML 日期/时间 选择器\n" + "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-) -"For latest version visit: http://www.dynarch.com/projects/calendar/\n" + -"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." + +"最新版本请访问: http://www.dynarch.com/projects/calendar/\n" + +"遵循 GNU LGPL 发布。详情请查阅 http://gnu.org/licenses/lgpl.html " + "\n\n" + -"Date selection:\n" + -"- Use the \xab, \xbb buttons to select year\n" + -"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" + -"- Hold mouse button on any of the above buttons for faster selection."; +"日期选择:\n" + +"- 使用 \xab,\xbb 按钮选择年\n" + +"- 使用 " + String.fromCharCode(0x2039) + "," + String.fromCharCode(0x203a) + " 按钮选择月\n" + +"- 在上述按钮上按住不放可以快速选择"; Calendar._TT["ABOUT_TIME"] = "\n\n" + -"Time selection:\n" + -"- Click on any of the time parts to increase it\n" + -"- or Shift-click to decrease it\n" + -"- or click and drag for faster selection."; +"时间选择:\n" + +"- 点击时间的任意部分来增加\n" + +"- Shift加点击来减少\n" + +"- 点击后拖动进行快速选择"; -Calendar._TT["PREV_YEAR"] = "上年 (hold for menu)"; -Calendar._TT["PREV_MONTH"] = "上月 (hold for menu)"; +Calendar._TT["PREV_YEAR"] = "上年(按住不放显示菜单)"; +Calendar._TT["PREV_MONTH"] = "上月(按住不放显示菜单)"; Calendar._TT["GO_TODAY"] = "回到今天"; -Calendar._TT["NEXT_MONTH"] = "下月 (hold for menu)"; -Calendar._TT["NEXT_YEAR"] = "下年 (hold for menu)"; +Calendar._TT["NEXT_MONTH"] = "下月(按住不放显示菜单)"; +Calendar._TT["NEXT_YEAR"] = "下年(按住不放显示菜单)"; Calendar._TT["SEL_DATE"] = "选择日期"; Calendar._TT["DRAG_TO_MOVE"] = "拖动"; Calendar._TT["PART_TODAY"] = " (今日)"; // the following is to inform that "%s" is to be the first day of week // %s will be replaced with the day name. -Calendar._TT["DAY_FIRST"] = "Display %s first"; +Calendar._TT["DAY_FIRST"] = "一周开始于 %s"; // This may be locale-dependent. It specifies the week-end days, as an array // of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1 @@ -117,11 +117,11 @@ Calendar._TT["WEEKEND"] = "0,6"; Calendar._TT["CLOSE"] = "关闭"; Calendar._TT["TODAY"] = "今天"; -Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value"; +Calendar._TT["TIME_PART"] = "Shift加点击或者拖动来变更"; // date formats Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d"; -Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e"; +Calendar._TT["TT_DATE_FORMAT"] = "星期%a %b%e日"; -Calendar._TT["WK"] = "wk"; -Calendar._TT["TIME"] = "Time:"; +Calendar._TT["WK"] = "周"; +Calendar._TT["TIME"] = "时间:"; diff --git a/public/javascripts/jstoolbar/lang/jstoolbar-zh-tw.js b/public/javascripts/jstoolbar/lang/jstoolbar-zh-tw.js index 1e46e24..86599c5 100644 --- a/public/javascripts/jstoolbar/lang/jstoolbar-zh-tw.js +++ b/public/javascripts/jstoolbar/lang/jstoolbar-zh-tw.js @@ -9,6 +9,8 @@ jsToolBar.strings['Heading 2'] = '標題 2'; jsToolBar.strings['Heading 3'] = '標題 3'; jsToolBar.strings['Unordered list'] = '項目清單'; jsToolBar.strings['Ordered list'] = '編號清單'; -jsToolBar.strings['Preformatted text'] = '格式化文字'; +jsToolBar.strings['Quote'] = '引文'; +jsToolBar.strings['Unquote'] = '取消引文'; +jsToolBar.strings['Preformatted text'] = '已格式文字'; jsToolBar.strings['Wiki link'] = '連結至 Wiki 頁面'; jsToolBar.strings['Image'] = '圖片'; diff --git a/public/javascripts/jstoolbar/lang/jstoolbar-zh.js b/public/javascripts/jstoolbar/lang/jstoolbar-zh.js index cd36a4b..a9b6ba2 100644 --- a/public/javascripts/jstoolbar/lang/jstoolbar-zh.js +++ b/public/javascripts/jstoolbar/lang/jstoolbar-zh.js @@ -1,14 +1,16 @@ jsToolBar.strings = {}; -jsToolBar.strings['Strong'] = 'Strong'; -jsToolBar.strings['Italic'] = 'Italic'; -jsToolBar.strings['Underline'] = 'Underline'; -jsToolBar.strings['Deleted'] = 'Deleted'; -jsToolBar.strings['Code'] = 'Inline Code'; -jsToolBar.strings['Heading 1'] = 'Heading 1'; -jsToolBar.strings['Heading 2'] = 'Heading 2'; -jsToolBar.strings['Heading 3'] = 'Heading 3'; -jsToolBar.strings['Unordered list'] = 'Unordered list'; -jsToolBar.strings['Ordered list'] = 'Ordered list'; -jsToolBar.strings['Preformatted text'] = 'Preformatted text'; -jsToolBar.strings['Wiki link'] = 'Link to a Wiki page'; -jsToolBar.strings['Image'] = 'Image'; +jsToolBar.strings['Strong'] = '粗体'; +jsToolBar.strings['Italic'] = '斜体'; +jsToolBar.strings['Underline'] = '下划线'; +jsToolBar.strings['Deleted'] = '删除线'; +jsToolBar.strings['Code'] = '程序代码'; +jsToolBar.strings['Heading 1'] = '标题 1'; +jsToolBar.strings['Heading 2'] = '标题 2'; +jsToolBar.strings['Heading 3'] = '标题 3'; +jsToolBar.strings['Unordered list'] = '无序列表'; +jsToolBar.strings['Ordered list'] = '排序列表'; +jsToolBar.strings['Quote'] = '引用'; +jsToolBar.strings['Unquote'] = '删除引用'; +jsToolBar.strings['Preformatted text'] = '格式化文本'; +jsToolBar.strings['Wiki link'] = '连接到 Wiki 页面'; +jsToolBar.strings['Image'] = '图片'; diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index d98a33c..a1a369c 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -108,7 +108,9 @@ class ApplicationHelperTest < HelperTestCase '!version:"1.0"' => 'version:"1.0"', '!source:/some/file' => 'source:/some/file', # invalid expressions - 'source:' => 'source:' + 'source:' => 'source:', + # url hash + "http://foo.bar/FAQ#3" => 'http://foo.bar/FAQ#3', } @project = Project.find(1) to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } diff --git a/vendor/plugins/rfpdf/lib/rfpdf/chinese.rb b/vendor/plugins/rfpdf/lib/rfpdf/chinese.rb index 6fe3eee..5684c70 100644 --- a/vendor/plugins/rfpdf/lib/rfpdf/chinese.rb +++ b/vendor/plugins/rfpdf/lib/rfpdf/chinese.rb @@ -1,473 +1,473 @@ -# Copyright (c) 2006 4ssoM LLC -# 1.12 contributed by Ed Moss. -# -# The MIT License -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# This is direct port of chinese.php -# -# Chinese PDF support. -# -# Usage is as follows: -# -# require 'fpdf' -# require 'chinese' -# pdf = FPDF.new -# pdf.extend(PDF_Chinese) -# -# This allows it to be combined with other extensions, such as the bookmark -# module. - -module PDF_Chinese - - Big5_widths={' '=>250,'!'=>250,'"'=>408,'#'=>668,''=>490,'%'=>875,'&'=>698,'\''=>250, - '('=>240,')'=>240,'*'=>417,'+'=>667,','=>250,'-'=>313,'.'=>250,'/'=>520,'0'=>500,'1'=>500, - '2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>250,''=>250, - '<'=>667,'='=>667,'>'=>667,'?'=>396,'@'=>921,'A'=>677,'B'=>615,'C'=>719,'D'=>760,'E'=>625, - 'F'=>552,'G'=>771,'H'=>802,'I'=>354,'J'=>354,'K'=>781,'L'=>604,'M'=>927,'N'=>750,'O'=>823, - 'P'=>563,'Q'=>823,'R'=>729,'S'=>542,'T'=>698,'U'=>771,'V'=>729,'W'=>948,'X'=>771,'Y'=>677, - 'Z'=>635,'['=>344,'\\'=>520,']'=>344,'^'=>469,'_'=>500,'`'=>250,'a'=>469,'b'=>521,'c'=>427, - 'd'=>521,'e'=>438,'f'=>271,'g'=>469,'h'=>531,'i'=>250,'j'=>250,'k'=>458,'l'=>240,'m'=>802, - 'n'=>531,'o'=>500,'p'=>521,'q'=>521,'r'=>365,'s'=>333,'t'=>292,'u'=>521,'v'=>458,'w'=>677, - 'x'=>479,'y'=>458,'z'=>427,'{'=>480,'|'=>496,'end'=>480,'~'=>667} - - GB_widths={' '=>207,'!'=>270,'"'=>342,'#'=>467,''=>462,'%'=>797,'&'=>710,'\''=>239, - '('=>374,')'=>374,'*'=>423,'+'=>605,','=>238,'-'=>375,'.'=>238,'/'=>334,'0'=>462,'1'=>462, - '2'=>462,'3'=>462,'4'=>462,'5'=>462,'6'=>462,'7'=>462,'8'=>462,'9'=>462,':'=>238,''=>238, - '<'=>605,'='=>605,'>'=>605,'?'=>344,'@'=>748,'A'=>684,'B'=>560,'C'=>695,'D'=>739,'E'=>563, - 'F'=>511,'G'=>729,'H'=>793,'I'=>318,'J'=>312,'K'=>666,'L'=>526,'M'=>896,'N'=>758,'O'=>772, - 'P'=>544,'Q'=>772,'R'=>628,'S'=>465,'T'=>607,'U'=>753,'V'=>711,'W'=>972,'X'=>647,'Y'=>620, - 'Z'=>607,'['=>374,'\\'=>333,']'=>374,'^'=>606,'_'=>500,'`'=>239,'a'=>417,'b'=>503,'c'=>427, - 'd'=>529,'e'=>415,'f'=>264,'g'=>444,'h'=>518,'i'=>241,'j'=>230,'k'=>495,'l'=>228,'m'=>793, - 'n'=>527,'o'=>524,'p'=>524,'q'=>504,'r'=>338,'s'=>336,'t'=>277,'u'=>517,'v'=>450,'w'=>652, - 'x'=>466,'y'=>452,'z'=>407,'{'=>370,'|'=>258,'end'=>370,'~'=>605} - - def AddCIDFont(family,style,name,cw,cMap,registry) -#ActionController::Base::logger.debug registry.to_a.join(":").to_s - fontkey=family.downcase+style.upcase - unless @fonts[fontkey].nil? - Error("Font already added: family style") - end - i=@fonts.length+1 - name=name.gsub(' ','') - @fonts[fontkey]={'i'=>i,'type'=>'Type0','name'=>name,'up'=>-130,'ut'=>40,'cw'=>cw, 'CMap'=>cMap,'registry'=>registry} - end - - def AddCIDFonts(family,name,cw,cMap,registry) - AddCIDFont(family,'',name,cw,cMap,registry) - AddCIDFont(family,'B',name+',Bold',cw,cMap,registry) - AddCIDFont(family,'I',name+',Italic',cw,cMap,registry) - AddCIDFont(family,'BI',name+',BoldItalic',cw,cMap,registry) - end - - def AddBig5Font(family='Big5',name='MSungStd-Light-Acro') - #Add Big5 font with proportional Latin - cw=Big5_widths - cMap='ETenms-B5-H' - registry={'ordering'=>'CNS1','supplement'=>0} -#ActionController::Base::logger.debug registry.to_a.join(":").to_s - AddCIDFonts(family,name,cw,cMap,registry) - end - - def AddBig5hwFont(family='Big5-hw',name='MSungStd-Light-Acro') - #Add Big5 font with half-witdh Latin - cw = {} - 32.upto(126) do |i| - cw[i.chr]=500 - end - cMap='ETen-B5-H' - registry={'ordering'=>'CNS1','supplement'=>0} - AddCIDFonts(family,name,cw,cMap,registry) - end - - def AddGBFont(family='GB',name='STSongStd-Light-Acro') - #Add GB font with proportional Latin - cw=GB_widths - cMap='GBKp-EUC-H' - registry={'ordering'=>'GB1','supplement'=>2} - AddCIDFonts(family,name,cw,cMap,registry) - end - - def AddGBhwFont(family='GB-hw',name='STSongStd-Light-Acro') - #Add GB font with half-width Latin - 32.upto(126) do |i| - cw[i.chr]=500 - end - cMap='GBK-EUC-H' - registry={'ordering'=>'GB1','supplement'=>2} - AddCIDFonts(family,name,cw,cMap,registry) - end - - def GetStringWidth(s) - if(@CurrentFont['type']=='Type0') - return GetMBStringWidth(s) - else - return super(s) - end - end - - def GetMBStringWidth(s) - #Multi-byte version of GetStringWidth() - l=0 - cw=@CurrentFont['cw'] - nb=s.length - i=0 - while(i0 and s[nb-1]=="\n") - nb-=1 - end - b=0 - if(border) - if(border==1) - border='LTRB' - b='LRT' - b2='LR' - else - b2='' - if(border.to_s.index('L')) - b2+='L' - end - if(border.to_s.index('R')) - b2+='R' - end - b=border.to_s.index('T') ? b2+'T' : b2 - end - end - sep=-1 - i=0 - j=0 - l=0 - nl=1 - while(iwmax) - #Automatic line break - if(sep==-1 or i==j) - if(i==j) - i+=ascii ? 1 : 2 - end - Cell(w,h,s[j,i-j],b,2,align,fill) - else - Cell(w,h,s[j,sep-j],b,2,align,fill) - i=(s[sep]==' ') ? sep+1 : sep - end - sep=-1 - j=i - l=0 -# nl+=1 - if(border and nl==2) - b=b2 - end - else - i+=ascii ? 1 : 2 - end - end - #Last chunk - if(border and not border.to_s.index('B').nil?) - b+='B' - end - Cell(w,h,s[j,i-j],b,2,align,fill) - @x=@lMargin - end - - def Write(h,txt,link='') - if(@CurrentFont['type']=='Type0') - MBWrite(h,txt,link) - else - super(h,txt,link) - end - end - - def MBWrite(h,txt,link) - #Multi-byte version of Write() - cw=@CurrentFont['cw'] - w=@w-@rMargin-@x - wmax=(w-2*@cMargin)*1000/@FontSize - s=txt.gsub("\r",'') - nb=s.length - sep=-1 - i=0 - j=0 - l=0 - nl=1 - while(iwmax) - #Automatic line break - if(sep==-1 or i==j) - if(@x>@lMargin) - #Move to next line - @x=@lMargin - @y+=h - w=@w-@rMargin-@x - wmax=(w-2*@cMargin)*1000/@FontSize - i+=1 - nl+=1 - next - end - if(i==j) - i+=ascii ? 1 : 2 - end - Cell(w,h,s[j,i-j],0,2,'',0,link) - else - Cell(w,h,s[j,sep-j],0,2,'',0,link) - i=(s[sep]==' ') ? sep+1 : sep - end - sep=-1 - j=i - l=0 - if(nl==1) - @x=@lMargin - w=@w-@rMargin-@x - wmax=(w-2*@cMargin)*1000/@FontSize - end - nl+=1 - else - i+=ascii ? 1 : 2 - end - end - #Last chunk - if(i!=j) - Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link) - end - end - -private - - def putfonts() - nf=@n - @diffs.each do |diff| - #Encodings - newobj() - out('<>') - out('endobj') - end - # mqr=get_magic_quotes_runtime() - # set_magic_quotes_runtime(0) - @FontFiles.each_pair do |file, info| - #Font file embedding - newobj() - @FontFiles[file]['n']=@n - if(defined('FPDF_FONTPATH')) - file=FPDF_FONTPATH+file - end - size=filesize(file) - if(!size) - Error('Font file not found') - end - out('<>') - f=fopen(file,'rb') - putstream(fread(f,size)) - fclose(f) - out('endobj') - end -# - # set_magic_quotes_runtime(mqr) -# - @fonts.each_pair do |k, font| - #Font objects - newobj() - @fonts[k]['n']=@n - out('<>') - out('endobj') - if(font['type']!='core') - #Widths - newobj() - cw=font['cw'] - s='[' - 32.upto(255) do |i| - s+=cw[i.chr]+' ' - end - out(s+']') - out('endobj') - #Descriptor - newobj() - s='<>') - out('endobj') - end - end - end - end - - def putType0(font) - #Type0 - out('/Subtype /Type0') - out('/BaseFont /'+font['name']+'-'+font['CMap']) - out('/Encoding /'+font['CMap']) - out('/DescendantFonts ['+(@n+1).to_s+' 0 R]') - out('>>') - out('endobj') - #CIDFont - newobj() - out('<>') - out('/FontDescriptor '+(@n+1).to_s+' 0 R') - if(font['CMap']=='ETen-B5-H') - w='13648 13742 500' - elsif(font['CMap']=='GBK-EUC-H') - w='814 907 500 7716 [500]' - else - # ActionController::Base::logger.debug font['cw'].keys.sort.join(' ').to_s - # ActionController::Base::logger.debug font['cw'].values.join(' ').to_s - w='1 [' - font['cw'].keys.sort.each {|key| - w+=font['cw'][key].to_s + " " -# ActionController::Base::logger.debug key.to_s -# ActionController::Base::logger.debug font['cw'][key].to_s - } - w +=']' - end - out('/W ['+w+']>>') - out('endobj') - #Font descriptor - newobj() - out('<>') - out('endobj') - end -end +# Copyright (c) 2006 4ssoM LLC +# 1.12 contributed by Ed Moss. +# +# The MIT License +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# This is direct port of chinese.php +# +# Chinese PDF support. +# +# Usage is as follows: +# +# require 'fpdf' +# require 'chinese' +# pdf = FPDF.new +# pdf.extend(PDF_Chinese) +# +# This allows it to be combined with other extensions, such as the bookmark +# module. + +module PDF_Chinese + + Big5_widths={' '=>250,'!'=>250,'"'=>408,'#'=>668,''=>490,'%'=>875,'&'=>698,'\''=>250, + '('=>240,')'=>240,'*'=>417,'+'=>667,','=>250,'-'=>313,'.'=>250,'/'=>520,'0'=>500,'1'=>500, + '2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>250,''=>250, + '<'=>667,'='=>667,'>'=>667,'?'=>396,'@'=>921,'A'=>677,'B'=>615,'C'=>719,'D'=>760,'E'=>625, + 'F'=>552,'G'=>771,'H'=>802,'I'=>354,'J'=>354,'K'=>781,'L'=>604,'M'=>927,'N'=>750,'O'=>823, + 'P'=>563,'Q'=>823,'R'=>729,'S'=>542,'T'=>698,'U'=>771,'V'=>729,'W'=>948,'X'=>771,'Y'=>677, + 'Z'=>635,'['=>344,'\\'=>520,']'=>344,'^'=>469,'_'=>500,'`'=>250,'a'=>469,'b'=>521,'c'=>427, + 'd'=>521,'e'=>438,'f'=>271,'g'=>469,'h'=>531,'i'=>250,'j'=>250,'k'=>458,'l'=>240,'m'=>802, + 'n'=>531,'o'=>500,'p'=>521,'q'=>521,'r'=>365,'s'=>333,'t'=>292,'u'=>521,'v'=>458,'w'=>677, + 'x'=>479,'y'=>458,'z'=>427,'{'=>480,'|'=>496,'end'=>480,'~'=>667} + + GB_widths={' '=>207,'!'=>270,'"'=>342,'#'=>467,''=>462,'%'=>797,'&'=>710,'\''=>239, + '('=>374,')'=>374,'*'=>423,'+'=>605,','=>238,'-'=>375,'.'=>238,'/'=>334,'0'=>462,'1'=>462, + '2'=>462,'3'=>462,'4'=>462,'5'=>462,'6'=>462,'7'=>462,'8'=>462,'9'=>462,':'=>238,''=>238, + '<'=>605,'='=>605,'>'=>605,'?'=>344,'@'=>748,'A'=>684,'B'=>560,'C'=>695,'D'=>739,'E'=>563, + 'F'=>511,'G'=>729,'H'=>793,'I'=>318,'J'=>312,'K'=>666,'L'=>526,'M'=>896,'N'=>758,'O'=>772, + 'P'=>544,'Q'=>772,'R'=>628,'S'=>465,'T'=>607,'U'=>753,'V'=>711,'W'=>972,'X'=>647,'Y'=>620, + 'Z'=>607,'['=>374,'\\'=>333,']'=>374,'^'=>606,'_'=>500,'`'=>239,'a'=>417,'b'=>503,'c'=>427, + 'd'=>529,'e'=>415,'f'=>264,'g'=>444,'h'=>518,'i'=>241,'j'=>230,'k'=>495,'l'=>228,'m'=>793, + 'n'=>527,'o'=>524,'p'=>524,'q'=>504,'r'=>338,'s'=>336,'t'=>277,'u'=>517,'v'=>450,'w'=>652, + 'x'=>466,'y'=>452,'z'=>407,'{'=>370,'|'=>258,'end'=>370,'~'=>605} + + def AddCIDFont(family,style,name,cw,cMap,registry) +#ActionController::Base::logger.debug registry.to_a.join(":").to_s + fontkey=family.downcase+style.upcase + unless @fonts[fontkey].nil? + Error("Font already added: family style") + end + i=@fonts.length+1 + name=name.gsub(' ','') + @fonts[fontkey]={'i'=>i,'type'=>'Type0','name'=>name,'up'=>-130,'ut'=>40,'cw'=>cw, 'CMap'=>cMap,'registry'=>registry} + end + + def AddCIDFonts(family,name,cw,cMap,registry) + AddCIDFont(family,'',name,cw,cMap,registry) + AddCIDFont(family,'B',name+',Bold',cw,cMap,registry) + AddCIDFont(family,'I',name+',Italic',cw,cMap,registry) + AddCIDFont(family,'BI',name+',BoldItalic',cw,cMap,registry) + end + + def AddBig5Font(family='Big5',name='MSungStd-Light-Acro') + #Add Big5 font with proportional Latin + cw=Big5_widths + cMap='ETenms-B5-H' + registry={'ordering'=>'CNS1','supplement'=>0} +#ActionController::Base::logger.debug registry.to_a.join(":").to_s + AddCIDFonts(family,name,cw,cMap,registry) + end + + def AddBig5hwFont(family='Big5-hw',name='MSungStd-Light-Acro') + #Add Big5 font with half-witdh Latin + cw = {} + 32.upto(126) do |i| + cw[i.chr]=500 + end + cMap='ETen-B5-H' + registry={'ordering'=>'CNS1','supplement'=>0} + AddCIDFonts(family,name,cw,cMap,registry) + end + + def AddGBFont(family='GB',name='STSongStd-Light-Acro') + #Add GB font with proportional Latin + cw=GB_widths + cMap='GBKp-EUC-H' + registry={'ordering'=>'GB1','supplement'=>2} + AddCIDFonts(family,name,cw,cMap,registry) + end + + def AddGBhwFont(family='GB-hw',name='STSongStd-Light-Acro') + #Add GB font with half-width Latin + 32.upto(126) do |i| + cw[i.chr]=500 + end + cMap='GBK-EUC-H' + registry={'ordering'=>'GB1','supplement'=>2} + AddCIDFonts(family,name,cw,cMap,registry) + end + + def GetStringWidth(s) + if(@CurrentFont['type']=='Type0') + return GetMBStringWidth(s) + else + return super(s) + end + end + + def GetMBStringWidth(s) + #Multi-byte version of GetStringWidth() + l=0 + cw=@CurrentFont['cw'] + nb=s.length + i=0 + while(i0 and s[nb-1]=="\n") + nb-=1 + end + b=0 + if(border) + if(border==1) + border='LTRB' + b='LRT' + b2='LR' + else + b2='' + if(border.to_s.index('L')) + b2+='L' + end + if(border.to_s.index('R')) + b2+='R' + end + b=border.to_s.index('T') ? b2+'T' : b2 + end + end + sep=-1 + i=0 + j=0 + l=0 + nl=1 + while(iwmax) + #Automatic line break + if(sep==-1 or i==j) + if(i==j) + i+=ascii ? 1 : 3 + end + Cell(w,h,s[j,i-j],b,2,align,fill) + else + Cell(w,h,s[j,sep-j],b,2,align,fill) + i=(s[sep]==' ') ? sep+1 : sep + end + sep=-1 + j=i + l=0 +# nl+=1 + if(border and nl==2) + b=b2 + end + else + i+=ascii ? 1 : 3 + end + end + #Last chunk + if(border and not border.to_s.index('B').nil?) + b+='B' + end + Cell(w,h,s[j,i-j],b,2,align,fill) + @x=@lMargin + end + + def Write(h,txt,link='') + if(@CurrentFont['type']=='Type0') + MBWrite(h,txt,link) + else + super(h,txt,link) + end + end + + def MBWrite(h,txt,link) + #Multi-byte version of Write() + cw=@CurrentFont['cw'] + w=@w-@rMargin-@x + wmax=(w-2*@cMargin)*1000/@FontSize + s=txt.gsub("\r",'') + nb=s.length + sep=-1 + i=0 + j=0 + l=0 + nl=1 + while(iwmax) + #Automatic line break + if(sep==-1 or i==j) + if(@x>@lMargin) + #Move to next line + @x=@lMargin + @y+=h + w=@w-@rMargin-@x + wmax=(w-2*@cMargin)*1000/@FontSize + i+=1 + nl+=1 + next + end + if(i==j) + i+=ascii ? 1 : 3 + end + Cell(w,h,s[j,i-j],0,2,'',0,link) + else + Cell(w,h,s[j,sep-j],0,2,'',0,link) + i=(s[sep]==' ') ? sep+1 : sep + end + sep=-1 + j=i + l=0 + if(nl==1) + @x=@lMargin + w=@w-@rMargin-@x + wmax=(w-2*@cMargin)*1000/@FontSize + end + nl+=1 + else + i+=ascii ? 1 : 3 + end + end + #Last chunk + if(i!=j) + Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link) + end + end + +private + + def putfonts() + nf=@n + @diffs.each do |diff| + #Encodings + newobj() + out('<>') + out('endobj') + end + # mqr=get_magic_quotes_runtime() + # set_magic_quotes_runtime(0) + @FontFiles.each_pair do |file, info| + #Font file embedding + newobj() + @FontFiles[file]['n']=@n + if(defined('FPDF_FONTPATH')) + file=FPDF_FONTPATH+file + end + size=filesize(file) + if(!size) + Error('Font file not found') + end + out('<>') + f=fopen(file,'rb') + putstream(fread(f,size)) + fclose(f) + out('endobj') + end +# + # set_magic_quotes_runtime(mqr) +# + @fonts.each_pair do |k, font| + #Font objects + newobj() + @fonts[k]['n']=@n + out('<>') + out('endobj') + if(font['type']!='core') + #Widths + newobj() + cw=font['cw'] + s='[' + 32.upto(255) do |i| + s+=cw[i.chr]+' ' + end + out(s+']') + out('endobj') + #Descriptor + newobj() + s='<>') + out('endobj') + end + end + end + end + + def putType0(font) + #Type0 + out('/Subtype /Type0') + out('/BaseFont /'+font['name']+'-'+font['CMap']) + out('/Encoding /'+font['CMap']) + out('/DescendantFonts ['+(@n+1).to_s+' 0 R]') + out('>>') + out('endobj') + #CIDFont + newobj() + out('<>') + out('/FontDescriptor '+(@n+1).to_s+' 0 R') + if(font['CMap']=='ETen-B5-H') + w='13648 13742 500' + elsif(font['CMap']=='GBK-EUC-H') + w='814 907 500 7716 [500]' + else + # ActionController::Base::logger.debug font['cw'].keys.sort.join(' ').to_s + # ActionController::Base::logger.debug font['cw'].values.join(' ').to_s + w='1 [' + font['cw'].keys.sort.each {|key| + w+=font['cw'][key].to_s + " " +# ActionController::Base::logger.debug key.to_s +# ActionController::Base::logger.debug font['cw'][key].to_s + } + w +=']' + end + out('/W ['+w+']>>') + out('endobj') + #Font descriptor + newobj() + out('<>') + out('endobj') + end +end