OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 , m_normalizedBufferLength(0) | 375 , m_normalizedBufferLength(0) |
376 , m_run(run) | 376 , m_run(run) |
377 , m_wordSpacingAdjustment(font->fontDescription().wordSpacing()) | 377 , m_wordSpacingAdjustment(font->fontDescription().wordSpacing()) |
378 , m_padding(0) | 378 , m_padding(0) |
379 , m_padPerWordBreak(0) | 379 , m_padPerWordBreak(0) |
380 , m_padError(0) | 380 , m_padError(0) |
381 , m_letterSpacing(font->fontDescription().letterSpacing()) | 381 , m_letterSpacing(font->fontDescription().letterSpacing()) |
382 , m_fromIndex(0) | 382 , m_fromIndex(0) |
383 , m_toIndex(m_run.length()) | 383 , m_toIndex(m_run.length()) |
384 , m_forTextEmphasis(forTextEmphasis) | 384 , m_forTextEmphasis(forTextEmphasis) |
385 , m_minGlyphBoundingBoxX(std::numeric_limits<float>::max()) | 385 , m_glyphBoundingBox(std::numeric_limits<float>::max(), std::numeric_limits<
float>::min(), std::numeric_limits<float>::min(), std::numeric_limits<float>::ma
x()) |
386 , m_maxGlyphBoundingBoxX(std::numeric_limits<float>::min()) | |
387 , m_minGlyphBoundingBoxY(std::numeric_limits<float>::max()) | |
388 , m_maxGlyphBoundingBoxY(std::numeric_limits<float>::min()) | |
389 { | 386 { |
390 m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]); | 387 m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]); |
391 normalizeCharacters(m_run, m_run.length(), m_normalizedBuffer.get(), &m_norm
alizedBufferLength); | 388 normalizeCharacters(m_run, m_run.length(), m_normalizedBuffer.get(), &m_norm
alizedBufferLength); |
392 setPadding(m_run.expansion()); | 389 setPadding(m_run.expansion()); |
393 setFontFeatures(); | 390 setFontFeatures(); |
394 } | 391 } |
395 | 392 |
396 bool HarfBuzzShaper::isWordEnd(unsigned index) | 393 bool HarfBuzzShaper::isWordEnd(unsigned index) |
397 { | 394 { |
398 // This could refer a high-surrogate, but should work. | 395 // This could refer a high-surrogate, but should work. |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 // In RTL, spacing should be added to left side of glyphs. | 896 // In RTL, spacing should be added to left side of glyphs. |
900 offsetX += spacing; | 897 offsetX += spacing; |
901 if (!isClusterEnd) | 898 if (!isClusterEnd) |
902 offsetX += m_letterSpacing; | 899 offsetX += m_letterSpacing; |
903 } | 900 } |
904 | 901 |
905 currentRun->setGlyphAndPositions(i, glyph, advance, offsetX, offsetY); | 902 currentRun->setGlyphAndPositions(i, glyph, advance, offsetX, offsetY); |
906 | 903 |
907 FloatRect glyphBounds = currentFontData->boundsForGlyph(glyph); | 904 FloatRect glyphBounds = currentFontData->boundsForGlyph(glyph); |
908 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y()); | 905 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y()); |
909 m_minGlyphBoundingBoxX = std::min(m_minGlyphBoundingBoxX, glyphBounds.x(
)); | 906 m_glyphBoundingBox.unite(glyphBounds); |
910 m_maxGlyphBoundingBoxX = std::max(m_maxGlyphBoundingBoxX, glyphBounds.ma
xX()); | |
911 m_minGlyphBoundingBoxY = std::min(m_minGlyphBoundingBoxY, glyphBounds.y(
)); | |
912 m_maxGlyphBoundingBoxY = std::max(m_maxGlyphBoundingBoxY, glyphBounds.ma
xY()); | |
913 glyphOrigin += FloatSize(advance + offsetX, offsetY); | 907 glyphOrigin += FloatSize(advance + offsetX, offsetY); |
914 | 908 |
915 totalAdvance += advance; | 909 totalAdvance += advance; |
916 } | 910 } |
917 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0); | 911 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0); |
918 m_totalWidth += currentRun->width(); | 912 m_totalWidth += currentRun->width(); |
919 } | 913 } |
920 | 914 |
921 void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer, Ha
rfBuzzRun* currentRun, FloatPoint& firstOffsetOfNextRun) | 915 void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer, Ha
rfBuzzRun* currentRun, FloatPoint& firstOffsetOfNextRun) |
922 { | 916 { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 if (!foundToX) | 1092 if (!foundToX) |
1099 toX = m_run.rtl() ? 0 : m_totalWidth; | 1093 toX = m_run.rtl() ? 0 : m_totalWidth; |
1100 | 1094 |
1101 // Using floorf() and roundf() as the same as mac port. | 1095 // Using floorf() and roundf() as the same as mac port. |
1102 if (fromX < toX) | 1096 if (fromX < toX) |
1103 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from
X), height); | 1097 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from
X), height); |
1104 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he
ight); | 1098 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he
ight); |
1105 } | 1099 } |
1106 | 1100 |
1107 } // namespace WebCore | 1101 } // namespace WebCore |
OLD | NEW |