#!/usr/bin/env ruby #-- # Last Change: Tue May 16 18:14:38 2006 #++ =begin rdoc == plinfo -- output information about a pl file. Usage: plinfo [options] tfmfile.pl [file...] -e, --encoding enc set the encoding for the file -l, --list-chars list all available characters -h, --help Show this help --- Author:: Patrick Gundlach License:: Copyright (c) 2005 Patrick Gundlach. Released under the terms of the GNU General Public License =end # :enddoc: require 'optparse' require 'ostruct' require 'rfil/tex/tfm' require 'rfil/tex/kpathsea' require 'rfil/tex/enc' include RFIL include TeX kpse=Kpathsea.new @options=OpenStruct.new ARGV.options { |opt| opt.banner = "Usage: #{File.basename($0)} [options] tfmfile.pl [file...]" opt.on("--encoding enc", "-e", "set the encoding for the file") { |e| kpse.open_file(e,"enc") { |f| @options.encoding = ENC.new(f) } } opt.on("--list-chars", "-l", "list all available characters") { @options.listchars=true } opt.on("--help", "-h", "Show this help") { puts opt; exit 0 } opt.separator "" opt.parse! } if ARGV.size < 1 puts "#{File.basename($0)}: Need at least one file argument." puts "Try `#{File.basename($0)} --help' for more information." exit 0 end def dump_maininfo(filename) puts "General font information:" puts "=========================" print "filename=#{File.basename(filename)} " # puts @isvpl ? "(vpl)" : "(pl)" puts "Family: #{@tfm.fontfamily}" puts "Designsize: #{@tfm.designsize}" puts "Codingscheme: #{@tfm.codingscheme}" puts "Fontdimen:" paramname=%w( SLANT SPACE STRETCH SHRINK XHEIGHT QUAD EXTRASPACE ) if @tfm.codingscheme=="TeX math symbols" paramname += %w(NUM1 NUM2 NUM3 DENOM1 DENOM2 SUP1 SUP2 SUP3 SUB1 SUB2 SUPDROP) elsif @tfm.codingscheme=="TeX math extension" paramname += %w(DEFAULT_RULE_THICKNESS BIG_OP_SPACING1 BIG_OP_SPACING2 BIG_OP_SPACING3 BIG_OP_SPACING4 BIG_OP_SPACING5) end (1..@tfm.params.size-1).each {|i| puts " #{paramname[i-1]} = #{@tfm.params[i]}" } end def dump_charsinfo stdformat="%9s|" count=0 0.upto(255) { |i| if c=@tfm.chars[i] if count % 32 == 0 puts "\n slot| width | height | depth | ic |lig/kern?| extra | char" puts "-----|---------|---------|---------|---------|---------|---------|-------" end has_krn= c[:lig_kern] ? "yes" : "" extra = "" char = @options.encoding ? @options.encoding[i] : "" puts sprintf("%5s|"+stdformat*6+" %s", "#{i}","#{c[:charwd]}","#{c[:charht]}","#{c[:chardp]}","#{c[:charic]}", has_krn,"",char) count += 1 end } end ARGV.each { |plfilename| @tfm=TFM.new() @tfm.read_pl(plfilename) dump_maininfo(plfilename) if @options.listchars dump_charsinfo end }