public ILgCharacterPropertyEngine CharPropEngine(int ich)
{
if (ich >= m_ichMinCpe && ich < m_ichLimCpe)
return m_cpe;
int ws;
if (m_tssText == null)
{
ws = m_wsf.UserWs;
// pick an arbitrary one, for any index.
m_ichMinCpe = 0;
m_ichLimCpe = int.MaxValue;
}
else
{
int irun = m_tssText.get_RunAt(ich);
m_tssText.GetBoundsOfRun(irun, out m_ichMinCpe, out m_ichLimCpe);
ws = m_tssText.get_WritingSystem(irun);
}
// different run, but may not differ in ws.
if (ws != m_wsCpe)
{
m_wsCpe = ws;
if (ws == -1)
{
// Bizarrely, the run has no WS specified. This happens occasionally in poorly-written tests.
// Maybe there's some other way. Fall back to a default engine.
m_cpe = LgIcuCharPropEngineClass.Create();
}
else
{
m_cpe = m_wsf.get_CharPropEngine(ws);
}
}
return m_cpe;
}
}