File: path_helpers.rb

package info (click to toggle)
ruby-ttfunk 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,472 kB
  • sloc: ruby: 7,954; makefile: 7
file content (19 lines) | stat: -rw-r--r-- 588 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module PathHelpers
  # Get a test font file.
  #
  # @param name [String] name of the font file
  # @param ext [Symbol, String] font file extension
  # @return [String] full path to the test font file
  # @raise [ArgumentError] if the requested font file can't be found
  def test_font(name, ext = :ttf)
    base_path = File.expand_path('../fonts', __dir__)
    valid_filename = File.join(base_path, "#{name}.#{ext}")
    if File.file?(valid_filename)
      valid_filename
    else
      raise ArgumentError, "#{valid_filename} not found"
    end
  end
end