/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
mLineThickness(0.0f),
mMeshRecordIndex(0u),
mUnderlineChunkId(0u),
- mStrikethroughPosition(0.0f)
+ mStrikethroughPosition(0.0f),
+ mStrikethroughChunkId(0u)
{
}
uint32_t mMeshRecordIndex;
uint32_t mUnderlineChunkId;
float mStrikethroughPosition;
+ uint32_t mStrikethroughChunkId;
};
struct MaxBlockSize
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;
+ }
void CacheGlyph(const GlyphInfo& glyph, FontId lastFontId, const AtlasGlyphManager::GlyphStyle& style, AtlasManager::AtlasSlot& slot)
{
const Size& defaultTextAtlasSize = mFontClient.GetDefaultTextAtlasSize(); //Retrieve default size of text-atlas-block from font-client.
Vector<TextCacheEntry>& newTextCache,
Vector<Extent>& extents,
uint32_t underlineChunkId,
- bool isGlyphCached)
+ bool isGlyphCached,
+ uint32_t strikethroughChunkId)
{
// Generate mesh data for this quad, plugging in our supplied position
AtlasManager::Mesh2D newMesh;
currentlineThickness,
slot,
underlineChunkId,
- position.y + (glyph.height * HALF));
+ position.y + (glyph.height * HALF),
+ strikethroughChunkId);
}
void CreateActors(const std::vector<MeshRecord>& meshContainer,
const bool strikethroughEnabled = view.IsStrikethroughEnabled();
const Vector4& strikethroughColor(view.GetStrikethroughColor());
const float strikethroughHeight = view.GetStrikethroughHeight();
+ Vector4 currentStrikethroughColor;
// Elided text info. Indices according to elided text.
const auto startIndexOfGlyphs = view.GetStartIndexOfElidedGlyphs();
0u,
numberOfUnderlineRuns);
+ // Get the strikethrough runs.
+ const Length numberOfStrikethroughRuns = view.GetNumberOfStrikethroughRuns();
+ Vector<StrikethroughGlyphRun> strikethroughRuns;
+ strikethroughRuns.Resize(numberOfStrikethroughRuns);
+ view.GetStrikethroughRuns(strikethroughRuns.Begin(), 0u, numberOfStrikethroughRuns);
+
bool thereAreUnderlinedGlyphs = false;
bool strikethroughGlyphsExist = false;
uint32_t underlineChunkId = 0u; // give id for each chunk.
bool isPreUnderlined = false; // status of underlined for previous glyph.
+ uint32_t strikethroughChunkId = 0u; // give id for each chunk.
+ bool isPrevGlyphStrikethrough = false; // status of strikethrough for previous glyph.
+
//Skip hyphenIndices less than startIndexOfGlyphs or between two middle of elided text
if(hyphenIndices)
{
const bool isGlyphUnderlined = underlineEnabled || IsGlyphUnderlined(i, underlineRuns);
thereAreUnderlinedGlyphs = thereAreUnderlinedGlyphs || isGlyphUnderlined;
- strikethroughGlyphsExist = strikethroughGlyphsExist || strikethroughEnabled;
+
+ currentStrikethroughColor = strikethroughColor;
+ const bool isStrikethroughGlyph = strikethroughEnabled || doGlyphHaveStrikethrough(i, strikethroughRuns, currentStrikethroughColor);
+ strikethroughGlyphsExist = strikethroughGlyphsExist || isStrikethroughGlyph;
// No operation for white space
if(glyph.width && glyph.height)
{
// Are we still using the same fontId as previous
- if((isGlyphUnderlined || strikethroughGlyphsExist) && (glyph.fontId != lastUnderlinedFontId))
+ if((isGlyphUnderlined || isStrikethroughGlyph) && (glyph.fontId != lastUnderlinedFontId))
{
// We need to fetch fresh font underline metrics
FontMetrics fontMetrics;
newTextCache,
extents,
underlineChunkId,
- false);
+ false,
+ 0u);
- if(strikethroughGlyphsExist)
+ if(isStrikethroughGlyph)
{
GenerateMesh(glyph,
positionPlusOutlineOffset,
newTextCache,
strikethroughExtents,
0u,
- true);
+ true,
+ strikethroughChunkId);
}
lastFontId = glyph.fontId; // Prevents searching for existing blocksizes when string of the same fontId.
newTextCache,
extents,
0u,
- false);
+ false,
+ 0u);
}
//The new underlined chunk. Add new id if they are not consecutive indices (this is for Markup case)
}
//Keep status of underlined for previous glyph to check consecutive indices
isPreUnderlined = isGlyphUnderlined;
+
+ if(isPrevGlyphStrikethrough && !isStrikethroughGlyph)
+ {
+ strikethroughChunkId++;
+ }
+
+ isPrevGlyphStrikethrough = isStrikethroughGlyph;
}
if(addHyphen)
if(strikethroughGlyphsExist)
{
// Check to see if any of the text needs a strikethrough
- GenerateStrikethrough(meshContainer, strikethroughExtents, strikethroughColor);
+ GenerateStrikethrough(meshContainer, strikethroughExtents, currentStrikethroughColor);
}
// For each MeshData object, create a mesh actor and add to the renderable actor
float lineThickness,
AtlasManager::AtlasSlot& slot,
uint32_t underlineChunkId,
- float strikethroughPosition)
+ float strikethroughPosition,
+ uint32_t strikethroughChunkId)
{
if(slot.mImageId)
{
underlinePosition,
lineThickness,
underlineChunkId,
- strikethroughPosition);
+ strikethroughPosition,
+ strikethroughChunkId);
}
return;
underlinePosition,
lineThickness,
underlineChunkId,
- strikethroughPosition);
+ strikethroughPosition,
+ strikethroughChunkId);
}
}
}
float underlinePosition,
float lineThickness,
uint32_t underlineChunkId,
- float strikethroughPosition)
+ float strikethroughPosition,
+ uint32_t strikethroughChunkId)
{
bool foundExtent = false;
for(Vector<Extent>::Iterator eIt = extents.Begin(),
eIt != eEndIt;
++eIt)
{
- if(Equals(baseLine, eIt->mBaseLine) && underlineChunkId == eIt->mUnderlineChunkId)
+ if(Equals(baseLine, eIt->mBaseLine) && underlineChunkId == eIt->mUnderlineChunkId && strikethroughChunkId == eIt->mStrikethroughChunkId)
{
foundExtent = true;
if(left < eIt->mLeft)
extent.mUnderlineChunkId = underlineChunkId;
extent.mLineThickness = lineThickness;
extent.mStrikethroughPosition = strikethroughPosition;
+ extent.mStrikethroughChunkId = strikethroughChunkId;
extents.PushBack(extent);
}
}