2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2014 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "wtf/Assertions.h"
44 FontWeightNormal
= FontWeight400
,
45 FontWeightBold
= FontWeight700
48 // Numeric values matching OS/2 & Windows Metrics usWidthClass table.
49 // https://www.microsoft.com/typography/otspec/os2.htm
51 FontStretchUltraCondensed
= 1,
52 FontStretchExtraCondensed
= 2,
53 FontStretchCondensed
= 3,
54 FontStretchSemiCondensed
= 4,
55 FontStretchNormal
= 5,
56 FontStretchSemiExpanded
= 6,
57 FontStretchExpanded
= 7,
58 FontStretchExtraExpanded
= 8,
59 FontStretchUltraExpanded
= 9
69 FontVariantNormal
= 0,
70 FontVariantSmallCaps
= 1
73 typedef unsigned FontTraitsBitfield
;
76 FontTraits(FontStyle style
, FontVariant variant
, FontWeight weight
, FontStretch stretch
)
78 m_traits
.m_style
= style
;
79 // TODO(drott): crbug.com/516673 Variant is not relevant for font selection,
80 // should be removed here.
81 m_traits
.m_variant
= variant
;
82 m_traits
.m_weight
= weight
;
83 m_traits
.m_stretch
= stretch
;
84 m_traits
.m_filler
= 0;
85 ASSERT(!(m_bitfield
>> 11));
87 FontTraits(FontTraitsBitfield bitfield
)
88 : m_bitfield(bitfield
)
90 ASSERT(!m_traits
.m_filler
);
91 ASSERT(!(m_bitfield
>> 11));
93 FontStyle
style() const { return static_cast<FontStyle
>(m_traits
.m_style
); }
94 FontVariant
variant() const { return static_cast<FontVariant
>(m_traits
.m_variant
); }
95 FontWeight
weight() const { return static_cast<FontWeight
>(m_traits
.m_weight
); }
96 FontStretch
stretch() const { return static_cast<FontStretch
>(m_traits
.m_stretch
); }
97 FontTraitsBitfield
bitfield() const { return m_bitfield
; }
101 unsigned m_style
: 2;
102 unsigned m_variant
: 1;
103 unsigned m_weight
: 4;
104 unsigned m_stretch
: 4;
105 unsigned m_filler
: 21;
107 FontTraitsBitfield m_bitfield
;
112 #endif // FontTraits_h