OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 0x1F110, 0x1F129, | 254 0x1F110, 0x1F129, |
255 0x1F130, 0x1F149, | 255 0x1F130, 0x1F149, |
256 0x1F150, 0x1F169, | 256 0x1F150, 0x1F169, |
257 0x1F170, 0x1F189, | 257 0x1F170, 0x1F189, |
258 0x1F200, 0x1F6FF | 258 0x1F200, 0x1F6FF |
259 }; | 259 }; |
260 | 260 |
261 return valueInIntervalList(cjkSymbolRanges, c); | 261 return valueInIntervalList(cjkSymbolRanges, c); |
262 } | 262 } |
263 | 263 |
264 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion) | 264 unsigned Character::expansionOpportunityCount(const LChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const ETextJustify textJu stify) |
265 { | 265 { |
266 unsigned count = 0; | 266 unsigned count = 0; |
267 if (direction == LTR) { | 267 if (textJustify == JustifyDistribute) { |
268 for (size_t i = 0; i < length; ++i) { | 268 count = length - 1; |
269 if (treatAsSpace(characters[i])) { | 269 } else { |
270 count++; | 270 if (direction == LTR) { |
271 isAfterExpansion = true; | 271 for (size_t i = 0; i < length; ++i) { |
272 } else { | 272 if (treatAsSpace(characters[i])) |
273 isAfterExpansion = false; | 273 count++; |
274 } | 274 } |
275 } | 275 } else { |
276 } else { | 276 for (size_t i = length; i > 0; --i) { |
277 for (size_t i = length; i > 0; --i) { | 277 if (treatAsSpace(characters[i - 1])) |
278 if (treatAsSpace(characters[i - 1])) { | 278 count++; |
279 count++; | |
280 isAfterExpansion = true; | |
281 } else { | |
282 isAfterExpansion = false; | |
283 } | 279 } |
284 } | 280 } |
285 } | 281 } |
282 if (direction == LTR) { | |
283 if (treatAsSpace(characters[length - 1])) | |
leviw_travelin_and_unemployed
2014/08/18 17:55:43
int lastCharacter = (direction == ltr) ? length -
dw.im
2014/08/21 00:20:55
Cool!
| |
284 isAfterExpansion = true; | |
285 else | |
286 isAfterExpansion = false; | |
287 } else { | |
288 if (treatAsSpace(characters[0])) | |
289 isAfterExpansion = true; | |
290 else | |
291 isAfterExpansion = false; | |
292 } | |
293 | |
286 return count; | 294 return count; |
287 } | 295 } |
288 | 296 |
289 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion) | 297 unsigned Character::expansionOpportunityCount(const UChar* characters, size_t le ngth, TextDirection direction, bool& isAfterExpansion, const ETextJustify textJu stify) |
290 { | 298 { |
291 static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundId eographsInComplexText(); | 299 static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundId eographsInComplexText(); |
292 unsigned count = 0; | 300 unsigned count = 0; |
293 if (direction == LTR) { | 301 if (direction == LTR) { |
294 for (size_t i = 0; i < length; ++i) { | 302 for (size_t i = 0; i < length; ++i) { |
295 UChar32 character = characters[i]; | 303 UChar32 character = characters[i]; |
296 if (treatAsSpace(character)) { | 304 if (treatAsSpace(character)) { |
297 count++; | 305 count++; |
298 isAfterExpansion = true; | 306 isAfterExpansion = true; |
299 continue; | 307 continue; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 { | 374 { |
367 return normalizeSpacesInternal(characters, length); | 375 return normalizeSpacesInternal(characters, length); |
368 } | 376 } |
369 | 377 |
370 String Character::normalizeSpaces(const UChar* characters, unsigned length) | 378 String Character::normalizeSpaces(const UChar* characters, unsigned length) |
371 { | 379 { |
372 return normalizeSpacesInternal(characters, length); | 380 return normalizeSpacesInternal(characters, length); |
373 } | 381 } |
374 | 382 |
375 } | 383 } |
OLD | NEW |