// Advance to the next script run, returning false when the end of the // TextRun has been reached. bool ComplexTextController::nextScriptRun() { // Ensure we're not pointing at the small caps buffer. m_item.string = m_run.characters(); if (!hb_utf16_script_run_next(0, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; // It is actually wrong to consider script runs at all in this code. // Other WebKit code (e.g. Mac) segments complex text just by finding // the longest span of text covered by a single font. // But we currently need to call hb_utf16_script_run_next anyway to fill // in the harfbuzz data structures to e.g. pick the correct script's shaper. // So we allow that to run first, then do a second pass over the range it // found and take the largest subregion that stays within a single font. m_currentFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false).fontData; unsigned endOfRun; for (endOfRun = 1; endOfRun < m_item.item.length; ++endOfRun) { const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos + endOfRun], false).fontData; if (nextFontData != m_currentFontData) break; } m_item.item.length = endOfRun; m_indexOfNextScriptRun = m_item.item.pos + endOfRun; setupFontForScriptRun(); shapeGlyphs(); setGlyphXPositions(rtl()); return true; }
// Advance to the next script run, returning false when the end of the // TextRun has been reached. bool nextScriptRun() { if (m_iterateBackwards) { // In right-to-left mode we need to render the shaped glyph backwards and // also render the script runs themselves backwards. So given a TextRun: // AAAAAAACTTTTTTT (A = Arabic, C = Common, T = Thai) // we render: // TTTTTTCAAAAAAA // (and the glyphs in each A, C and T section are backwards too) if (!hb_utf16_script_run_prev(&m_numCodePoints, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; } else { if (!hb_utf16_script_run_next(&m_numCodePoints, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; // It is actually wrong to consider script runs at all in this code. // Other WebKit code (e.g. Mac) segments complex text just by finding // the longest span of text covered by a single font. // But we currently need to call hb_utf16_script_run_next anyway to fill // in the harfbuzz data structures to e.g. pick the correct script's shaper. // So we allow that to run first, then do a second pass over the range it // found and take the largest subregion that stays within a single font. const FontData* glyphData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false, false).fontData; int endOfRun; for (endOfRun = 1; endOfRun < m_item.item.length; ++endOfRun) { const FontData* nextGlyphData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos + endOfRun], false, false).fontData; if (nextGlyphData != glyphData) break; } m_item.item.length = endOfRun; m_indexOfNextScriptRun = m_item.item.pos + endOfRun; } setupFontForScriptRun(); shapeGlyphs(); setGlyphXPositions(rtl()); return true; }
// Advance to the next script run, returning false when the end of the // TextRun has been reached. bool nextScriptRun() { if (m_iterateBackwards) { // In right-to-left mode we need to render the shaped glyph backwards and // also render the script runs themselves backwards. So given a TextRun: // AAAAAAACTTTTTTT (A = Arabic, C = Common, T = Thai) // we render: // TTTTTTCAAAAAAA // (and the glyphs in each A, C and T section are backwards too) if (!hb_utf16_script_run_prev(&m_numCodePoints, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; } else { if (!hb_utf16_script_run_next(&m_numCodePoints, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; } setupFontForScriptRun(); if (!shapeGlyphs()) return false; setGlyphXPositions(rtl()); return true; }
// Advance to the next script run, returning false when the end of the // TextRun has been reached. bool ComplexTextController::nextScriptRun() { // Ensure we're not pointing at the small caps buffer. m_item.string = m_run.characters(); if (!hb_utf16_script_run_next(0, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; // It is actually wrong to consider script runs at all in this code. // Other WebKit code (e.g. Mac) segments complex text just by finding // the longest span of text covered by a single font. // But we currently need to call hb_utf16_script_run_next anyway to fill // in the harfbuzz data structures to e.g. pick the correct script's shaper. // So we allow that to run first, then do a second pass over the range it // found and take the largest subregion that stays within a single font. SurrogatePairAwareTextIterator iterator(static_cast<const UChar*>(&m_item.string[m_item.item.pos]), 0, static_cast<int>(m_item.item.length), static_cast<int>(m_item.item.length)); UChar32 character; unsigned clusterLength = 0; if (!iterator.consume(character, clusterLength)) return false; m_currentFontData = m_font->glyphDataForCharacter(character, false).fontData; iterator.advance(clusterLength); while (iterator.consume(character, clusterLength)) { const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(character, false).fontData; if (nextFontData != m_currentFontData) break; iterator.advance(clusterLength); } m_item.item.length = iterator.currentCharacter(); m_indexOfNextScriptRun = m_item.item.pos + iterator.currentCharacter(); setupFontForScriptRun(); shapeGlyphs(); setGlyphPositions(rtl()); return true; }