Comments (12)
from fpdf2.
#20 is a new one that I haven't seen yet. typically the problem with font handling is that like the cmap is out of range for some unicode characters or something like that.
from fpdf2.
I'm not sure there is a need for a "global" issue given there are already specific issues.
What do you think?
from fpdf2.
I figured that in the long term font handling should be "overhauled" (actually, hauled out to the trash and replaced with some font library), so this would be a good place to discuss. Also, I'm used to JIRA's "epic" concept which lets issues be linked to one another. I would prefer we keep this open for now.
I somehow think that even after #26 theres gonna be some unicode stuff that crops up just because font handling is for font libs not fpdf.
from fpdf2.
If you're used to JIRA, you may want to check out GitHub Projects: https://github.com/alexanderankin/pyfpdf/projects
I fully agree about using a dedicated lib for font handling!
from fpdf2.
Hi,
Dont know if my question belongs here, but starting a seperate issue for it seems a bit much.
The self.charwidths attribute of the TTFontFile class is a list.
However the FPDF class wants it to be a dictionary.
Is my observation correct? Is it easy to fix? (I'm not that much at home in the ttfonts python file).
Kind regards,
from fpdf2.
from fpdf2.
@bwdalmijn What makes you think that "the FPDF class wants it to be a dictionary" ?
from fpdf2.
@Lucas-C When i try adding a font and then using it (TrueType Fontfile that is):
The functions I use are slightly modified compared to yours, but the mechanics are the same.
pdf.add_font("courier",style='',fname="cour.ttf",file_type="uni")
pdf.add_font("courier",style='B',fname="courb.ttf",file_type="uni")
pdf.add_font("courier",style='I',fname="couri.ttf",file_type="uni")
pdf.add_font("courier",style='BI',fname="courbi.ttf",file_type="uni")
pdf.set_font("courier",9)
when "compiling" i get the error message:
AttributeError: 'list' object has no attribute 'get'
This refers to the "cw" element of a font in the dictionary FPDF.fonts.
The 'cw' element of a core-font, for instance, is a dictionary, where the characters are used as keys for their respective widths.
This way the functions in the fpdf class know how to extract the widths for each character.
This is missing when a ttf file is broken down and made into a font dictionary.
This should explain what i meant earlier.
Kind regards,
from fpdf2.
Thank you for the detailed explanations.
There is a minimal code snippet showing how to load "courier.ttf" and use it to render some text:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.add_font("Courier", style="", fname="courier.ttf", uni=True)
pdf.set_font("Courier", "", 36)
pdf.text(50, 50, "Hello!")
pdf.output("hello.pdf")
I have just tested this with latest version of the code on this repository, and it works fine.
Maybe the exception you got came from your custom code?
To help you we will need a minimal code that reproduces your issue, with a specific published version of fpdf2
.
Otherwise I'm sorry but we won't be able to help you 😔
from fpdf2.
Hi @Lucas-C,
Thank you for the reply.
If it works fine for you then correct assumption would be that my alterations caused the error, yes.
Thank you for trying it out.
I will dig a bit to see what's going on.
If you're interested I could drop the main fpdf.py somewhere. That is basically all that differs.
King regards,
from fpdf2.
fpdf/fpdf.py
changed a lot in the last 2 weeks, with the addition of black
as code formatter.
Your version may be very different now.
If yours adds some useful features, and you want to contribute to this repo by adding them in fpdf2
, feel free to open a Pull Request to submit your code!
from fpdf2.
Related Issues (20)
- How to set text color using CMYK colors? HOT 5
- Issue on Khmer Unicode Font Subscripts HOT 22
- Unexpected HTML end tag </span>, start tag was <p> HOT 2
- Word wrapping for Thai text (zero-width space) may not work as intended // wrapmode==WORD should also use zero-width space? HOT 2
- Add Cell Level Controll for Table Borders HOT 1
- Wrong signature for `pdf.table` HOT 4
- OSS-Fuzz Integration HOT 8
- multipage table using fpdf HOT 2
- Get rid of FPDF class/instance attributes getting passed to HTML2PDF. HOT 5
- Proposal for Generic Robust Substitution Mechanism HOT 1
- `local_context()` blocks appear to "leak" into one another HOT 6
- HTML: indent of lists on new line not flush HOT 5
- Line spacing for a long line that is displayed in several lines. HOT 5
- Text columns issue with top margin HOT 1
- Markdown not escaping MD special characters HOT 2
- Solution needed: Typographical Margins, Line Height, Leading HOT 1
- write_html() ignores font changes HOT 4
- call .write_html in footer cause RecursionError HOT 1
- pdf.font_style = "B" and pdf.emphasis = "BOLD" should behave the same way as pdf.set_font(style="B") HOT 1
- Lowercase hex (e.g. #fff) do not convert properly
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 fpdf2.