Adding 'height' to `Text` fails when is lower than `fontSize`
See original GitHub issueI am attempting to replicate a table layout and running into similar issues as other reports such as this (https://github.com/diegomura/react-pdf/issues/348) have described where text either doesn’t appear or overlays other components.
One of the suggested solutions is to add a height to the css to assist the renderer. I have tried doing this however this causes an immediate crash. It is very simple to reproduce, just go to one of the examples at https://react-pdf.org/repl and add a height to the title or author css and you will get it.
The message varies, on Chrome it is Uncaught (in promise) TypeError: Cannot read property 'copy' of undefined
but on FireFox it is completely different Unhandled promise rejection TypeError: "h[Math.min(...)] is undefined"
.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks! I think this is happening when you define a height to
Text
that is less than the line height (in this case12
). Thanks for reporting this, but not sure what should we render in cases like that. Not sure also why would you define afontSize: 12
andheight: 10
, but I’ll at least try not to throw a cryptic error in these cases.If you don’t mind, I’ll change the issue name for something more descriptive. Thanks!
This does not throw an error anymore. I still think that the current behavior is the expected: if you set up a fixed height to a Text and that’s not enough to render it, nothing should render. After all, there’s no enough space for it. Sometimes setting the exact height (or even some pt more) is not enough, since fonts have a
descent
distance defined. Closing this now