OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2008 Holger Hans Peter Freyther | 3 * Copyright (C) 2008 Holger Hans Peter Freyther |
4 * Copyright (C) 2014 Google Inc. All rights reserved. | 4 * Copyright (C) 2014 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include "platform/fonts/SimpleShaper.h" | 24 #include "platform/fonts/SimpleShaper.h" |
25 | 25 |
26 #include "platform/fonts/Character.h" | 26 #include "platform/fonts/Character.h" |
27 #include "platform/fonts/Font.h" | 27 #include "platform/fonts/Font.h" |
28 #include "platform/fonts/FontPlatformFeatures.h" | |
29 #include "platform/fonts/GlyphBuffer.h" | 28 #include "platform/fonts/GlyphBuffer.h" |
30 #include "platform/fonts/Latin1TextIterator.h" | 29 #include "platform/fonts/Latin1TextIterator.h" |
31 #include "platform/fonts/SimpleFontData.h" | 30 #include "platform/fonts/SimpleFontData.h" |
32 #include "platform/text/SurrogatePairAwareTextIterator.h" | 31 #include "platform/text/SurrogatePairAwareTextIterator.h" |
33 #include "wtf/MathExtras.h" | 32 #include "wtf/MathExtras.h" |
34 | 33 |
35 using namespace WTF; | 34 using namespace WTF; |
36 using namespace Unicode; | 35 using namespace Unicode; |
37 | 36 |
38 namespace blink { | 37 namespace blink { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 m_fallbackFonts->add(fontData); | 106 m_fallbackFonts->add(fontData); |
108 } | 107 } |
109 | 108 |
110 float SimpleShaper::adjustSpacing(float width, const CharacterData& charData, | 109 float SimpleShaper::adjustSpacing(float width, const CharacterData& charData, |
111 const SimpleFontData& fontData, GlyphBuffer* glyphBuffer) | 110 const SimpleFontData& fontData, GlyphBuffer* glyphBuffer) |
112 { | 111 { |
113 // Account for letter-spacing. | 112 // Account for letter-spacing. |
114 if (width) | 113 if (width) |
115 width += m_font->fontDescription().letterSpacing(); | 114 width += m_font->fontDescription().letterSpacing(); |
116 | 115 |
117 static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundId
eographsInComplexText(); | |
118 bool treatAsSpace = Character::treatAsSpace(charData.character); | 116 bool treatAsSpace = Character::treatAsSpace(charData.character); |
119 if (treatAsSpace || (expandAroundIdeographs && Character::isCJKIdeographOrSy
mbol(charData.character))) { | 117 if (treatAsSpace) { |
120 // Distribute the run's total expansion evenly over all expansion opport
unities in the run. | 118 // Distribute the run's total expansion evenly over all expansion opport
unities in the run. |
121 if (m_expansion) { | 119 if (m_expansion) { |
122 if (!treatAsSpace && !m_isAfterExpansion) { | 120 if (!treatAsSpace && !m_isAfterExpansion) { |
123 // Take the expansion opportunity before this ideograph. | 121 // Take the expansion opportunity before this ideograph. |
124 m_expansion -= m_expansionPerOpportunity; | 122 m_expansion -= m_expansionPerOpportunity; |
125 float expansionAtThisOpportunity = m_expansionPerOpportunity; | 123 float expansionAtThisOpportunity = m_expansionPerOpportunity; |
126 m_runWidthSoFar += expansionAtThisOpportunity; | 124 m_runWidthSoFar += expansionAtThisOpportunity; |
127 if (glyphBuffer) { | 125 if (glyphBuffer) { |
128 if (glyphBuffer->isEmpty()) { | 126 if (glyphBuffer->isEmpty()) { |
129 if (m_forTextEmphasis) | 127 if (m_forTextEmphasis) |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 float initialWidth = m_runWidthSoFar; | 254 float initialWidth = m_runWidthSoFar; |
257 | 255 |
258 if (!advance(m_currentCharacter + 1)) | 256 if (!advance(m_currentCharacter + 1)) |
259 return false; | 257 return false; |
260 | 258 |
261 width = m_runWidthSoFar - initialWidth; | 259 width = m_runWidthSoFar - initialWidth; |
262 return true; | 260 return true; |
263 } | 261 } |
264 | 262 |
265 } // namespace blink | 263 } // namespace blink |
OLD | NEW |