From 235f83d470866decff55a50c0ea380ab174457d8 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 21 Sep 2013 00:12:01 -0400 Subject: v4 v5: i18n CJK: zh ja ko, add languages Chinese, Japanese, Korean * texpdf, has large texlive xetex dependencies (Korean untested) --- lib/sisu/v4/constants.rb | 2 +- lib/sisu/v4/dal_syntax.rb | 2 +- lib/sisu/v4/i18n.rb | 6 ++++++ lib/sisu/v4/options.rb | 11 ++++------ lib/sisu/v4/param_make.rb | 24 ++++++++++++++++++++++ lib/sisu/v4/sysenv.rb | 27 +++++++++++++++++++++++++ lib/sisu/v4/texpdf_format.rb | 48 +++++++++++++++++++++++++++++++++++++++++--- lib/sisu/v5/constants.rb | 2 +- lib/sisu/v5/dal_syntax.rb | 2 +- lib/sisu/v5/i18n.rb | 6 ++++++ lib/sisu/v5/options.rb | 11 ++++------ lib/sisu/v5/param_make.rb | 24 ++++++++++++++++++++++ lib/sisu/v5/sysenv.rb | 27 +++++++++++++++++++++++++ lib/sisu/v5/texpdf_format.rb | 48 +++++++++++++++++++++++++++++++++++++++++--- 14 files changed, 216 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb index 28bb2f49..962b1ca4 100644 --- a/lib/sisu/v4/constants.rb +++ b/lib/sisu/v4/constants.rb @@ -209,7 +209,7 @@ Px={ po_subscript_o: ',{', po_subscript_c: '},', po_hilite_o: '*{', po_hilite_c: '}*', po_monospace_o: '#{', po_monospace_c: '}#', - lng_lst: %w[am bg bn br ca cs cy da de el en eo es et eu fi fr ga gl he hi hr hy ia is it la lo lt lv ml mr nl nn no oc pl pt pt_BR ro ru sa se sk sl sq sr sv ta te th tk tr uk ur us vi], + lng_lst: %w[am bg bn br ca cs cy da de el en eo es et eu fi fr ga gl he hi hr hy ia is it ja ko la lo lt lv ml mr nl nn no oc pl pt pt_BR ro ru sa se sk sl sq sr sv ta te th tk tr uk ur us vi zh], lv1: '*', lv2: '=', lv3: '=', diff --git a/lib/sisu/v4/dal_syntax.rb b/lib/sisu/v4/dal_syntax.rb index c49f41f7..0f57307e 100644 --- a/lib/sisu/v4/dal_syntax.rb +++ b/lib/sisu/v4/dal_syntax.rb @@ -332,7 +332,7 @@ module SiSU_DAL_Syntax dob end def fontface(dob) - leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>/ + leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。]|\>/ dob=fontface_lines(dob,leader) dob.obj=dob.obj.gsub(/(#{leader})\*\{(.+?)\}\*/m, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis diff --git a/lib/sisu/v4/i18n.rb b/lib/sisu/v4/i18n.rb index 3bccc1fc..7480e15f 100644 --- a/lib/sisu/v4/i18n.rb +++ b/lib/sisu/v4/i18n.rb @@ -91,6 +91,8 @@ module SiSU_i18n ia: { c: 'ia', n: 'Interlingua', t: 'Interlingua', xlp: 'interlingua' }, is: { c: 'is', n: 'Icelandic', t: 'Icelandic', xlp: 'icelandic' }, it: { c: 'it', n: 'Italian', t: 'Italiano', xlp: 'italian' }, + ja: { c: 'ja', n: 'Japanese', t: '日本語 (Nihongo)', xlp: 'japanese' }, + ko: { c: 'ko', n: 'Korean', t: 'Korean', xlp: 'korean' }, la: { c: 'la', n: 'Latin', t: 'Latin', xlp: 'latin' }, lo: { c: 'lo', n: 'Lao', t: 'Lao', xlp: 'lao' }, lt: { c: 'lt', n: 'Lithuanian', t: 'Lithuanian', xlp: 'lithuanian' }, @@ -122,6 +124,7 @@ module SiSU_i18n ur: { c: 'ur', n: 'Urdu', t: 'Urdu', xlp: 'urdu' }, us: { c: 'en', n: 'English (American)',t: 'English', xlp: 'english' }, vi: { c: 'vi', n: 'Vietnamese', t: 'Vietnamese', xlp: 'vietnamese' }, + zh: { c: 'zh', n: 'Chinese', t: '中文', xlp: 'chinese' }, en: { c: 'en', n: 'English', t: 'English', xlp: 'english' }, xx: { c: 'xx', n: 'Default', t: 'English', xlp: 'english' }, } @@ -154,6 +157,8 @@ module SiSU_i18n 'ia' => table[:ia], 'is' => table[:is], 'it' => table[:it], + 'ja' => table[:ja], + 'ko' => table[:ko], 'la' => table[:la], 'lo' => table[:lo], 'lt' => table[:lt], @@ -185,6 +190,7 @@ module SiSU_i18n 'ur' => table[:ur], 'us' => table[:en], 'vi' => table[:vi], + 'zh' => table[:zh], 'en' => table[:en], 'xx' => table[:en] } diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb index 9d6821ac..54ef7ccc 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v4/options.rb @@ -66,14 +66,12 @@ module SiSU_Commandline require_relative 'param_make' # param_make.rb @@sisu_call_origin_path=nil class HeaderCommon - def initialize(make_instruct_array) - @make_instruct_array=make_instruct_array - end def sisu_document_make_instructions @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@emphasis_set_to=@bold_match_list=@italics_match_list=@substitution_match_list=@footer_links=@home_button_links=@links=nil + make_instruct_array=SiSU_Env::GetInit.new.sisu_document_make.makefile_read @makeset=false - if @make_instruct_array - @make_instruct_array.each do |para| #% scan document + if make_instruct_array + make_instruct_array.each do |para| #% scan document if para =~/^(?:@make:|@links:)[+-]?\s/ case para when /^@make:(.+)/m #% header processing - make @@ -153,8 +151,7 @@ module SiSU_Commandline @base_stub=@base_path.gsub(u,'\1') @a=sisu_glob_rules(a) @a.freeze - make_instruct_array=SiSU_Env::GetInit.new.sisu_document_make.makefile_read - @make_instructions=HeaderCommon.new(make_instruct_array).sisu_document_make_instructions + @make_instructions=HeaderCommon.new.sisu_document_make_instructions @make_instructions_pod=nil init end diff --git a/lib/sisu/v4/param_make.rb b/lib/sisu/v4/param_make.rb index 616ef77d..32576fb8 100644 --- a/lib/sisu/v4/param_make.rb +++ b/lib/sisu/v4/param_make.rb @@ -360,6 +360,30 @@ module SiSU_Param_Make ? @h['texpdf_font_mono'] : @env.font.texpdf.mono end + def cjk + @h['texpdf_font_cjk'] \ + && (@h['texpdf_font_cjk']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk'] + : @env.font.texpdf.cjk + end + def cjk_zh + @h['texpdf_font_cjk_zh'] \ + && (@h['texpdf_font_cjk_zh']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_zh'] + : @env.font.texpdf.cjk_zh + end + def cjk_ja + @h['texpdf_font_cjk_ja'] \ + && (@h['texpdf_font_cjk_ja']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_ja'] + : @env.font.texpdf.cjk_ja + end + def cjk_ko + @h['texpdf_font_cjk_ko'] \ + && (@h['texpdf_font_cjk_ko']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_ko'] + : @env.font.texpdf.cjk_ko + end self end def promo diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb index 4db204d8..b13d5a88 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v4/sysenv.rb @@ -1780,6 +1780,9 @@ WOK end def font def texpdf + # you may wish to check selected font against available fonts: + # fc-list :outline -f "%{family}\n" + # fc-list :lang=ja def main (defined? @rc['default']['texpdf_font']) \ && (@rc['default']['texpdf_font']=~/\S{3,}/) \ @@ -1804,6 +1807,30 @@ WOK ? @rc['default']['texpdf_font_mono'] : 'Liberation Mono' end + def cjk + (defined? @rc['default']['texpdf_font_cjk']) \ + && (@rc['default']['texpdf_font_cjk']=~/\S{3,}/) \ + ? @rc['default']['texpdf_font_cjk'] + : 'IPAGothic' # 'IPAGothic' # 'IPAMincho' # 'TakaoMincho' # 'VL Gothic' + end + def cjk_zh + (defined? @rc['default']['texpdf_font_cjk_zh']) \ + && (@rc['default']['texpdf_font_cjk_zh']=~/\S{3,}/) \ + ? @rc['default']['texpdf_font_cjk_zh'] + : 'IPAGothic' + end + def cjk_ja + (defined? @rc['default']['texpdf_font_cjk_ja']) \ + && (@rc['default']['texpdf_font_cjk_ja']=~/\S{3,}/) \ + ? @rc['default']['texpdf_font_cjk_ja'] + : 'IPAGothic' + end + def cjk_ko + (defined? @rc['default']['texpdf_font_cjk_ko']) \ + && (@rc['default']['texpdf_font_cjk_ko']=~/\S{3,}/) \ + ? @rc['default']['texpdf_font_cjk_ko'] + : 'IPAGothic' + end self end self diff --git a/lib/sisu/v4/texpdf_format.rb b/lib/sisu/v4/texpdf_format.rb index b010bb08..d87a457e 100644 --- a/lib/sisu/v4/texpdf_format.rb +++ b/lib/sisu/v4/texpdf_format.rb @@ -794,11 +794,52 @@ module SiSU_TeX_Pdf @md.make.texpdf_font.mono else @env.font.texpdf.mono end - # you may wish to check selected font against avaiable fonts: + texpdf_font_cjk=if @md.opt.lng =~/zh/ \ + and defined? @md.make.texpdf_font.cjk_zh \ + and not @md.make.texpdf_font.cjk_zh.nil? \ + and @md.make.texpdf_font.cjk_zh=~/\S{3,}/ + @md.make.texpdf_font.cjk_zh + elsif @md.opt.lng =~/ja/ \ + and defined? @md.make.texpdf_font.cjk_ja \ + and not @md.make.texpdf_font.cjk_ja.nil? \ + and @md.make.texpdf_font.cjk_ja=~/\S{3,}/ + @md.make.texpdf_font.cjk_ja + elsif @md.opt.lng =~/ko/ \ + and defined? @md.make.texpdf_font.cjk_ko \ + and not @md.make.texpdf_font.cjk_ko.nil? \ + and @md.make.texpdf_font.cjk_ko=~/\S{3,}/ + @md.make.texpdf_font.cjk_ko + elsif @md.opt.lng =~/(?:zh|ja|ko)/ \ + and defined? @md.make.texpdf_font.cjk \ + and not @md.make.texpdf_font.cjk.nil? \ + and @md.make.texpdf_font.cjk=~/\S{3,}/ + @md.make.texpdf_font.cjk + else + case @md.opt.lng + when /zh/; @env.font.texpdf.cjk_zh + when /ja/; @env.font.texpdf.cjk_ja + when /ko/; @env.font.texpdf.cjk_ko + else @env.font.texpdf.cjk + end + end + # you may wish to check selected font against available fonts: # fc-list :outline -f "%{family}\n" + # fc-list :lang=ja case @tex2pdf when /xe/ - <<-WOK + if @md.opt.lng =~/(?:zh|ja|ko)/ + <<-WOK +\\usepackage{ucs, fontspec, xltxtra, xunicode, xeCJK} +\\setmainCJKlanguage{#{tex_head_lang[:mainlang]}} +\\setCJKmainfont{#{texpdf_font_cjk}} +\\XeTeXlinebreaklocale "#{tex_head_lang[:mainlang]}" +\\XeTeXlinebreakskip = 0pt plus 1pt +\\setotherlanguage{#{tex_head_lang[:otherlang]}} +\\setmainfont{#{texpdf_font}} +\\setmonofont[Scale=0.85]{#{texpdf_font_mono}} + WOK + else + <<-WOK \\usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} \\setmainlanguage{#{tex_head_lang[:mainlang]}} \\setotherlanguage{#{tex_head_lang[:otherlang]}} @@ -806,7 +847,8 @@ module SiSU_TeX_Pdf \\setmonofont[Scale=0.85]{#{texpdf_font_mono}} % \\setsansfont{#{texpdf_font_sans}} % \\setromanfont{#{texpdf_font_serif}} - WOK + WOK + end when /pdf/ if @md.file_encoding =~ /iso-?8859/i #% iso8859 <<-WOK diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index bc98ca99..78655871 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -209,7 +209,7 @@ Px={ po_subscript_o: ',{', po_subscript_c: '},', po_hilite_o: '*{', po_hilite_c: '}*', po_monospace_o: '#{', po_monospace_c: '}#', - lng_lst: %w[am bg bn br ca cs cy da de el en eo es et eu fi fr ga gl he hi hr hy ia is it la lo lt lv ml mr nl nn no oc pl pt pt_BR ro ru sa se sk sl sq sr sv ta te th tk tr uk ur us vi], + lng_lst: %w[am bg bn br ca cs cy da de el en eo es et eu fi fr ga gl he hi hr hy ia is it ja ko la lo lt lv ml mr nl nn no oc pl pt pt_BR ro ru sa se sk sl sq sr sv ta te th tk tr uk ur us vi zh], lv1: '*', lv2: '=', lv3: '=', diff --git a/lib/sisu/v5/dal_syntax.rb b/lib/sisu/v5/dal_syntax.rb index f6d01d22..1e1d8542 100644 --- a/lib/sisu/v5/dal_syntax.rb +++ b/lib/sisu/v5/dal_syntax.rb @@ -332,7 +332,7 @@ module SiSU_DAL_Syntax dob end def fontface(dob) - leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>/ + leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。]|\>/ dob=fontface_lines(dob,leader) dob.obj=dob.obj.gsub(/(#{leader})\*\{(.+?)\}\*/m, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis diff --git a/lib/sisu/v5/i18n.rb b/lib/sisu/v5/i18n.rb index b635af15..cfd02244 100644 --- a/lib/sisu/v5/i18n.rb +++ b/lib/sisu/v5/i18n.rb @@ -91,6 +91,8 @@ module SiSU_i18n ia: { c: 'ia', n: 'Interlingua', t: 'Interlingua', xlp: 'interlingua' }, is: { c: 'is', n: 'Icelandic', t: 'Icelandic', xlp: 'icelandic' }, it: { c: 'it', n: 'Italian', t: 'Italiano', xlp: 'italian' }, + ja: { c: 'ja', n: 'Japanese', t: '日本語 (Nihongo)', xlp: 'japanese' }, + ko: { c: 'ko', n: 'Korean', t: 'Korean', xlp: 'korean' }, la: { c: 'la', n: 'Latin', t: 'Latin', xlp: 'latin' }, lo: { c: 'lo', n: 'Lao', t: 'Lao', xlp: 'lao' }, lt: { c: 'lt', n: 'Lithuanian', t: 'Lithuanian', xlp: 'lithuanian' }, @@ -122,6 +124,7 @@ module SiSU_i18n ur: { c: 'ur', n: 'Urdu', t: 'Urdu', xlp: 'urdu' }, us: { c: 'en', n: 'English (American)',t: 'English', xlp: 'english' }, vi: { c: 'vi', n: 'Vietnamese', t: 'Vietnamese', xlp: 'vietnamese' }, + zh: { c: 'zh', n: 'Chinese', t: '中文', xlp: 'chinese' }, en: { c: 'en', n: 'English', t: 'English', xlp: 'english' }, xx: { c: 'xx', n: 'Default', t: 'English', xlp: 'english' }, } @@ -154,6 +157,8 @@ module SiSU_i18n 'ia' => table[:ia], 'is' => table[:is], 'it' => table[:it], + 'ja' => table[:ja], + 'ko' => table[:ko], 'la' => table[:la], 'lo' => table[:lo], 'lt' => table[:lt], @@ -185,6 +190,7 @@ module SiSU_i18n 'ur' => table[:ur], 'us' => table[:en], 'vi' => table[:vi], + 'zh' => table[:zh], 'en' => table[:en], 'xx' => table[:en] } diff --git a/lib/sisu/v5/options.rb b/lib/sisu/v5/options.rb index 031258af..422762d1 100644 --- a/lib/sisu/v5/options.rb +++ b/lib/sisu/v5/options.rb @@ -66,14 +66,12 @@ module SiSU_Commandline require_relative 'param_make' # param_make.rb @@sisu_call_origin_path=nil class HeaderCommon - def initialize(make_instruct_array) - @make_instruct_array=make_instruct_array - end def sisu_document_make_instructions @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@emphasis_set_to=@bold_match_list=@italics_match_list=@substitution_match_list=@footer_links=@home_button_links=@links=nil + make_instruct_array=SiSU_Env::GetInit.new.sisu_document_make.makefile_read @makeset=false - if @make_instruct_array - @make_instruct_array.each do |para| #% scan document + if make_instruct_array + make_instruct_array.each do |para| #% scan document if para =~/^(?:@make:|@links:)[+-]?\s/ case para when /^@make:(.+)/m #% header processing - make @@ -153,8 +151,7 @@ module SiSU_Commandline @base_stub=@base_path.gsub(u,'\1') @a=sisu_glob_rules(a) @a.freeze - make_instruct_array=SiSU_Env::GetInit.new.sisu_document_make.makefile_read - @make_instructions=HeaderCommon.new(make_instruct_array).sisu_document_make_instructions + @make_instructions=HeaderCommon.new.sisu_document_make_instructions @make_instructions_pod=nil init end diff --git a/lib/sisu/v5/param_make.rb b/lib/sisu/v5/param_make.rb index ba89c7b3..ec538ccb 100644 --- a/lib/sisu/v5/param_make.rb +++ b/lib/sisu/v5/param_make.rb @@ -360,6 +360,30 @@ module SiSU_Param_Make ? @h['texpdf_font_mono'] : @env.font.texpdf.mono end + def cjk + @h['texpdf_font_cjk'] \ + && (@h['texpdf_font_cjk']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk'] + : @env.font.texpdf.cjk + end + def cjk_zh + @h['texpdf_font_cjk_zh'] \ + && (@h['texpdf_font_cjk_zh']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_zh'] + : @env.font.texpdf.cjk_zh + end + def cjk_ja + @h['texpdf_font_cjk_ja'] \ + && (@h['texpdf_font_cjk_ja']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_ja'] + : @env.font.texpdf.cjk_ja + end + def cjk_ko + @h['texpdf_font_cjk_ko'] \ + && (@h['texpdf_font_cjk_ko']=~/\S{3,}/) \ + ? @h['texpdf_font_cjk_ko'] + : @env.font.texpdf.cjk_ko + end self end def promo diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index 62ef451f..0616abb7 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -1780,6 +1780,9 @@ WOK end def font def texpdf + # you may wish to check selected font against available fonts: + # fc-list :outline -f "%{family}\n" + # fc-list :lang=ja def main (defined? @rc['default']['texpdf_font']) \ && (@rc['default']['texpdf_font']=~/\S{3,}/) \ @@ -1804,6 +1807,30 @@ WOK ? @rc['default']['texpdf_font_mono'] : 'Liberation Mono' end + def cjk + (defined? @rc['default']['texpdf_font_cjk']) \ + && (@rc['default']['texpdf_font_cjk']=~/\S{3,}/) \ + ? @rc['default']['texpdf_font_cjk'] + : 'IPAGothic' # 'IPAGothic' # 'IPAMincho' # 'TakaoMincho' # 'VL Gothic' + end + def cjk_zh + (defined? @rc['default']['texpdf_font_cjk_zh']) \ + && (@rc['default']['texpdf_font_cjk_zh']=~/\S{3,}/) \ + ? @rc['default']['texpdf_font_cjk_zh'] + : 'IPAGothic' + end + def cjk_ja + (defined? @rc['default']['texpdf_font_cjk_ja']) \ + && (@rc['default']['texpdf_font_cjk_ja']=~/\S{3,}/) \ + ? @rc['default']['texpdf_font_cjk_ja'] + : 'IPAGothic' + end + def cjk_ko + (defined? @rc['default']['texpdf_font_cjk_ko']) \ + && (@rc['default']['texpdf_font_cjk_ko']=~/\S{3,}/) \ + ? @rc['default']['texpdf_font_cjk_ko'] + : 'IPAGothic' + end self end self diff --git a/lib/sisu/v5/texpdf_format.rb b/lib/sisu/v5/texpdf_format.rb index 172dfa56..5ed6ca75 100644 --- a/lib/sisu/v5/texpdf_format.rb +++ b/lib/sisu/v5/texpdf_format.rb @@ -794,11 +794,52 @@ module SiSU_TeX_Pdf @md.make.texpdf_font.mono else @env.font.texpdf.mono end - # you may wish to check selected font against avaiable fonts: + texpdf_font_cjk=if @md.opt.lng =~/zh/ \ + and defined? @md.make.texpdf_font.cjk_zh \ + and not @md.make.texpdf_font.cjk_zh.nil? \ + and @md.make.texpdf_font.cjk_zh=~/\S{3,}/ + @md.make.texpdf_font.cjk_zh + elsif @md.opt.lng =~/ja/ \ + and defined? @md.make.texpdf_font.cjk_ja \ + and not @md.make.texpdf_font.cjk_ja.nil? \ + and @md.make.texpdf_font.cjk_ja=~/\S{3,}/ + @md.make.texpdf_font.cjk_ja + elsif @md.opt.lng =~/ko/ \ + and defined? @md.make.texpdf_font.cjk_ko \ + and not @md.make.texpdf_font.cjk_ko.nil? \ + and @md.make.texpdf_font.cjk_ko=~/\S{3,}/ + @md.make.texpdf_font.cjk_ko + elsif @md.opt.lng =~/(?:zh|ja|ko)/ \ + and defined? @md.make.texpdf_font.cjk \ + and not @md.make.texpdf_font.cjk.nil? \ + and @md.make.texpdf_font.cjk=~/\S{3,}/ + @md.make.texpdf_font.cjk + else + case @md.opt.lng + when /zh/; @env.font.texpdf.cjk_zh + when /ja/; @env.font.texpdf.cjk_ja + when /ko/; @env.font.texpdf.cjk_ko + else @env.font.texpdf.cjk + end + end + # you may wish to check selected font against available fonts: # fc-list :outline -f "%{family}\n" + # fc-list :lang=ja case @tex2pdf when /xe/ - <<-WOK + if @md.opt.lng =~/(?:zh|ja|ko)/ + <<-WOK +\\usepackage{ucs, fontspec, xltxtra, xunicode, xeCJK} +\\setmainCJKlanguage{#{tex_head_lang[:mainlang]}} +\\setCJKmainfont{#{texpdf_font_cjk}} +\\XeTeXlinebreaklocale "#{tex_head_lang[:mainlang]}" +\\XeTeXlinebreakskip = 0pt plus 1pt +\\setotherlanguage{#{tex_head_lang[:otherlang]}} +\\setmainfont{#{texpdf_font}} +\\setmonofont[Scale=0.85]{#{texpdf_font_mono}} + WOK + else + <<-WOK \\usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} \\setmainlanguage{#{tex_head_lang[:mainlang]}} \\setotherlanguage{#{tex_head_lang[:otherlang]}} @@ -806,7 +847,8 @@ module SiSU_TeX_Pdf \\setmonofont[Scale=0.85]{#{texpdf_font_mono}} % \\setsansfont{#{texpdf_font_sans}} % \\setromanfont{#{texpdf_font_serif}} - WOK + WOK + end when /pdf/ if @md.file_encoding =~ /iso-?8859/i #% iso8859 <<-WOK -- cgit v1.2.3