Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗑️ Calculate line height and font metrics - CLOSED 🗑️ #8

Conversation

fabOnReact
Copy link
Owner

Child of PR facebook#35704

requires moving the logic to AbsSizeSpan and calculate the ratio use to increase the original font

FontMetrics (top, bottom, ascent and descent) are calculated on the original fontSize
They are not updated after changing fontSize. Increase the fontSize to text would log same fontMetrics

// top      -------------  -26 
// ascent   -------------  -30 
// baseline __my Text____   0  
// descent  _____________   8  
// bottom   _____________   1  

To work around this, we need to store the original fontSize (for ex. 1) and the new fontSize (for ex. 20) and calculate a ratio.

The ration is used to adjust the fontMetrics to the new fontSize.
The result is used to shift the baseline of the font to align top or bottom

…eight.

Reimplement solution from commit and comment (also relevant comment-1, commit-1, comment-2 and commit-2) which uses total height and number of lines to calculate average height. If textAttributes.mFontSize is not null, use the average lineHeight to position the text.
@fabOnReact
Copy link
Owner Author

fabOnReact commented Jan 12, 2023

86b0e7f

P type task
2 review Review formula values logged with getFontMetrics().topgetFontMetrics outputs correct value (top is higher then ascent)
3 bug Implement logic that uses TextView height to align text without lineHeight. Reimplement solution from commit and comment (also relevant comment-1, commit-1, comment-2 and commit-2) which uses total height and number of lines to calculate average height. If textAttributes.mFontSize is not null, use the average lineHeight to position the text.
3.1 task Read stackoverflow discussion and try to understand how to calculate font height of an AbsoluteSizeSpan after changing size.

P type task
2 review "Review formula values logged with getFontMetrics().top
getFontMetrics outputs correct value (top is higher then ascent)"
3 bug Implement logic that uses TextView height to align text without lineHeight. Reimplement solution from commit and comment (also relevant comment-1, commit-1, comment-2 and commit-2) which uses total height and number of lines to calculate average height. If textAttributes.mFontSize is not null, use the average lineHeight to position the text.
3.1 task Read stackoverflow discussion and try to understand how to calculate font height of an AbsoluteSizeSpan after changing size.

@fabOnReact fabOnReact changed the title Calculate line height and font metrics 🗑️ Calculate line height and font metrics - CLOSED 🗑️ Jan 12, 2023
@fabOnReact fabOnReact closed this Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant