Flutter Engine
The Flutter Engine
Classes | Functions
using_skia_and_harfbuzz.cpp File Reference
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include "include/core/SkCanvas.h"
#include "include/core/SkStream.h"
#include "include/core/SkTextBlob.h"
#include "include/core/SkTypeface.h"
#include "include/docs/SkPDFDocument.h"
#include "include/ports/SkFontMgr_empty.h"
#include "modules/skshaper/include/SkShaper_harfbuzz.h"
#include "modules/skshaper/include/SkShaper_skunicode.h"
#include "modules/skunicode/include/SkUnicode.h"

Go to the source code of this file.

Classes

struct  BaseOption
 
struct  Option< T >
 
struct  DoubleOption
 
struct  StringOption
 
struct  Config
 
class  Placement
 

Functions

static sk_sp< SkDocumentMakePDFDocument (const Config &config, SkWStream *wStream)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 245 of file using_skia_and_harfbuzz.cpp.

245 {
246 Config config(argc, argv);
247 SkFILEWStream wStream(config.output_file_name.value.c_str());
248 sk_sp<SkDocument> doc = MakePDFDocument(config, &wStream);
249 assert(doc);
250 Placement placement(&config, doc.get());
251
252 const std::string &font_file = config.font_file.value;
253 sk_sp<SkTypeface> typeface;
254 if (font_file.size() > 0) {
255 // There are different font managers for different platforms. See include/ports
257 assert(mgr);
258 typeface = mgr->makeFromFile(font_file.c_str(), 0 /* index */);
259 }
260 std::unique_ptr<SkShaper> shaper =
262 assert(shaper);
263 //SkString line("This is هذا هو الخط a line.");
264 //SkString line("⁧This is a line هذا هو الخط.⁩");
265 for (std::string line; std::getline(std::cin, line);) {
266 placement.WriteLine(*shaper, line.c_str(), line.size());
267 }
268
269 doc->close();
270 wStream.flush();
271 return 0;
272}
SK_API sk_sp< SkFontMgr > SkFontMgr_New_Custom_Empty()
sk_sp< SkUnicode > get_unicode()
sk_sp< SkTypeface > makeFromFile(const char path[], int ttcIndex=0) const
Definition: SkFontMgr.cpp:143
T * get() const
Definition: SkRefCnt.h:303
char ** argv
Definition: library.h:9
SKSHAPER_API std::unique_ptr< SkShaper > ShaperDrivenWrapper(sk_sp< SkUnicode > unicode, sk_sp< SkFontMgr > fallback)
static sk_sp< SkDocument > MakePDFDocument(const Config &config, SkWStream *wStream)

◆ MakePDFDocument()

static sk_sp< SkDocument > MakePDFDocument ( const Config config,
SkWStream wStream 
)
static

Definition at line 228 of file using_skia_and_harfbuzz.cpp.

228 {
229 SkPDF::Metadata pdf_info;
230 pdf_info.fTitle = config.title.value.c_str();
231 pdf_info.fAuthor = config.author.value.c_str();
232 pdf_info.fSubject = config.subject.value.c_str();
233 pdf_info.fKeywords = config.keywords.value.c_str();
234 pdf_info.fCreator = config.creator.value.c_str();
235 #if 0
236 SkPDF::DateTime now;
238 pdf_info.fCreation = now;
239 pdf_info.fModified = now;
240 pdf_info.fPDFA = true;
241 #endif
242 return SkPDF::MakeDocument(wStream, pdf_info);
243}
void GetDateTime(SkPDF::DateTime *)
Definition: SkPDFUtils.cpp:431
SK_API sk_sp< SkDocument > MakeDocument(SkWStream *stream, const Metadata &metadata)
StringOption author
StringOption keywords
StringOption title
StringOption creator
StringOption subject
SkString fSubject
Definition: SkPDFDocument.h:96
SkString fAuthor
Definition: SkPDFDocument.h:92
SkString fKeywords
DateTime fCreation
DateTime fModified