• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 Google LLC.
2 #ifndef Shaper_DEFINED
3 #define Shaper_DEFINED
4 
5 #include "experimental/sktext/src/TextRun.h"
6 #include "modules/skshaper/include/SkShaper.h"
7 
8 namespace skia {
9 namespace text {
10 
11 class Processor;
12 class Shaper : public SkShaper::RunHandler{
13 public:
Shaper(Processor * processor,TextFontStyle textFontStyle)14     Shaper(Processor* processor, TextFontStyle textFontStyle)
15             : fProcessor(processor)
16             , fFontManager(textFontStyle.fFontManager)
17             , fDefaultTextDirection(textFontStyle.fTextDirection)
18             , fCurrentRun(nullptr) { }
19     bool process();
20 
21 private:
22     SkFont createFont(const FontBlock& block);
23     sk_sp<SkTypeface> matchTypeface(const SkString& fontFamily, SkFontStyle fontStyle);
24 
beginLine()25     void beginLine() override {}
runInfo(const RunInfo &)26     void runInfo(const RunInfo&) override {}
commitRunInfo()27     void commitRunInfo() override {}
commitLine()28     void commitLine() override {}
29 
runBuffer(const RunInfo & info)30     Buffer runBuffer(const RunInfo& info) override {
31         fCurrentRun = std::make_unique<TextRun>(info);
32         return fCurrentRun->newRunBuffer();
33     }
34 
35     void commitRunBuffer(const RunInfo&) override;
36 
37     Processor* fProcessor;
38     sk_sp<SkFontMgr> fFontManager;
39     TextDirection fDefaultTextDirection;
40     std::unique_ptr<TextRun> fCurrentRun;
41 };
42 
43 } // namespace text
44 } // namespace skia
45 #endif
46