Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
xtyxtyx committed Dec 21, 2024
1 parent d22bf84 commit c62f295
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Sources/CSkia/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ auto fontMgr = SkFontMgr_New_DirectWrite(nullptr);
auto fontMgr = SkFontMgr_New_FontConfig(nullptr);
#endif

ParagraphBuilder *paragraph_builder_new(ParagraphStyle &style, FontCollection_sp &fontCollection)
ParagraphBuilder *paragraph_builder_new(ParagraphStyle &style, const FontCollection_sp &fontCollection)
{
auto result = ParagraphBuilder::make(style, fontCollection);
return result.release();
Expand Down Expand Up @@ -162,18 +162,18 @@ FontCollection_sp sk_fontcollection_new()
return collection;
}

SkTypeface_sp sk_typeface_create_from_data(FontCollection_sp &collection, const char *data, size_t length)
SkTypeface_sp sk_typeface_create_from_data(const FontCollection_sp &collection, const char *data, size_t length)
{
auto bytes = SkData::MakeWithCopy(data, length);
return collection->getFallbackManager()->makeFromData(bytes);
}

std::vector<SkTypeface_sp> sk_fontcollection_find_typefaces(FontCollection_sp &collection, std::vector<SkString> &families, SkFontStyle style)
std::vector<SkTypeface_sp> sk_fontcollection_find_typefaces(const FontCollection_sp &collection, const std::vector<SkString> &families, SkFontStyle style)
{
return collection->findTypefaces(families, style);
}

SkTypeface_sp sk_fontcollection_default_fallback(FontCollection_sp &collection, SkUnichar unicode, SkFontStyle style, const SkString &locale)
SkTypeface_sp sk_fontcollection_default_fallback(const FontCollection_sp &collection, SkUnichar unicode, SkFontStyle style, const SkString &locale)
{
return collection->defaultFallback(unicode, style, locale);
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/CSkia/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ typedef sk_sp<SkTextBlob> SkTextBlob_sp;

// MARK: - ParagraphBuilder

ParagraphBuilder *paragraph_builder_new(ParagraphStyle &style, FontCollection_sp &fontCollection);
ParagraphBuilder *paragraph_builder_new(ParagraphStyle &style, const FontCollection_sp &fontCollection);
void paragraph_builder_add_text(ParagraphBuilder *builder, const char *text);
void paragraph_builder_push_style(ParagraphBuilder *builder, const TextStyle *style);
void paragraph_builder_pop(ParagraphBuilder *builder);
Expand All @@ -138,9 +138,9 @@ void paragraph_unref(Paragraph *paragraph);
// MARK: - Font

FontCollection_sp sk_fontcollection_new();
SkTypeface_sp sk_typeface_create_from_data(FontCollection_sp &collection, const char *data, size_t length);
std::vector<SkTypeface_sp> sk_fontcollection_find_typefaces(FontCollection_sp &collection, std::vector<SkString> &families, SkFontStyle style);
SkTypeface_sp sk_fontcollection_default_fallback(FontCollection_sp &collection, SkUnichar unicode, SkFontStyle style, const SkString &locale);
SkTypeface_sp sk_typeface_create_from_data(const FontCollection_sp &collection, const char *data, size_t length);
std::vector<SkTypeface_sp> sk_fontcollection_find_typefaces(const FontCollection_sp &collection, const std::vector<SkString> &families, SkFontStyle style);
SkTypeface_sp sk_fontcollection_default_fallback(const FontCollection_sp &collection, SkUnichar unicode, SkFontStyle style, const SkString &locale);
std::vector<SkGlyphID> sk_typeface_get_glyphs(SkTypeface_sp &typeface, const SkUnichar *text, size_t length);
SkGlyphID sk_typeface_get_glyph(SkTypeface_sp &typeface, SkUnichar unicode);
int sk_typeface_count_glyphs(SkTypeface_sp &typeface);
Expand Down
8 changes: 4 additions & 4 deletions Sources/Shaft/Backend/Skia/SkiaFontCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SkiaFontCollection: FontCollection {
public func makeTypefaceFrom(_ data: Data) -> any Typeface {
let typeface = data.withUnsafeBytes { (ptr: UnsafeRawBufferPointer) in
let data = ptr.bindMemory(to: UInt8.self)
return sk_typeface_create_from_data(&collection, data.baseAddress, data.count)
return sk_typeface_create_from_data(collection, data.baseAddress, data.count)
}
return SkiaTypeface(typeface)
}
Expand All @@ -25,8 +25,8 @@ public class SkiaFontCollection: FontCollection {
}

let typefaces = sk_fontcollection_find_typefaces(
&self.collection,
&families,
self.collection,
families,
toSkiaFontStyle(fontStyle: style, fontWeight: weight)
)

Expand All @@ -35,7 +35,7 @@ public class SkiaFontCollection: FontCollection {

public func findTypefaceFor(_ codepoint: UInt32) -> (any Typeface)? {
let typeface = sk_fontcollection_default_fallback(
&self.collection,
self.collection,
SkUnichar(codepoint),
SkFontStyle(),
SkString()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Shaft/Backend/Skia/SkiaParagraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SkiaParagraphBuilder: ParagraphBuilder {
public init(_ style: ParagraphStyle, fontCollection: SkiaFontCollection) {
var skiaStyle = skia.textlayout.ParagraphStyle()
style.copyToSkia(&skiaStyle)
builder = paragraph_builder_new(&skiaStyle, &fontCollection.collection)
builder = paragraph_builder_new(&skiaStyle, fontCollection.collection)
}

deinit {
Expand Down

0 comments on commit c62f295

Please sign in to comment.