xref: /aosp_15_r20/external/skia/src/ports/SkFontScanner_FreeType_priv.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_FREE_TYPE_PRIV_H_
9 #define SKFONTSCANNER_FREE_TYPE_PRIV_H_
10 
11 #include "include/core/SkFontScanner.h"
12 #include "include/core/SkTypeface.h"
13 #include "include/core/SkTypes.h"
14 #include "src/ports/SkTypeface_FreeType.h"
15 
16 class SkFontScanner_FreeType : public SkFontScanner {
17 public:
18     SkFontScanner_FreeType();
19     ~SkFontScanner_FreeType() override;
20 
21     bool scanFile(SkStreamAsset* stream, int* numFaces) const override;
22     bool scanFace(SkStreamAsset* stream, int faceIndex, int* numInstances) const override;
23     bool scanInstance(SkStreamAsset* stream,
24                       int faceIndex,
25                       int instanceIndex,
26                       SkString* name,
27                       SkFontStyle* style,
28                       bool* isFixedPitch,
29                       AxisDefinitions* axes) const override;
30     sk_sp<SkTypeface> MakeFromStream(std::unique_ptr<SkStreamAsset> stream,
31                                      const SkFontArguments& args) const override;
32     SkTypeface::FactoryId getFactoryId() const override;
33     static void computeAxisValues(
34             AxisDefinitions axisDefinitions,
35             const SkFontArguments::VariationPosition position,
36             SkFixed* axisValues,
37             const SkString& name,
38             SkFontStyle* style,
39             const SkFontArguments::VariationPosition::Coordinate* currentPosition = nullptr);
40 private:
41     FT_Face openFace(SkStreamAsset* stream, int ttcIndex, FT_Stream ftStream) const;
42     FT_Library fLibrary;
43     mutable SkMutex fLibraryMutex;
44 };
45 
46 #endif // SKFONTSCANNER_FREE_TYPE_PRIV_H_
47