Skip to content

Commit

Permalink
Code generator (#25)
Browse files Browse the repository at this point in the history
* Code generator

* New source files

* Fixed tests

* Add SkiaDemo for testing

* Build and run generator seperately in vscode debug settings

* Generate fields in FT_Generic_ struct

* Move FreeTypeSharp/Native to FreeTypeSharp/Generated

* Update result filename

* Generate extra functions and structs

* Bump version

* Include .pdb files in nuget package

* Generate FT_Kerning_Mode_

* Add FreeTypeSharp/FreeTypeCalc.cs back

* Add FT.Constants.cs back; rename DllMap.cs to FT.DllMap.cs
  • Loading branch information
ryancheung authored Apr 14, 2024
1 parent 6d1564a commit cd61a6b
Show file tree
Hide file tree
Showing 141 changed files with 2,277 additions and 2,533 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,6 @@ Network Trash Folder
Temporary Items
.apdisk

# Project
.vscode

# Cake
.cake

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "freetype"]
path = freetype
url = [email protected]:ryancheung/freetype.git
47 changes: 47 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "Launch Code Generator (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildGenerator",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/FreeTypeSharp.Generator/bin/Debug/net8.0/FreeTypeSharp.Generator.dll",
"args": [
"-o${workspaceFolder}/FreeTypeSharp/Generated",
"-f${workspaceFolder}/FreeTypeSharp.Generator/main.h",
"-i${workspaceFolder}/freetype/include",
"-nFreeTypeSharp"
],
"cwd": "${workspaceFolder}/FreeTypeSharp.Generator/bin/Debug/net8.0",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "Launch SkiaDemo (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/FreeTypeSharp.SkiaDemo/bin/Debug/net8.0/FreeTypeSharp.SkiaDemo.dll",
"args": [],
"cwd": "${workspaceFolder}/FreeTypeSharp.SkiaDemo/bin/Debug/net8.0",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/FreeTypeSharp.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "buildGenerator",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/FreeTypeSharp.Generator/FreeTypeSharp.Generator.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
</PropertyGroup>

Expand Down
10 changes: 5 additions & 5 deletions FreeTypeSharp.Android.Test/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
using Android.Runtime;
using Android.Widget;
using System;
using FreeTypeSharp;
using static FreeTypeSharp.Native.FT;
using static FreeTypeSharp.FT;

namespace FreeTypeSharp.Android.Test
{
[Activity(Label = "@string/app_name", MainLauncher = true)]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
protected unsafe override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);

// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);

var textView1 = FindViewById<TextView>(Resource.Id.textView1);
var textView1 = FindViewById<TextView>(Resource.Id.textView1);

var library = new FreeTypeLibrary();
FT_Library_Version(library.Native, out var major, out var minor, out var patch);
int major, minor, patch;
FT_Library_Version(library.Native, &major, &minor, &patch);
textView1.Text = $"FreeType version: {major}.{minor}.{patch}";
}
}
Expand Down
1 change: 1 addition & 0 deletions FreeTypeSharp.Core.Test/FreeTypeSharp.Core.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions FreeTypeSharp.Core.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System;
using static FreeTypeSharp.Native.FT;
using static FreeTypeSharp.FT;

namespace FreeTypeSharp.Core.Test
{
class Program
{
static void Main(string[] args)
unsafe static void Main(string[] args)
{
var library = new FreeTypeLibrary();
FT_Library_Version(library.Native, out var major, out var minor, out var patch);
int major, minor, patch;
FT_Library_Version(library.Native, &major, &minor, &patch);
Console.WriteLine($"FreeType version: {major}.{minor}.{patch}");
}
}
Expand Down
17 changes: 17 additions & 0 deletions FreeTypeSharp.Generator/FreeTypeSharp.Generator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="CppSharp" Version="1.1.5.3168" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
</ItemGroup>

</Project>
Loading

0 comments on commit cd61a6b

Please sign in to comment.