2013-03-25 18:44:17 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2013-03-25 20:44:02 +00:00
|
|
|
#ifndef SkFontStyle_DEFINED
|
|
|
|
#define SkFontStyle_DEFINED
|
2013-03-25 18:44:17 +00:00
|
|
|
|
|
|
|
#include "SkTypes.h"
|
|
|
|
|
2013-04-10 13:10:40 +00:00
|
|
|
class SK_API SkFontStyle {
|
2013-03-25 18:44:17 +00:00
|
|
|
public:
|
|
|
|
enum Weight {
|
|
|
|
kThin_Weight = 100,
|
|
|
|
kExtraLight_Weight = 200,
|
|
|
|
kLight_Weight = 300,
|
|
|
|
kNormal_Weight = 400,
|
|
|
|
kMedium_Weight = 500,
|
|
|
|
kSemiBold_Weight = 600,
|
|
|
|
kBold_Weight = 700,
|
|
|
|
kExtraBold_Weight = 800,
|
|
|
|
kBlack_Weight = 900
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Width {
|
|
|
|
kUltraCondensed_Width = 1,
|
|
|
|
kExtraCondensed_Width = 2,
|
|
|
|
kCondensed_Width = 3,
|
|
|
|
kSemiCondensed_Width = 4,
|
|
|
|
kNormal_Width = 5,
|
|
|
|
kSemiExpanded_Width = 6,
|
|
|
|
kExpanded_Width = 7,
|
|
|
|
kExtraExpanded_Width = 8,
|
|
|
|
kUltaExpanded_Width = 9
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Slant {
|
|
|
|
kUpright_Slant,
|
|
|
|
kItalic_Slant,
|
|
|
|
};
|
|
|
|
|
|
|
|
SkFontStyle();
|
|
|
|
SkFontStyle(int weight, int width, Slant);
|
|
|
|
|
|
|
|
bool operator==(const SkFontStyle& rhs) const {
|
|
|
|
return fUnion.fU32 == rhs.fUnion.fU32;
|
|
|
|
}
|
|
|
|
|
|
|
|
int weight() const { return fUnion.fR.fWeight; }
|
|
|
|
int width() const { return fUnion.fR.fWidth; }
|
2013-04-22 18:48:45 +00:00
|
|
|
Slant slant() const { return (Slant)fUnion.fR.fSlant; }
|
2013-03-25 18:44:17 +00:00
|
|
|
|
|
|
|
bool isItalic() const {
|
|
|
|
return kItalic_Slant == fUnion.fR.fSlant;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint16_t fWeight; // 100 .. 900
|
|
|
|
uint8_t fWidth; // 1 .. 9
|
|
|
|
uint8_t fSlant; // 0 .. 2
|
|
|
|
} fR;
|
|
|
|
uint32_t fU32;
|
|
|
|
} fUnion;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|