• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <minikin/MinikinFont.h>
18 #include "flutter/fml/macros.h"
19 #include "third_party/skia/include/core/SkPaint.h"
20 #include "third_party/skia/include/core/SkTypeface.h"
21 
22 namespace txt {
23 
24 class FontSkia : public minikin::MinikinFont {
25  public:
26   explicit FontSkia(sk_sp<SkTypeface> typeface);
27 
28   ~FontSkia();
29 
30   float GetHorizontalAdvance(uint32_t glyph_id,
31                              const minikin::MinikinPaint& paint) const override;
32 
33   void GetBounds(minikin::MinikinRect* bounds,
34                  uint32_t glyph_id,
35                  const minikin::MinikinPaint& paint) const override;
36 
37   hb_face_t* CreateHarfBuzzFace() const override;
38 
39   const std::vector<minikin::FontVariation>& GetAxes() const override;
40 
41   const sk_sp<SkTypeface>& GetSkTypeface() const;
42 
43  private:
44   sk_sp<SkTypeface> typeface_;
45   std::vector<minikin::FontVariation> variations_;
46 
47   FML_DISALLOW_COPY_AND_ASSIGN(FontSkia);
48 };
49 
50 }  // namespace txt
51