Skip to content

Commit a74f612

Browse files
committed
Thinreports raises Errors::UnknownFont when specified font family can't be found
1 parent c148694 commit a74f612

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/thinreports/core/errors.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ def initialize(id, item_type = 'Basic')
3333
end
3434
end
3535

36+
class UnknownFont < Basic
37+
# @param [Prawn::Errors::UnknownFont] exception
38+
def initialize(exception)
39+
super("#{exception.class}: #{exception.message}")
40+
end
41+
end
42+
3643
class DisabledListSection < Basic
3744
def initialize(section)
3845
super("The #{section} section is disabled.")

lib/thinreports/generator/pdf/document/graphics/text.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module Graphics
2222
# @option attrs [Boolean] :single (false)
2323
# @option attrs [:trancate, :shrink_to_fit, :expand] :overflow (:trancate)
2424
# @option attrs [:none, :break_word] :word_wrap (:none)
25+
# @raise [Thinreports::Errors::UnknownFont] When :font can't be found in built-in fonts and registerd fonts
2526
def text_box(content, x, y, w, h, attrs = {})
2627

2728
return if attrs[:color] == 'none'
@@ -40,7 +41,8 @@ def text_box(content, x, y, w, h, attrs = {})
4041
else
4142
pdf.formatted_text_box([text_params], box_params)
4243
end
43-
44+
rescue Prawn::Errors::UnknownFont => e
45+
raise Thinreports::Errors::UnknownFont, e
4446
rescue Prawn::Errors::CannotFit
4547
# Nothing to do.
4648
#

0 commit comments

Comments
 (0)