static void normalizeCharacters(const TextRun& run, unsigned length, UChar* destination, unsigned* destinationLength) { unsigned position = 0; bool error = false; const UChar* source; String stringFor8BitRun; if (run.is8Bit()) { stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), run.length()); source = stringFor8BitRun.characters16(); } else { source = run.characters16(); } *destinationLength = 0; while (position < length) { UChar32 character; U16_NEXT(source, position, length, character); // Don't normalize tabs as they are not treated as spaces for word-end. if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter(character)) character = spaceCharacter; else if (Character::treatAsSpace(character) && character != noBreakSpaceCharacter) character = spaceCharacter; else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) character = zeroWidthSpaceCharacter; U16_APPEND(destination, *destinationLength, length, character, error); ASSERT_UNUSED(error, !error); } }
UniscribeHelperTextRun::UniscribeHelperTextRun(const TextRun& run, const Font& font) : UniscribeHelper(0, run.length(), run.rtl(), font.primaryFont()->platformData().hfont(), font.primaryFont()->platformData().scriptCache(), font.primaryFont()->platformData().scriptFontProperties(), font.primaryFont()->spaceGlyph()) , m_font(&font) , m_fontIndex(0) { if (run.is8Bit()) { m_stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), run.length()); setInput(m_stringFor8BitRun.characters16()); } else { setInput(run.characters16()); } setDirectionalOverride(run.directionalOverride()); setLetterSpacing(font.letterSpacing()); setSpaceWidth(font.spaceWidth()); setWordSpacing(font.wordSpacing()); setAscent(font.fontMetrics().ascent()); setRangeProperties(font.fontDescription().featureSettings()); init(); // Expansion is the amount to add to make justification happen. This // should be done after Init() so all the runs are already measured. if (run.expansion() > 0) justify(run.expansion()); }
static void normalizeCharacters(const TextRun& run, UChar* destination, int length) { int position = 0; bool error = false; const UChar* source; String stringFor8BitRun; if (run.is8Bit()) { stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), run.length()); source = stringFor8BitRun.characters16(); } else source = run.characters16(); while (position < length) { UChar32 character; int nextPosition = position; U16_NEXT(source, nextPosition, length, character); // Don't normalize tabs as they are not treated as spaces for word-end. if (Font::treatAsSpace(character) && character != '\t') character = ' '; else if (Font::treatAsZeroWidthSpaceInComplexScript(character)) character = zeroWidthSpace; U16_APPEND(destination, position, length, character, error); ASSERT_UNUSED(error, !error); position = nextPosition; } }
bool ShapeResultSpacing::isFirstRun(const TextRun& run) const { if (&run == &m_textRun) return true; return run.is8Bit() ? run.characters8() == m_textRun.characters8() : run.characters16() == m_textRun.characters16(); }
void computeNormalizedSpaces(const TextRun& run, bool mirror, String& normalizedSpacesStringCache) { if (normalizedSpacesStringCache.length() == static_cast<unsigned>(run.charactersLength())) return; if (run.is8Bit()) normalizedSpacesStringCache = Font::normalizeSpaces(run.characters8(), run.charactersLength()); else normalizedSpacesStringCache = Font::normalizeSpaces(run.characters16(), run.charactersLength()); if (mirror) normalizedSpacesStringCache = createStringWithMirroredCharacters(normalizedSpacesStringCache); }
SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* textRenderer, const TextRun& run) { ASSERT(textRenderer); float scalingFactor = textRenderer->scalingFactor(); ASSERT(scalingFactor); const Font& scaledFont = textRenderer->scaledFont(); int length = 0; // Calculate width/height using the scaled font, divide this result by the scalingFactor afterwards. m_width = scaledFont.width(run, length, m_glyph.name) / scalingFactor; m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor; m_glyph.unicodeString = run.is8Bit() ? String(run.characters8(), length) : String(run.characters16(), length); m_glyph.isValid = true; ASSERT(length >= 0); m_length = static_cast<unsigned>(length); }