| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/render_text_mac.h" | 5 #include "ui/gfx/render_text_mac.h" |
| 6 | 6 |
| 7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
| 9 #include <CoreText/CoreText.h> | 9 #include <CoreText/CoreText.h> |
| 10 | 10 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 continue; | 391 continue; |
| 392 } | 392 } |
| 393 | 393 |
| 394 runs_.emplace_back(); | 394 runs_.emplace_back(); |
| 395 TextRun* run = &runs_.back(); | 395 TextRun* run = &runs_.back(); |
| 396 run->ct_run = ct_run; | 396 run->ct_run = ct_run; |
| 397 run->origin = run_origin; | 397 run->origin = run_origin; |
| 398 run->width = run_width; | 398 run->width = run_width; |
| 399 run->glyphs.resize(glyph_count); | 399 run->glyphs.resize(glyph_count); |
| 400 CTRunGetGlyphs(ct_run, empty_cf_range, &run->glyphs[0]); | 400 CTRunGetGlyphs(ct_run, empty_cf_range, &run->glyphs[0]); |
| 401 // CTRunGetGlyphs() sometimes returns glyphs with value 65535 and zero | |
| 402 // width (this has been observed at the beginning of a string containing | |
| 403 // Arabic content). Passing these to Skia will trigger an assertion; | |
| 404 // instead set their values to 0. | |
| 405 for (size_t glyph = 0; glyph < glyph_count; glyph++) { | |
| 406 if (run->glyphs[glyph] == 65535) | |
| 407 run->glyphs[glyph] = 0; | |
| 408 } | |
| 409 | 401 |
| 410 run->glyph_positions.resize(glyph_count); | 402 run->glyph_positions.resize(glyph_count); |
| 411 const CGPoint* positions_ptr = CTRunGetPositionsPtr(ct_run); | 403 const CGPoint* positions_ptr = CTRunGetPositionsPtr(ct_run); |
| 412 std::vector<CGPoint> positions; | 404 std::vector<CGPoint> positions; |
| 413 if (positions_ptr == NULL) { | 405 if (positions_ptr == NULL) { |
| 414 positions.resize(glyph_count); | 406 positions.resize(glyph_count); |
| 415 CTRunGetPositions(ct_run, empty_cf_range, &positions[0]); | 407 CTRunGetPositions(ct_run, empty_cf_range, &positions[0]); |
| 416 positions_ptr = &positions[0]; | 408 positions_ptr = &positions[0]; |
| 417 } | 409 } |
| 418 for (size_t glyph = 0; glyph < glyph_count; glyph++) { | 410 for (size_t glyph = 0; glyph < glyph_count; glyph++) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // TODO(karandeepb): This is not invoked on any codepath currently. Style the | 450 // TODO(karandeepb): This is not invoked on any codepath currently. Style the |
| 459 // returned text if need be. | 451 // returned text if need be. |
| 460 if (obscured()) | 452 if (obscured()) |
| 461 return false; | 453 return false; |
| 462 | 454 |
| 463 decorated_text->text = GetTextFromRange(range); | 455 decorated_text->text = GetTextFromRange(range); |
| 464 return true; | 456 return true; |
| 465 } | 457 } |
| 466 | 458 |
| 467 } // namespace gfx | 459 } // namespace gfx |
| OLD | NEW |