question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding 'height' to `Text` fails when is lower than `fontSize`

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
diegomuracommented, Jan 21, 2019

Thanks! I think this is happening when you define a height to Text that is less than the line height (in this case 12). Thanks for reporting this, but not sure what should we render in cases like that. Not sure also why would you define a fontSize: 12 and height: 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!

0reactions
diegomuracommented, Apr 14, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line-Height does not match the font-size - Stack Overflow
1em is equal to 1 times the number of pixels in a font size. So if your font-size is 60px, 1em = 60px....
Read more >
font-size-adjust - CSS: Cascading Style Sheets | MDN
The font-size-adjust CSS property sets the size of lower-case letters relative to the current font size (which defines the size of ...
Read more >
CSS font-size-adjust: How to auto-adjust your font size
Learn how the CSS font-size-adjust property can help you auto-adjust ... of lowercase letters, rather than the height of uppercase letters.
Read more >
How to Tame Line Height in CSS
When a browser encounters the line-height property, what it actually does is take the line of text and place it in the middle...
Read more >
CSS font-size property - W3Schools
Set the font size for different elements: div.a { font-size: 15px; } ... smaller, Sets the font-size to a smaller size than the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found