damoiser / qr-bills

Ruby Gem to generate QR-Bills for Swiss payments
BSD 3-Clause "New" or "Revised" License
21 stars 15 forks source link

LiberationSans-Regular fonts 404 (Not Found) #32

Open pendelru opened 7 months ago

pendelru commented 7 months ago

The entire QR-bill shows up but the fonts cannot be loaded:

GET https:///app/vendor/bundle/ruby/3.0.0/gems/qr-bills-1.0.9/web/assets/fonts/LiberationSans-Regular.woff net::ERR_ABORTED 404 (Not Found) GET https:///app/vendor/bundle/ruby/3.0.0/gems/qr-bills-1.0.9/web/assets/fonts/LiberationSans-Regular.ttf net::ERR_ABORTED 404 (Not Found)

Code: params[:output_params][:format] = "html" @bill = QRBills.generate(params) <%= raw @bill[:output] %>

Can anybody help?

phylor commented 6 months ago

I assume you want to embed the HTML output in a website. For that, the fonts need to be served by your web server. If you use Rails and sprockets, you need to copy the fonts to your assets/fonts directory.

In addition, you need to configure qr-bill to use those font paths:

  params[:fonts][:eot] = font_url('LiberationSans-Regular.eot')
  params[:fonts][:woff] = font_url('LiberationSans-Regular.woff')
  params[:fonts][:ttf] = font_url('LiberationSans-Regular.ttf')
  params[:fonts][:svg] = font_url('LiberationSans-Regular.svg')

The URLs here have to be publicly available, as the browser will try to fetch them.