• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright 2024 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 
8 #ifndef SKFONTSCANNER_H_
9 #define SKFONTSCANNER_H_
10 
11 #include "include/core/SkFontArguments.h"
12 #include "include/core/SkFontParameters.h"
13 #include "include/core/SkRefCnt.h"
14 #include "include/core/SkTypes.h"
15 #include "include/private/base/SkFixed.h"
16 #include "include/private/base/SkNoncopyable.h"
17 #include "include/private/base/SkTArray.h"
18 class SkFontStyle;
19 class SkStreamAsset;
20 class SkString;
21 class SkTypeface;
22 
23 class SkFontScanner : public SkNoncopyable {
24 public:
25     virtual ~SkFontScanner() = default;
26     using AxisDefinitions = skia_private::STArray<4, SkFontParameters::Variation::Axis, true>;
27     using VariationPosition = skia_private::STArray<4, SkFontArguments::VariationPosition::Coordinate, true>;
28 
29     virtual bool scanFile(SkStreamAsset* stream, int* numFaces) const = 0;
30     virtual bool scanFace(SkStreamAsset* stream, int faceIndex, int* numInstances) const = 0;
31     /* instanceIndex 0 is the default instance, 1 to numInstances are the named instances. */
32     virtual bool scanInstance(SkStreamAsset* stream,
33                               int faceIndex,
34                               int instanceIndex,
35                               SkString* name,
36                               SkFontStyle* style,
37                               bool* isFixedPitch,
38                               AxisDefinitions* axes,
39                               VariationPosition* position) const = 0;
40     virtual sk_sp<SkTypeface> MakeFromStream(std::unique_ptr<SkStreamAsset> stream,
41                                              const SkFontArguments& args) const = 0;
42     virtual SkFourByteTag getFactoryId() const = 0;
43 };
44 
45 #endif // SKFONTSCANNER_H_
46