Line data Source code
1 : /*
2 : * Copyright 2015 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #include "SkFontStyle.h"
9 : #include "SkTypeface.h"
10 : #include "SkTypes.h"
11 :
12 0 : SkFontStyle::SkFontStyle() {
13 0 : fUnion.fU32 = 0;
14 0 : fUnion.fR.fWeight = kNormal_Weight;
15 0 : fUnion.fR.fWidth = kNormal_Width;
16 0 : fUnion.fR.fSlant = kUpright_Slant;
17 0 : }
18 :
19 2 : SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
20 2 : fUnion.fU32 = 0;
21 2 : fUnion.fR.fWeight = SkTPin<int>(weight, kInvisible_Weight, kExtraBlack_Weight);
22 2 : fUnion.fR.fWidth = SkTPin<int>(width, kUltraCondensed_Width, kUltraExpanded_Width);
23 2 : fUnion.fR.fSlant = SkTPin<int>(slant, kUpright_Slant, kOblique_Slant);
24 2 : }
25 :
26 0 : /*static*/SkFontStyle SkFontStyle::FromOldStyle(unsigned oldStyle) {
27 0 : return SkFontStyle((oldStyle & SkTypeface::kBold) ? SkFontStyle::kBold_Weight
28 : : SkFontStyle::kNormal_Weight,
29 : SkFontStyle::kNormal_Width,
30 0 : (oldStyle & SkTypeface::kItalic) ? SkFontStyle::kItalic_Slant
31 0 : : SkFontStyle::kUpright_Slant);
32 : }
|