File: font_description.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (600 lines) | stat: -rw-r--r-- 21,807 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
/*
 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
 *           (C) 2000 Dirk Mueller (mueller@kde.org)
 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights
 * reserved.
 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_DESCRIPTION_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_DESCRIPTION_H_

#include <unicode/uscript.h>

#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/platform/font_family_names.h"
#include "third_party/blink/renderer/platform/fonts/font_cache_key.h"
#include "third_party/blink/renderer/platform/fonts/font_family.h"
#include "third_party/blink/renderer/platform/fonts/font_optical_sizing.h"
#include "third_party/blink/renderer/platform/fonts/font_orientation.h"
#include "third_party/blink/renderer/platform/fonts/font_palette.h"
#include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
#include "third_party/blink/renderer/platform/fonts/font_size_adjust.h"
#include "third_party/blink/renderer/platform/fonts/font_smoothing_mode.h"
#include "third_party/blink/renderer/platform/fonts/font_variant_alternates.h"
#include "third_party/blink/renderer/platform/fonts/font_variant_east_asian.h"
#include "third_party/blink/renderer/platform/fonts/font_variant_emoji.h"
#include "third_party/blink/renderer/platform/fonts/font_variant_numeric.h"
#include "third_party/blink/renderer/platform/fonts/font_width_variant.h"
#include "third_party/blink/renderer/platform/fonts/opentype/font_settings.h"
#include "third_party/blink/renderer/platform/fonts/shaping/text_spacing_trim.h"
#include "third_party/blink/renderer/platform/fonts/text_rendering_mode.h"
#include "third_party/blink/renderer/platform/fonts/typesetting_features.h"
#include "third_party/blink/renderer/platform/text/layout_locale.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/skia/include/core/SkFontStyle.h"

namespace blink {

typedef struct { uint32_t parts[2]; } FieldsAsUnsignedType;

class PLATFORM_EXPORT FontDescription {
  USING_FAST_MALLOC(FontDescription);

 public:
  enum HashCategory {
    kHashEmptyValue = 0,
    kHashDeletedValue,
    kHashRegularValue
  };

  enum GenericFamilyType : uint8_t {
    kNoFamily,
    kStandardFamily,
    kWebkitBodyFamily,
    kSerifFamily,
    kSansSerifFamily,
    kMonospaceFamily,
    kCursiveFamily,
    kFantasyFamily
  };
  static String ToString(GenericFamilyType);

  enum LigaturesState {
    kNormalLigaturesState,
    kDisabledLigaturesState,
    kEnabledLigaturesState
  };
  static String ToString(LigaturesState);

  enum Kerning { kAutoKerning, kNormalKerning, kNoneKerning };
  static String ToString(Kerning);

  static String ToString(FontSelectionValue);

  enum FontVariantCaps {
    kCapsNormal,
    kSmallCaps,
    kAllSmallCaps,
    kPetiteCaps,
    kAllPetiteCaps,
    kUnicase,
    kTitlingCaps
  };
  static String ToString(FontVariantCaps);
  static String ToStringForIdl(FontVariantCaps);

  enum FontSynthesisWeight {
    kAutoFontSynthesisWeight,
    kNoneFontSynthesisWeight
  };
  static String ToString(FontSynthesisWeight);

  enum FontSynthesisStyle { kAutoFontSynthesisStyle, kNoneFontSynthesisStyle };
  static String ToString(FontSynthesisStyle);

  enum FontSynthesisSmallCaps {
    kAutoFontSynthesisSmallCaps,
    kNoneFontSynthesisSmallCaps
  };
  static String ToString(FontSynthesisSmallCaps);

  enum FontVariantPosition {
    kNormalVariantPosition,
    kSubVariantPosition,
    kSuperVariantPosition
  };
  static String ToString(FontVariantPosition);

  FontDescription();
  FontDescription(const FontDescription&);

  static FontDescription CreateHashTableEmptyValue();
  explicit FontDescription(WTF::HashTableDeletedValueType);

  FontDescription& operator=(const FontDescription&);

  bool operator==(const FontDescription&) const;
  bool operator!=(const FontDescription& other) const {
    return !(*this == other);
  }

  struct VariantLigatures {
    STACK_ALLOCATED();

   public:
    VariantLigatures(LigaturesState state = kNormalLigaturesState)
        : common(state),
          discretionary(state),
          historical(state),
          contextual(state) {}

    String ToString() const;

    unsigned common : 2;
    unsigned discretionary : 2;
    unsigned historical : 2;
    unsigned contextual : 2;

    bool operator==(const VariantLigatures& other) const {
      return common == other.common && discretionary == other.discretionary
        && historical == other.historical && contextual == other.contextual;
    }
  };

  struct Size {
    STACK_ALLOCATED();

   public:
    Size(unsigned keyword, float value, bool is_absolute)
        : keyword(keyword), is_absolute(is_absolute), value(value) {}

    String ToString() const;

    unsigned keyword : 4;      // FontDescription::KeywordSize
    unsigned is_absolute : 1;  // FontDescription::IsAbsoluteSize
    float value;               // FontDescription::SpecifiedSize
  };

  struct FamilyDescription {
    STACK_ALLOCATED();

   public:
    FamilyDescription(GenericFamilyType generic_family)
        : generic_family(generic_family) {}
    FamilyDescription(GenericFamilyType generic_family,
                      const FontFamily& family)
        : generic_family(generic_family), family(family) {}

    String ToString() const;

    GenericFamilyType generic_family;
    FontFamily family;
  };

  const FontFamily& Family() const { return family_list_; }
  FamilyDescription GetFamilyDescription() const {
    return FamilyDescription(GenericFamily(), Family());
  }
  const FontFamily& FirstFamily() const { return family_list_; }
  Size GetSize() const {
    return Size(KeywordSize(), SpecifiedSize(), IsAbsoluteSize());
  }
  float SpecifiedSize() const { return specified_size_; }
  // Returns the result of applying font-size-adjust to the specified size. This
  // is useful as an input to optical sizing and takes zooming out of the
  // equation for determining the font size to be used for font-optical-sizing:
  // auto;.
  float AdjustedSpecifiedSize() const;
  float ComputedSize() const { return computed_size_; }

  // TODO(xiaochengh): The functions and members for size-adjust descriptor and
  // font-size-adjust property have similar names and are very confusing. Rename
  // them for better clarity.

  // For CSS font-size-adjust property
  FontSizeAdjust SizeAdjust() const { return size_adjust_; }
  bool HasSizeAdjust() const { return !!size_adjust_; }

  // Return a copy with the size-adjust descriptor applied.
  // https://drafts.csswg.org/css-fonts-5/#descdef-font-face-size-adjust
  FontDescription SizeAdjustedFontDescription(float size_adjust) const;

  // The used value of font-size applying font-size-adjust or size-adjust.
  // TODO(crbug.com/451346): Make font-size-adjust and size-adjust work
  // together.
  float AdjustedSize() const { return adjusted_size_; }

  int ComputedPixelSize() const { return int(computed_size_ + 0.5f); }
  FontVariantCaps VariantCaps() const {
    return static_cast<FontVariantCaps>(fields_.variant_caps_);
  }
  bool IsAbsoluteSize() const { return fields_.is_absolute_size_; }
  FontSelectionValue Weight() const { return font_selection_request_.weight; }
  FontSelectionValue Style() const { return font_selection_request_.slope; }
  FontSelectionValue Stretch() const { return font_selection_request_.width; }
  static FontSelectionValue LighterWeight(FontSelectionValue);
  static FontSelectionValue BolderWeight(FontSelectionValue);
  static Size LargerSize(const Size&);
  static Size SmallerSize(const Size&);
  GenericFamilyType GenericFamily() const {
    return static_cast<GenericFamilyType>(fields_.generic_family_);
  }

  // only use fixed default size when there is only one font family, and that
  // family is "monospace"
  bool IsMonospace() const {
    return Family().FamilyName() == font_family_names::kMonospace &&
           Family().FamilyIsGeneric() && !Family().Next();
  }
  Kerning GetKerning() const { return static_cast<Kerning>(fields_.kerning_); }
  TextSpacingTrim GetTextSpacingTrim() const {
    return static_cast<TextSpacingTrim>(fields_.text_spacing_trim_);
  }
  FontVariantEastAsian VariantEastAsian() const {
    return FontVariantEastAsian::InitializeFromUnsigned(
        fields_.variant_east_asian_);
  }
  VariantLigatures GetVariantLigatures() const;
  FontVariantNumeric VariantNumeric() const {
    return FontVariantNumeric::InitializeFromUnsigned(fields_.variant_numeric_);
  }
  LigaturesState CommonLigaturesState() const {
    return static_cast<LigaturesState>(fields_.common_ligatures_state_);
  }
  LigaturesState DiscretionaryLigaturesState() const {
    return static_cast<LigaturesState>(fields_.discretionary_ligatures_state_);
  }
  LigaturesState HistoricalLigaturesState() const {
    return static_cast<LigaturesState>(fields_.historical_ligatures_state_);
  }
  LigaturesState ContextualLigaturesState() const {
    return static_cast<LigaturesState>(fields_.contextual_ligatures_state_);
  }
  unsigned KeywordSize() const { return fields_.keyword_size_; }
  FontSmoothingMode FontSmoothing() const {
    return static_cast<FontSmoothingMode>(fields_.font_smoothing_);
  }
  OpticalSizing FontOpticalSizing() const {
    return static_cast<OpticalSizing>(fields_.font_optical_sizing_);
  }
  const FontPalette* GetFontPalette() const { return font_palette_.get(); }
  const FontVariantAlternates* GetFontVariantAlternates() const {
    return font_variant_alternates_.get();
  }
  TextRenderingMode TextRendering() const {
    return static_cast<TextRenderingMode>(fields_.text_rendering_);
  }
  const LayoutLocale* Locale() const { return locale_.get(); }
  const LayoutLocale& LocaleOrDefault() const {
    return LayoutLocale::ValueOrDefault(locale_.get());
  }
  UScriptCode GetScript() const { return LocaleOrDefault().GetScript(); }
  bool IsSyntheticBold() const { return fields_.synthetic_bold_; }
  bool IsSyntheticItalic() const { return fields_.synthetic_italic_; }
  bool IsSyntheticOblique() const { return fields_.synthetic_oblique_; }
  bool UseSubpixelPositioning() const {
    return fields_.subpixel_text_position_;
  }
  FontSynthesisWeight GetFontSynthesisWeight() const {
    return static_cast<FontSynthesisWeight>(fields_.font_synthesis_weight_);
  }
  bool SyntheticBoldAllowed() const {
    return fields_.font_synthesis_weight_ == kAutoFontSynthesisWeight;
  }
  FontSynthesisStyle GetFontSynthesisStyle() const {
    return static_cast<FontSynthesisStyle>(fields_.font_synthesis_style_);
  }
  bool SyntheticItalicAllowed() const {
    return fields_.font_synthesis_style_ == kAutoFontSynthesisStyle;
  }
  FontSynthesisSmallCaps GetFontSynthesisSmallCaps() const {
    return static_cast<FontSynthesisSmallCaps>(
        fields_.font_synthesis_small_caps_);
  }

  FontSelectionRequest GetFontSelectionRequest() const;
  float WordSpacing() const { return word_spacing_; }
  float LetterSpacing() const { return letter_spacing_; }
  FontOrientation Orientation() const {
    return static_cast<FontOrientation>(fields_.orientation_);
  }
  bool IsVerticalAnyUpright() const {
    return blink::IsVerticalAnyUpright(Orientation());
  }
  bool IsVerticalNonCJKUpright() const {
    return blink::IsVerticalNonCJKUpright(Orientation());
  }
  bool IsVerticalUpright(UChar32 character) const {
    return blink::IsVerticalUpright(Orientation(), character);
  }
  bool IsVerticalBaseline() const {
    return blink::IsVerticalBaseline(Orientation());
  }
  FontWidthVariant WidthVariant() const {
    return static_cast<FontWidthVariant>(fields_.width_variant_);
  }
  const FontFeatureSettings* FeatureSettings() const {
    return feature_settings_.get();
  }
  const FontVariationSettings* VariationSettings() const {
    return variation_settings_.get();
  }
  FontVariantPosition VariantPosition() const {
    return static_cast<FontVariantPosition>(fields_.variant_position_);
  }
  FontVariantEmoji VariantEmoji() const {
    return static_cast<FontVariantEmoji>(fields_.variant_emoji_);
  }

  float EffectiveFontSize()
      const;  // Returns either the computedSize or the computedPixelSize
  FontCacheKey CacheKey(const FontFaceCreationParams&,
                        bool is_unique_match) const;

  void SetFamily(const FontFamily& family) { family_list_ = family; }
  void SetComputedSize(float s) { computed_size_ = ClampTo<float>(s); }
  void SetSpecifiedSize(float s) { specified_size_ = ClampTo<float>(s); }
  void SetAdjustedSize(float s) { adjusted_size_ = ClampTo<float>(s); }
  void SetSizeAdjust(const FontSizeAdjust& size_adjust) {
    size_adjust_ = size_adjust;
  }

  void SetStyle(FontSelectionValue i);
  void SetWeight(FontSelectionValue w) { font_selection_request_.weight = w; }
  void SetStretch(FontSelectionValue s) { font_selection_request_.width = s; }

  void SetVariantCaps(FontVariantCaps);
  void SetVariantEastAsian(const FontVariantEastAsian);
  void SetVariantLigatures(const VariantLigatures&);
  void SetVariantNumeric(const FontVariantNumeric&);
  void SetIsAbsoluteSize(bool s) { fields_.is_absolute_size_ = s; }

  void SetGenericFamily(GenericFamilyType generic_family) {
    fields_.generic_family_ = generic_family;
  }
  void SetKerning(Kerning kerning) {
    fields_.kerning_ = kerning;
    UpdateTypesettingFeatures();
  }
  void SetTextSpacingTrim(TextSpacingTrim text_spacing_trim) {
    fields_.text_spacing_trim_ = static_cast<unsigned>(text_spacing_trim);
  }
  void SetKeywordSize(unsigned s) { fields_.keyword_size_ = s; }
  void SetFontSmoothing(FontSmoothingMode smoothing) {
    fields_.font_smoothing_ = smoothing;
  }
  void SetFontOpticalSizing(OpticalSizing font_optical_sizing) {
    fields_.font_optical_sizing_ = font_optical_sizing;
  }
  void SetFontPalette(scoped_refptr<const FontPalette> palette) {
    font_palette_ = std::move(palette);
  }
  void SetFontVariantAlternates(
      scoped_refptr<const FontVariantAlternates> alternates) {
    font_variant_alternates_ = std::move(alternates);
  }
  void SetTextRendering(TextRenderingMode rendering) {
    fields_.text_rendering_ = rendering;
    UpdateTypesettingFeatures();
  }
  void SetOrientation(FontOrientation orientation);
  void SetWidthVariant(FontWidthVariant width_variant) {
    fields_.width_variant_ = width_variant;
  }
  void SetLocale(scoped_refptr<const LayoutLocale> locale) {
    locale_ = std::move(locale);
  }
  void SetSyntheticBold(bool synthetic_bold) {
    fields_.synthetic_bold_ = synthetic_bold;
  }
  void SetSyntheticItalic(bool synthetic_italic) {
    fields_.synthetic_italic_ = synthetic_italic;
  }
  void SetFontSynthesisWeight(FontSynthesisWeight font_synthesis_weight) {
    fields_.font_synthesis_weight_ = font_synthesis_weight;
  }
  void SetFontSynthesisStyle(FontSynthesisStyle font_synthesis_style) {
    fields_.font_synthesis_style_ = font_synthesis_style;
  }
  void SetFontSynthesisSmallCaps(
      FontSynthesisSmallCaps font_synthesis_small_caps) {
    fields_.font_synthesis_small_caps_ = font_synthesis_small_caps;
  }
  void SetFeatureSettings(scoped_refptr<const FontFeatureSettings> settings) {
    feature_settings_ = std::move(settings);
  }
  void SetVariationSettings(
      scoped_refptr<const FontVariationSettings> settings) {
    variation_settings_ = std::move(settings);
  }
  void SetVariantPosition(FontVariantPosition variant_position) {
    fields_.variant_position_ = variant_position;
  }
  void SetVariantEmoji(FontVariantEmoji variant_emoji) {
    fields_.variant_emoji_ = variant_emoji;
  }
  void SetWordSpacing(float s) { word_spacing_ = s; }
  void SetLetterSpacing(float s) {
    letter_spacing_ = s;
    UpdateTypesettingFeatures();
  }

  TypesettingFeatures GetTypesettingFeatures() const {
    return static_cast<TypesettingFeatures>(fields_.typesetting_features_);
  }

  static void SetSubpixelPositioning(bool b) {
    use_subpixel_text_positioning_ = b;
  }
  static bool SubpixelPositioning() { return use_subpixel_text_positioning_; }

  void SetSubpixelAscentDescent(bool sp) {
    fields_.subpixel_ascent_descent_ = sp;
  }

  bool SubpixelAscentDescent() const {
    return fields_.subpixel_ascent_descent_;
  }

  HashCategory GetHashCategory() const {
    return static_cast<HashCategory>(fields_.hash_category_);
  }

  bool IsHashTableEmptyValue() const {
    return GetHashCategory() == kHashEmptyValue;
  }

  bool IsHashTableDeletedValue() const {
    return GetHashCategory() == kHashDeletedValue;
  }

  unsigned StyleHashWithoutFamilyList() const;
  unsigned GetHash() const;

  // TODO(drott): We should not expose internal structure here, but rather
  // introduce a hash function here.
  unsigned BitmapFields() const { return fields_as_unsigned_.parts[0]; }
  unsigned AuxiliaryBitmapFields() const {
    return fields_as_unsigned_.parts[1];
  }

  SkFontStyle SkiaFontStyle() const;

  void UpdateFromSkiaFontStyle(const SkFontStyle& font_style);

  int MinimumPrefixWidthToHyphenate() const;

  ResolvedFontFeatures ResolveFontFeatures() const;

  String ToString() const;

 private:
  void UpdateSyntheticOblique();

  FontFamily family_list_;  // The list of font families to be used.
  scoped_refptr<const FontFeatureSettings> feature_settings_;
  scoped_refptr<const FontVariationSettings> variation_settings_;
  scoped_refptr<const LayoutLocale> locale_;
  scoped_refptr<const FontPalette> font_palette_;
  scoped_refptr<const FontVariantAlternates> font_variant_alternates_;

  void UpdateTypesettingFeatures();

  // Specified CSS value. Independent of rendering issues such as integer
  // rounding, minimum font sizes, and zooming.
  float specified_size_;
  // Computed size adjusted for the minimum font size and the zoom factor.
  float computed_size_;

  // (Given aspect value / aspect value of a font family) * specifiedSize.
  // This value is adjusted for the minimum font size and the zoom factor
  // as well as a computed size is.
  float adjusted_size_;

  float letter_spacing_;
  float word_spacing_;

  FontSizeAdjust size_adjust_;

  // Covers stretch, style, weight.
  FontSelectionRequest font_selection_request_;
  FontSelectionValue original_slope;

  struct BitFields {
    DISALLOW_NEW();

    String ToString() const;

    unsigned orientation_ : kFontOrientationBitCount;

    unsigned width_variant_ : 2;  // FontWidthVariant

    unsigned variant_caps_ : 3;  // FontVariantCaps
    unsigned
        is_absolute_size_ : 1;  // Whether or not CSS specified an explicit size
    // (logical sizes like "medium" don't count).
    unsigned generic_family_ : 3;  // GenericFamilyType

    unsigned kerning_ : 2;  // Kerning

    unsigned common_ligatures_state_ : 2;
    unsigned discretionary_ligatures_state_ : 2;
    unsigned historical_ligatures_state_ : 2;
    unsigned contextual_ligatures_state_ : 2;

    // We cache whether or not a font is currently represented by a CSS keyword
    // (e.g., medium).  If so, then we can accurately translate across different
    // generic families to adjust for different preference settings (e.g., 13px
    // monospace vs. 16px everything else).  Sizes are 1-8 (like the HTML size
    // values for <font>).
    unsigned keyword_size_ : 4;

    unsigned font_smoothing_ : 2;  // FontSmoothingMode
    unsigned text_rendering_ : 2;  // TextRenderingMode
    unsigned synthetic_bold_ : 1;
    unsigned synthetic_italic_ : 1;
    unsigned synthetic_oblique_ : 1;
    unsigned font_synthesis_weight_ : 1;
    unsigned font_synthesis_style_ : 1;
    unsigned font_synthesis_small_caps_ : 1;
    unsigned subpixel_text_position_ : 1;
    unsigned typesetting_features_ : 3;
    unsigned variant_numeric_ : 8;
    unsigned variant_east_asian_ : 6;
    unsigned subpixel_ascent_descent_ : 1;
    unsigned font_optical_sizing_ : 1;
    unsigned has_size_adjust_descriptor_ : 1;
    unsigned variant_position_ : 2;
    unsigned variant_emoji_ : 2;
    unsigned text_spacing_trim_ : kTextSpacingTrimBitCount;

    unsigned hash_category_ : 2;  // HashCategory
  };

  static_assert(sizeof(BitFields) == sizeof(FieldsAsUnsignedType),
                "Mapped bitfield datatypes must have identical size.");
  union {
    BitFields fields_;
    FieldsAsUnsignedType fields_as_unsigned_;
  };

  static bool use_subpixel_text_positioning_;
};

}  // namespace blink

namespace WTF {

template <>
struct HashTraits<blink::FontDescription>
    : SimpleClassHashTraits<blink::FontDescription> {
  // FontDescription default constructor creates a regular value instead of the
  // empty value.
  static blink::FontDescription EmptyValue() {
    return blink::FontDescription::CreateHashTableEmptyValue();
  }
};

}  // namespace WTF

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_DESCRIPTION_H_