File: rbpdf-font.rb

package info (click to toggle)
ruby-rbpdf 1.21.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,488 kB
  • sloc: ruby: 138,259; makefile: 12
file content (30 lines) | stat: -rw-r--r-- 652 bytes parent folder | download | duplicates (4)
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
30
# Copyright (c) 2011-2017 NAITOH Jun
# Released under the MIT license
# http://www.opensource.org/licenses/MIT

module RBPDFFontDescriptor
  @@descriptors = { 'freesans' => {} }
  @@font_name = 'freesans'

  def self.font(font_name)
    @@descriptors[font_name.gsub(".rb", "")]
  end

  def self.define(font_name = 'freesans')
    @@descriptors[font_name] ||= {}
    yield @@descriptors[font_name]
  end

  #
  # Return fonts path
  #
  def self.getfontpath()
    # Is it in this plugin's font folder?
    fpath = File.join File.dirname(__FILE__), 'fonts'
    if File.exist?(fpath)
      return fpath
    end
    # Could not find it.
    nil
  end
end