1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_FONT_H_
6 #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_FONT_H_
7 
8 #include <memory>
9 
10 #include "third_party/blink/public/platform/web_common.h"
11 #include "third_party/skia/include/core/SkColor.h"
12 
13 // To avoid conflicts with the CreateWindow macro from the Windows SDK...
14 #undef DrawText
15 
16 namespace cc {
17 class PaintCanvas;
18 }
19 
20 namespace gfx {
21 class PointF;
22 class RectF;
23 }
24 
25 namespace blink {
26 struct WebFontDescription;
27 struct WebTextRun;
28 
29 class WebFont {
30  public:
31   BLINK_PLATFORM_EXPORT static WebFont* Create(const WebFontDescription&);
32   BLINK_PLATFORM_EXPORT ~WebFont();
33 
34   BLINK_PLATFORM_EXPORT WebFontDescription GetFontDescription() const;
35   BLINK_PLATFORM_EXPORT int Ascent() const;
36   BLINK_PLATFORM_EXPORT int Descent() const;
37   BLINK_PLATFORM_EXPORT int Height() const;
38   BLINK_PLATFORM_EXPORT int LineSpacing() const;
39   BLINK_PLATFORM_EXPORT float XHeight() const;
40   BLINK_PLATFORM_EXPORT void DrawText(cc::PaintCanvas*,
41                                       const WebTextRun&,
42                                       const gfx::PointF& left_baseline,
43                                       SkColor) const;
44   BLINK_PLATFORM_EXPORT int CalculateWidth(const WebTextRun&) const;
45   BLINK_PLATFORM_EXPORT int OffsetForPosition(const WebTextRun&,
46                                               float position) const;
47   BLINK_PLATFORM_EXPORT gfx::RectF SelectionRectForText(
48       const WebTextRun&,
49       const gfx::PointF& left_baseline,
50       int height,
51       int from = 0,
52       int to = -1) const;
53 
54  private:
55   explicit WebFont(const WebFontDescription&);
56 
57   class Impl;
58   std::unique_ptr<Impl> private_;
59 };
60 
61 }  // namespace blink
62 
63 #endif
64