Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] libImpeller: Respect the paragraph style line height specification. #56066

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion impeller/toolkit/interop/impeller.h
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,12 @@ void ImpellerParagraphStyleSetFontSize(
float size);

//------------------------------------------------------------------------------
/// @brief Set the paragraph height.
/// @brief The height of the text as a multiple of text size.
///
/// When height is 0.0, the line height will be determined by the
/// font's metrics directly, which may differ from the font size.
/// Otherwise the line height of the text will be a multiple of font
/// size, and be exactly fontSize * height logical pixels tall.
///
/// @param[in] paragraph_style The paragraph style.
/// @param[in] height The height.
Expand Down
1 change: 1 addition & 0 deletions impeller/toolkit/interop/impeller_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ TEST_P(InteropPlaygroundTest, CanCreateParagraphs) {
auto style = Adopt<ParagraphStyle>(ImpellerParagraphStyleNew());
ASSERT_TRUE(style);
ImpellerParagraphStyleSetFontSize(style.GetC(), 150.0f);
ImpellerParagraphStyleSetHeight(style.GetC(), 2.0f);

{
auto paint = Adopt<Paint>(ImpellerPaintNew());
Expand Down
1 change: 1 addition & 0 deletions impeller/toolkit/interop/paragraph_style.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void ParagraphStyle::SetFontSize(double size) {

void ParagraphStyle::SetHeight(double height) {
style_.height = height;
style_.has_height_override = (height != 0.0);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this isn't an optional. There is also a similar pattern around struts.

}

void ParagraphStyle::SetTextAlignment(txt::TextAlign alignment) {
Expand Down