| 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, |
| 30 |
VariationPosition* position) const override; |
| 31 |
sk_sp<SkTypeface> MakeFromStream(std::unique_ptr<SkStreamAsset> stream, |
| 32 |
const SkFontArguments& args) const override; |
| 33 |
SkTypeface::FactoryId getFactoryId() const override; |
| 34 |
static void computeAxisValues( |
| 35 |
const AxisDefinitions& axisDefinitions, |
| 36 |
const SkFontArguments::VariationPosition currentPosition, |
| 37 |
const SkFontArguments::VariationPosition requestedPosition, |
| 38 |
SkFixed* axisValues, |
| 39 |
const SkString& name, |
| 40 |
SkFontStyle* style); |
| 41 |
private: |
| 42 |
FT_Face openFace(SkStreamAsset* stream, int ttcIndex, FT_Stream ftStream) const; |
| 43 |
FT_Library fLibrary; |
| 44 |
mutable SkMutex fLibraryMutex; |
| 45 |
}; |
| 46 |
|
| 47 |
#endif // SKFONTSCANNER_FREE_TYPE_PRIV_H_ |