OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 { | 115 { |
116 LineLayoutSVGInlineText textLineLayout = LineLayoutSVGInlineText(textBox->ge
tLineLayoutItem()); | 116 LineLayoutSVGInlineText textLineLayout = LineLayoutSVGInlineText(textBox->ge
tLineLayoutItem()); |
117 TextRun run = SVGTextMetrics::constructTextRun(textLineLayout, textFragment.
characterOffset, textFragment.length, textLineLayout.styleRef().direction()); | 117 TextRun run = SVGTextMetrics::constructTextRun(textLineLayout, textFragment.
characterOffset, textFragment.length, textLineLayout.styleRef().direction()); |
118 | 118 |
119 float scalingFactor = textLineLayout.scalingFactor(); | 119 float scalingFactor = textLineLayout.scalingFactor(); |
120 ASSERT(scalingFactor); | 120 ASSERT(scalingFactor); |
121 const Font& scaledFont = textLineLayout.scaledFont(); | 121 const Font& scaledFont = textLineLayout.scaledFont(); |
122 FloatRect glyphOverflowBounds; | 122 FloatRect glyphOverflowBounds; |
123 | 123 |
124 float width = scaledFont.width(run, nullptr, &glyphOverflowBounds); | 124 float width = scaledFont.width(run, nullptr, &glyphOverflowBounds); |
125 float ascent = scaledFont.fontMetrics().floatAscent(); | 125 float ascent = scaledFont.getFontMetrics().floatAscent(); |
126 float descent = scaledFont.fontMetrics().floatDescent(); | 126 float descent = scaledFont.getFontMetrics().floatDescent(); |
127 textFragment.glyphOverflow.setFromBounds(glyphOverflowBounds, ascent, descen
t, width); | 127 textFragment.glyphOverflow.setFromBounds(glyphOverflowBounds, ascent, descen
t, width); |
128 textFragment.glyphOverflow.top /= scalingFactor; | 128 textFragment.glyphOverflow.top /= scalingFactor; |
129 textFragment.glyphOverflow.left /= scalingFactor; | 129 textFragment.glyphOverflow.left /= scalingFactor; |
130 textFragment.glyphOverflow.right /= scalingFactor; | 130 textFragment.glyphOverflow.right /= scalingFactor; |
131 textFragment.glyphOverflow.bottom /= scalingFactor; | 131 textFragment.glyphOverflow.bottom /= scalingFactor; |
132 } | 132 } |
133 | 133 |
134 void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox) | 134 void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox) |
135 { | 135 { |
136 ASSERT(!m_currentTextFragment.length); | 136 ASSERT(!m_currentTextFragment.length); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 // whether this character starts a new text chunk, before doing any furt
her processing. | 396 // whether this character starts a new text chunk, before doing any furt
her processing. |
397 if (m_visualMetricsIterator.characterOffset() == textBox->start()) | 397 if (m_visualMetricsIterator.characterOffset() == textBox->start()) |
398 textBox->setStartsNewTextChunk(logicalAttributes->context()->charact
erStartsNewTextChunk(m_logicalCharacterOffset)); | 398 textBox->setStartsNewTextChunk(logicalAttributes->context()->charact
erStartsNewTextChunk(m_logicalCharacterOffset)); |
399 | 399 |
400 float angle = SVGTextLayoutAttributes::isEmptyValue(data.rotate) ? 0 : d
ata.rotate; | 400 float angle = SVGTextLayoutAttributes::isEmptyValue(data.rotate) ? 0 : d
ata.rotate; |
401 | 401 |
402 // Calculate glyph orientation angle. | 402 // Calculate glyph orientation angle. |
403 // Font::width() calculates the resolved FontOrientation for each charac
ter, | 403 // Font::width() calculates the resolved FontOrientation for each charac
ter, |
404 // but is not exposed today to avoid the API complexity. | 404 // but is not exposed today to avoid the API complexity. |
405 UChar32 currentCharacter = textLineLayout.codepointAt(m_visualMetricsIte
rator.characterOffset()); | 405 UChar32 currentCharacter = textLineLayout.codepointAt(m_visualMetricsIte
rator.characterOffset()); |
406 FontOrientation fontOrientation = font.fontDescription().orientation(); | 406 FontOrientation fontOrientation = font.getFontDescription().orientation(
); |
407 fontOrientation = adjustOrientationForCharacterInMixedVertical(fontOrien
tation, currentCharacter); | 407 fontOrientation = adjustOrientationForCharacterInMixedVertical(fontOrien
tation, currentCharacter); |
408 | 408 |
409 // Calculate glyph advance. | 409 // Calculate glyph advance. |
410 // Shaping engine takes care of x/y orientation shifts for different fon
tOrientation values. | 410 // Shaping engine takes care of x/y orientation shifts for different fon
tOrientation values. |
411 float glyphAdvance = visualMetrics.advance(fontOrientation); | 411 float glyphAdvance = visualMetrics.advance(fontOrientation); |
412 | 412 |
413 // Assign current text position to x/y values, if needed. | 413 // Assign current text position to x/y values, if needed. |
414 updateCharacterPositionIfNeeded(x, y); | 414 updateCharacterPositionIfNeeded(x, y); |
415 | 415 |
416 // Apply dx/dy value adjustments to current text position, if needed. | 416 // Apply dx/dy value adjustments to current text position, if needed. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 } | 548 } |
549 | 549 |
550 if (!didStartTextFragment) | 550 if (!didStartTextFragment) |
551 return; | 551 return; |
552 | 552 |
553 // Close last open fragment, if needed. | 553 // Close last open fragment, if needed. |
554 recordTextFragment(textBox); | 554 recordTextFragment(textBox); |
555 } | 555 } |
556 | 556 |
557 } // namespace blink | 557 } // namespace blink |
OLD | NEW |