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 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 result->m_glyphBoundingBox.unite(glyphBounds); | 1133 result->m_glyphBoundingBox.unite(glyphBounds); |
1134 glyphOrigin += FloatSize(advance + offsetX, offsetY); | 1134 glyphOrigin += FloatSize(advance + offsetX, offsetY); |
1135 } | 1135 } |
1136 | 1136 |
1137 run->m_width = totalAdvance > 0.0 ? totalAdvance : 0.0; | 1137 run->m_width = totalAdvance > 0.0 ? totalAdvance : 0.0; |
1138 result->m_width += run->m_width; | 1138 result->m_width += run->m_width; |
1139 result->m_numGlyphs += numGlyphs; | 1139 result->m_numGlyphs += numGlyphs; |
1140 result->m_runs[index] = run.release(); | 1140 result->m_runs[index] = run.release(); |
1141 } | 1141 } |
1142 | 1142 |
| 1143 PassRefPtr<ShapeResult> ShapeResult::createForTabulationCharacters(const Font* f
ont, |
| 1144 const TextRun& textRun, float positionOffset, unsigned count) |
| 1145 { |
| 1146 const SimpleFontData* fontData = font->primaryFont(); |
| 1147 OwnPtr<ShapeResult::RunInfo> run = adoptPtr(new ShapeResult::RunInfo(fontDat
a, |
| 1148 // Tab characters are always LTR or RTL, not TTB, even when isVerticalAn
yUpright(). |
| 1149 textRun.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR, |
| 1150 HB_SCRIPT_COMMON, 0, count, count)); |
| 1151 float position = textRun.xPos() + positionOffset; |
| 1152 float startPosition = position; |
| 1153 for (unsigned i = 0; i < count; i++) { |
| 1154 float advance = font->tabWidth(*fontData, textRun.tabSize(), position); |
| 1155 run->m_glyphData[i].characterIndex = i; |
| 1156 run->setGlyphAndPositions(i, fontData->spaceGlyph(), advance, 0, 0); |
| 1157 position += advance; |
| 1158 } |
| 1159 run->m_width = position - startPosition; |
| 1160 |
| 1161 RefPtr<ShapeResult> result = ShapeResult::create(font, count, textRun.direct
ion()); |
| 1162 result->m_width = run->m_width; |
| 1163 result->m_numGlyphs = count; |
| 1164 result->m_runs.append(run.release()); |
| 1165 return result.release(); |
| 1166 } |
| 1167 |
1143 float HarfBuzzShaper::adjustSpacing(ShapeResult::RunInfo* run, size_t glyphIndex
, unsigned currentCharacterIndex, float& offset, float& totalAdvance) | 1168 float HarfBuzzShaper::adjustSpacing(ShapeResult::RunInfo* run, size_t glyphIndex
, unsigned currentCharacterIndex, float& offset, float& totalAdvance) |
1144 { | 1169 { |
1145 float spacing = 0; | 1170 float spacing = 0; |
1146 UChar32 character = m_normalizedBuffer[currentCharacterIndex]; | 1171 UChar32 character = m_normalizedBuffer[currentCharacterIndex]; |
1147 if (m_letterSpacing && !Character::treatAsZeroWidthSpace(character)) | 1172 if (m_letterSpacing && !Character::treatAsZeroWidthSpace(character)) |
1148 spacing += m_letterSpacing; | 1173 spacing += m_letterSpacing; |
1149 | 1174 |
1150 bool treatAsSpace = Character::treatAsSpace(character); | 1175 bool treatAsSpace = Character::treatAsSpace(character); |
1151 if (treatAsSpace && currentCharacterIndex && (character != '\t' || !m_textRu
n.allowTabs())) | 1176 if (treatAsSpace && currentCharacterIndex && (character != '\t' || !m_textRu
n.allowTabs())) |
1152 spacing += m_wordSpacingAdjustment; | 1177 spacing += m_wordSpacingAdjustment; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 return spacing; | 1215 return spacing; |
1191 } | 1216 } |
1192 | 1217 |
1193 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere
d by !m_expansionOpportunityCount above | 1218 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere
d by !m_expansionOpportunityCount above |
1194 spacing += nextExpansionPerOpportunity(); | 1219 spacing += nextExpansionPerOpportunity(); |
1195 m_isAfterExpansion = true; | 1220 m_isAfterExpansion = true; |
1196 return spacing; | 1221 return spacing; |
1197 } | 1222 } |
1198 | 1223 |
1199 } // namespace blink | 1224 } // namespace blink |
OLD | NEW |