TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned position, unsigned length, TextDirection textDirection) { RenderStyle* style = text->style(); ASSERT(style); TextRun run(static_cast<const LChar*>(0) // characters, will be set below if non-zero. , 0 // length, will be set below if non-zero. , 0 // xPos, only relevant with allowTabs=true , 0 // padding, only relevant for justified text, not relevant for SVG , TextRun::AllowTrailingExpansion , textDirection , isOverride(style->unicodeBidi()) /* directionalOverride */); if (length) { if (text->is8Bit()) run.setText(text->characters8() + position, length); else run.setText(text->characters16() + position, length); } if (textRunNeedsRenderingContext(style->font())) run.setRenderingContext(SVGTextRunRenderingContext::create(text)); // We handle letter & word spacing ourselves. run.disableSpacing(); // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. run.setCharactersLength(text->textLength() - position); ASSERT(run.charactersLength() >= run.length()); return run; }
TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFragment& fragment) const { ASSERT(style); ASSERT(textRenderer()); RenderText* text = textRenderer(); ASSERT(text); TextRun run(text->characters() + fragment.characterOffset , fragment.length , false /* allowTabs */ , 0 /* xPos, only relevant with allowTabs=true */ , 0 /* padding, only relevant for justified text, not relevant for SVG */ , TextRun::AllowTrailingExpansion , direction() , m_dirOverride || style->rtlOrdering() == VisualOrder /* directionalOverride */); if (textRunNeedsRenderingContext(style->font())) run.setRenderingContext(SVGTextRunRenderingContext::create(text)); run.disableRoundingHacks(); // We handle letter & word spacing ourselves. run.disableSpacing(); // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. run.setCharactersLength(text->textLength() - fragment.characterOffset); ASSERT(run.charactersLength() >= run.length()); return run; }
SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* text, unsigned position, unsigned length, float width, Glyph glyphNameGlyphId) { ASSERT(text); bool needsContext = textRunNeedsRenderingContext(text->style()->font()); float scalingFactor = text->scalingFactor(); ASSERT(scalingFactor); m_width = width / scalingFactor; m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; m_glyph = needsContext ? glyphNameGlyphId : 0; m_length = length; }
SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* text, unsigned position, unsigned length, float width, const String& glyphName) { ASSERT(text); bool needsContext = textRunNeedsRenderingContext(text->style()->font()); float scalingFactor = text->scalingFactor(); ASSERT(scalingFactor); m_width = width / scalingFactor; m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; if (needsContext) { m_glyph.isValid = true; m_glyph.unicodeString = text->substring(position, length); m_glyph.name = glyphName; } m_length = length; }
TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFragment& fragment) const { ASSERT(style); ASSERT(textRenderer()); RenderText* text = textRenderer(); ASSERT(text); // FIXME(crbug.com/264211): This should not be necessary but can occur if we // layout during layout. Remove this when 264211 is fixed. RELEASE_ASSERT(!text->needsLayout()); TextRun run(static_cast<const LChar*>(0) // characters, will be set below if non-zero. , 0 // length, will be set below if non-zero. , 0 // xPos, only relevant with allowTabs=true , 0 // padding, only relevant for justified text, not relevant for SVG , TextRun::AllowTrailingExpansion , direction() , dirOverride() || style->rtlOrdering() == VisualOrder /* directionalOverride */); if (fragment.length) { if (text->is8Bit()) run.setText(text->characters8() + fragment.characterOffset, fragment.length); else run.setText(text->characters16() + fragment.characterOffset, fragment.length); } if (textRunNeedsRenderingContext(style->font())) run.setRenderingContext(SVGTextRunRenderingContext::create(text)); run.disableRoundingHacks(); // We handle letter & word spacing ourselves. run.disableSpacing(); // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. run.setCharactersLength(text->textLength() - fragment.characterOffset); ASSERT(run.charactersLength() >= run.length()); return run; }