Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/gfx/render_text_win.cc

Issue 10143009: Use font linking based on the original run font in RenderTextWin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_win.h" 5 #include "ui/gfx/render_text_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 590
591 HRESULT hr = E_FAIL; 591 HRESULT hr = E_FAIL;
592 string_size_.set_height(0); 592 string_size_.set_height(0);
593 for (size_t i = 0; i < runs_.size(); ++i) { 593 for (size_t i = 0; i < runs_.size(); ++i) {
594 internal::TextRun* run = runs_[i]; 594 internal::TextRun* run = runs_[i];
595 size_t run_length = run->range.length(); 595 size_t run_length = run->range.length();
596 const wchar_t* run_text = &(text()[run->range.start()]); 596 const wchar_t* run_text = &(text()[run->range.start()]);
597 bool tried_fallback = false; 597 bool tried_fallback = false;
598 size_t linked_font_index = 0; 598 size_t linked_font_index = 0;
599 const std::vector<Font>* linked_fonts = NULL; 599 const std::vector<Font>* linked_fonts = NULL;
600 Font original_font = run->font;
600 601
601 // Select the font desired for glyph generation. 602 // Select the font desired for glyph generation.
602 SelectObject(cached_hdc_, run->font.GetNativeFont()); 603 SelectObject(cached_hdc_, run->font.GetNativeFont());
603 604
604 SCRIPT_FONTPROPERTIES font_properties; 605 SCRIPT_FONTPROPERTIES font_properties;
605 memset(&font_properties, 0, sizeof(font_properties)); 606 memset(&font_properties, 0, sizeof(font_properties));
606 font_properties.cBytes = sizeof(SCRIPT_FONTPROPERTIES); 607 font_properties.cBytes = sizeof(SCRIPT_FONTPROPERTIES);
607 ScriptGetFontProperties(cached_hdc_, &run->script_cache, &font_properties); 608 ScriptGetFontProperties(cached_hdc_, &run->script_cache, &font_properties);
608 609
609 run->logical_clusters.reset(new WORD[run_length]); 610 run->logical_clusters.reset(new WORD[run_length]);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 Font fallback_font; 655 Font fallback_font;
655 if (ChooseFallbackFont(cached_hdc_, run->font, run_text, run_length, 656 if (ChooseFallbackFont(cached_hdc_, run->font, run_text, run_length,
656 &fallback_font)) { 657 &fallback_font)) {
657 ApplySubstituteFont(run, fallback_font); 658 ApplySubstituteFont(run, fallback_font);
658 continue; 659 continue;
659 } 660 }
660 } 661 }
661 662
662 // The meta file approach did not yield a replacement font, try to find 663 // The meta file approach did not yield a replacement font, try to find
663 // one using font linking. First time through, get the linked fonts list. 664 // one using font linking. First time through, get the linked fonts list.
664 if (linked_fonts == NULL) 665 if (linked_fonts == NULL) {
665 linked_fonts = GetLinkedFonts(run->font); 666 // First, try to get the list for the original font.
667 linked_fonts = GetLinkedFonts(original_font);
668
669 // If there are no linked fonts for the original font, try querying the
670 // ones for the Uniscribe fallback font. This may happen if the first
671 // font is a custom font that has no linked fonts in the Registry.
msw 2012/04/23 20:20:59 nit: Should registry be capitalized? Are you refer
Alexei Svitkine (slow) 2012/04/23 21:13:14 Yes, the Windows Registry. It's capitalized in the
672 if (linked_fonts->empty())
673 linked_fonts = GetLinkedFonts(run->font);
msw 2012/04/23 20:20:59 Have you considered appending the linked fonts for
Alexei Svitkine (slow) 2012/04/23 21:13:14 I've thought about it, but decided to keep it up m
msw 2012/04/24 00:05:11 Cool, how about a TODO or less directed/actionable
674 }
666 675
667 // None of the linked fonts worked, break out of the loop. 676 // None of the linked fonts worked, break out of the loop.
668 if (linked_font_index == linked_fonts->size()) { 677 if (linked_font_index == linked_fonts->size()) {
669 // TODO(msw): Don't use SCRIPT_UNDEFINED. Apparently Uniscribe can 678 // TODO(msw): Don't use SCRIPT_UNDEFINED. Apparently Uniscribe can
670 // crash on certain surrogate pairs with SCRIPT_UNDEFINED. 679 // crash on certain surrogate pairs with SCRIPT_UNDEFINED.
671 // See https://bugzilla.mozilla.org/show_bug.cgi?id=341500 680 // See https://bugzilla.mozilla.org/show_bug.cgi?id=341500
672 // And http://maxradi.us/documents/uniscribe/ 681 // And http://maxradi.us/documents/uniscribe/
673 run->script_analysis.eScript = SCRIPT_UNDEFINED; 682 run->script_analysis.eScript = SCRIPT_UNDEFINED;
674 // Reset |hr| to 0 to not trigger the DCHECK() below when a font is 683 // Reset |hr| to 0 to not trigger the DCHECK() below when a font is
675 // not found that can display the text. This is expected behavior 684 // not found that can display the text. This is expected behavior
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 internal::TextRun* run) { 793 internal::TextRun* run) {
785 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD); 794 size_t caret = IndexOfAdjacentGrapheme(run->range.end(), CURSOR_BACKWARD);
786 return SelectionModel(caret, CURSOR_FORWARD); 795 return SelectionModel(caret, CURSOR_FORWARD);
787 } 796 }
788 797
789 RenderText* RenderText::CreateRenderText() { 798 RenderText* RenderText::CreateRenderText() {
790 return new RenderTextWin; 799 return new RenderTextWin;
791 } 800 }
792 801
793 } // namespace gfx 802 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698