OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
6 #include "UniscribeHelper.h" | 6 #include "UniscribeHelper.h" |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include "FontUtilsChromiumWin.h" | 10 #include "FontUtilsChromiumWin.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 , m_isRtl(isRtl) | 79 , m_isRtl(isRtl) |
80 , m_hfont(hfont) | 80 , m_hfont(hfont) |
81 , m_scriptCache(scriptCache) | 81 , m_scriptCache(scriptCache) |
82 , m_fontProperties(fontProperties) | 82 , m_fontProperties(fontProperties) |
83 , m_directionalOverride(false) | 83 , m_directionalOverride(false) |
84 , m_inhibitLigate(false) | 84 , m_inhibitLigate(false) |
85 , m_letterSpacing(0) | 85 , m_letterSpacing(0) |
86 , m_spaceWidth(0) | 86 , m_spaceWidth(0) |
87 , m_wordSpacing(0) | 87 , m_wordSpacing(0) |
88 , m_ascent(0) | 88 , m_ascent(0) |
| 89 , m_disableFontFallback(false) |
| 90 |
89 { | 91 { |
90 m_logfont.lfFaceName[0] = 0; | 92 m_logfont.lfFaceName[0] = 0; |
91 } | 93 } |
92 | 94 |
93 UniscribeHelper::~UniscribeHelper() | 95 UniscribeHelper::~UniscribeHelper() |
94 { | 96 { |
95 } | 97 } |
96 | 98 |
97 void UniscribeHelper::InitWithOptionalLengthProtection(bool lengthProtection) | 99 void UniscribeHelper::InitWithOptionalLengthProtection(bool lengthProtection) |
98 { | 100 { |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 SCRIPT_ITEM& run, | 503 SCRIPT_ITEM& run, |
502 Shaping& shaping) | 504 Shaping& shaping) |
503 { | 505 { |
504 HFONT hfont = m_hfont; | 506 HFONT hfont = m_hfont; |
505 SCRIPT_CACHE* scriptCache = m_scriptCache; | 507 SCRIPT_CACHE* scriptCache = m_scriptCache; |
506 SCRIPT_FONTPROPERTIES* fontProperties = m_fontProperties; | 508 SCRIPT_FONTPROPERTIES* fontProperties = m_fontProperties; |
507 int ascent = m_ascent; | 509 int ascent = m_ascent; |
508 HDC tempDC = NULL; | 510 HDC tempDC = NULL; |
509 HGDIOBJ oldFont = 0; | 511 HGDIOBJ oldFont = 0; |
510 HRESULT hr; | 512 HRESULT hr; |
511 bool lastFallbackTried = false; | 513 // When used to fill up glyph pages for simple scripts in non-BMP, |
| 514 // we don't want any font fallback in this class. The simple script |
| 515 // font path can take care of font fallback. |
| 516 bool lastFallbackTried = m_disableFontFallback; |
512 bool result; | 517 bool result; |
513 | 518 |
514 int generatedGlyphs = 0; | 519 int generatedGlyphs = 0; |
515 | 520 |
516 // In case HFONT passed in ctor cannot render this run, we have to scan | 521 // In case HFONT passed in ctor cannot render this run, we have to scan |
517 // other fonts from the beginning of the font list. | 522 // other fonts from the beginning of the font list. |
518 ResetFontIndex(); | 523 ResetFontIndex(); |
519 | 524 |
520 // Compute shapes. | 525 // Compute shapes. |
521 while (true) { | 526 while (true) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 } | 570 } |
566 | 571 |
567 // The current font can't render this run. clear DC and try | 572 // The current font can't render this run. clear DC and try |
568 // next font. | 573 // next font. |
569 if (tempDC) { | 574 if (tempDC) { |
570 SelectObject(tempDC, oldFont); | 575 SelectObject(tempDC, oldFont); |
571 ReleaseDC(NULL, tempDC); | 576 ReleaseDC(NULL, tempDC); |
572 tempDC = NULL; | 577 tempDC = NULL; |
573 } | 578 } |
574 | 579 |
575 if (NextWinFontData(&hfont, &scriptCache, &fontProperties, &ascent)) { | 580 if (!m_disableFontFallback && |
| 581 NextWinFontData(&hfont, &scriptCache, &fontProperties, &ascent)) { |
576 // The primary font does not support this run. Try next font. | 582 // The primary font does not support this run. Try next font. |
577 // In case of web page rendering, they come from fonts specified in | 583 // In case of web page rendering, they come from fonts specified in |
578 // CSS stylesheets. | 584 // CSS stylesheets. |
579 continue; | 585 continue; |
580 } else if (!lastFallbackTried) { | 586 } else if (!lastFallbackTried) { |
581 lastFallbackTried = true; | 587 lastFallbackTried = true; |
582 | 588 |
583 // Generate a last fallback font based on the script of | 589 // Generate a last fallback font based on the script of |
584 // a character to draw while inheriting size and styles | 590 // a character to draw while inheriting size and styles |
585 // from the primary font | 591 // from the primary font |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 numGlyphs = itemLength * 3 / 2 + 16; | 687 numGlyphs = itemLength * 3 / 2 + 16; |
682 } | 688 } |
683 | 689 |
684 // Convert a string to a glyph string trying the primary font, fonts in | 690 // Convert a string to a glyph string trying the primary font, fonts in |
685 // the fallback list and then script-specific last resort font. | 691 // the fallback list and then script-specific last resort font. |
686 Shaping& shaping = m_shapes[i]; | 692 Shaping& shaping = m_shapes[i]; |
687 if (!Shape(&m_input[startItem], itemLength, numGlyphs, m_runs[i], | 693 if (!Shape(&m_input[startItem], itemLength, numGlyphs, m_runs[i], |
688 shaping)) | 694 shaping)) |
689 continue; | 695 continue; |
690 | 696 |
| 697 // At the moment, the only time m_disableFontFallback is set is |
| 698 // when we look up glyph indices for non-BMP code ranges. So, |
| 699 // we can skip the glyph placement. When that becomes not the case |
| 700 // any more, we have to add a new flag to control glyph placement. |
| 701 if (m_disableFontFallback) |
| 702 continue; |
| 703 |
691 // Compute placements. Note that offsets is documented incorrectly | 704 // Compute placements. Note that offsets is documented incorrectly |
692 // and is actually an array. | 705 // and is actually an array. |
693 | 706 |
694 // DC that we lazily create if Uniscribe commands us to. | 707 // DC that we lazily create if Uniscribe commands us to. |
695 // (this does not happen often because scriptCache is already | 708 // (this does not happen often because scriptCache is already |
696 // updated when calling ScriptShape). | 709 // updated when calling ScriptShape). |
697 HDC tempDC = NULL; | 710 HDC tempDC = NULL; |
698 HGDIOBJ oldFont = NULL; | 711 HGDIOBJ oldFont = NULL; |
699 HRESULT hr; | 712 HRESULT hr; |
700 while (true) { | 713 while (true) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 // justification array contains both the advance and the extra space | 892 // justification array contains both the advance and the extra space |
880 // added for justification, so is the width we want. | 893 // added for justification, so is the width we want. |
881 int justification = 0; | 894 int justification = 0; |
882 for (size_t i = 0; i < shaping.m_justify.size(); i++) | 895 for (size_t i = 0; i < shaping.m_justify.size(); i++) |
883 justification += shaping.m_justify[i]; | 896 justification += shaping.m_justify[i]; |
884 | 897 |
885 return shaping.m_prePadding + justification; | 898 return shaping.m_prePadding + justification; |
886 } | 899 } |
887 | 900 |
888 } // namespace WebCore | 901 } // namespace WebCore |
OLD | NEW |