-/// Helper method to fetch the underline metrics for the specified font glyph
-void FetchFontDecorationlinesMetrics(
- TextAbstraction::FontClient& fontClient,
- const GlyphInfo* const glyphInfo,
- float& currentUnderlinePosition,
- const float underlineHeight,
- float& currentUnderlineThickness,
- float& maxUnderlineThickness,
- FontId& lastlinedFontId,
- const float strikethroughHeight,
- float& currentStrikethroughThickness,
- float& maxStrikethroughThickness)
-{
- FontMetrics fontMetrics;
- fontClient.GetFontMetrics(glyphInfo->fontId, fontMetrics);
- currentUnderlinePosition = ceil(fabsf(fontMetrics.underlinePosition));
- const float descender = ceil(fabsf(fontMetrics.descender));
-
- if(fabsf(underlineHeight) < Math::MACHINE_EPSILON_1000)
- {
- currentUnderlineThickness = fontMetrics.underlineThickness;
-
- // Ensure underline will be at least a pixel high
- if(currentUnderlineThickness < 1.0f)
- {
- currentUnderlineThickness = 1.0f;
- }
- else
- {
- currentUnderlineThickness = ceil(currentUnderlineThickness);
- }
- }
-
- if(fabsf(strikethroughHeight) < Math::MACHINE_EPSILON_1000)
- {
- // Ensure strikethrough will be at least a pixel high
- if(currentStrikethroughThickness < 1.0f)
- {
- currentStrikethroughThickness = 1.0f;
- }
- else
- {
- currentStrikethroughThickness = ceil(currentStrikethroughThickness);
- }
- }
-
- // The underline thickness should be the max underline thickness of all glyphs of the line.
- if(currentUnderlineThickness > maxUnderlineThickness)
- {
- maxUnderlineThickness = currentUnderlineThickness;
- }
-
- // The strikethrough thickness should be the max strikethrough thickness of all glyphs of the line.
- if(currentStrikethroughThickness > maxStrikethroughThickness)
- {
- maxStrikethroughThickness = currentStrikethroughThickness;
- }
-
- // Clamp the underline position at the font descender and check for ( as EFL describes it ) a broken font
- if(currentUnderlinePosition > descender)
- {
- currentUnderlinePosition = descender;
- }
-
- if(fabsf(currentUnderlinePosition) < Math::MACHINE_EPSILON_1000)
- {
- // Move offset down by one ( EFL behavior )
- currentUnderlinePosition = 1.0f;
- }
-
- lastlinedFontId = glyphInfo->fontId;
-}
-