Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
xtyxtyx committed Dec 21, 2024
1 parent 3cb0a9d commit 4066704
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
16 changes: 2 additions & 14 deletions Sources/CSkia/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@

using namespace skia::textlayout;

// FontCollection_sp test_font_collection()
// {
// // auto c = SkCanvas();
// auto fontCollection = sk_make_sp<FontCollection>();
// // auto fontMgr = SkFontMgr::RefDefault()
// auto fontMgr = SkFontMgr::RefEmpty();
// assert(fontMgr != nullptr);
// fontCollection->setDefaultFontManager(fontMgr);
// return fontCollection;
// // return nullptr;
// }

template struct sk_sp<FontCollection>;
template struct sk_sp<SkSurface>;
template struct sk_sp<SkImage>;
Expand Down Expand Up @@ -153,9 +141,9 @@ std::vector<SkString> skstring_vector_new()
return std::vector<SkString>();
}

const char *skstring_c_str(const SkString &string)
void skstring_c_str(const SkString &string, const char **out)
{
return string.c_str();
*out = string.c_str();
}

sk_sp<SkColorSpace> color_space_new_srgb()
Expand Down
8 changes: 5 additions & 3 deletions Sources/CSkia/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#define SK_METAL
#define SK_GANESH

#include <swift/bridging>

#include "include/android/SkAnimatedImage.h"
#include "include/codec/SkAndroidCodec.h"
#include "include/codec/SkBmpDecoder.h"
Expand All @@ -16,6 +14,7 @@
#include "include/core/SkBlurTypes.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkData.h"
#include "include/core/SkDocument.h"
#include "include/core/SkFontMetrics.h"
Expand Down Expand Up @@ -107,6 +106,8 @@ typedef sk_sp<ParagraphBuilder> ParagraphBuilder_sp;
typedef sk_sp<SkTypeface> SkTypeface_sp;
typedef sk_sp<SkTextBlob> SkTextBlob_sp;

template void SkSafeUnref<FontCollection>(FontCollection *obj);

// FontCollection_sp test_font_collection();

// MARK: - ParagraphBuilder
Expand Down Expand Up @@ -212,8 +213,9 @@ GrDirectContext_sp gr_mtl_direct_context_make(GrMtlBackendContext &context);
// MARK: - Misc

std::vector<SkString> skstring_vector_new();
const char *skstring_c_str(const SkString &string) SWIFT_RETURNS_INDEPENDENT_VALUE;
void skstring_c_str(const SkString &string, const char **out);
sk_sp<SkColorSpace> color_space_new_srgb();

sk_sp<SkColorSpace> color_space_new_null();

#endif // CSKIA_UTILS_H
4 changes: 3 additions & 1 deletion Sources/Shaft/Backend/Skia/SkiaFontCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public class SkiaTypeface: Typeface {
public var familyName: String {
var skString = SkString()
sk_typeface_get_family_name(&self.typeface, &skString)
return String(cString: skstring_c_str(skString))
var cString: UnsafePointer<CChar>?
skstring_c_str(skString, &cString)
return String(cString: cString!)
}
}

Expand Down

0 comments on commit 4066704

Please sign in to comment.