diff options
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby/textools.rb')
-rw-r--r-- | Master/texmf-dist/scripts/context/ruby/textools.rb | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/textools.rb b/Master/texmf-dist/scripts/context/ruby/textools.rb index 345a2757204..b6300215e78 100644 --- a/Master/texmf-dist/scripts/context/ruby/textools.rb +++ b/Master/texmf-dist/scripts/context/ruby/textools.rb @@ -658,6 +658,87 @@ class Commands end + @@knownchars = Hash.new + + @@knownchars['ae'] = 'aeligature' ; @@knownchars['oe'] = 'oeligature' + @@knownchars['AE'] = 'AEligature' ; @@knownchars['OE'] = 'OEligature' + + @@knownchars['acute' ] = 'textacute' + @@knownchars['breve' ] = 'textbreve' + @@knownchars['caron' ] = 'textcaron' + @@knownchars['cedilla' ] = 'textcedilla' + @@knownchars['circumflex' ] = 'textcircumflex' + @@knownchars['diaeresis' ] = 'textdiaeresis' + @@knownchars['dotaccent' ] = 'textdotaccent' + @@knownchars['grave' ] = 'textgrave' + @@knownchars['hungarumlaut'] = 'texthungarumlaut' + @@knownchars['macron' ] = 'textmacron' + @@knownchars['ogonek' ] = 'textogonek' + @@knownchars['ring' ] = 'textring' + @@knownchars['tilde' ] = 'texttilde' + + @@knownchars['cent' ] = 'textcent' + @@knownchars['currency'] = 'textcurrency' + @@knownchars['euro' ] = 'texteuro' + @@knownchars['florin' ] = 'textflorin' + @@knownchars['sterling'] = 'textsterling' + @@knownchars['yen' ] = 'textyen' + + @@knownchars['brokenbar'] = 'textbrokenbar' + @@knownchars['bullet' ] = 'textbullet' + @@knownchars['dag' ] = 'textdag' + @@knownchars['ddag' ] = 'textddag' + @@knownchars['degree' ] = 'textdegree' + @@knownchars['div' ] = 'textdiv' + @@knownchars['ellipsis' ] = 'textellipsis' + @@knownchars['fraction' ] = 'textfraction' + @@knownchars['lognot' ] = 'textlognot' + @@knownchars['minus' ] = 'textminus' + @@knownchars['mu' ] = 'textmu' + @@knownchars['multiply' ] = 'textmultiply' + @@knownchars['pm' ] = 'textpm' + + def encmake + afmfile = @commandline.argument('first') + encoding = @commandline.argument('second') || 'dummy' + if afmfile && FileTest.file?(afmfile) then + chars = Array.new + IO.readlines(afmfile).each do |line| + if line =~ /C\s+(\d+).*?N\s+([a-zA-Z\-\.]+?)\s*;/ then + chars[$1.to_i] = $2 + end + end + if f = File.open(encoding+'.enc','w') then + f << "% Encoding file, generated by textools.rb from #{afmfile}\n" + f << "\n" + f << "/#{encoding.gsub(/[^a-zA-Z]/,'')}encoding [\n" + 256.times do |i| + f << " /#{chars[i] || '.notdef'}\n" + end + f << "] def\n" + f.close + end + if f = File.open('enco-'+encoding+'.tex','w') then + f << "% ConTeXt file, generated by textools.rb from #{afmfile}\n" + f << "\n" + f << "\\startencoding[#{encoding}]\n\n" + 256.times do |i| + if str = chars[i] then + tmp = str.gsub(/dieresis/,'diaeresis') + if chr = @@knownchars[tmp] then + f << " \\definecharacter #{chr} #{i}\n" + elsif tmp.length > 5 then + f << " \\definecharacter #{tmp} #{i}\n" + end + end + end + f << "\n\\stopencoding\n" + f << "\n\\endinput\n" + f.close + end + end + end + private def flushencoding (file, from, to, names) @@ -930,6 +1011,7 @@ commandline.registeraction('updatetree' , 'fromroot toroot [--force --noch commandline.registeraction('downcasefilenames', '[--recurse] [--force]') # not yet documented commandline.registeraction('stripformfeeds' , '[--recurse] [--force]') # not yet documented commandline.registeraction('showfont' , 'filename') +commandline.registeraction('encmake' , 'afmfile encodingname') commandline.registeraction('tpmmake' , 'tpm file (run in texmf root)') |