gfx/skia/trunk/include/ports/SkFontStyle.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/ports/SkFontStyle.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,70 @@
     1.4 +/*
     1.5 + * Copyright 2013 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkFontStyle_DEFINED
    1.12 +#define SkFontStyle_DEFINED
    1.13 +
    1.14 +#include "SkTypes.h"
    1.15 +
    1.16 +class SK_API SkFontStyle {
    1.17 +public:
    1.18 +    enum Weight {
    1.19 +        kThin_Weight        = 100,
    1.20 +        kExtraLight_Weight  = 200,
    1.21 +        kLight_Weight       = 300,
    1.22 +        kNormal_Weight      = 400,
    1.23 +        kMedium_Weight      = 500,
    1.24 +        kSemiBold_Weight    = 600,
    1.25 +        kBold_Weight        = 700,
    1.26 +        kExtraBold_Weight   = 800,
    1.27 +        kBlack_Weight       = 900
    1.28 +    };
    1.29 +
    1.30 +    enum Width {
    1.31 +        kUltraCondensed_Width   = 1,
    1.32 +        kExtraCondensed_Width   = 2,
    1.33 +        kCondensed_Width        = 3,
    1.34 +        kSemiCondensed_Width    = 4,
    1.35 +        kNormal_Width           = 5,
    1.36 +        kSemiExpanded_Width     = 6,
    1.37 +        kExpanded_Width         = 7,
    1.38 +        kExtraExpanded_Width    = 8,
    1.39 +        kUltaExpanded_Width     = 9
    1.40 +    };
    1.41 +
    1.42 +    enum Slant {
    1.43 +        kUpright_Slant,
    1.44 +        kItalic_Slant,
    1.45 +    };
    1.46 +
    1.47 +    SkFontStyle();
    1.48 +    SkFontStyle(int weight, int width, Slant);
    1.49 +
    1.50 +    bool operator==(const SkFontStyle& rhs) const {
    1.51 +        return fUnion.fU32 == rhs.fUnion.fU32;
    1.52 +    }
    1.53 +
    1.54 +    int weight() const { return fUnion.fR.fWeight; }
    1.55 +    int width() const { return fUnion.fR.fWidth; }
    1.56 +    Slant slant() const { return (Slant)fUnion.fR.fSlant; }
    1.57 +
    1.58 +    bool isItalic() const {
    1.59 +        return kItalic_Slant == fUnion.fR.fSlant;
    1.60 +    }
    1.61 +
    1.62 +private:
    1.63 +    union {
    1.64 +        struct {
    1.65 +            uint16_t fWeight;   // 100 .. 900
    1.66 +            uint8_t  fWidth;    // 1 .. 9
    1.67 +            uint8_t  fSlant;    // 0 .. 2
    1.68 +        } fR;
    1.69 +        uint32_t    fU32;
    1.70 +    } fUnion;
    1.71 +};
    1.72 +
    1.73 +#endif

mercurial