xref: /aosp_15_r20/external/skia/include/core/SkFontScanner.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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/SkRefCnt.h"
13 #include "include/core/SkTypes.h"
14 #include "include/private/base/SkFixed.h"
15 #include "include/private/base/SkNoncopyable.h"
16 #include "include/private/base/SkTArray.h"
17 class SkFontStyle;
18 class SkStreamAsset;
19 class SkString;
20 class SkTypeface;
21 
22 class SkFontScanner : public SkNoncopyable {
23 public:
24     virtual ~SkFontScanner() = default;
25     struct AxisDefinition {
26         SkFourByteTag fTag;
27         SkScalar fMinimum;
28         SkScalar fDefault;
29         SkScalar fMaximum;
30     };
31     typedef skia_private::STArray<4, AxisDefinition, true> AxisDefinitions;
32 
33     virtual bool scanFile(SkStreamAsset* stream, int* numFaces) const = 0;
34     virtual bool scanFace(SkStreamAsset* stream, int faceIndex, int* numInstances) const = 0;
35     /* instanceIndex 0 is the default instance, 1 to numInstances are the named instances. */
36     virtual bool scanInstance(SkStreamAsset* stream,
37                               int faceIndex,
38                               int instanceIndex,
39                               SkString* name,
40                               SkFontStyle* style,
41                               bool* isFixedPitch,
42                               AxisDefinitions* axes) const = 0;
43     virtual sk_sp<SkTypeface> MakeFromStream(std::unique_ptr<SkStreamAsset> stream,
44                                              const SkFontArguments& args) const = 0;
45     virtual SkFourByteTag getFactoryId() const = 0;
46 };
47 
48 #endif // SKFONTSCANNER_H_
49