1 | // LAF OS Library |
2 | // Copyright (C) 2019 Igara Studio S.A. |
3 | // |
4 | // This file is released under the terms of the MIT license. |
5 | // Read LICENSE.txt for more information. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "os/draw_text.h" |
12 | #include "os/paint.h" |
13 | #include "os/skia/skia_helpers.h" |
14 | #include "os/skia/skia_surface.h" |
15 | |
16 | #include "include/core/SkTextBlob.h" |
17 | #include "include/utils/SkTextUtils.h" |
18 | #include "modules/skshaper/include/SkShaper.h" |
19 | |
20 | namespace os { |
21 | |
22 | void draw_text( |
23 | Surface* surface, Font* font, |
24 | const std::string& text, |
25 | const gfx::Point& pos, |
26 | const Paint* paint, |
27 | const TextAlign textAlign, |
28 | DrawTextDelegate* delegate) |
29 | { |
30 | SkFont skFont; // wrap SkFont with os::Font |
31 | SkTextUtils::Draw( |
32 | &static_cast<SkiaSurface*>(surface)->canvas(), |
33 | text.c_str(), text.size(), |
34 | SkTextEncoding::kUTF8, |
35 | SkIntToScalar(pos.x), |
36 | SkIntToScalar(pos.y), |
37 | skFont, (paint ? paint->skPaint(): SkPaint()), |
38 | (SkTextUtils::Align)textAlign); |
39 | } |
40 | |
41 | } // namespace os |
42 | |