diff --git a/lib/thinreports/core/errors.rb b/lib/thinreports/core/errors.rb index db121737..d52676a5 100644 --- a/lib/thinreports/core/errors.rb +++ b/lib/thinreports/core/errors.rb @@ -33,6 +33,13 @@ def initialize(id, item_type = 'Basic') end end + class UnknownFont < Basic + # @param [Prawn::Errors::UnknownFont] exception + def initialize(exception) + super("#{exception.class}: #{exception.message}") + end + end + class DisabledListSection < Basic def initialize(section) super("The #{section} section is disabled.") diff --git a/lib/thinreports/generator/pdf/document/graphics/text.rb b/lib/thinreports/generator/pdf/document/graphics/text.rb index 5bb2024f..2ab269d8 100644 --- a/lib/thinreports/generator/pdf/document/graphics/text.rb +++ b/lib/thinreports/generator/pdf/document/graphics/text.rb @@ -22,6 +22,7 @@ module Graphics # @option attrs [Boolean] :single (false) # @option attrs [:trancate, :shrink_to_fit, :expand] :overflow (:trancate) # @option attrs [:none, :break_word] :word_wrap (:none) + # @raise [Thinreports::Errors::UnknownFont] When :font can't be found in built-in fonts and registerd fonts def text_box(content, x, y, w, h, attrs = {}) return if attrs[:color] == 'none' @@ -40,7 +41,8 @@ def text_box(content, x, y, w, h, attrs = {}) else pdf.formatted_text_box([text_params], box_params) end - + rescue Prawn::Errors::UnknownFont => e + raise Thinreports::Errors::UnknownFont, e rescue Prawn::Errors::CannotFit # Nothing to do. #