OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #include "config.h" | 24 #include "config.h" |
25 #include "core/platform/graphics/Font.h" | 25 #include "core/platform/graphics/Font.h" |
26 | 26 |
27 #include "core/platform/graphics/TextRun.h" | 27 #include "core/platform/graphics/TextRun.h" |
28 #include "core/platform/graphics/WidthIterator.h" | 28 #include "core/platform/graphics/WidthIterator.h" |
29 #include "core/platform/text/transcoder/FontTranscoder.h" | |
30 #include "platform/geometry/FloatRect.h" | 29 #include "platform/geometry/FloatRect.h" |
31 #include "wtf/MainThread.h" | 30 #include "wtf/MainThread.h" |
32 #include "wtf/MathExtras.h" | 31 #include "wtf/MathExtras.h" |
33 #include "wtf/StdLibExtras.h" | 32 #include "wtf/StdLibExtras.h" |
34 #include "wtf/UnusedParam.h" | 33 #include "wtf/UnusedParam.h" |
35 #include "wtf/text/StringBuilder.h" | 34 #include "wtf/text/StringBuilder.h" |
36 | 35 |
37 using namespace WTF; | 36 using namespace WTF; |
38 using namespace Unicode; | 37 using namespace Unicode; |
39 | 38 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 TypesettingFeatures Font::s_defaultTypesettingFeatures = 0; | 85 TypesettingFeatures Font::s_defaultTypesettingFeatures = 0; |
87 | 86 |
88 // =============================================================================
=============== | 87 // =============================================================================
=============== |
89 // Font Implementation (Cross-Platform Portion) | 88 // Font Implementation (Cross-Platform Portion) |
90 // =============================================================================
=============== | 89 // =============================================================================
=============== |
91 | 90 |
92 Font::Font() | 91 Font::Font() |
93 : m_letterSpacing(0) | 92 : m_letterSpacing(0) |
94 , m_wordSpacing(0) | 93 , m_wordSpacing(0) |
95 , m_isPlatformFont(false) | 94 , m_isPlatformFont(false) |
96 , m_needsTranscoding(false) | |
97 , m_typesettingFeatures(0) | 95 , m_typesettingFeatures(0) |
98 { | 96 { |
99 } | 97 } |
100 | 98 |
101 Font::Font(const FontDescription& fd, float letterSpacing, float wordSpacing) | 99 Font::Font(const FontDescription& fd, float letterSpacing, float wordSpacing) |
102 : m_fontDescription(fd) | 100 : m_fontDescription(fd) |
103 , m_letterSpacing(letterSpacing) | 101 , m_letterSpacing(letterSpacing) |
104 , m_wordSpacing(wordSpacing) | 102 , m_wordSpacing(wordSpacing) |
105 , m_isPlatformFont(false) | 103 , m_isPlatformFont(false) |
106 , m_needsTranscoding(fontTranscoder().needsTranscoding(fd)) | |
107 , m_typesettingFeatures(computeTypesettingFeatures()) | 104 , m_typesettingFeatures(computeTypesettingFeatures()) |
108 { | 105 { |
109 } | 106 } |
110 | 107 |
111 Font::Font(const FontPlatformData& fontData, bool isPrinterFont, FontSmoothingMo
de fontSmoothingMode) | 108 Font::Font(const FontPlatformData& fontData, bool isPrinterFont, FontSmoothingMo
de fontSmoothingMode) |
112 : m_fontFallbackList(FontFallbackList::create()) | 109 : m_fontFallbackList(FontFallbackList::create()) |
113 , m_letterSpacing(0) | 110 , m_letterSpacing(0) |
114 , m_wordSpacing(0) | 111 , m_wordSpacing(0) |
115 , m_isPlatformFont(true) | 112 , m_isPlatformFont(true) |
116 , m_typesettingFeatures(computeTypesettingFeatures()) | 113 , m_typesettingFeatures(computeTypesettingFeatures()) |
117 { | 114 { |
118 m_fontDescription.setUsePrinterFont(isPrinterFont); | 115 m_fontDescription.setUsePrinterFont(isPrinterFont); |
119 m_fontDescription.setFontSmoothing(fontSmoothingMode); | 116 m_fontDescription.setFontSmoothing(fontSmoothingMode); |
120 m_needsTranscoding = fontTranscoder().needsTranscoding(fontDescription()); | |
121 m_fontFallbackList->setPlatformFont(fontData); | 117 m_fontFallbackList->setPlatformFont(fontData); |
122 } | 118 } |
123 | 119 |
124 Font::Font(const Font& other) | 120 Font::Font(const Font& other) |
125 : m_fontDescription(other.m_fontDescription) | 121 : m_fontDescription(other.m_fontDescription) |
126 , m_fontFallbackList(other.m_fontFallbackList) | 122 , m_fontFallbackList(other.m_fontFallbackList) |
127 , m_letterSpacing(other.m_letterSpacing) | 123 , m_letterSpacing(other.m_letterSpacing) |
128 , m_wordSpacing(other.m_wordSpacing) | 124 , m_wordSpacing(other.m_wordSpacing) |
129 , m_isPlatformFont(other.m_isPlatformFont) | 125 , m_isPlatformFont(other.m_isPlatformFont) |
130 , m_needsTranscoding(other.m_needsTranscoding) | |
131 , m_typesettingFeatures(computeTypesettingFeatures()) | 126 , m_typesettingFeatures(computeTypesettingFeatures()) |
132 { | 127 { |
133 } | 128 } |
134 | 129 |
135 Font& Font::operator=(const Font& other) | 130 Font& Font::operator=(const Font& other) |
136 { | 131 { |
137 m_fontDescription = other.m_fontDescription; | 132 m_fontDescription = other.m_fontDescription; |
138 m_fontFallbackList = other.m_fontFallbackList; | 133 m_fontFallbackList = other.m_fontFallbackList; |
139 m_letterSpacing = other.m_letterSpacing; | 134 m_letterSpacing = other.m_letterSpacing; |
140 m_wordSpacing = other.m_wordSpacing; | 135 m_wordSpacing = other.m_wordSpacing; |
141 m_isPlatformFont = other.m_isPlatformFont; | 136 m_isPlatformFont = other.m_isPlatformFont; |
142 m_needsTranscoding = other.m_needsTranscoding; | |
143 m_typesettingFeatures = other.m_typesettingFeatures; | 137 m_typesettingFeatures = other.m_typesettingFeatures; |
144 return *this; | 138 return *this; |
145 } | 139 } |
146 | 140 |
147 bool Font::operator==(const Font& other) const | 141 bool Font::operator==(const Font& other) const |
148 { | 142 { |
149 // Our FontData don't have to be checked, since checking the font descriptio
n will be fine. | 143 // Our FontData don't have to be checked, since checking the font descriptio
n will be fine. |
150 // FIXME: This does not work if the font was made with the FontPlatformData
constructor. | 144 // FIXME: This does not work if the font was made with the FontPlatformData
constructor. |
151 if (loadingCustomFonts() || other.loadingCustomFonts()) | 145 if (loadingCustomFonts() || other.loadingCustomFonts()) |
152 return false; | 146 return false; |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 } | 689 } |
696 | 690 |
697 void Font::willUseFontData() const | 691 void Font::willUseFontData() const |
698 { | 692 { |
699 const FontFamily& family = fontDescription().family(); | 693 const FontFamily& family = fontDescription().family(); |
700 if (m_fontFallbackList && m_fontFallbackList->fontSelector() && !family.fami
lyIsEmpty()) | 694 if (m_fontFallbackList && m_fontFallbackList->fontSelector() && !family.fami
lyIsEmpty()) |
701 m_fontFallbackList->fontSelector()->willUseFontData(fontDescription(), f
amily.family()); | 695 m_fontFallbackList->fontSelector()->willUseFontData(fontDescription(), f
amily.family()); |
702 } | 696 } |
703 | 697 |
704 } | 698 } |
OLD | NEW |