summaryrefslogtreecommitdiff
path: root/support/rfil/lib/rfil/font/truetype.rb
blob: 6c26287eb4f2a22123cbe593ebe4f7cec56fb6fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# truetype.rb -- read truetype font metrics
#--
# Last Change: Tue May 16 17:16:56 2006
#++

require 'rfil/font/afm'

module RFIL
  module Font
    # Read TrueType fonts. Use like the AFM class.
    class TrueType < AFM
      def initialize(options={})
        super
        @outlinetype=:truetype
      end
      def read(filename)
        @filename=File.basename(filename)
        @fontfilename=filename
        @name=@filename.chomp(".ttf")
        self.pathname=Pathname.new(filename).realpath.to_s
        a=`ttf2afm #{@fontfilename}`
        parse(a)
        # ttf2afm does not give an xheight!?
        @xheight=@chars['x'].ury unless @xheight
        self
      end
    end
  end
end