skia2/modules/skparagraph/include/ParagraphBuilder.h
Julia Lavrova b6b7fffc35 Reland "Removing ICU dependencies from skparagraph BUILD.gn file"
This reverts commit 05ce2817f2.

Reason for revert: Fixing the build

Original change's description:
> Revert "Removing ICU dependencies from skparagraph BUILD.gn file"
>
> This reverts commit f1711adb1a.
>
> Reason for revert: Build break
>
> Original change's description:
> > Removing ICU dependencies from skparagraph BUILD.gn file
> >
> > (and from the sources, too)
> >
> > Change-Id: I9d8ff51c91aad4b770b1f183c04734d31252b851
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313148
> > Commit-Queue: Julia Lavrova <jlavrova@google.com>
> > Reviewed-by: Ben Wagner <bungeman@google.com>
>
> TBR=bungeman@google.com,jlavrova@google.com
>
> Change-Id: I1fce2436855e3e2a4cb7d1d7204b3ae49fd530e8
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314540
> Reviewed-by: Julia Lavrova <jlavrova@google.com>
> Commit-Queue: Julia Lavrova <jlavrova@google.com>

TBR=bungeman@google.com,jlavrova@google.com

Change-Id: I13d78d75698df47930adc2514d1328abc556a209
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316444
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
2020-09-11 18:31:24 +00:00

69 lines
2.4 KiB
C++

// Copyright 2019 Google LLC.
#ifndef ParagraphBuilder_DEFINED
#define ParagraphBuilder_DEFINED
#include <memory>
#include <stack>
#include <string>
#include <tuple>
#include "modules/skparagraph/include/FontCollection.h"
#include "modules/skparagraph/include/Paragraph.h"
#include "modules/skparagraph/include/ParagraphStyle.h"
#include "modules/skparagraph/include/TextStyle.h"
namespace skia {
namespace textlayout {
class ParagraphBuilder {
public:
ParagraphBuilder(const ParagraphStyle&, sk_sp<FontCollection>) { }
virtual ~ParagraphBuilder() = default;
// Push a style to the stack. The corresponding text added with AddText will
// use the top-most style.
virtual void pushStyle(const TextStyle& style) = 0;
// Remove a style from the stack. Useful to apply different styles to chunks
// of text such as bolding.
// Example:
// builder.PushStyle(normal_style);
// builder.AddText("Hello this is normal. ");
//
// builder.PushStyle(bold_style);
// builder.AddText("And this is BOLD. ");
//
// builder.Pop();
// builder.AddText(" Back to normal again.");
virtual void pop() = 0;
virtual TextStyle peekStyle() = 0;
// Adds text to the builder. Forms the proper runs to use the upper-most style
// on the style_stack
virtual void addText(const std::u16string& text) = 0;
// Adds text to the builder, using the top-most style on on the style_stack.
virtual void addText(const char* text) = 0; // Don't use this one - going away soon
virtual void addText(const char* text, size_t len) = 0;
// Pushes the information required to leave an open space, where Flutter may
// draw a custom placeholder into.
// Internally, this method adds a single object replacement character (0xFFFC)
virtual void addPlaceholder(const PlaceholderStyle& placeholderStyle) = 0;
virtual void setParagraphStyle(const ParagraphStyle& style) = 0;
// Constructs a SkParagraph object that can be used to layout and paint the text to a SkCanvas.
virtual std::unique_ptr<Paragraph> Build() = 0;
// Just until we fix all the google3 code
static std::unique_ptr<ParagraphBuilder> make(const ParagraphStyle& style,
sk_sp<FontCollection> fontCollection);
};
} // namespace textlayout
} // namespace skia
#endif // ParagraphBuilder_DEFINED