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