7#include "core/fpdfdoc/cpdf_defaultappearance.h"
12#include "core/fpdfapi/parser/cpdf_simple_parser.h"
13#include "core/fpdfapi/parser/fpdf_parser_utility.h"
14#include "core/fxcrt/fx_string.h"
15#include "core/fxge/cfx_color.h"
16#include "third_party/base/notreached.h"
27 std::vector<uint32_t> pBuf(nParams);
34 if (buf_index == nParams)
38 if (buf_count > nParams)
41 ByteStringView word = parser->GetWord();
46 if (buf_count < nParams)
68 float* fFontSize)
const {
73 ByteString csFontNameTag;
75 if (FindTagParamFromStart(&syntax,
"Tf", 2)) {
76 csFontNameTag
= ByteString(syntax
.GetWord());
77 csFontNameTag.Delete(0, 1);
78 *fFontSize = StringToFloat(syntax
.GetWord());
80 return PDF_NameDecode(csFontNameTag.AsStringView());
88 if (FindTagParamFromStart(&syntax,
"g", 1)) {
89 float gray = StringToFloat(syntax
.GetWord());
92 if (FindTagParamFromStart(&syntax,
"rg", 3)) {
93 float r = StringToFloat(syntax
.GetWord());
94 float g = StringToFloat(syntax
.GetWord());
95 float b = StringToFloat(syntax
.GetWord());
98 if (FindTagParamFromStart(&syntax,
"k", 4)) {
99 float c = StringToFloat(syntax
.GetWord());
100 float m = StringToFloat(syntax
.GetWord());
101 float y = StringToFloat(syntax
.GetWord());
102 float k = StringToFloat(syntax
.GetWord());
105 return absl::nullopt;
110 absl::optional<CFX_Color> maybe_color = GetColor();
111 if (!maybe_color.has_value())
112 return absl::nullopt;
114 const CFX_Color& color = maybe_color.value();
116 int g =
static_cast<
int>(color
.fColor1 * 255 + 0.5f);
121 int r =
static_cast<
int>(color
.fColor1 * 255 + 0.5f);
122 int g =
static_cast<
int>(color
.fColor2 * 255 + 0.5f);
123 int b =
static_cast<
int>(color
.fColor3 * 255 + 0.5f);
134 static_cast<
int>(g * 255 + 0.5f)
,
135 static_cast<
int>(b * 255 + 0.5f)
));
137 NOTREACHED_NORETURN();
143 ByteStringView token,
145 return FindTagParamFromStart(parser, token, nParams);
~CPDF_DefaultAppearance()
CPDF_DefaultAppearance(const ByteString &csDA)
absl::optional< ByteString > GetFont(float *fFontSize) const
static bool FindTagParamFromStartForTesting(CPDF_SimpleParser *parser, ByteStringView token, int nParams)
absl::optional< CFX_Color > GetColor() const
CPDF_DefaultAppearance(const CPDF_DefaultAppearance &cDA)
absl::optional< CFX_Color::TypeAndARGB > GetColorARGB() const
uint32_t GetCurPos() const
void SetCurPos(uint32_t pos)
ByteString & operator=(ByteString &&that) noexcept
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
TypeAndARGB(CFX_Color::Type type_in, FX_ARGB argb_in)
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)