-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1444f4d
commit 631331f
Showing
5 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require_relative 'ttf' | ||
|
||
module Prawn | ||
class Font | ||
# @private | ||
class TTC < TTF | ||
# Returns a list of the names of all named fonts in the given ttc file. | ||
# They are returned in order of their appearance in the file. | ||
# | ||
def self.font_names(file) | ||
TTFunk::Collection.open(file) do |ttc| | ||
ttc.map { |font| font.name.font_name.first } | ||
end | ||
end | ||
|
||
private | ||
|
||
def read_ttf_file | ||
TTFunk::File.from_ttc( | ||
@name, | ||
font_option_to_index(@name, @options[:font]) | ||
) | ||
end | ||
|
||
def font_option_to_index(file, option) | ||
if option.is_a?(Numeric) | ||
option | ||
else | ||
self.class.font_names(file).index { |n| n == option } || 0 | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters