-bool IsGlyphUnderlined(GlyphIndex index,
- const Vector<GlyphRun>& underlineRuns)
-{
- for(Vector<GlyphRun>::ConstIterator it = underlineRuns.Begin(),
- endIt = underlineRuns.End();
- it != endIt;
- ++it)
- {
- const GlyphRun& run = *it;
-
- if((run.glyphIndex <= index) && (index < run.glyphIndex + run.numberOfGlyphs))
- {
- return true;
- }
- }
-
- return false;
-}
-
-bool doGlyphHaveStrikethrough(GlyphIndex index,
- const Vector<StrikethroughGlyphRun>& strikethroughRuns,
- Vector4& strikethroughColor)
-{
- for(Vector<StrikethroughGlyphRun>::ConstIterator it = strikethroughRuns.Begin(),
- endIt = strikethroughRuns.End();
- it != endIt;
- ++it)
- {
- const StrikethroughGlyphRun& run = *it;
-
- if((run.glyphRun.glyphIndex <= index) && (index < run.glyphRun.glyphIndex + run.glyphRun.numberOfGlyphs))
- {
- if(run.isColorSet)
- {
- strikethroughColor = run.color;
- }
-
- return true;
- }
- }
-
- return false;
-}
-
-/// 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;
-}
-