mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-04 08:03:23 +00:00
Merged r1492 to r1498 from trunk.
git-svn-id: http://redmine.rubyforge.org/svn/branches/0.7-stable@1529 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
15ecbbf928
commit
3f62305e91
@ -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?
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
<p class="other-formats">
|
||||
<%= l(:label_export_to) %>
|
||||
<span><%= link_to 'Atom', {:format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
|
||||
<span><%= link_to 'Atom', {:query_id => @query, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
|
||||
<span><%= link_to 'CSV', {:format => 'csv'}, :class => 'csv' %></span>
|
||||
<span><%= link_to 'PDF', {:format => 'pdf'}, :class => 'pdf' %></span>
|
||||
</p>
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<% unless @replies.empty? %>
|
||||
<h3 class="icon22 icon22-comment"><%= l(:label_reply_plural) %></h3>
|
||||
<% @replies.each do |message| %>
|
||||
<a name="<%= "message-#{message.id}" %>"></a>
|
||||
@ -30,6 +31,7 @@
|
||||
<%= link_to_attachments message.attachments, :no_author => true %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||
<p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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: 開發人員
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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]]')
|
||||
|
||||
@ -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" +
|
||||
|
||||
@ -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"] = "时间:";
|
||||
|
||||
@ -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'] = '圖片';
|
||||
|
||||
@ -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'] = '图片';
|
||||
|
||||
@ -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" => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
|
||||
}
|
||||
@project = Project.find(1)
|
||||
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
||||
|
||||
946
vendor/plugins/rfpdf/lib/rfpdf/chinese.rb
vendored
946
vendor/plugins/rfpdf/lib/rfpdf/chinese.rb
vendored
@ -1,473 +1,473 @@
|
||||
# Copyright (c) 2006 4ssoM LLC <www.4ssoM.com>
|
||||
# 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(i<nb)
|
||||
c=s[i]
|
||||
if(c<128)
|
||||
l+=cw[c.chr] if cw[c.chr]
|
||||
i+=1
|
||||
else
|
||||
l+=1000
|
||||
i+=2
|
||||
end
|
||||
end
|
||||
return l*@FontSize/1000
|
||||
end
|
||||
|
||||
def MultiCell(w,h,txt,border=0,align='L',fill=0)
|
||||
if(@CurrentFont['type']=='Type0')
|
||||
MBMultiCell(w,h,txt,border,align,fill)
|
||||
else
|
||||
super(w,h,txt,border,align,fill)
|
||||
end
|
||||
end
|
||||
|
||||
def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
|
||||
#Multi-byte version of MultiCell()
|
||||
cw=@CurrentFont['cw']
|
||||
if(w==0)
|
||||
w=@w-@rMargin-@x
|
||||
end
|
||||
wmax=(w-2*@cMargin)*1000/@FontSize
|
||||
s=txt.gsub("\r",'')
|
||||
nb=s.length
|
||||
if(nb>0 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(i<nb)
|
||||
#Get next character
|
||||
c=s[i]
|
||||
#Check if ASCII or MB
|
||||
ascii=(c<128)
|
||||
if(c=="\n")
|
||||
#Explicit line break
|
||||
Cell(w,h,s[j,i-j],b,2,align,fill)
|
||||
i+=1
|
||||
sep=-1
|
||||
j=i
|
||||
l=0
|
||||
nl+=1
|
||||
if(border and nl==2)
|
||||
b=b2
|
||||
end
|
||||
next
|
||||
end
|
||||
if(!ascii)
|
||||
sep=i
|
||||
ls=l
|
||||
elsif(c==' ')
|
||||
sep=i
|
||||
ls=l
|
||||
end
|
||||
l+=ascii ? (cw[c.chr] || 0) : 1000
|
||||
if(l>wmax)
|
||||
#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(i<nb)
|
||||
#Get next character
|
||||
c=s[i]
|
||||
#Check if ASCII or MB
|
||||
ascii=(c<128)
|
||||
if(c=="\n")
|
||||
#Explicit line break
|
||||
Cell(w,h,s[j,i-j],0,2,'',0,link)
|
||||
i+=1
|
||||
sep=-1
|
||||
j=i
|
||||
l=0
|
||||
if(nl==1)
|
||||
@x=@lMargin
|
||||
w=@w-@rMargin-@x
|
||||
wmax=(w-2*@cMargin)*1000/@FontSize
|
||||
end
|
||||
nl+=1
|
||||
next
|
||||
end
|
||||
if(!ascii or c==' ')
|
||||
sep=i
|
||||
end
|
||||
l+=ascii ? cw[c.chr] : 1000
|
||||
if(l>wmax)
|
||||
#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('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['+diff+']>>')
|
||||
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('<</Length '+size)
|
||||
if(file[-2]=='.z')
|
||||
out('/Filter /FlateDecode')
|
||||
end
|
||||
out('/Length1 '+info['length1'])
|
||||
unless info['length2'].nil?
|
||||
out('/Length2 '+info['length2']+' /Length3 0')
|
||||
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('<</Type /Font')
|
||||
if(font['type']=='Type0')
|
||||
putType0(font)
|
||||
else
|
||||
name=font['name']
|
||||
out('/BaseFont /'+name)
|
||||
if(font['type']=='core')
|
||||
#Standard font
|
||||
out('/Subtype /Type1')
|
||||
if(name!='Symbol' and name!='ZapfDingbats')
|
||||
out('/Encoding /WinAnsiEncoding')
|
||||
end
|
||||
else
|
||||
#Additional font
|
||||
out('/Subtype /'+font['type'])
|
||||
out('/FirstChar 32')
|
||||
out('/LastChar 255')
|
||||
out('/Widths '+(@n+1)+' 0 R')
|
||||
out('/FontDescriptor '+(@n+2)+' 0 R')
|
||||
if(font['enc'])
|
||||
if !font['diff'].nil?
|
||||
out('/Encoding '+(nf+font['diff'])+' 0 R')
|
||||
else
|
||||
out('/Encoding /WinAnsiEncoding')
|
||||
end
|
||||
end
|
||||
end
|
||||
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='<</Type /FontDescriptor /FontName /'+name
|
||||
font['desc'].each_pair do |k, v|
|
||||
s+=' /'+k+' '+v
|
||||
end
|
||||
file=font['file']
|
||||
if(file)
|
||||
s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@FontFiles[file]['n']+' 0 R'
|
||||
end
|
||||
out(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('<</Type /Font')
|
||||
out('/Subtype /CIDFontType0')
|
||||
out('/BaseFont /'+font['name'])
|
||||
out('/CIDSystemInfo <</Registry '+textstring('Adobe')+' /Ordering '+textstring(font['registry']['ordering'])+' /Supplement '+font['registry']['supplement'].to_s+'>>')
|
||||
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('<</Type /FontDescriptor')
|
||||
out('/FontName /'+font['name'])
|
||||
out('/Flags 6')
|
||||
out('/FontBBox [0 -200 1000 900]')
|
||||
out('/ItalicAngle 0')
|
||||
out('/Ascent 800')
|
||||
out('/Descent -200')
|
||||
out('/CapHeight 800')
|
||||
out('/StemV 50')
|
||||
out('>>')
|
||||
out('endobj')
|
||||
end
|
||||
end
|
||||
# Copyright (c) 2006 4ssoM LLC <www.4ssoM.com>
|
||||
# 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(i<nb)
|
||||
c=s[i]
|
||||
if(c<128)
|
||||
l+=cw[c.chr] if cw[c.chr]
|
||||
i+=1
|
||||
else
|
||||
l+=1000
|
||||
i+=2
|
||||
end
|
||||
end
|
||||
return l*@FontSize/1000
|
||||
end
|
||||
|
||||
def MultiCell(w,h,txt,border=0,align='L',fill=0)
|
||||
if(@CurrentFont['type']=='Type0')
|
||||
MBMultiCell(w,h,txt,border,align,fill)
|
||||
else
|
||||
super(w,h,txt,border,align,fill)
|
||||
end
|
||||
end
|
||||
|
||||
def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
|
||||
#Multi-byte version of MultiCell()
|
||||
cw=@CurrentFont['cw']
|
||||
if(w==0)
|
||||
w=@w-@rMargin-@x
|
||||
end
|
||||
wmax=(w-2*@cMargin)*1000/@FontSize
|
||||
s=txt.gsub("\r",'')
|
||||
nb=s.length
|
||||
if(nb>0 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(i<nb)
|
||||
#Get next character
|
||||
c=s[i]
|
||||
#Check if ASCII or MB
|
||||
ascii=(c<128)
|
||||
if(c.chr=="\n")
|
||||
#Explicit line break
|
||||
Cell(w,h,s[j,i-j],b,2,align,fill)
|
||||
i+=1
|
||||
sep=-1
|
||||
j=i
|
||||
l=0
|
||||
nl+=1
|
||||
if(border and nl==2)
|
||||
b=b2
|
||||
end
|
||||
next
|
||||
end
|
||||
if(!ascii)
|
||||
sep=i
|
||||
ls=l
|
||||
elsif(c==' ')
|
||||
sep=i
|
||||
ls=l
|
||||
end
|
||||
l+=ascii ? (cw[c.chr] || 0) : 1100
|
||||
if(l>wmax)
|
||||
#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(i<nb)
|
||||
#Get next character
|
||||
c=s[i]
|
||||
#Check if ASCII or MB
|
||||
ascii=(c<128)
|
||||
if(c.chr=="\n")
|
||||
#Explicit line break
|
||||
Cell(w,h,s[j,i-j],0,2,'',0,link)
|
||||
i+=1
|
||||
sep=-1
|
||||
j=i
|
||||
l=0
|
||||
if(nl==1)
|
||||
@x=@lMargin
|
||||
w=@w-@rMargin-@x
|
||||
wmax=(w-2*@cMargin)*1000/@FontSize
|
||||
end
|
||||
nl+=1
|
||||
next
|
||||
end
|
||||
if(!ascii or c==' ')
|
||||
sep=i
|
||||
end
|
||||
l+=ascii ? cw[c.chr] : 1100
|
||||
if(l>wmax)
|
||||
#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('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['+diff+']>>')
|
||||
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('<</Length '+size)
|
||||
if(file[-2]=='.z')
|
||||
out('/Filter /FlateDecode')
|
||||
end
|
||||
out('/Length1 '+info['length1'])
|
||||
unless info['length2'].nil?
|
||||
out('/Length2 '+info['length2']+' /Length3 0')
|
||||
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('<</Type /Font')
|
||||
if(font['type']=='Type0')
|
||||
putType0(font)
|
||||
else
|
||||
name=font['name']
|
||||
out('/BaseFont /'+name)
|
||||
if(font['type']=='core')
|
||||
#Standard font
|
||||
out('/Subtype /Type1')
|
||||
if(name!='Symbol' and name!='ZapfDingbats')
|
||||
out('/Encoding /WinAnsiEncoding')
|
||||
end
|
||||
else
|
||||
#Additional font
|
||||
out('/Subtype /'+font['type'])
|
||||
out('/FirstChar 32')
|
||||
out('/LastChar 255')
|
||||
out('/Widths '+(@n+1)+' 0 R')
|
||||
out('/FontDescriptor '+(@n+2)+' 0 R')
|
||||
if(font['enc'])
|
||||
if !font['diff'].nil?
|
||||
out('/Encoding '+(nf+font['diff'])+' 0 R')
|
||||
else
|
||||
out('/Encoding /WinAnsiEncoding')
|
||||
end
|
||||
end
|
||||
end
|
||||
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='<</Type /FontDescriptor /FontName /'+name
|
||||
font['desc'].each_pair do |k, v|
|
||||
s+=' /'+k+' '+v
|
||||
end
|
||||
file=font['file']
|
||||
if(file)
|
||||
s+=' /FontFile'+(font['type']=='Type1' ? '' : '2')+' '+@FontFiles[file]['n']+' 0 R'
|
||||
end
|
||||
out(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('<</Type /Font')
|
||||
out('/Subtype /CIDFontType0')
|
||||
out('/BaseFont /'+font['name'])
|
||||
out('/CIDSystemInfo <</Registry '+textstring('Adobe')+' /Ordering '+textstring(font['registry']['ordering'])+' /Supplement '+font['registry']['supplement'].to_s+'>>')
|
||||
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('<</Type /FontDescriptor')
|
||||
out('/FontName /'+font['name'])
|
||||
out('/Flags 6')
|
||||
out('/FontBBox [0 -200 1000 900]')
|
||||
out('/ItalicAngle 0')
|
||||
out('/Ascent 800')
|
||||
out('/Descent -200')
|
||||
out('/CapHeight 800')
|
||||
out('/StemV 50')
|
||||
out('>>')
|
||||
out('endobj')
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user