Comments (10)
Oh well. I may consider tightening up Prawn's public API to not allow that but as of right now you should make sure you're providing proper data to Prawn.
from prawn-rails.
This code only updates a hash. It doesn't load fonts or do anything else. This operation is not expensive and won't save you much CPU time to move it into initializer. Do it wherever you instantiate a document.
from prawn-rails.
In fact I want to load custom fonts globally
from prawn-rails.
Make it a constant if you want to keep only one instance of the list:
MY_FONTS = {
"Helvetica": {
normal: Rails.root.join("app/assets/fonts/Helvetica.ttf"),
italic: Rails.root.join("app/assets/fonts/Helvetica-Oblique.ttf"),
bold: Rails.root.join("app/assets/fonts/app/assets/fonts/Helvetica-Bold.ttf"),
bold_italic: Rails.root.join("app/assets/fonts/Helvetica-BoldOblique.ttf"),
}
}
Elsewhere:
pdf.font_families.update(MY_FONTS)
from prawn-rails.
I think I mis-express myself
When I execute rspec
, `prawn| is loaded with some afm fonts, and I need to load ttf fonts
I have an error when executing my spec
/usr/share/gems/gems/prawn-2.2.2/lib/prawn/font/afm.rb:105:in `normalize_encoding'
from prawn-rails.
AFM is not a font. It's a font metric. It basically contains only character sizes and advances (how far cursor should move after a specific character). Those are only present for so called PDF built-in fonts. Those are 14 actual Adobe fonts that should be distributed with any PDF renderer (software that reads PDF files and produces some sort of image, either for displaying on a screen, or printing, or saving to a file, etc.). The AFM files used in Prawn for laying out the text but no actual fonts ever included in the PDFs. That is when you us any of those default fonts. The code is not used when you use a TTF font.
from prawn-rails.
As I understand, ttf fonts SHOULD be included on the software which read pdf ?
from prawn-rails.
These 14 default fonts — yes. Any other font has to be embedded into PDF file. Thats's what happens when you use your own TTF fonts with Prawn.
from prawn-rails.
Thanks for explaination 😛
It appears that my problem was about a nil
that was sent in https://github.com/prawnpdf/prawn/blob/master/lib/prawn/font/afm.rb#L108 (because of a nilable field in database)
from prawn-rails.
I've found a way to do this 😛 but up to you to choose between allowing nil
or documenting this
I can also provide any PR
, if you want 😜
from prawn-rails.
Related Issues (20)
- Undefined Method HOT 3
- Please use semantic versioning HOT 2
- Couldn't change the filename using @filename HOT 5
- ActionController::UnknownFormat HOT 7
- Rendering of large PDF file: flush possible? HOT 1
- Possible missing step or error in README? HOT 5
- undefined method `headers' for nil after upgrading to v1.0.0 HOT 5
- Prawn::Emoji Support? HOT 8
- Render a .pdf.prawn view into a file HOT 11
- Add an option to control Content-Disposition HOT 8
- Is there any way to load pie chart using chartkiq in PDF HOT 1
- Bootstrap css import
- Rails 6: DEPRECATION WARNING: Single arity template handlers are deprecated. HOT 3
- Rails 6: Deprecation Warning: Single arity template handlers are deprecated. HOT 1
- Using with prawn-icon HOT 1
- DEPRECATION WARNING: Rendering actions with '.' in the name is deprecated HOT 5
- Release a new version on Rubygems HOT 2
- PrawnRails initializer doesn't get loaded HOT 7
- Issue running on Ruby 3.1 or 3.2 because official prawn gem hasnt released a new version. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prawn-rails.