#ifndef AlternateFontFamily_h
#define AlternateFontFamily_h
#include "platform/fonts/FontDescription.h"
#include "wtf/text/AtomicString.h"
namespace WebCore {
inline const AtomicString& adjustFamilyNameToAvoidUnsupportedFonts(const AtomicString& familyName)
{
#if OS(WIN)
DEFINE_STATIC_LOCAL(AtomicString, courier, ("Courier", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(AtomicString, courierNew, ("Courier New", AtomicString::ConstructFromLiteral));
if (equalIgnoringCase(familyName, courier))
return courierNew;
DEFINE_STATIC_LOCAL(AtomicString, msSans, ("MS Sans Serif", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(AtomicString, microsoftSans, ("Microsoft Sans Serif", AtomicString::ConstructFromLiteral));
if (equalIgnoringCase(familyName, msSans))
return microsoftSans;
DEFINE_STATIC_LOCAL(AtomicString, msSerif, ("MS Serif", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(AtomicString, timesNewRoman, ("Times New Roman", AtomicString::ConstructFromLiteral));
if (equalIgnoringCase(familyName, msSerif))
return timesNewRoman;
#endif
return familyName;
}
inline const AtomicString& alternateFamilyName(const AtomicString& familyName)
{
DEFINE_STATIC_LOCAL(AtomicString, courier, ("Courier", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(AtomicString, courierNew, ("Courier New", AtomicString::ConstructFromLiteral));
if (equalIgnoringCase(familyName, courier))
return courierNew;
#if !OS(WIN)
if (equalIgnoringCase(familyName, courierNew))
return courier;
#endif
DEFINE_STATIC_LOCAL(AtomicString, times, ("Times", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(AtomicString, timesNewRoman, ("Times New Roman", AtomicString::ConstructFromLiteral));
if (equalIgnoringCase(familyName, times))
return timesNewRoman;
if (equalIgnoringCase(familyName, timesNewRoman))
return times;
DEFINE_STATIC_LOCAL(AtomicString, arial, ("Arial", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(AtomicString, helvetica, ("Helvetica", AtomicString::ConstructFromLiteral));
if (equalIgnoringCase(familyName, arial))
return helvetica;
if (equalIgnoringCase(familyName, helvetica))
return arial;
return emptyAtom;
}
inline const AtomicString getFallbackFontFamily(const FontDescription& description)
{
DEFINE_STATIC_LOCAL(const AtomicString, sansStr, ("sans-serif", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(const AtomicString, serifStr, ("serif", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(const AtomicString, monospaceStr, ("monospace", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(const AtomicString, cursiveStr, ("cursive", AtomicString::ConstructFromLiteral));
DEFINE_STATIC_LOCAL(const AtomicString, fantasyStr, ("fantasy", AtomicString::ConstructFromLiteral));
switch (description.genericFamily()) {
case FontDescription::SansSerifFamily:
return sansStr;
case FontDescription::SerifFamily:
return serifStr;
case FontDescription::MonospaceFamily:
return monospaceStr;
case FontDescription::CursiveFamily:
return cursiveStr;
case FontDescription::FantasyFamily:
return fantasyStr;
default:
return emptyAtom;
}
}
}
#endif