Skip to content

Commit

Permalink
Updated font-data.rb to work within .jar file
Browse files Browse the repository at this point in the history
The .glob('*.ttf') command doesn't work nicely in all environments (e.g. within the .jar of asciidoctorj - see jessedoyle#45). This modification removes the .glob command by hardcoding the respective .ttf file
  • Loading branch information
PartTimeDataScientist authored Feb 8, 2022
1 parent 49c26ad commit 03dab15
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/prawn/icon/font_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,26 @@ def legend_path
File.join(File.dirname(path), "#{@set}.yml")
end

def font_path(key)
font_files = {
fab: "fa-brands.ttf",
far: "fa-regular.ttf",
fas: "fa-solid.ttf",
fi: "foundation-icons.ttf",
pf: "paymentfont-webfont.ttf"
}
path = Icon.configuration.font_directory.to_s + "/" + key.to_s + "/" + font_files.fetch(key)
File.expand_path(path)
end

def load_fonts(document)
document.font_families[@set.to_s] ||= { normal: path }
self
end

def path
font = Icon.configuration.font_directory
.join(@set.to_s)
.glob('*.ttf')
.first

font = font_path(@set)

if font.nil?
raise Prawn::Errors::UnknownFont,
"Icon font not found for set: #{@set}"
Expand Down

0 comments on commit 03dab15

Please sign in to comment.