Skip to content

Commit 40f43b9

Browse files
authored
Merge pull request libRocket#289 from Triang3l/patch-1
Handle rem units in ElementUtilities::GetLineHeight
2 parents f164420 + 1d6cabf commit 40f43b9

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎Source/Core/ElementUtilities.cpp‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,18 @@ int ElementUtilities::GetFontSize(Element* element)
136136
// Returns an element's line height, if it has a font defined.
137137
int ElementUtilities::GetLineHeight(Element* element)
138138
{
139-
FontFaceHandle* font_face_handle = element->GetFontFaceHandle();
139+
const Property* line_height_property = element->GetLineHeightProperty();
140+
141+
Element* font_element = element;
142+
if (line_height_property->unit == Property::REM)
143+
font_element = element->GetOwnerDocument();
144+
145+
FontFaceHandle* font_face_handle = font_element->GetFontFaceHandle();
140146
if (font_face_handle == NULL)
141147
return 0;
142148

143149
int line_height = font_face_handle->GetLineHeight();
144150
float inch = element->GetRenderInterface()->GetPixelsPerInch();
145-
const Property* line_height_property = element->GetLineHeightProperty();
146151

147152
switch (line_height_property->unit)
148153
{
@@ -155,6 +160,7 @@ int ElementUtilities::GetLineHeight(Element* element)
155160
ROCKET_UNUSED_SWITCH_ENUM(Property::RELATIVE_UNIT);
156161
case Property::NUMBER:
157162
case Property::EM:
163+
case Property::REM:
158164
// If the property is a straight number or an em measurement, then it scales the line height.
159165
return Math::Round(line_height_property->value.Get< float >() * line_height);
160166
case Property::PERCENT:

0 commit comments

Comments
 (0)