| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 float xOrientationShift = 0; | 498 float xOrientationShift = 0; |
| 499 float yOrientationShift = 0; | 499 float yOrientationShift = 0; |
| 500 float glyphAdvance = baselineLayout.calculateGlyphAdvanceAndOrientation(
m_isVerticalText, visualMetrics, orientationAngle, xOrientationShift, yOrientati
onShift); | 500 float glyphAdvance = baselineLayout.calculateGlyphAdvanceAndOrientation(
m_isVerticalText, visualMetrics, orientationAngle, xOrientationShift, yOrientati
onShift); |
| 501 | 501 |
| 502 // Assign current text position to x/y values, if needed. | 502 // Assign current text position to x/y values, if needed. |
| 503 updateCharacterPositionIfNeeded(x, y); | 503 updateCharacterPositionIfNeeded(x, y); |
| 504 | 504 |
| 505 // Apply dx/dy value adjustments to current text position, if needed. | 505 // Apply dx/dy value adjustments to current text position, if needed. |
| 506 updateRelativePositionAdjustmentsIfNeeded(data.dx, data.dy); | 506 updateRelativePositionAdjustmentsIfNeeded(data.dx, data.dy); |
| 507 | 507 |
| 508 // Calculate SVG Fonts kerning, if needed. | |
| 509 float kerning = spacingLayout.calculateSVGKerning(m_isVerticalText, visu
alMetrics.glyph()); | |
| 510 | |
| 511 // Calculate CSS 'letter-spacing' and 'word-spacing' for next character,
if needed. | 508 // Calculate CSS 'letter-spacing' and 'word-spacing' for next character,
if needed. |
| 512 float spacing = spacingLayout.calculateCSSSpacing(currentCharacter); | 509 float spacing = spacingLayout.calculateCSSSpacing(currentCharacter); |
| 513 | 510 |
| 514 float textPathOffset = 0; | 511 float textPathOffset = 0; |
| 515 if (m_inPathLayout) { | 512 if (m_inPathLayout) { |
| 516 float scaledGlyphAdvance = glyphAdvance * m_textPathScaling; | 513 float scaledGlyphAdvance = glyphAdvance * m_textPathScaling; |
| 517 if (m_isVerticalText) { | 514 if (m_isVerticalText) { |
| 518 // If there's an absolute y position available, it marks the beg
inning of a new position along the path. | 515 // If there's an absolute y position available, it marks the beg
inning of a new position along the path. |
| 519 if (y != SVGTextLayoutAttributes::emptyValue()) | 516 if (y != SVGTextLayoutAttributes::emptyValue()) |
| 520 m_textPathCurrentOffset = y + m_textPathStartOffset; | 517 m_textPathCurrentOffset = y + m_textPathStartOffset; |
| 521 | 518 |
| 522 m_textPathCurrentOffset += m_dy - kerning; | 519 m_textPathCurrentOffset += m_dy; |
| 523 m_dy = 0; | 520 m_dy = 0; |
| 524 | 521 |
| 525 // Apply dx/dy correction and setup translations that move to th
e glyph midpoint. | 522 // Apply dx/dy correction and setup translations that move to th
e glyph midpoint. |
| 526 xOrientationShift += m_dx + baselineShift; | 523 xOrientationShift += m_dx + baselineShift; |
| 527 yOrientationShift -= scaledGlyphAdvance / 2; | 524 yOrientationShift -= scaledGlyphAdvance / 2; |
| 528 } else { | 525 } else { |
| 529 // If there's an absolute x position available, it marks the beg
inning of a new position along the path. | 526 // If there's an absolute x position available, it marks the beg
inning of a new position along the path. |
| 530 if (x != SVGTextLayoutAttributes::emptyValue()) | 527 if (x != SVGTextLayoutAttributes::emptyValue()) |
| 531 m_textPathCurrentOffset = x + m_textPathStartOffset; | 528 m_textPathCurrentOffset = x + m_textPathStartOffset; |
| 532 | 529 |
| 533 m_textPathCurrentOffset += m_dx - kerning; | 530 m_textPathCurrentOffset += m_dx; |
| 534 m_dx = 0; | 531 m_dx = 0; |
| 535 | 532 |
| 536 // Apply dx/dy correction and setup translations that move to th
e glyph midpoint. | 533 // Apply dx/dy correction and setup translations that move to th
e glyph midpoint. |
| 537 xOrientationShift -= scaledGlyphAdvance / 2; | 534 xOrientationShift -= scaledGlyphAdvance / 2; |
| 538 yOrientationShift += m_dy - baselineShift; | 535 yOrientationShift += m_dy - baselineShift; |
| 539 } | 536 } |
| 540 | 537 |
| 541 // Calculate current offset along path. | 538 // Calculate current offset along path. |
| 542 textPathOffset = m_textPathCurrentOffset + scaledGlyphAdvance / 2; | 539 textPathOffset = m_textPathCurrentOffset + scaledGlyphAdvance / 2; |
| 543 | 540 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 559 bool ok = m_textPathCalculator->pointAndNormalAtLength(textPathOffse
t, point, angle); | 556 bool ok = m_textPathCalculator->pointAndNormalAtLength(textPathOffse
t, point, angle); |
| 560 ASSERT_UNUSED(ok, ok); | 557 ASSERT_UNUSED(ok, ok); |
| 561 x = point.x(); | 558 x = point.x(); |
| 562 y = point.y(); | 559 y = point.y(); |
| 563 | 560 |
| 564 // For vertical text on path, the actual angle has to be rotated 90
degrees anti-clockwise, not the orientation angle! | 561 // For vertical text on path, the actual angle has to be rotated 90
degrees anti-clockwise, not the orientation angle! |
| 565 if (m_isVerticalText) | 562 if (m_isVerticalText) |
| 566 angle -= 90; | 563 angle -= 90; |
| 567 } else { | 564 } else { |
| 568 // Apply all previously calculated shift values. | 565 // Apply all previously calculated shift values. |
| 569 if (m_isVerticalText) { | 566 if (m_isVerticalText) |
| 570 x += baselineShift; | 567 x += baselineShift; |
| 571 y -= kerning; | 568 else |
| 572 } else { | |
| 573 x -= kerning; | |
| 574 y -= baselineShift; | 569 y -= baselineShift; |
| 575 } | |
| 576 | 570 |
| 577 x += m_dx; | 571 x += m_dx; |
| 578 y += m_dy; | 572 y += m_dy; |
| 579 } | 573 } |
| 580 | 574 |
| 581 // Determine whether we have to start a new fragment. | 575 // Determine whether we have to start a new fragment. |
| 582 bool shouldStartNewFragment = m_dx || m_dy || m_isVerticalText || m_inPa
thLayout || angle || angle != lastAngle | 576 bool shouldStartNewFragment = m_dx || m_dy || m_isVerticalText || m_inPa
thLayout || angle || angle != lastAngle |
| 583 || orientationAngle || kerning || applySpacingToNextCharacter || def
inesTextLength; | 577 || orientationAngle || applySpacingToNextCharacter || definesTextLen
gth; |
| 584 | 578 |
| 585 // If we already started a fragment, close it now. | 579 // If we already started a fragment, close it now. |
| 586 if (didStartTextFragment && shouldStartNewFragment) { | 580 if (didStartTextFragment && shouldStartNewFragment) { |
| 587 applySpacingToNextCharacter = false; | 581 applySpacingToNextCharacter = false; |
| 588 recordTextFragment(textBox, visualMetricsValues); | 582 recordTextFragment(textBox, visualMetricsValues); |
| 589 } | 583 } |
| 590 | 584 |
| 591 // Eventually start a new fragment, if not yet done. | 585 // Eventually start a new fragment, if not yet done. |
| 592 if (!didStartTextFragment || shouldStartNewFragment) { | 586 if (!didStartTextFragment || shouldStartNewFragment) { |
| 593 ASSERT(!m_currentTextFragment.characterOffset); | 587 ASSERT(!m_currentTextFragment.characterOffset); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 } | 637 } |
| 644 | 638 |
| 645 if (!didStartTextFragment) | 639 if (!didStartTextFragment) |
| 646 return; | 640 return; |
| 647 | 641 |
| 648 // Close last open fragment, if needed. | 642 // Close last open fragment, if needed. |
| 649 recordTextFragment(textBox, visualMetricsValues); | 643 recordTextFragment(textBox, visualMetricsValues); |
| 650 } | 644 } |
| 651 | 645 |
| 652 } | 646 } |
| OLD | NEW |