OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com> | 2 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com> |
3 * Copyright (C) 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 27 matching lines...) Expand all Loading... |
38 float sizes[2]; | 38 float sizes[2]; |
39 // FXIME: Make them fit into one word. | 39 // FXIME: Make them fit into one word. |
40 uint32_t bitfields; | 40 uint32_t bitfields; |
41 uint32_t bitfields2 : 8; | 41 uint32_t bitfields2 : 8; |
42 }; | 42 }; |
43 | 43 |
44 COMPILE_ASSERT(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), Fon
tDescription_should_stay_small); | 44 COMPILE_ASSERT(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), Fon
tDescription_should_stay_small); |
45 | 45 |
46 FontWeight FontDescription::lighterWeight(void) const | 46 FontWeight FontDescription::lighterWeight(void) const |
47 { | 47 { |
48 // FIXME: Should actually return the CSS weight corresponding to next lighte
st | |
49 // weight of the currently used font family. | |
50 switch (m_weight) { | 48 switch (m_weight) { |
51 case FontWeight100: | 49 case FontWeight100: |
52 case FontWeight200: | 50 case FontWeight200: |
53 return FontWeight100; | |
54 | |
55 case FontWeight300: | 51 case FontWeight300: |
56 return FontWeight200; | |
57 | |
58 case FontWeight400: | 52 case FontWeight400: |
59 case FontWeight500: | 53 case FontWeight500: |
60 return FontWeight300; | 54 return FontWeight100; |
61 | 55 |
62 case FontWeight600: | 56 case FontWeight600: |
63 case FontWeight700: | 57 case FontWeight700: |
64 return FontWeight400; | 58 return FontWeight400; |
65 | 59 |
66 case FontWeight800: | 60 case FontWeight800: |
67 return FontWeight500; | |
68 | |
69 case FontWeight900: | 61 case FontWeight900: |
70 return FontWeight700; | 62 return FontWeight700; |
71 } | 63 } |
72 ASSERT_NOT_REACHED(); | 64 ASSERT_NOT_REACHED(); |
73 return FontWeightNormal; | 65 return FontWeightNormal; |
74 } | 66 } |
75 | 67 |
76 FontWeight FontDescription::bolderWeight(void) const | 68 FontWeight FontDescription::bolderWeight(void) const |
77 { | 69 { |
78 // FIXME: Should actually return the CSS weight corresponding to next heavie
st | |
79 // weight of the currently used font family. | |
80 switch (m_weight) { | 70 switch (m_weight) { |
81 case FontWeight100: | 71 case FontWeight100: |
82 case FontWeight200: | 72 case FontWeight200: |
83 return FontWeight300; | |
84 | |
85 case FontWeight300: | 73 case FontWeight300: |
86 return FontWeight400; | 74 return FontWeight400; |
87 | 75 |
88 case FontWeight400: | 76 case FontWeight400: |
89 case FontWeight500: | 77 case FontWeight500: |
90 return FontWeight700; | 78 return FontWeight700; |
91 | 79 |
92 case FontWeight600: | 80 case FontWeight600: |
93 case FontWeight700: | 81 case FontWeight700: |
94 return FontWeight800; | |
95 | |
96 case FontWeight800: | 82 case FontWeight800: |
97 case FontWeight900: | 83 case FontWeight900: |
98 return FontWeight900; | 84 return FontWeight900; |
99 } | 85 } |
100 ASSERT_NOT_REACHED(); | 86 ASSERT_NOT_REACHED(); |
101 return FontWeightNormal; | 87 return FontWeightNormal; |
102 } | 88 } |
103 | 89 |
104 FontTraitsMask FontDescription::traitsMask() const | 90 FontTraitsMask FontDescription::traitsMask() const |
105 { | 91 { |
106 return static_cast<FontTraitsMask>((m_italic ? FontStyleItalicMask : FontSty
leNormalMask) | 92 return static_cast<FontTraitsMask>((m_italic ? FontStyleItalicMask : FontSty
leNormalMask) |
107 | (m_smallCaps ? FontVariantSmallCapsMask : FontVariantNormalMask) | 93 | (m_smallCaps ? FontVariantSmallCapsMask : FontVariantNormalMask) |
108 | (FontWeight100Mask << (m_weight - FontWeight100))); | 94 | (FontWeight100Mask << (m_weight - FontWeight100))); |
109 | 95 |
110 } | 96 } |
111 | 97 |
112 FontDescription FontDescription::makeNormalFeatureSettings() const | 98 FontDescription FontDescription::makeNormalFeatureSettings() const |
113 { | 99 { |
114 FontDescription normalDescription(*this); | 100 FontDescription normalDescription(*this); |
115 normalDescription.setFeatureSettings(0); | 101 normalDescription.setFeatureSettings(0); |
116 return normalDescription; | 102 return normalDescription; |
117 } | 103 } |
118 | 104 |
119 } // namespace WebCore | 105 } // namespace WebCore |
OLD | NEW |