Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions core/fpdfdoc/cpdf_appearancegenerator_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,22 @@ ByteString GetColorStringWithDefault(const CPDF_Array* color_array,
return GenerateColorAP(default_color, operation);
}

// The stroke colour operator for /C, or none when /C names no colour: left
// out, or the empty array ISO 32000 defines as "no colour; transparent".
// Acrobat draws neither with a stroke, so the shape keeps only its fill.
std::optional<ByteString> GetStrokeColorString(const CPDF_Dictionary* dict) {
RetainPtr<const CPDF_Array> color_array =
dict->GetArrayFor(pdfium::annotation::kC);
if (!color_array) {
return std::nullopt;
}
const CFX_Color color = fpdfdoc::CFXColorFromArray(*color_array);
if (color.nColorType == CFX_Color::Type::kTransparent) {
return std::nullopt;
}
return GenerateColorAP(color, PaintOperation::kStroke);
}

float GetBorderWidth(const CPDF_Dictionary* dict) {
RetainPtr<const CPDF_Dictionary> border_style_dict = dict->GetDictFor("BS");
if (border_style_dict) {
Expand Down
21 changes: 17 additions & 4 deletions core/fpdfdoc/cpdf_appearancegenerator_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ ByteString GenerateBorderAP(const CFX_FloatRect& rect,
ByteString GetColorStringWithDefault(const CPDF_Array* color_array,
const CFX_Color& default_color,
PaintOperation operation);
std::optional<ByteString> GetStrokeColorString(const CPDF_Dictionary* dict);
float GetBorderWidth(const CPDF_Dictionary* dict);
ByteString GetDashPatternString(const CPDF_Dictionary* dict);
ByteString GetPaintOperatorString(bool is_stroke_rect, bool is_fill_rect);
Expand Down Expand Up @@ -260,13 +261,25 @@ bool GenerateStrikeOutAP(APGenerationTarget* target,

// cpdf_appearancegenerator_shapes.cpp
ByteString ReadLineEndingToken(const CPDF_Array* le, size_t idx);
// `stroked` false fills a closed ending without outlining it: a line with no
// stroke colour keeps only its filled endings.
void EmitArrowPath(fxcrt::ostringstream& out,
float stroke_w,
ArrowStyle style,
bool do_fill);
void EmitCirclePath(fxcrt::ostringstream& out, float stroke_w, bool filled);
void EmitSquarePath(fxcrt::ostringstream& out, float stroke_w, bool filled);
void EmitDiamondPath(fxcrt::ostringstream& out, float stroke_w, bool filled);
bool do_fill,
bool stroked = true);
void EmitCirclePath(fxcrt::ostringstream& out,
float stroke_w,
bool filled,
bool stroked = true);
void EmitSquarePath(fxcrt::ostringstream& out,
float stroke_w,
bool filled,
bool stroked = true);
void EmitDiamondPath(fxcrt::ostringstream& out,
float stroke_w,
bool filled,
bool stroked = true);
void EmitButtOrSlashPath(fxcrt::ostringstream& out,
float stroke_w,
float len_factor);
Expand Down
Loading