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/font_fallback_win.h" | 5 #include "ui/gfx/font_fallback_win.h" |
6 | 6 |
7 #include <dwrite_2.h> | 7 #include <dwrite_2.h> |
8 #include <usp10.h> | 8 #include <usp10.h> |
9 #include <wrl.h> | 9 #include <wrl.h> |
10 | 10 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // LinkedFontsIterator doesn't care about the font size, so we always pass 10. | 334 // LinkedFontsIterator doesn't care about the font size, so we always pass 10. |
335 internal::LinkedFontsIterator linked_fonts(Font(font_family, 10)); | 335 internal::LinkedFontsIterator linked_fonts(Font(font_family, 10)); |
336 std::vector<Font> fallback_fonts; | 336 std::vector<Font> fallback_fonts; |
337 Font current; | 337 Font current; |
338 while (linked_fonts.NextFont(¤t)) | 338 while (linked_fonts.NextFont(¤t)) |
339 fallback_fonts.push_back(current); | 339 fallback_fonts.push_back(current); |
340 return fallback_fonts; | 340 return fallback_fonts; |
341 } | 341 } |
342 | 342 |
343 bool GetFallbackFont(const Font& font, | 343 bool GetFallbackFont(const Font& font, |
344 const wchar_t* text, | 344 const base::char16* text, |
345 int text_length, | 345 int text_length, |
346 Font* result) { | 346 Font* result) { |
347 // Creating a DirectWrite font fallback can be expensive. It's ok in the | 347 // Creating a DirectWrite font fallback can be expensive. It's ok in the |
348 // browser process because we can use the shared system fallback, but in the | 348 // browser process because we can use the shared system fallback, but in the |
349 // renderer this can cause hangs. Code that needs font fallback in the | 349 // renderer this can cause hangs. Code that needs font fallback in the |
350 // renderer should instead use the font proxy. | 350 // renderer should instead use the font proxy. |
351 DCHECK(base::MessageLoopForUI::IsCurrent()); | 351 DCHECK(base::MessageLoopForUI::IsCurrent()); |
352 | 352 |
353 // Check that we have at least as much text as was claimed. If we have less | 353 // Check that we have at least as much text as was claimed. If we have less |
354 // text than expected then DirectWrite will become confused and crash. This | 354 // text than expected then DirectWrite will become confused and crash. This |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 base::string16 name; | 406 base::string16 name; |
407 if (FAILED(GetFamilyNameFromDirectWriteFont(mapped_font.Get(), &name))) | 407 if (FAILED(GetFamilyNameFromDirectWriteFont(mapped_font.Get(), &name))) |
408 return false; | 408 return false; |
409 *result = Font(base::UTF16ToUTF8(name), font.GetFontSize() * scale); | 409 *result = Font(base::UTF16ToUTF8(name), font.GetFontSize() * scale); |
410 return true; | 410 return true; |
411 } | 411 } |
412 return false; | 412 return false; |
413 } | 413 } |
414 | 414 |
415 } // namespace gfx | 415 } // namespace gfx |
OLD | NEW |