• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CORE_FXGE_CFX_TEXTRENDEROPTIONS_H_
6 #define CORE_FXGE_CFX_TEXTRENDEROPTIONS_H_
7 
8 struct CFX_TextRenderOptions {
9   // AliasingType defines the options for drawing pixels on the edges of the
10   // text. The values are defined in an incrementing order due to the latter
11   // aliasing type's dependency on the previous one.
12   enum AliasingType {
13     // No transparent pixels on glyph edges.
14     kAliasing,
15 
16     // May have transparent pixels on glyph edges.
17     kAntiAliasing,
18 
19     // LCD optimization, can be enabled when anti-aliasing is allowed.
20     kLcd,
21   };
22 
23   constexpr CFX_TextRenderOptions() = default;
CFX_TextRenderOptionsCFX_TextRenderOptions24   constexpr explicit CFX_TextRenderOptions(AliasingType type)
25       : aliasing_type(type) {}
26   constexpr CFX_TextRenderOptions(const CFX_TextRenderOptions& other) = default;
27   CFX_TextRenderOptions& operator=(const CFX_TextRenderOptions& other) =
28       default;
29 
30   // Indicates whether anti-aliasing is enabled.
IsSmoothCFX_TextRenderOptions31   bool IsSmooth() const {
32     return aliasing_type == kAntiAliasing || aliasing_type == kLcd;
33   }
34 
35   // Aliasing option for fonts.
36   AliasingType aliasing_type = kAntiAliasing;
37 
38   // Font is CID font.
39   bool font_is_cid = false;
40 
41   // Using the native text output available on some platforms.
42   bool native_text = true;
43 };
44 
45 inline bool operator==(const CFX_TextRenderOptions& lhs,
46                        const CFX_TextRenderOptions& rhs) {
47   return lhs.aliasing_type == rhs.aliasing_type &&
48          lhs.font_is_cid == rhs.font_is_cid &&
49          lhs.native_text == rhs.native_text;
50 }
51 
52 inline bool operator!=(const CFX_TextRenderOptions& lhs,
53                        const CFX_TextRenderOptions& rhs) {
54   return !(lhs == rhs);
55 }
56 
57 #endif  // CORE_FXGE_CFX_TEXTRENDEROPTIONS_H_
58