theseus/app/lib/snail_mail/components/page_component.rb
2025-06-24 15:32:58 -04:00

28 lines
811 B
Ruby

module SnailMail
module Components
class PageComponent < BaseComponent
def before_template
start_new_page unless page_number > 0
register_fonts
fallback_fonts(["arial", "noto"])
end
private
def register_fonts
font_families.update(
"comic" => { normal: font_path("comic sans.ttf") },
"arial" => { normal: font_path("arial.otf") },
"f25" => { normal: font_path("f25.ttf") },
"imb" => { normal: font_path("imb.ttf") },
"gohu" => { normal: font_path("gohu.ttf") },
"noto" => { normal: font_path("noto sans regular.ttf") },
)
end
def font_path(font_name)
File.join(Rails.root, "app", "lib", "snail_mail", "assets", "fonts", font_name)
end
end
end
end