diegomura / diegomura/react-pdf

Text is Not Centered in Line Height

Open
#2,269 4 comments 6 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

**Describe the bug**
The text rendered is not centered in the line height. While this is expected behavior for type-setting programs such as Adobe InDesign and Affinity Publisher, it is not expected when working with web technologies. Encountered this when converting a design in Figma to React PDF.

*I'm unsure if this is intended behavior, so reporting this as a bug instead of a feature request.*

**To Reproduce**
Steps to reproduce the behavior:
1. Go to [this repl session](https://react-pdf-repl.vercel.app/?modules=true&cp_code=JYWwDg9gTgLgBAbzgEQgYwK4gKYDsYA0cAKtgB6FwAKAhgObZwC-cAZlBCHAOQACU2GmhgBaMABNWAegG5x2AVG4AoZeUiw481jQwAbeAAoAlHAC8APjiHlcOAB5UmHPgu27D2gzgBnYAC9sMwQAbQAmAAYIokiIgF0mNw8Pe1IKC3spNJgrdztMr2wkhyknLDwc5WNlIA&version=3.0.2).
2. Hover over the "Hello, World" text and notice that it hugs the top and left of the bounding box, with a large area below it that is the rest of the leading.

**Expected behavior**
Expect text to be centered in the line height box (leading) instead of hugging the top of the line height box.

**Screenshots**

An example of how text is positioned in the leading with HTML:
![Leading in Browser](https://user-images.githubusercontent.com/19335924/230157276-20f79662-e5cc-4d4a-aa30-40b9800ae9c2.png)

An example of how text is positioned in the leading with `react-pdf`:
![Leading in React-PDF](https://user-images.githubusercontent.com/19335924/230157283-2f2556db-875e-47e2-af28-4c9c3302438f.png)

**Desktop (please complete the following information):**
- OS: Windows 11
- Browser: Firefox 111.0.1
- React-pdf version: v3.1.9

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.