IFACEMETHODIMP TextAnalysis::SetBidiLevel( UINT32 textPosition, UINT32 textLength, UINT8 explicitLevel, UINT8 resolvedLevel ) { try { SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { LinkedRun& run = FetchNextRun(&textLength); run.bidiLevel = resolvedLevel; run.isReversed = !!(resolvedLevel & 1); } } catch (...) { return E_FAIL; // Unknown error, probably out of memory. } return S_OK; }
STDMETHODIMP TextAnalysis::GetVerticalGlyphOrientation( UINT32 textPosition, _Out_ UINT32* textLength, _Out_ DWRITE_VERTICAL_GLYPH_ORIENTATION* glyphOrientation, _Out_ UINT8* bidiLevel ) { SetCurrentRun(textPosition); const LinkedRun& run = m_runs[m_currentRunIndex]; *bidiLevel = run.bidiLevel; *glyphOrientation = DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT; // Find the next range where a bidi level changes. const size_t totalRuns = m_runs.size(); UINT32 lastRunPosition = textPosition; UINT32 nextRunIndex = m_currentRunIndex; do { const LinkedRun& nextRun = m_runs[nextRunIndex]; if (nextRun.bidiLevel != run.bidiLevel) { break; } lastRunPosition = nextRun.textStart + nextRun.textLength; nextRunIndex = nextRun.nextRunIndex; } while (nextRunIndex < totalRuns && nextRunIndex != 0); *textLength = lastRunPosition - textPosition; return S_OK; }
IFACEMETHODIMP TextAnalysis::SetScriptAnalysis(UINT32 textPosition, UINT32 textLength, DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis) { SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { Run *run = FetchNextRun(&textLength); run->mScript = *scriptAnalysis; } return S_OK; }
IFACEMETHODIMP TextAnalysis::SetBidiLevel(UINT32 textPosition, UINT32 textLength, UINT8 explicitLevel, UINT8 resolvedLevel) { SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { Run *run = FetchNextRun(&textLength); run->mBidiLevel = resolvedLevel; } return S_OK; }
IFACEMETHODIMP TextAnalysis::SetNumberSubstitution( UINT32 textPosition, UINT32 textLength, IDWriteNumberSubstitution* numberSubstitution ) { try { SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { LinkedRun& run = FetchNextRun(&textLength); run.isNumberSubstituted = (numberSubstitution != nullptr); } } catch (...) { return E_FAIL; // Unknown error, probably out of memory. } return S_OK; }
IFACEMETHODIMP TextAnalysis::SetScriptAnalysis( UINT32 textPosition, UINT32 textLength, DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis ) { try { SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { LinkedRun& run = FetchNextRun(&textLength); run.script = *scriptAnalysis; } } catch (...) { return E_FAIL; // Unknown error, probably out of memory. } return S_OK; }
IFACEMETHODIMP TextAnalysis::SetGlyphOrientation( UINT32 textPosition, UINT32 textLength, DWRITE_GLYPH_ORIENTATION_ANGLE glyphOrientationAngle, UINT8 adjustedBidiLevel, BOOL isSideways, BOOL isRightToLeft ) { try { // Mapping from angle down to small orientation. const static UINT8 glyphOrientations[] = { GlyphOrientationCW0, GlyphOrientationCW90, GlyphOrientationCW180, GlyphOrientationCW270, }; SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { LinkedRun& run = FetchNextRun(&textLength); run.glyphOrientation = glyphOrientations[glyphOrientationAngle & 3]; run.isSideways = !!isSideways; run.isReversed = !!isRightToLeft; run.bidiLevel = adjustedBidiLevel; } } catch (...) { return E_FAIL; // Unknown error, probably out of memory. } return S_OK; }