From 4ceb5ecac549b1525c5301ea805c82fa321208a2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jun 2010 21:46:50 -0400 Subject: texpdf set/select font, default "Liberation Sans" * requires that Liberation fonts be installed, hence version bump * set font in: sisurc.yml under default: texpdf_font: marked up document under @make: :texpdf_font: default if nothing set "Liberation Sans" --- lib/sisu/v2/param.rb | 29 +++++++++++++++++------------ lib/sisu/v2/sysenv.rb | 14 +++++++++++--- lib/sisu/v2/texpdf_format.rb | 1 + 3 files changed, 29 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v2/param.rb b/lib/sisu/v2/param.rb index a4ac4589..98478626 100644 --- a/lib/sisu/v2/param.rb +++ b/lib/sisu/v2/param.rb @@ -148,8 +148,8 @@ module SiSU_Param end end class Md - def initialize(str,opt) - @s,@opt=str,opt + def initialize(str,opt,env) + @s,@opt,@env=str,opt,env end def validate_length(s,l,n) #s=(s.length <= l) ? s : nil @@ -668,6 +668,11 @@ module SiSU_Param else nil end end + def texpdf_font + @h['texpdf_font'] && (@h['texpdf_font']=~/\S{3,}/) \ + ? @h['texpdf_font'] \ + : @env.font.texpdf + end def skin @h['skin'] end @@ -922,23 +927,23 @@ module SiSU_Param case para when /^@ocn:\s+(.+?)$/m; @ocn=$1 #% processing when /^@title:(.+)/m #% metainfo DC - @title=Md.new($1.strip,@opt).title + @title=Md.new($1.strip,@opt,@env).title when /^@creator:(.+)/m #% metainfo DC - @creator=Md.new($1.strip,@opt).creator + @creator=Md.new($1.strip,@opt,@env).creator @authorship=@author=@creator.author @authors=@creator.author_detail when /^@classify:(.+)/m; classify=$1 - @classify=Md.new($1.strip,@opt).classify + @classify=Md.new($1.strip,@opt,@env).classify when /^@publisher:\s+(.+)/m - @publisher=Md.new($1.strip,@opt).current_publisher + @publisher=Md.new($1.strip,@opt,@env).current_publisher when /^@original:(.+)/m - @original=Md.new($1.strip,@opt).original + @original=Md.new($1.strip,@opt,@env).original @source=@original.source when /^@writing_focus[:.]nationality:\s+(.+?)$/; @writing_focus=$1 # e.g. Finland (where and article on Finnish law) when /^@date:(.+)/m #% metainfo DC - @date=Md.new($1.strip,@opt).date + @date=Md.new($1.strip,@opt,@env).date when /^@rights:(.+)/m; #@rights=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC copyright, public domain, copyleft, creative commons, etc. - @rights=Md.new($1.strip,@opt).rights + @rights=Md.new($1.strip,@opt,@env).rights when /^@papersize:\s+(.+?)$/m #% metainfo DC l=$1 if @mod.inspect !~/--papersize[=-]\S+/ @@ -946,7 +951,7 @@ module SiSU_Param @papersize=l end when /^@make:(.+)/m #% metainfo DC - @make=Md.new($1.strip,@opt).make + @make=Md.new($1.strip,@opt,@env).make if defined? @make.breaks \ and @make.breaks[:page_new] #clearpage @pagenew=@make.breaks[:page_new] @@ -978,7 +983,7 @@ module SiSU_Param @man_section=(defined? @make.manpage.section) ? @make.manpage.section : 1 end when /^@links:\s+(.+?)\Z/m #% processing - doc_links=Md.new($1.strip,@opt).links + doc_links=Md.new($1.strip,@opt,@env).links count=1 @lnk=[] doc_links.each do |doc_link| @@ -989,7 +994,7 @@ module SiSU_Param end end when /^@notes?:\s(.+)/ #% metainfo - Md.new($1.strip,@opt).notes + Md.new($1.strip,@opt,@env).notes when /^@base_program:\s+(.+?)$/; @base_program=$1 #% processing end @lv1 ||=/^1~/ diff --git a/lib/sisu/v2/sysenv.rb b/lib/sisu/v2/sysenv.rb index 4daccbcd..8a9e38be 100644 --- a/lib/sisu/v2/sysenv.rb +++ b/lib/sisu/v2/sysenv.rb @@ -1265,6 +1265,14 @@ WOK end end end + def font + def texpdf + (defined? @rc['default']['texpdf_font']) \ + ? @rc['default']['texpdf_font'] \ + : 'Liberation Sans' #'Liberation Sans' #'Liberation Serif' + end + self + end def path #dir def home @sys.home @@ -1329,9 +1337,9 @@ WOK @yamlrc_dir end def man #check use - if defined? @rc['webserv']['man']; "#{webserv}/#{@rc['webserv']['man']}" - else defaults[:webserv_man] - end + (defined? @rc['webserv']['man']) \ + ? "#{webserv}/#{@rc['webserv']['man']}" \ + : defaults[:webserv_man] end def webserv_path #testing, check need, remove webserv diff --git a/lib/sisu/v2/texpdf_format.rb b/lib/sisu/v2/texpdf_format.rb index b53864ec..87a946d0 100644 --- a/lib/sisu/v2/texpdf_format.rb +++ b/lib/sisu/v2/texpdf_format.rb @@ -635,6 +635,7 @@ module SiSU_TeX_Pdf \\usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} \\setmainlanguage{#{tex_head_lang}} \\setotherlanguage{english} +\\setmainfont{#{@md.make.texpdf_font}} WOK when /pdf/ if @md.file_encoding =~ /iso-?8859/i #% iso8859 -- cgit v1.2.3