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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 else if (Character::treatAsSpace(character) && character != characterTab
ulation) | 363 else if (Character::treatAsSpace(character) && character != characterTab
ulation) |
364 character = space; | 364 character = space; |
365 else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) | 365 else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) |
366 character = zeroWidthSpace; | 366 character = zeroWidthSpace; |
367 | 367 |
368 U16_APPEND(destination, *destinationLength, length, character, error); | 368 U16_APPEND(destination, *destinationLength, length, character, error); |
369 ASSERT_UNUSED(error, !error); | 369 ASSERT_UNUSED(error, !error); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run, ForTextEmph
asisOrNot forTextEmphasis, HashSet<const SimpleFontData*>* fallbackFonts) | 373 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run, ForTextEmph
asisOrNot forTextEmphasis, HashSet<const SimpleFontData*>* fallbackFonts, FloatR
ect* bounds) |
374 : m_font(font) | 374 : m_font(font) |
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_glyphBoundingBox(bounds) |
385 , m_fallbackFonts(fallbackFonts) | 386 , m_fallbackFonts(fallbackFonts) |
386 { | 387 { |
387 m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]); | 388 m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]); |
388 normalizeCharacters(m_run, m_run.length(), m_normalizedBuffer.get(), &m_norm
alizedBufferLength); | 389 normalizeCharacters(m_run, m_run.length(), m_normalizedBuffer.get(), &m_norm
alizedBufferLength); |
389 setPadding(m_run.expansion()); | 390 setPadding(m_run.expansion()); |
390 setFontFeatures(); | 391 setFontFeatures(); |
391 } | 392 } |
392 | 393 |
393 // In complex text word-spacing affects each line-break, space (U+0020) and non-
breaking space (U+00A0). | 394 // In complex text word-spacing affects each line-break, space (U+0020) and non-
breaking space (U+00A0). |
394 static inline bool isCodepointSpace(UChar c) | 395 static inline bool isCodepointSpace(UChar c) |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 advance += spacing; | 923 advance += spacing; |
923 if (m_run.rtl()) { | 924 if (m_run.rtl()) { |
924 // In RTL, spacing should be added to left side of glyphs. | 925 // In RTL, spacing should be added to left side of glyphs. |
925 offsetX += spacing; | 926 offsetX += spacing; |
926 if (!isClusterEnd) | 927 if (!isClusterEnd) |
927 offsetX += m_letterSpacing; | 928 offsetX += m_letterSpacing; |
928 } | 929 } |
929 | 930 |
930 currentRun->setGlyphAndPositions(i, glyph, advance, offsetX, offsetY); | 931 currentRun->setGlyphAndPositions(i, glyph, advance, offsetX, offsetY); |
931 | 932 |
932 FloatRect glyphBounds = currentFontData->boundsForGlyph(glyph); | 933 if (m_glyphBoundingBox) { |
933 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y()); | 934 FloatRect glyphBounds = currentFontData->boundsForGlyph(glyph); |
934 m_glyphBoundingBox.unite(glyphBounds); | 935 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y()); |
935 glyphOrigin += FloatSize(advance + offsetX, offsetY); | 936 m_glyphBoundingBox->unite(glyphBounds); |
| 937 glyphOrigin += FloatSize(advance + offsetX, offsetY); |
| 938 } |
936 | 939 |
937 totalAdvance += advance; | 940 totalAdvance += advance; |
938 } | 941 } |
939 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0); | 942 currentRun->setWidth(totalAdvance > 0.0 ? totalAdvance : 0.0); |
940 m_totalWidth += currentRun->width(); | 943 m_totalWidth += currentRun->width(); |
941 } | 944 } |
942 | 945 |
943 float HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer, | 946 float HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer, |
944 HarfBuzzRun* currentRun, float initialAdvance) | 947 HarfBuzzRun* currentRun, float initialAdvance) |
945 { | 948 { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 // possibly invalid from, to arguments. | 1142 // possibly invalid from, to arguments. |
1140 if (!foundToX && !foundFromX) | 1143 if (!foundToX && !foundFromX) |
1141 fromX = toX = 0; | 1144 fromX = toX = 0; |
1142 | 1145 |
1143 if (fromX < toX) | 1146 if (fromX < toX) |
1144 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); | 1147 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); |
1145 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); | 1148 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); |
1146 } | 1149 } |
1147 | 1150 |
1148 } // namespace blink | 1151 } // namespace blink |
OLD | NEW |