Commit 5c161452 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

optionally disable shape antialiasing

parent a223c148
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -25,6 +25,10 @@

namespace clip {

enum class AntialiasingMode {
  ENABLE, DISABLE
};

struct PageTextElement {
  std::string text;
  std::vector<text::GlyphPlacementGroup> glyphs;
@@ -44,6 +48,7 @@ struct PageShapeElement {
  std::optional<Color> fill_color;
  std::optional<uint32_t> zindex;
  Rectangle clip;
  std::optional<AntialiasingMode> antialiasing_mode;
};

} // namespace clip
+12 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ Status svg_shape(
    SVGDataRef svg) {
  std::string fill_opts;
  std::string stroke_opts;
  std::string extra_opts;

  if (elem.fill_color) {
    fill_opts = svg_attr("fill", elem.fill_color->to_hex_str(4));
@@ -155,12 +156,23 @@ Status svg_shape(
    }
  }

  if (elem.antialiasing_mode) {
    switch (*elem.antialiasing_mode) {
      case AntialiasingMode::ENABLE:
        break;
      case AntialiasingMode::DISABLE:
        extra_opts += svg_attr("shape-rendering", "crispEdges");
        break;
    }
  }

  svg->buffer
      << "  "
      << "<path"
      << svg_attr("d", svg_path_data(path_transform(elem.path, svg->proj)))
      << fill_opts
      << stroke_opts
      << extra_opts
      << "/>"
      << "\n";

+1 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ ReturnCode draw(

    PageShapeElement rect;
    rect.fill_color = color;
    rect.antialiasing_mode = AntialiasingMode::DISABLE;
    path_add_rectangle(&rect.path, Point(sx, sy), {size_x, size_y});
    page_add_shape(layer, rect);
  }
+4000 −4000

File changed.

Preview size limit exceeded, changes collapsed.