From df9e4219258cd799a11be6f2d18f2af5b88d8352 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 12 May 2014 21:56:28 -0400 Subject: v6: texpdf, pdf default font size configurable (cli & sisurc.yml) (no fractions) * --pdf-fontsize-12 --pdf-fontsize-8 * default: texpdf_fontsize: 12 * (Closes: #744405) --- lib/sisu/v6/options.rb | 4 ++++ lib/sisu/v6/sysenv.rb | 22 +++++++++++++++++++++ lib/sisu/v6/texpdf_format.rb | 47 +++++++++++++++++++++++++++++++------------- 3 files changed, 59 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v6/options.rb b/lib/sisu/v6/options.rb index 115281c7..462d9166 100644 --- a/lib/sisu/v6/options.rb +++ b/lib/sisu/v6/options.rb @@ -968,6 +968,10 @@ module SiSU_Commandline || mod.inspect =~/"--hash-digests"/) \ ? { bool: true, set: :on } : { bool: false, set: :na } + act[:pdf_font_size]=if mod.inspect =~/"--(?:pdf-)?font-?size[=-](\d{1,2})(?:pt)?"/ + $1 + else :na + end act[:hash_digest_algo]=if mod.inspect =~/"--hash-(?:sha)?512"/ :sha512 elsif mod.inspect =~/"--hash-(?:sha)?256"/ diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb index fd36691e..6136d248 100644 --- a/lib/sisu/v6/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -1875,6 +1875,15 @@ WOK "#{source_file_path}/#{file}" end def font + def size(pt=nil) + if pt && pt != :na + pt + elsif defined? @rc['default']['fontsize'] \ + && @rc['default']['fontsize']=~/\d{1,2}/ + @rc['default']['fontsize'] + else :na + end + end def texpdf # you may wish to check selected font against available fonts: # fc-list :outline -f "%{family}\n" @@ -1927,6 +1936,19 @@ WOK ? @rc['default']['texpdf_fontface_cjk_ko'] : 'IPAGothic' end + def size(pt=nil) + if pt && pt != :na + pt + elsif (defined? @rc['default']['texpdf_fontsize']) \ + && (@rc['default']['texpdf_fontsize']=~/\d{1,2}/) + @rc['default']['texpdf_fontsize'] + elsif (defined? @rc['default']['fontsize']) \ + && (@rc['default']['fontsize']=~/\d{1,2}/) + @rc['default']['fontsize'] + else + :na + end + end self end self diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb index 015a9934..56bb1c0b 100644 --- a/lib/sisu/v6/texpdf_format.rb +++ b/lib/sisu/v6/texpdf_format.rb @@ -923,60 +923,79 @@ module SiSU_TeX_Pdf end def tex_head_paper_dimensions d={} + fontsize_set=if defined? @env.font.texpdf.size(@md.opt.act[:pdf_font_size]) \ + and not @env.font.texpdf.size(@md.opt.act[:pdf_font_size]).nil? + @env.font.texpdf.size(@md.opt.act[:pdf_font_size]) + else :na + end case @layout when :portrait - d[:papertype],d[:fontsize]='a4paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='0mm','0mm','-12pt' d[:headheight],d[:headsep],d[:columnsep]='12pt','35pt','' d[:marginparsep],d[:marginparwidth]='4mm','8mm' case @ps #@md.papersize when /a4/i #European default, SiSU default - d[:papertype],d[:fontsize]='a4paper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:textheight],d[:textwidth]=@tx.a4.portrait.h,@tx.a4.portrait.w when /letter/i #U.S. default - d[:papertype],d[:fontsize]='letterpaper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='letterpaper',fontsize d[:textheight],d[:textwidth]=@tx.letter.portrait.h,@tx.letter.portrait.w when /legal/i #U.S. alternative - d[:papertype],d[:fontsize]='legalpaper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='legalpaper',fontsize d[:textheight],d[:textwidth]=@tx.legal.portrait.h,@tx.legal.portrait.w when /book|b5/i #book default - larger - d[:papertype],d[:fontsize]='b5paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='b5paper',fontsize d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-4mm','-4mm','-36pt' d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','' d[:textheight],d[:textwidth]=@tx.b5.portrait.h,@tx.b5.portrait.w when /a5/i - d[:papertype],d[:fontsize]='a5paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a5paper',fontsize d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='-4mm','-4mm','-36pt' d[:headheight],d[:headsep],d[:columnsep]='11pt','12pt','' d[:marginparsep],d[:marginparwidth]='4mm','6mm' d[:textheight],d[:textwidth]=@tx.a5.portrait.h,@tx.a5.portrait.w else #default currently A4 - d[:papertype],d[:fontsize]='a4paper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:textheight],d[:textwidth]=@tx.a4.portrait.h,@tx.a4.portrait.w end when :landscape - d[:papertype],d[:fontsize]='a4paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:oddsidemargin],d[:evensidemargin],d[:topmargin]='6mm','6mm','-12mm' d[:headheight],d[:headsep],d[:columnsep]='12pt','20pt','40pt' d[:marginparsep],d[:marginparwidth]='4mm','8mm' case @ps #@md.papersize when /a4/i #European default, SiSU default - d[:papertype],d[:fontsize]='a4paper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w when /letter/i #U.S. default - d[:papertype],d[:fontsize]='letterpaper','11pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='letterpaper',fontsize d[:textheight],d[:textwidth]=@tx.letter.landscape.h,@tx.letter.landscape.w when /legal/i #U.S. alternative - d[:papertype],d[:fontsize],d[:columnsep]='legalpaper','11pt','48pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize],d[:columnsep]='legalpaper',fontsize,'48pt' d[:textheight],d[:textwidth]=@tx.legal.landscape.h,@tx.legal.landscape.w when /book|b5/i #book default - larger - d[:papertype],d[:fontsize],d[:columnsep]='b5paper','11pt','35pt' + fontsize=(fontsize_set==:na) ? '11pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize],d[:columnsep]='b5paper',fontsize,'35pt' d[:textheight],d[:textwidth]=@tx.b5.landscape.h,@tx.b5.landscape.w when /a5/i - d[:papertype],d[:fontsize],d[:columnsep]='a5paper','10pt','32pt' + fontsize=(fontsize_set==:na) ? '10pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize],d[:columnsep]='a5paper',fontsize,'32pt' d[:textheight],d[:textwidth]=@tx.a5.landscape.h,@tx.a5.landscape.w else #default currently A4 - d[:papertype],d[:fontsize]='a4paper','12pt' + fontsize=(fontsize_set==:na) ? '12pt' : (fontsize_set + 'pt') + d[:papertype],d[:fontsize]='a4paper',fontsize d[:textheight],d[:textwidth]=@tx.a4.landscape.h,@tx.a4.landscape.w end end -- cgit v1.2.3