Skip to content

Commit

Permalink
Try fix ci build
Browse files Browse the repository at this point in the history
  • Loading branch information
xtyxtyx committed Dec 21, 2024
1 parent 5d9632f commit f3c8d2a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
11 changes: 2 additions & 9 deletions Sources/CSkia/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,9 @@ auto fontMgr = SkFontMgr_New_DirectWrite(nullptr);
auto fontMgr = SkFontMgr_New_FontConfig(nullptr);
#endif

// The singleton font collection that will be used by all paragraph builders.
auto fontCollection1 = sk_make_sp<FontCollection>();

ParagraphBuilder *paragraph_builder_new(ParagraphStyle &style)
ParagraphBuilder *paragraph_builder_new(ParagraphStyle &style, FontCollection_sp &fontCollection)
{
// auto fontCollection1 = sk_make_sp<FontCollection>();
fontCollection1->setDefaultFontManager(fontMgr);

auto result = ParagraphBuilder::make(style, fontCollection1);
// auto result = ParagraphBuilder::make(*style, font_collection);
auto result = ParagraphBuilder::make(style, fontCollection);
auto result2 = result.release();
return result2;
}
Expand Down
2 changes: 1 addition & 1 deletion 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);
ParagraphBuilder *paragraph_builder_new(ParagraphStyle &style, 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 Down
7 changes: 2 additions & 5 deletions Sources/Shaft/Backend/Skia/SkiaParagraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

import CSkia

// let fontCollection = test_font_collection()

public class SkiaParagraphBuilder: ParagraphBuilder {
public required init(_ style: ParagraphStyle) {
public init(_ style: ParagraphStyle, fontCollection: SkiaFontCollection) {
var skiaStyle = skia.textlayout.ParagraphStyle()
style.copyToSkia(&skiaStyle)
// builder = paragraph_builder_new(&skiaStyle, fontCollection)
builder = paragraph_builder_new(&skiaStyle)
builder = paragraph_builder_new(&skiaStyle, &fontCollection.collection)
}

deinit {
Expand Down
5 changes: 3 additions & 2 deletions Sources/Shaft/Backend/Skia/SkiaRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SkiaRenderer: Renderer {
}

public func createParagraphBuilder(_ style: ParagraphStyle) -> ParagraphBuilder {
SkiaParagraphBuilder(style)
SkiaParagraphBuilder(style, fontCollection: _fontCollection)
}

public func createTextBlob(_ glyphs: [GlyphID], positions: [Offset], font: any Font)
Expand All @@ -28,5 +28,6 @@ public class SkiaRenderer: Renderer {
SkiaPath()
}

public let fontCollection: FontCollection = SkiaFontCollection()
public let _fontCollection = SkiaFontCollection()
public var fontCollection: FontCollection { _fontCollection }
}
2 changes: 0 additions & 2 deletions Sources/Shaft/Core/TextTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,6 @@ public struct ParagraphStyle {
}

public protocol ParagraphBuilder: AnyObject {
init(_ style: ParagraphStyle)

/// Applies the given style to the added text until [pop] is called.
///
/// See [pop] for details.
Expand Down

0 comments on commit f3c8d2a

Please sign in to comment.