aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/shape/SkShaper.h
blob: 190a4d834e1d8beba4e72d576f58543c237d54eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkShaper_DEFINED
#define SkShaper_DEFINED

#include <memory>

#include "SkPoint.h"
#include "SkTypeface.h"

class SkPaint;
class SkTextBlobBuilder;

/**
   Shapes text using HarfBuzz and places the shaped text into a
   TextBlob.

   If compiled without HarfBuzz, fall back on SkPaint::textToGlyphs.
 */
class SkShaper {
public:
    SkShaper(sk_sp<SkTypeface> face);
    ~SkShaper();

    bool good() const;
    SkPoint shape(SkTextBlobBuilder* dest,
                   const SkPaint& srcPaint,
                   const char* utf8text,
                   size_t textBytes,
                   bool leftToRight,
                   SkPoint point,
                   SkScalar width) const;

private:
    SkShaper(const SkShaper&) = delete;
    SkShaper& operator=(const SkShaper&) = delete;

    struct Impl;
    std::unique_ptr<Impl> fImpl;
};

#endif  // SkShaper_DEFINED