Fix MeasureTextEx() height calculation #3770
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For multiline strings
MeasureTextEx()
is returning a much higher value than the actual text height.Pretty much like
DrawTextEx()
this patch just incrementtextLineSpacing
in the height when it sees\n
and don't applyscaleFactor
at the end.Small program to simulate the issue:
Without the fix
![Screenshot 2024-01-31 at 5 40 00 PM](https://private-user-images.githubusercontent.com/1334759/301367138-2a824eaa-3ffb-4240-aac0-06420eabdd42.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MzcwNDEsIm5iZiI6MTczOTczNjc0MSwicGF0aCI6Ii8xMzM0NzU5LzMwMTM2NzEzOC0yYTgyNGVhYS0zZmZiLTQyNDAtYWFjMC0wNjQyMGVhYmRkNDIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTZUMjAxMjIxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTEwOTJkN2QyZTNiNGM1YzhiZTFhMDA4Yzg5NjYyMDc0NDE2OGE5NGI5YThmYTY4YjczNDRmMTkyNjgxM2YwMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.QLiicPaEixodtMkPVJ0GEDnXc21Ew8fp-eravPPD7Zw)
With the fix
![Screenshot 2024-01-31 at 5 39 25 PM](https://private-user-images.githubusercontent.com/1334759/301367136-edad37c7-01ef-4d5b-a785-bc0382dd2ccf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MzcwNDEsIm5iZiI6MTczOTczNjc0MSwicGF0aCI6Ii8xMzM0NzU5LzMwMTM2NzEzNi1lZGFkMzdjNy0wMWVmLTRkNWItYTc4NS1iYzAzODJkZDJjY2YucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTZUMjAxMjIxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZmFiZjNlN2IyMzdjNTdlYWRmMDQxM2I1OGFkYTg3YjgzMjZkY2RjNjE2MTdlMDFlYjY4MGM4OThlZTYyMWFiNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.0IjR6zWLXAxCI5Gp4sF5kLeLRxm2wtUDCGqfR6e4y2A)