OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2009, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 m_fontconfigInterfaceId(0), | 52 m_fontconfigInterfaceId(0), |
53 m_ttcIndex(0) {} | 53 m_ttcIndex(0) {} |
54 | 54 |
55 explicit FontFaceCreationParams(AtomicString family) | 55 explicit FontFaceCreationParams(AtomicString family) |
56 : m_creationType(CreateFontByFamily), | 56 : m_creationType(CreateFontByFamily), |
57 m_family(family), | 57 m_family(family), |
58 m_filename(CString()), | 58 m_filename(CString()), |
59 m_fontconfigInterfaceId(0), | 59 m_fontconfigInterfaceId(0), |
60 m_ttcIndex(0) { | 60 m_ttcIndex(0) { |
61 #if OS(WIN) | 61 #if OS(WIN) |
62 // Leading "@" in the font name enables Windows vertical flow flag for the f
ont. | 62 // Leading "@" in the font name enables Windows vertical flow flag for the |
63 // Because we do vertical flow by ourselves, we don't want to use the Window
s feature. | 63 // font. Because we do vertical flow by ourselves, we don't want to use the |
64 // IE disregards "@" regardless of the orientation, so we follow the behavio
r and | 64 // Windows feature. IE disregards "@" regardless of the orientation, so we |
65 // normalize the family name. | 65 // follow the behavior and normalize the family name. |
66 m_family = (m_family.isEmpty() || m_family[0] != '@') | 66 m_family = (m_family.isEmpty() || m_family[0] != '@') |
67 ? m_family | 67 ? m_family |
68 : AtomicString(m_family.impl()->substring(1)); | 68 : AtomicString(m_family.impl()->substring(1)); |
69 #endif | 69 #endif |
70 } | 70 } |
71 | 71 |
72 FontFaceCreationParams(CString filename, | 72 FontFaceCreationParams(CString filename, |
73 int fontconfigInterfaceId, | 73 int fontconfigInterfaceId, |
74 int ttcIndex = 0) | 74 int ttcIndex = 0) |
75 : m_creationType(CreateFontByFciIdAndTtcIndex), | 75 : m_creationType(CreateFontByFciIdAndTtcIndex), |
(...skipping 15 matching lines...) Expand all Loading... |
91 return m_fontconfigInterfaceId; | 91 return m_fontconfigInterfaceId; |
92 } | 92 } |
93 int ttcIndex() const { | 93 int ttcIndex() const { |
94 ASSERT(m_creationType == CreateFontByFciIdAndTtcIndex); | 94 ASSERT(m_creationType == CreateFontByFciIdAndTtcIndex); |
95 return m_ttcIndex; | 95 return m_ttcIndex; |
96 } | 96 } |
97 | 97 |
98 unsigned hash() const { | 98 unsigned hash() const { |
99 if (m_creationType == CreateFontByFciIdAndTtcIndex) { | 99 if (m_creationType == CreateFontByFciIdAndTtcIndex) { |
100 StringHasher hasher; | 100 StringHasher hasher; |
101 // Hashing the filename and ints in this way is sensitive to character enc
oding | 101 // Hashing the filename and ints in this way is sensitive to character |
102 // and endianness. However, since the hash is not transferred over a netwo
rk | 102 // encoding and endianness. However, since the hash is not transferred |
103 // or permanently stored and only used for the runtime of Chromium, | 103 // over a network or permanently stored and only used for the runtime of |
104 // this is not a concern. | 104 // Chromium, this is not a concern. |
105 hasher.addCharacters(reinterpret_cast<const LChar*>(m_filename.data()), | 105 hasher.addCharacters(reinterpret_cast<const LChar*>(m_filename.data()), |
106 m_filename.length()); | 106 m_filename.length()); |
107 hasher.addCharacters(reinterpret_cast<const LChar*>(&m_ttcIndex), | 107 hasher.addCharacters(reinterpret_cast<const LChar*>(&m_ttcIndex), |
108 sizeof(m_ttcIndex)); | 108 sizeof(m_ttcIndex)); |
109 hasher.addCharacters( | 109 hasher.addCharacters( |
110 reinterpret_cast<const LChar*>(&m_fontconfigInterfaceId), | 110 reinterpret_cast<const LChar*>(&m_fontconfigInterfaceId), |
111 sizeof(m_fontconfigInterfaceId)); | 111 sizeof(m_fontconfigInterfaceId)); |
112 return hasher.hash(); | 112 return hasher.hash(); |
113 } | 113 } |
114 return CaseFoldingHash::hash(m_family.isEmpty() ? "" : m_family); | 114 return CaseFoldingHash::hash(m_family.isEmpty() ? "" : m_family); |
(...skipping 11 matching lines...) Expand all Loading... |
126 FontFaceCreationType m_creationType; | 126 FontFaceCreationType m_creationType; |
127 AtomicString m_family; | 127 AtomicString m_family; |
128 CString m_filename; | 128 CString m_filename; |
129 int m_fontconfigInterfaceId; | 129 int m_fontconfigInterfaceId; |
130 int m_ttcIndex; | 130 int m_ttcIndex; |
131 }; | 131 }; |
132 | 132 |
133 } // namespace blink | 133 } // namespace blink |
134 | 134 |
135 #endif // FontFaceCreationParams_h | 135 #endif // FontFaceCreationParams_h |
OLD | NEW |