Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ alphaSkia is a special cross platform [Skia](https://skia.org/) wrapper used in
alphaSkia a slightly adapted [Semantic Versioning](https://semver.org/) scheme where the `PATCH` part indicates
the Skia milestone version we have integrated.

Currently we are on [Skia m120](https://github.com/CoderLine/alphaSkia/blob/main/.gitmodules#L8)
Currently we are on [Skia m135](https://github.com/CoderLine/alphaSkia/blob/main/.gitmodules#L8)

Given a version number `MAJOR.MINOR.SKIA`:

Expand Down
37 changes: 25 additions & 12 deletions build/Build.DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,31 @@ partial class Build
);
});

void DotNetWriteVersionInfoProps()
private string DotNetVersion
{
string semVer;
if (IsLocalBuild)
{
semVer = $"{VersionInfo.FileVersion.ToString(3)}-local.{VersionInfo.FileVersion.Revision}";
}
else if (!IsReleaseBuild)
{
semVer = $"{VersionInfo.FileVersion.ToString(3)}-alpha.{VersionInfo.FileVersion.Revision}";
}
else
get
{
semVer = $"{VersionInfo.FileVersion.ToString(3)}";
string semVer;
if (IsLocalBuild)
{
semVer = $"{VersionInfo.FileVersion.ToString(3)}-local.{VersionInfo.FileVersion.Revision}";
}
else if (!IsReleaseBuild)
{
semVer = $"{VersionInfo.FileVersion.ToString(3)}-alpha.{VersionInfo.FileVersion.Revision}";
}
else
{
semVer = $"{VersionInfo.FileVersion.ToString(3)}";
}

return semVer;
}
}

void DotNetWriteVersionInfoProps()
{
var semVer = DotNetVersion;
var props = $"""
<Project>
<PropertyGroup>
Expand All @@ -102,6 +111,7 @@ void DotNetWriteVersionInfoProps()

[Parameter] string Framework;

[PublicAPI]
public Target DotNetTest => t => t
.DependsOn(PrepareGitHubArtifacts)
.Requires(() => Framework)
Expand All @@ -110,6 +120,7 @@ void DotNetWriteVersionInfoProps()
Log.Information($"Running DotNet tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (OS fonts)");
DotNetTasks.DotNetRun(t => t
.SetProcessWorkingDirectory(RootDirectory / "test" / "dotnet" / "AlphaSkia.Test")
.SetProperty("AlphaSkiaTestVersion", DotNetVersion)
.SetRuntime(TargetOperatingSystem.Current.DotNetRid + "-" +
(Architecture ?? Architecture.Current))
.SetFramework(Framework)
Expand All @@ -119,6 +130,7 @@ void DotNetWriteVersionInfoProps()
Log.Information($"Running DotNet tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (FreeType fonts)");
DotNetTasks.DotNetRun(t => t
.SetProcessWorkingDirectory(RootDirectory / "test" / "dotnet" / "AlphaSkia.Test")
.SetProperty("AlphaSkiaTestVersion", DotNetVersion)
.SetRuntime(TargetOperatingSystem.Current.DotNetRid + "-" +
(Architecture ?? Architecture.Current))
.SetFramework(Framework)
Expand All @@ -129,6 +141,7 @@ void DotNetWriteVersionInfoProps()

[Parameter] [Secret] readonly string NugetApiKey = GetVariable<string>("NUGET_API_KEY");

[PublicAPI]
public Target DotNetPublish => t => t
.DependsOn(PrepareGitHubArtifacts)
.Requires(() => IsGitHubActions)
Expand Down
2 changes: 2 additions & 0 deletions build/Build.Java.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void JavaBuildInternal()
workingDirectory: RootDirectory / "lib" / "java");
}

[PublicAPI]
public Target JavaTest => t => t
.DependsOn(PrepareGitHubArtifacts)
.Executes(() =>
Expand Down Expand Up @@ -146,6 +147,7 @@ string JavaVersion
}
}

[PublicAPI]
public Target JavaPublish => t => t
.DependsOn(PrepareGitHubArtifacts)
.Executes(() =>
Expand Down
11 changes: 7 additions & 4 deletions build/Build.LibAlphaSkia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ partial class Build
"../../wrapper/src/alphaskia_canvas.cpp",
"../../wrapper/src/alphaskia_image.cpp",
"../../wrapper/src/alphaskia_typeface.cpp",
"../../wrapper/src/alphaskia_textstyle.cpp",
"../../wrapper/src/alphaskia_data.cpp",
"../../wrapper/src/alphaskia_string.cpp"
]
Expand Down Expand Up @@ -156,6 +157,7 @@ partial class Build
"../../lib/java/jni/src/AlphaSkiaCanvas.cpp",
"../../lib/java/jni/src/AlphaSkiaData.cpp",
"../../lib/java/jni/src/AlphaSkiaImage.cpp",
"../../lib/java/jni/src/AlphaSkiaTextStyle.cpp",
"../../lib/java/jni/src/AlphaSkiaTypeface.cpp"
]
}
Expand Down Expand Up @@ -356,14 +358,14 @@ void CopyBuildOutputTo(AbsolutePath path)
{
// libs
outDir.Copy(path,
ExistsPolicy.MergeAndOverwriteIfNewer,
ExistsPolicy.MergeAndOverwrite,
null,
file => !libExtensions.Contains(file.Extension)
);
// copy header
(RootDirectory / "wrapper" / "include" / "alphaskia.h").Copy(
DistBasePath / "include" / "alphaskia" / "alphaskia.h",
ExistsPolicy.MergeAndOverwriteIfNewer
ExistsPolicy.MergeAndOverwrite
);
}

Expand Down Expand Up @@ -415,13 +417,13 @@ void BuildAlphaSkiaTest()
// copy for artifacts
var distPath = DistBasePath / libDir;
var exePath = outDir / (buildTarget + exeExtension);
exePath.Copy(distPath / exePath.Name, ExistsPolicy.MergeAndOverwriteIfNewer);
exePath.Copy(distPath / exePath.Name, ExistsPolicy.MergeAndOverwrite);

// copy shared lib beside executable
var libExtensions = new HashSet<string>(GetLibExtensions(Variant), StringComparer.OrdinalIgnoreCase);
foreach (var file in sharedLibPath.GetFiles().Where(f => libExtensions.Contains(f.Extension)))
{
file.Copy(outDir / file.Name, ExistsPolicy.MergeAndOverwriteIfNewer);
file.Copy(outDir / file.Name, ExistsPolicy.MergeAndOverwrite);
}

// run executable
Expand All @@ -439,6 +441,7 @@ void BuildAlphaSkiaTest()
"--freetype",
workingDirectory: outDir
);

}
else
{
Expand Down
91 changes: 73 additions & 18 deletions build/Build.LibSkia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ partial class Build
"third_party/externals/zlib",
"third_party/externals/wuffs",
"third_party/externals/vulkanmemoryallocator",
"third_party/externals/libgrapheme",
"third_party/externals/icu",
"third_party/externals/unicodetools",

// Android font manager
"third_party/externals/expat"
Expand Down Expand Up @@ -63,7 +66,7 @@ partial class Build

if (LibSkiaSkip.Value)
{
DistBasePath.Copy(ArtifactBasePath, ExistsPolicy.MergeAndOverwriteIfNewer);
DistBasePath.Copy(ArtifactBasePath, ExistsPolicy.MergeAndOverwrite);
}
else
{
Expand All @@ -87,9 +90,32 @@ partial class Build
.After(LibSkiaGitSyncDeps)
.Executes(() =>
{

// add harfbuzz and freetype as dependency as we want it for alphaSkia
var buildFile = SkiaPath / "BUILD.gn";
var buildFileSource = buildFile.ReadAllText();


var skiaGniStart = buildFileSource.IndexOf("import(\"gn/skia.gni\")", StringComparison.Ordinal);
if (skiaGniStart == -1)
{
throw new IOException("BUILD.gn of skia changed, cannot patch files");
}

var skiaGniEnd = buildFileSource.IndexOf("\n", skiaGniStart, StringComparison.Ordinal);
if (skiaGniEnd == -1)
{
throw new IOException("BUILD.gn of skia changed, cannot patch files");
}

buildFileSource = buildFileSource[..skiaGniEnd]
+ "import(\"modules/skparagraph/skparagraph.gni\")\n"
+ "import(\"third_party/icu/icu.gni\")\n"
+ "import(\"modules/skunicode/skunicode.gni\")\n"
+ "import(\"modules/skshaper/skshaper.gni\")\n"
+ buildFileSource[skiaGniEnd..];


var skiaComponentStart = buildFileSource.IndexOf("skia_component(\"skia\")", StringComparison.Ordinal);
if (skiaComponentStart == -1)
{
Expand All @@ -114,8 +140,8 @@ partial class Build
if (!depsList.Contains("//third_party/harfbuzz"))
{
var newDepsList = depsList.TrimEnd('\r', '\n', '\t', ' ', ',')
+ ", \"//third_party/harfbuzz\", \"//third_party/freetype2\", "
;
+ ", \"//third_party/harfbuzz\", \"//third_party/freetype2\", skia_libgrapheme_third_party_dir, skia_icu_bidi_third_party_dir"
;
buildFileSource = buildFileSource[..depsListStart]
+ newDepsList
+ buildFileSource[depsListEnd..];
Expand All @@ -135,22 +161,15 @@ partial class Build
}

var sources = buildFileSource.Substring(sourcesStart, sourcesEnd);
if (!sources.Contains("# AlphaSkia Patch FreeType"))
if (!sources.Contains("# AlphaSkia Patch FreeType and SkParagraph"))
{
var newSources = "# AlphaSkia Patch FreeType\n";
var newSources = "# AlphaSkia Patch FreeType and SkParagraph\n";
// ensure we have freetype available
newSources += " include_dirs = [ \"externals/freetype/include\" ]\n";
newSources += " sources += [\n";
newSources += " \"src/ports/SkFontHost_FreeType.cpp\",\n";
newSources += " \"src/ports/SkFontHost_FreeType_common.cpp\",\n";
newSources += " \"src/ports/SkFontHost_FreeType_common.h\",\n";
newSources += " ]\n";
newSources += " sources += skia_ports_freetype_sources\n";
// ensure we have the custom embedded FontMgr available (for in-memory freetype usage)
newSources += " sources += [\n";
newSources += " \"src/ports/SkFontMgr_custom.h\",\n";
newSources += " \"src/ports/SkFontMgr_custom.cpp\",\n";
newSources += " \"src/ports/SkFontMgr_custom_embedded.cpp\",\n";
newSources += " ]\n";
newSources += " sources += skia_ports_fontmgr_embedded_sources\n";
newSources += " sources += skia_ports_fontmgr_custom_sources\n";
// ensure we have the OS specific font managers available
newSources += " if (is_win) {\n";
newSources += " sources += skia_ports_windows_fonts_sources\n";
Expand Down Expand Up @@ -181,6 +200,38 @@ partial class Build
newSources += " sources += skia_ports_fontmgr_coretext_sources\n";
newSources += " }\n";
newSources += " ";

// Directly add some submodules to the main skia lib

// SkShaper
newSources += " defines += [ \"SK_SHAPER_HARFBUZZ_AVAILABLE\", \"SK_SHAPER_UNICODE_AVAILABLE\", \"SKSHAPER_IMPLEMENTATION=1\" ]\n";
newSources += " sources += skia_shaper_primitive_sources\n";
newSources += " sources += skia_shaper_skunicode_sources\n";
newSources += " sources += skia_shaper_harfbuzz_sources\n";
newSources += " public += skia_unicode_public\n";

// SkUnicode
newSources += " defines += [\"SK_UNICODE_AVAILABLE\", \"SKUNICODE_IMPLEMENTATION=1\", \"SK_UNICODE_LIBGRAPHEME_IMPLEMENTATION\" ]\n";
newSources += " configs += [\"//third_party/icu/config:no_cxx\"]\n";

newSources += " sources += skia_unicode_sources\n";
newSources += " sources += skia_unicode_icu_bidi_sources\n";
newSources += " sources += skia_unicode_bidi_subset_sources\n";
newSources += " sources += skia_unicode_libgrapheme_sources\n";
newSources += " public += skia_unicode_public\n";
newSources += " defines += [\n";
newSources += " \"U_DISABLE_RENAMING=0\",\n";
newSources += " \"U_USING_ICU_NAMESPACE=0\",\n";
newSources += " \"U_LIB_SUFFIX_C_NAME=_skia\",\n";
newSources += " \"U_HAVE_LIB_SUFFIX=1\",\n";
newSources += " \"U_DISABLE_VERSION_SUFFIX=1\",\n";
newSources += " ]\n";

// SkParagraph
newSources += " defines += [ \"SK_ENABLE_PARAGRAPH\" ]\n";
newSources += " sources += skparagraph_sources\n";
newSources += " public += skparagraph_public\n";

newSources += " sources += [\n";
newSources += " \"../../wrapper/src/SkFontMgr_alphaskia.cpp\",\n";
newSources += " \"../../wrapper/include/SkFontMgr_alphaskia.h\",\n";
Expand All @@ -203,8 +254,8 @@ partial class Build
newSources += " }\n";

buildFileSource = buildFileSource[..sourcesEnd]
+ newSources
+ buildFileSource[sourcesEnd..];
+ newSources
+ buildFileSource[sourcesEnd..];
}

buildFile.WriteAllText(buildFileSource);
Expand Down Expand Up @@ -253,7 +304,11 @@ void BuildSkia()
gnArgs["skia_use_icu"] = "false";
gnArgs["skia_use_piex"] = "false";
gnArgs["skia_use_sfntly"] = "false";
gnArgs["skia_use_libgrapheme"] = "true";
gnArgs["skia_enable_skshaper"] = "true";
gnArgs["skia_enable_skparagraph"] = "true";
gnArgs["skia_enable_skunicode"] = "true";
gnArgs["skia_use_harfbuzz"] = "true";
gnArgs["skia_pdf_subset_harfbuzz"] = "false";
gnArgs["skia_enable_pdf"] = "false";
gnArgs["skia_use_dng_sdk"] = "false";
Expand Down Expand Up @@ -285,7 +340,7 @@ void BuildSkia()
void CopyBuildOutputTo(AbsolutePath path)
{
// libs
outDir.Copy(path, ExistsPolicy.MergeAndOverwriteIfNewer, null,
outDir.Copy(path, ExistsPolicy.MergeAndOverwrite, null,
file => !libExtension.Contains(file.Extension));
}

Expand Down
6 changes: 3 additions & 3 deletions build/Build.Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ partial class Build

foreach (var tgz in (RootDirectory / "lib" / "node").GetFiles("*.tgz", int.MaxValue))
{
tgz.Copy(RootDirectory / "dist" / "nodetars" / tgz.Name, ExistsPolicy.MergeAndOverwriteIfNewer);
tgz.Copy(RootDirectory / "dist" / "nodetars" / tgz.Name, ExistsPolicy.MergeAndOverwrite);
}

PrepareTgzForTest();
Expand All @@ -72,7 +72,7 @@ void PrepareTgzForTest()
+ tgz.Extension;

tgz.Copy(RootDirectory / "dist" / "nodetars" / nameWithoutVersion,
ExistsPolicy.MergeAndOverwriteIfNewer);
ExistsPolicy.MergeAndOverwrite);
files.Add(nameWithoutVersion);
}

Expand Down Expand Up @@ -215,7 +215,7 @@ void CopyNodeAddonsToPackages()
}

subDirectory.Copy(RootDirectory / "lib" / "node" / packageName / "lib" / subDirectory.Name,
ExistsPolicy.MergeAndOverwriteIfNewer, null, fi => fi.Extension != ".node");
ExistsPolicy.MergeAndOverwrite, null, fi => fi.Extension != ".node");
}
}

Expand Down
14 changes: 7 additions & 7 deletions lib/dotnet/AlphaSkia/AlphaSkiaCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,31 +281,31 @@ public void Stroke()
/// Fills a text with the current color and provided details.
/// </summary>
/// <param name="text">The text to draw.</param>
/// <param name="typeface">The typeface to use for drawing the text.</param>
/// <param name="textStyle">The text style to use for drawing the text.</param>
/// <param name="fontSize">The font size to use when drawing the text.</param>
/// <param name="x">The X-position where to draw the text to.</param>
/// <param name="y">The Y-position where to draw the text to.</param>
/// <param name="textAlign">How to align the text at the given position horizontally.</param>
/// <param name="baseline">How to align the text at the given position vertically.</param>
public void FillText(string text, AlphaSkiaTypeface typeface, float fontSize, float x, float y,
public void FillText(string text, AlphaSkiaTextStyle textStyle, float fontSize, float x, float y,
AlphaSkiaTextAlign textAlign,
AlphaSkiaTextBaseline baseline)
{
CheckDisposed();
NativeMethods.alphaskia_canvas_fill_text(Handle, text, text.Length, typeface.Handle, fontSize, x, y, textAlign, baseline);
NativeMethods.alphaskia_canvas_fill_text(Handle, text, text.Length, textStyle.Handle, fontSize, x, y, textAlign, baseline);
}

/// <summary>
/// Measures the given text.
/// </summary>
/// <param name="text">The text to measure.</param>
/// <param name="typeface">The typeface to use for drawing the text.</param>
/// <param name="fontSize">The font size to use when drawing the text.</param>
/// <param name="textStyle">The text style to use for measuring the text.</param>
/// <param name="fontSize">The font size to use when measuring the text.</param>
/// <returns>The horizontal width of the text when it would be drawn.</returns>
public float MeasureText(string text, AlphaSkiaTypeface typeface, float fontSize)
public float MeasureText(string text, AlphaSkiaTextStyle textStyle, float fontSize)
{
CheckDisposed();
return NativeMethods.alphaskia_canvas_measure_text(Handle, text, text.Length, typeface.Handle, fontSize);
return NativeMethods.alphaskia_canvas_measure_text(Handle, text, text.Length, textStyle.Handle, fontSize);
}

/// <summary>
Expand Down
Loading
Loading