31#if defined(SK_UNICODE_ICU_IMPLEMENTATION)
37 SkDEBUGFAIL(
"Only ICU implementation of SkUnicode is supported");
48 virtual void set(
const std::string& _value) = 0;
51 BaseOption(std::string _selector, std::string _description)
57 static void Init(
const std::vector<BaseOption*> &,
int argc,
char **
argv);
63 Option(std::string _selector, std::string _description,
T defaultValue)
65 ,
value(defaultValue) {}
69 int argc,
char **
argv) {
70 std::map<std::string, BaseOption *>
options;
74 for (
int i = 1;
i < argc;
i++) {
75 std::string option_selector(
argv[
i]);
76 auto it =
options.find(option_selector);
81 const char *option_value =
argv[
i + 1];
82 it->second->set(option_value);
85 printf(
"Ignoring unrecognized option: %s.\n",
argv[
i]);
87 printf(
"\tTakes text from stdin and produces pdf file.\n");
88 printf(
"Supported options:\n");
90 printf(
"\t%s\t%s (%s)\n", opt->selector.c_str(),
91 opt->description.c_str(), opt->valueToString().c_str());
99 void set(
const std::string& _value)
override {
value = atof(_value.c_str()); }
101 std::ostringstream stm;
105 DoubleOption(std::string _selector, std::string _description,
double defaultValue)
107 std::move(_description),
108 std::move(defaultValue)) {}
112 void set(
const std::string& _value)
override {
value = _value; }
114 StringOption(std::string _selector, std::string _description, std::string defaultValue)
116 std::move(_description),
117 std::move(defaultValue)) {}
136 StringOption(
"-o",
".pdf output file name",
"out-skiahf.pdf");
151 : config(conf), document(doc), pageCanvas(nullptr) {
164 std::unique_ptr<SkShaper::BiDiRunIterator> bidi =
168 std::unique_ptr<SkShaper::LanguageRunIterator> language =
172 std::unique_ptr<SkShaper::ScriptRunIterator>
script =
176 std::unique_ptr<SkShaper::FontRunIterator> fontRuns =
191 SkPoint endPoint = textBlobBuilder.endPoint();
240 pdf_info.
fPDFA =
true;
254 if (font_file.size() > 0) {
260 std::unique_ptr<SkShaper> shaper =
265 for (std::string
line; std::getline(std::cin,
line);) {
#define SkDEBUGFAIL(message)
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Empty()
#define SkDoubleToScalar(x)
sk_sp< SkUnicode > get_unicode()
void WriteLine(const SkShaper &shaper, const char *text, size_t textBytes)
Placement(const Config *conf, SkDocument *doc)
void drawPaint(const SkPaint &paint)
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
SkCanvas * beginPage(SkScalar width, SkScalar height, const SkRect *content=nullptr)
static sk_sp< SkFontMgr > RefEmpty()
sk_sp< SkTypeface > makeFromFile(const char path[], int ttcIndex=0) const
void setSubpixel(bool subpixel)
void setEdging(Edging edging)
void setSize(SkScalar textSize)
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
void setColor(SkColor color)
void setAntiAlias(bool aa)
static std::unique_ptr< FontRunIterator > MakeFontMgrRunIterator(const char *utf8, size_t utf8Bytes, const SkFont &font, sk_sp< SkFontMgr > fallback)
static std::unique_ptr< LanguageRunIterator > MakeStdLanguageRunIterator(const char *utf8, size_t utf8Bytes)
virtual void shape(const char *utf8, size_t utf8Bytes, const SkFont &srcFont, bool leftToRight, SkScalar width, RunHandler *) const =0
void GetDateTime(SkPDF::DateTime *)
SK_API sk_sp< SkDocument > MakeDocument(SkWStream *stream, const Metadata &metadata)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
SKSHAPER_API std::unique_ptr< SkShaper > ShaperDrivenWrapper(sk_sp< SkUnicode > unicode, sk_sp< SkFontMgr > fallback)
SKSHAPER_API std::unique_ptr< SkShaper::ScriptRunIterator > ScriptRunIterator(const char *utf8, size_t utf8Bytes)
SKSHAPER_API std::unique_ptr< SkShaper::BiDiRunIterator > BidiRunIterator(sk_sp< SkUnicode > unicode, const char *utf8, size_t utf8Bytes, uint8_t bidiLevel)
SKUNICODE_API sk_sp< SkUnicode > Make()
virtual std::string valueToString()=0
static void Init(const std::vector< BaseOption * > &, int argc, char **argv)
BaseOption(std::string _selector, std::string _description)
virtual void set(const std::string &_value)=0
Config(int argc, char **argv)
DoubleOption line_spacing_ratio
StringOption output_file_name
DoubleOption(std::string _selector, std::string _description, double defaultValue)
std::string valueToString() override
void set(const std::string &_value) override
Option(std::string _selector, std::string _description, T defaultValue)
constexpr float y() const
void set(const std::string &_value) override
StringOption(std::string _selector, std::string _description, std::string defaultValue)
std::string valueToString() override
int main(int argc, char **argv)
static sk_sp< SkDocument > MakePDFDocument(const Config &config, SkWStream *wStream)