void ImplLayoutRuns::AddPos( int nCharPos, bool bRTL )
{ // check if charpos could extend current run if (!maRuns.empty())
{ auto& rLastRun = maRuns.back(); if (bRTL == rLastRun.m_bRTL)
{ if (nCharPos + 1 == rLastRun.m_nMinRunPos)
{ // extend current run by new charpos
rLastRun.m_nMinRunPos = nCharPos;
}
if (nCharPos == rLastRun.m_nEndRunPos)
{ // extend current run by new charpos
++rLastRun.m_nEndRunPos;
}
}
// ignore new charpos when it is in current run if ((rLastRun.m_nMinRunPos <= nCharPos) && (nCharPos < rLastRun.m_nEndRunPos))
{ return;
}
}
// else append a new run consisting of the new charpos
maRuns.emplace_back(nCharPos, nCharPos + 1, bRTL);
}
void ImplLayoutRuns::AddRun( int nCharPos0, int nCharPos1, bool bRTL )
{ if( nCharPos0 == nCharPos1 ) return;
auto nOrderedCharPos0 = std::min(nCharPos0, nCharPos1); auto nOrderedCharPos1 = std::max(nCharPos0, nCharPos1);
bool ImplLayoutRuns::GetNextPos( int* nCharPos, bool* bRightToLeft )
{ // negative nCharPos => reset to first run if( *nCharPos < 0 )
mnRunIndex = 0;
// return false when all runs completed if( mnRunIndex >= static_cast<int>(maRuns.size()) ) returnfalse;
constauto& rRun = maRuns.at(mnRunIndex);
if( *nCharPos < 0 )
{ // get first valid nCharPos in run
*nCharPos = rRun.m_nMinRunPos;
} else
{ // advance to next nCharPos
++(*nCharPos);
// advance to next run if current run is completed if (*nCharPos == rRun.m_nEndRunPos)
{
++mnRunIndex; if (mnRunIndex >= static_cast<int>(maRuns.size()))
{ returnfalse;
}
void ImplLayoutRuns::PrepareFallbackRuns(ImplLayoutRuns* paRuns, ImplLayoutRuns* paFallbackRuns)
{ // Normalize the input fallback runs. This is required for efficient lookup.
paFallbackRuns->Normalize();
// Adjust fallback runs to have the same order and limits of the original runs.
ImplLayoutRuns aNewRuns; for (constauto& rRun : *paRuns)
{ auto nTailIndex = aNewRuns.size();
// Search for the first fallback run intersecting this run auto it = std::lower_bound(paFallbackRuns->begin(), paFallbackRuns->end(),
rRun.m_nMinRunPos, [](constauto& rCompRun, int nValue)
{ return rCompRun.m_nEndRunPos < nValue; }); for (; it != paFallbackRuns->end(); ++it)
{ if (rRun.m_nEndRunPos <= it->m_nMinRunPos)
{ break;
}
int nSubMin = std::max(rRun.m_nMinRunPos, it->m_nMinRunPos); int nSubMax = std::min(rRun.m_nEndRunPos, it->m_nEndRunPos);
aNewRuns.AddRun(nSubMin, nSubMax, rRun.m_bRTL);
}
// RTL subruns must be added in reverse order if (rRun.m_bRTL)
{
aNewRuns.ReverseTail(nTailIndex);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.