OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
4 * Copyright (C) 2013 Google, Inc. All rights reserved. | 4 * Copyright (C) 2013 Google, Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #include "platform/fonts/FontDescription.h" | 34 #include "platform/fonts/FontDescription.h" |
35 #include "wtf/text/AtomicString.h" | 35 #include "wtf/text/AtomicString.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 // We currently do not support bitmap fonts on windows (with GDI_FONTS_ON_WINDOW
S enabled). | 39 // We currently do not support bitmap fonts on windows (with GDI_FONTS_ON_WINDOW
S enabled). |
40 // Instead of trying to construct a bitmap font and then going down the fallback
path map | 40 // Instead of trying to construct a bitmap font and then going down the fallback
path map |
41 // certain common bitmap fonts to their truetype equivalent up front. This also
allows the | 41 // certain common bitmap fonts to their truetype equivalent up front. This also
allows the |
42 // GDI_FONTS_ON_WINDOWS disabled code path to match our current behavior. | 42 // GDI_FONTS_ON_WINDOWS disabled code path to match our current behavior. |
43 static const AtomicString& alternateFamilyNameAvoidingBitmapFonts(const AtomicSt
ring& familyName) | 43 inline const AtomicString& alternateFamilyNameAvoidingBitmapFonts(const AtomicSt
ring& familyName) |
44 { | 44 { |
45 #if OS(WIN) | 45 #if OS(WIN) |
46 // On Windows, 'Courier New' (truetype font) is always present and | 46 // On Windows, 'Courier New' (truetype font) is always present and |
47 // 'Courier' is a bitmap font. On Mac on the other hand 'Courier' is | 47 // 'Courier' is a bitmap font. On Mac on the other hand 'Courier' is |
48 // a truetype font. Thus pages asking for Courier are better of | 48 // a truetype font. Thus pages asking for Courier are better of |
49 // using 'Courier New' on windows. | 49 // using 'Courier New' on windows. |
50 DEFINE_STATIC_LOCAL(AtomicString, courier, ("Courier", AtomicString::Constru
ctFromLiteral)); | 50 DEFINE_STATIC_LOCAL(AtomicString, courier, ("Courier", AtomicString::Constru
ctFromLiteral)); |
51 DEFINE_STATIC_LOCAL(AtomicString, courierNew, ("Courier New", AtomicString::
ConstructFromLiteral)); | 51 DEFINE_STATIC_LOCAL(AtomicString, courierNew, ("Courier New", AtomicString::
ConstructFromLiteral)); |
52 if (equalIgnoringCase(familyName, courier)) | 52 if (equalIgnoringCase(familyName, courier)) |
53 return courierNew; | 53 return courierNew; |
54 | 54 |
55 // Alias 'MS Sans Serif' (bitmap font) -> 'Microsoft Sans Serif' | 55 // Alias 'MS Sans Serif' (bitmap font) -> 'Microsoft Sans Serif' |
56 // (truetype font). | 56 // (truetype font). |
57 DEFINE_STATIC_LOCAL(AtomicString, msSans, ("MS Sans Serif", AtomicString::Co
nstructFromLiteral)); | 57 DEFINE_STATIC_LOCAL(AtomicString, msSans, ("MS Sans Serif", AtomicString::Co
nstructFromLiteral)); |
58 DEFINE_STATIC_LOCAL(AtomicString, microsoftSans, ("Microsoft Sans Serif", At
omicString::ConstructFromLiteral)); | 58 DEFINE_STATIC_LOCAL(AtomicString, microsoftSans, ("Microsoft Sans Serif", At
omicString::ConstructFromLiteral)); |
59 if (equalIgnoringCase(familyName, msSans)) | 59 if (equalIgnoringCase(familyName, msSans)) |
60 return microsoftSans; | 60 return microsoftSans; |
61 | 61 |
62 // Alias 'MS Serif' (bitmap) -> 'Times New Roman' (truetype font). | 62 // Alias 'MS Serif' (bitmap) -> 'Times New Roman' (truetype font). |
63 // There's no 'Microsoft Sans Serif-equivalent' for Serif. | 63 // There's no 'Microsoft Sans Serif-equivalent' for Serif. |
64 DEFINE_STATIC_LOCAL(AtomicString, msSerif, ("MS Serif", AtomicString::Constr
uctFromLiteral)); | 64 DEFINE_STATIC_LOCAL(AtomicString, msSerif, ("MS Serif", AtomicString::Constr
uctFromLiteral)); |
65 DEFINE_STATIC_LOCAL(AtomicString, timesNewRoman, ("Times New Roman", AtomicS
tring::ConstructFromLiteral)); | 65 DEFINE_STATIC_LOCAL(AtomicString, timesNewRoman, ("Times New Roman", AtomicS
tring::ConstructFromLiteral)); |
66 if (equalIgnoringCase(familyName, msSerif)) | 66 if (equalIgnoringCase(familyName, msSerif)) |
67 return timesNewRoman; | 67 return timesNewRoman; |
68 #endif | 68 #endif |
69 | 69 |
70 return emptyAtom; | 70 return emptyAtom; |
71 } | 71 } |
72 | 72 |
73 static const AtomicString& alternateFamilyName(const AtomicString& familyName) | 73 inline const AtomicString& alternateFamilyName(const AtomicString& familyName) |
74 { | 74 { |
75 // Alias Courier <-> Courier New | 75 // Alias Courier <-> Courier New |
76 DEFINE_STATIC_LOCAL(AtomicString, courier, ("Courier", AtomicString::Constru
ctFromLiteral)); | 76 DEFINE_STATIC_LOCAL(AtomicString, courier, ("Courier", AtomicString::Constru
ctFromLiteral)); |
77 DEFINE_STATIC_LOCAL(AtomicString, courierNew, ("Courier New", AtomicString::
ConstructFromLiteral)); | 77 DEFINE_STATIC_LOCAL(AtomicString, courierNew, ("Courier New", AtomicString::
ConstructFromLiteral)); |
78 if (equalIgnoringCase(familyName, courier)) | 78 if (equalIgnoringCase(familyName, courier)) |
79 return courierNew; | 79 return courierNew; |
80 #if !OS(WIN) | 80 #if !OS(WIN) |
81 // On Windows, Courier New (truetype font) is always present and | 81 // On Windows, Courier New (truetype font) is always present and |
82 // Courier is a bitmap font. So, we don't want to map Courier New to | 82 // Courier is a bitmap font. So, we don't want to map Courier New to |
83 // Courier. | 83 // Courier. |
(...skipping 14 matching lines...) Expand all Loading... |
98 DEFINE_STATIC_LOCAL(AtomicString, helvetica, ("Helvetica", AtomicString::Con
structFromLiteral)); | 98 DEFINE_STATIC_LOCAL(AtomicString, helvetica, ("Helvetica", AtomicString::Con
structFromLiteral)); |
99 if (equalIgnoringCase(familyName, arial)) | 99 if (equalIgnoringCase(familyName, arial)) |
100 return helvetica; | 100 return helvetica; |
101 if (equalIgnoringCase(familyName, helvetica)) | 101 if (equalIgnoringCase(familyName, helvetica)) |
102 return arial; | 102 return arial; |
103 | 103 |
104 return emptyAtom; | 104 return emptyAtom; |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 static const AtomicString getFallbackFontFamily(const FontDescription& descripti
on) | 108 inline const AtomicString getFallbackFontFamily(const FontDescription& descripti
on) |
109 { | 109 { |
110 DEFINE_STATIC_LOCAL(const AtomicString, sansStr, ("Sans", AtomicString::Cons
tructFromLiteral)); | 110 DEFINE_STATIC_LOCAL(const AtomicString, sansStr, ("Sans", AtomicString::Cons
tructFromLiteral)); |
111 DEFINE_STATIC_LOCAL(const AtomicString, serifStr, ("Serif", AtomicString::Co
nstructFromLiteral)); | 111 DEFINE_STATIC_LOCAL(const AtomicString, serifStr, ("Serif", AtomicString::Co
nstructFromLiteral)); |
112 DEFINE_STATIC_LOCAL(const AtomicString, monospaceStr, ("Monospace", AtomicSt
ring::ConstructFromLiteral)); | 112 DEFINE_STATIC_LOCAL(const AtomicString, monospaceStr, ("Monospace", AtomicSt
ring::ConstructFromLiteral)); |
113 | 113 |
114 switch (description.genericFamily()) { | 114 switch (description.genericFamily()) { |
115 case FontDescription::SerifFamily: | 115 case FontDescription::SerifFamily: |
116 return serifStr; | 116 return serifStr; |
117 case FontDescription::MonospaceFamily: | 117 case FontDescription::MonospaceFamily: |
118 return monospaceStr; | 118 return monospaceStr; |
119 case FontDescription::SansSerifFamily: | 119 case FontDescription::SansSerifFamily: |
120 return sansStr; | 120 return sansStr; |
121 default: | 121 default: |
122 return AtomicString(); | 122 return AtomicString(); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 } // namespace WebCore | 126 } // namespace WebCore |
127 | 127 |
128 #endif // AlternateFontFamily_h | 128 #endif // AlternateFontFamily_h |
OLD | NEW |