├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .gitmodules
├── .vscode
├── launch.json
└── tasks.json
├── FreeTypeSharp.Android.Test
├── AndroidManifest.xml
├── FreeTypeSharp.Android.Test.csproj
├── MainActivity.cs
└── Resources
│ ├── AboutResources.txt
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ ├── ic_launcher_foreground.png
│ └── ic_launcher_round.png
│ └── values
│ ├── ic_launcher_background.xml
│ └── strings.xml
├── FreeTypeSharp.Core.Test
├── FreeTypeSharp.Core.Test.csproj
└── Program.cs
├── FreeTypeSharp.Generator
├── FreeTypeSharp.Generator.csproj
├── Program.cs
└── main.h
├── FreeTypeSharp.SkiaDemo
├── FreeTypeSharp.SkiaDemo.csproj
└── Program.cs
├── FreeTypeSharp.iOS.Test
├── AppDelegate.cs
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon1024.png
│ │ ├── Icon120.png
│ │ ├── Icon152.png
│ │ ├── Icon167.png
│ │ ├── Icon180.png
│ │ ├── Icon20.png
│ │ ├── Icon29.png
│ │ ├── Icon40.png
│ │ ├── Icon58.png
│ │ ├── Icon60.png
│ │ ├── Icon76.png
│ │ ├── Icon80.png
│ │ └── Icon87.png
├── Entitlements.plist
├── FreeTypeSharp.iOS.Test.csproj
├── Info.plist
├── LaunchScreen.storyboard
├── Main.cs
├── Resources
│ └── LaunchScreen.xib
└── SceneDelegate.cs
├── FreeTypeSharp.sln
├── FreeTypeSharp
├── DummyApiDefinition.cs
├── FT.Constants.cs
├── FT.DllMap.cs
├── FreeTypeCalc.cs
├── FreeTypeException.cs
├── FreeTypeFaceFacade.cs
├── FreeTypeLibrary.cs
├── FreeTypeSharp.UWP.csproj
├── FreeTypeSharp.csproj
└── Generated
│ ├── FT.cs
│ ├── FTC_CMapCacheRec_.cs
│ ├── FTC_ImageCacheRec_.cs
│ ├── FTC_ImageTypeRec_.cs
│ ├── FTC_ManagerRec_.cs
│ ├── FTC_NodeRec_.cs
│ ├── FTC_SBitCacheRec_.cs
│ ├── FTC_SBitRec_.cs
│ ├── FTC_ScalerRec_.cs
│ ├── FT_BBox_.cs
│ ├── FT_Bitmap_.cs
│ ├── FT_Bitmap_Size_.cs
│ ├── FT_COLR_Paint_.cs
│ ├── FT_CharMapRec_.cs
│ ├── FT_ClipBox_.cs
│ ├── FT_ColorIndex_.cs
│ ├── FT_ColorStopIterator_.cs
│ ├── FT_ColorStop_.cs
│ ├── FT_Color_.cs
│ ├── FT_Color_Root_Transform_.cs
│ ├── FT_DriverRec_.cs
│ ├── FT_Encoding_.cs
│ ├── FT_Error.cs
│ ├── FT_FACE_FLAG.cs
│ ├── FT_FaceRec_.cs
│ ├── FT_Face_InternalRec_.cs
│ ├── FT_Generic_.cs
│ ├── FT_GlyphRec_.cs
│ ├── FT_GlyphSlotRec_.cs
│ ├── FT_Glyph_Class_.cs
│ ├── FT_Glyph_Format_.cs
│ ├── FT_Glyph_Metrics_.cs
│ ├── FT_Kerning_Mode_.cs
│ ├── FT_LOAD.cs
│ ├── FT_LayerIterator_.cs
│ ├── FT_LibraryRec_.cs
│ ├── FT_ListNodeRec_.cs
│ ├── FT_ListRec_.cs
│ ├── FT_Matrix_.cs
│ ├── FT_MemoryRec_.cs
│ ├── FT_ModuleRec_.cs
│ ├── FT_Module_Class_.cs
│ ├── FT_Opaque_Paint_.cs
│ ├── FT_Open_Args_.cs
│ ├── FT_Orientation_.cs
│ ├── FT_Outline_.cs
│ ├── FT_Outline_Funcs_.cs
│ ├── FT_Palette_Data_.cs
│ ├── FT_Parameter_.cs
│ ├── FT_Pixel_Mode_.cs
│ ├── FT_Raster_Params_.cs
│ ├── FT_Render_Mode_.cs
│ ├── FT_RendererRec_.cs
│ ├── FT_STYLE_FLAG.cs
│ ├── FT_SizeRec_.cs
│ ├── FT_Size_InternalRec_.cs
│ ├── FT_Size_Metrics_.cs
│ ├── FT_Size_RequestRec_.cs
│ ├── FT_Size_Request_Type_.cs
│ ├── FT_Slot_InternalRec_.cs
│ ├── FT_StreamDesc_.cs
│ ├── FT_StreamRec_.cs
│ ├── FT_StrokerBorder_.cs
│ ├── FT_StrokerRec_.cs
│ ├── FT_Stroker_LineCap_.cs
│ ├── FT_Stroker_LineJoin_.cs
│ ├── FT_SubGlyphRec_.cs
│ ├── FT_TrueTypeEngineType_.cs
│ └── FT_Vector_.cs
├── LICENSE.txt
├── README.md
└── runtimes
└── FreeType2
├── android
├── arm64-v8a
│ └── libfreetype.so
├── armeabi-v7a
│ └── libfreetype.so
├── x86
│ └── libfreetype.so
└── x86_64
│ └── libfreetype.so
├── ios
└── FreeType2.xcframework
│ ├── Info.plist
│ ├── ios-arm64
│ └── libfreetype.a
│ └── ios-arm64_x86_64-simulator
│ └── libfreetype.a
├── linux-x64
└── libfreetype.so
├── osx
└── libfreetype.dylib
├── tvos
└── FreeType2.xcframework
│ ├── Info.plist
│ ├── tvos-arm64
│ └── libfreetype.a
│ └── tvos-arm64_x86_64-simulator
│ └── libfreetype.a
├── win-arm64
└── freetype.dll
├── win-x64
└── freetype.dll
├── win-x86
└── freetype.dll
├── win10-arm64
└── freetype.dll
├── win10-x64
└── freetype.dll
└── win10-x86
└── freetype.dll
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on: [push,pull_request]
4 |
5 | jobs:
6 | Build:
7 | runs-on: macos-latest
8 |
9 | steps:
10 | - name: Checkout
11 | uses: actions/checkout@v4
12 |
13 | - name: Install dotnet workloads
14 | run: dotnet workload install android ios tvos
15 |
16 | - name: Build
17 | run: dotnet pack FreeTypeSharp/FreeTypeSharp.csproj
18 |
19 | - uses: actions/upload-artifact@v4
20 | with:
21 | name: ${{ github.event.repository.name }} Artifacts
22 | path: |
23 | FreeTypeSharp/bin/Release/*.nupkg
24 |
25 | BuildUWP:
26 | runs-on: windows-latest
27 |
28 | steps:
29 | - name: Checkout
30 | uses: actions/checkout@v4
31 |
32 | - name: Add msbuild to PATH
33 | uses: microsoft/setup-msbuild@v2
34 |
35 | - name: Build
36 | run: msbuild FreeTypeSharp/FreeTypeSharp.UWP.csproj -t:Restore,Pack /property:Configuration=Release
37 |
38 | - uses: actions/upload-artifact@v4
39 | with:
40 | name: ${{ github.event.repository.name }} UWP Artifacts
41 | path: |
42 | FreeTypeSharp/bin/Release/*.nupkg
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Tools pulled down during build
16 | .tools/
17 | .dotnet/
18 | .packages/
19 |
20 | # Build results
21 | [Dd]ebug/
22 | [Dd]ebugPublic/
23 | [Rr]elease/
24 | [Rr]eleases/
25 | x64/
26 | x86/
27 | bld/
28 | [Bb]in/
29 | [Oo]bj/
30 | [Ll]og/
31 |
32 | # Visual Studio 2015/2017 cache/options directory
33 | .vs/
34 | # Uncomment if you have tasks that create the project's static files in wwwroot
35 | #wwwroot/
36 |
37 | # Visual Studio 2017 auto generated files
38 | Generated\ Files/
39 |
40 | # MSTest test Results
41 | [Tt]est[Rr]esult*/
42 | [Bb]uild[Ll]og.*
43 |
44 | # NUNIT
45 | *.VisualState.xml
46 | TestResult.xml
47 |
48 | # Build Results of an ATL Project
49 | [Dd]ebugPS/
50 | [Rr]eleasePS/
51 | dlldata.c
52 |
53 | # Benchmark Results
54 | BenchmarkDotNet.Artifacts/
55 |
56 | # .NET Core
57 | project.lock.json
58 | project.fragment.lock.json
59 | artifacts/
60 | .dotnet/
61 |
62 | # StyleCop
63 | StyleCopReport.xml
64 |
65 | # Files built by Visual Studio
66 | *_i.c
67 | *_p.c
68 | *_i.h
69 | *.ilk
70 | *.meta
71 | *.obj
72 | *.iobj
73 | *.pch
74 | *.pdb
75 | *.ipdb
76 | *.pgc
77 | *.pgd
78 | *.rsp
79 | *.sbr
80 | *.tlb
81 | *.tli
82 | *.tlh
83 | *.tmp
84 | *.tmp_proj
85 | *.log
86 | *.vspscc
87 | *.vssscc
88 | .builds
89 | *.pidb
90 | *.svclog
91 | *.scc
92 |
93 | # Chutzpah Test files
94 | _Chutzpah*
95 |
96 | # Visual C++ cache files
97 | ipch/
98 | *.aps
99 | *.ncb
100 | *.opendb
101 | *.opensdf
102 | *.sdf
103 | *.cachefile
104 | *.VC.db
105 | *.VC.VC.opendb
106 |
107 | # Visual Studio profiler
108 | *.psess
109 | *.vsp
110 | *.vspx
111 | *.sap
112 |
113 | # Visual Studio Trace Files
114 | *.e2e
115 |
116 | # TFS 2012 Local Workspace
117 | $tf/
118 |
119 | # Guidance Automation Toolkit
120 | *.gpState
121 |
122 | # ReSharper is a .NET coding add-in
123 | _ReSharper*/
124 | *.[Rr]e[Ss]harper
125 | *.DotSettings.user
126 |
127 | # JustCode is a .NET coding add-in
128 | .JustCode
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # Visual Studio Code
145 | .vscode/*
146 | !.vscode/settings.json
147 | !.vscode/tasks.json
148 | !.vscode/launch.json
149 | !.vscode/extensions.json
150 |
151 | # NCrunch
152 | _NCrunch_*
153 | .*crunch*.local.xml
154 | nCrunchTemp_*
155 |
156 | # MightyMoose
157 | *.mm.*
158 | AutoTest.Net/
159 |
160 | # Web workbench (sass)
161 | .sass-cache/
162 |
163 | # Installshield output folder
164 | [Ee]xpress/
165 |
166 | # DocProject is a documentation generator add-in
167 | DocProject/buildhelp/
168 | DocProject/Help/*.HxT
169 | DocProject/Help/*.HxC
170 | DocProject/Help/*.hhc
171 | DocProject/Help/*.hhk
172 | DocProject/Help/*.hhp
173 | DocProject/Help/Html2
174 | DocProject/Help/html
175 |
176 | # Click-Once directory
177 | publish/
178 |
179 | # Publish Web Output
180 | *.[Pp]ublish.xml
181 | *.azurePubxml
182 | # Note: Comment the next line if you want to checkin your web deploy settings,
183 | # but database connection strings (with potential passwords) will be unencrypted
184 | *.pubxml
185 | *.publishproj
186 |
187 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
188 | # checkin your Azure Web App publish settings, but sensitive information contained
189 | # in these scripts will be unencrypted
190 | PublishScripts/
191 |
192 | # NuGet Packages
193 | *.nupkg
194 | # The packages folder can be ignored because of Package Restore
195 | **/[Pp]ackages/*
196 | # except build/, which is used as an MSBuild target.
197 | !**/[Pp]ackages/build/
198 | # Uncomment if necessary however generally it will be regenerated when needed
199 | #!**/[Pp]ackages/repositories.config
200 | # NuGet v3's project.json files produces more ignorable files
201 | *.nuget.props
202 | *.nuget.targets
203 |
204 | # Microsoft Azure Build Output
205 | csx/
206 | *.build.csdef
207 |
208 | # Microsoft Azure Emulator
209 | ecf/
210 | rcf/
211 |
212 | # Windows Store app package directories and files
213 | AppPackages/
214 | BundleArtifacts/
215 | Package.StoreAssociation.xml
216 | _pkginfo.txt
217 | *.appx
218 |
219 | # Visual Studio cache files
220 | # files ending in .cache can be ignored
221 | *.[Cc]ache
222 | # but keep track of directories ending in .cache
223 | !*.[Cc]ache/
224 |
225 | # Others
226 | ClientBin/
227 | ~$*
228 | *~
229 | *.dbmdl
230 | *.dbproj.schemaview
231 | *.jfm
232 | *.pfx
233 | *.publishsettings
234 | orleans.codegen.cs
235 |
236 | # Including strong name files can present a security risk
237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
238 | #*.snk
239 |
240 | # Since there are multiple workflows, uncomment next line to ignore bower_components
241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
242 | #bower_components/
243 |
244 | # RIA/Silverlight projects
245 | Generated_Code/
246 |
247 | # Backup & report files from converting an old project file
248 | # to a newer Visual Studio version. Backup files are not needed,
249 | # because we have git ;-)
250 | _UpgradeReport_Files/
251 | Backup*/
252 | UpgradeLog*.XML
253 | UpgradeLog*.htm
254 | ServiceFabricBackup/
255 | *.rptproj.bak
256 |
257 | # SQL Server files
258 | *.mdf
259 | *.ldf
260 | *.ndf
261 |
262 | # Business Intelligence projects
263 | *.rdl.data
264 | *.bim.layout
265 | *.bim_*.settings
266 | *.rptproj.rsuser
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # JetBrains Rider
303 | .idea/
304 | *.sln.iml
305 |
306 | # CodeRush
307 | .cr/
308 |
309 | # Python Tools for Visual Studio (PTVS)
310 | __pycache__/
311 | *.pyc
312 |
313 | # Cake - Uncomment if you are using it
314 | # tools/**
315 | # !tools/packages.config
316 |
317 | # Tabs Studio
318 | *.tss
319 |
320 | # Telerik's JustMock configuration file
321 | *.jmconfig
322 |
323 | # BizTalk build output
324 | *.btp.cs
325 | *.btm.cs
326 | *.odx.cs
327 | *.xsd.cs
328 |
329 | # OpenCover UI analysis results
330 | OpenCover/
331 |
332 | # Azure Stream Analytics local run output
333 | ASALocalRun/
334 |
335 | # MSBuild Binary and Structured Log
336 | *.binlog
337 |
338 | # NVidia Nsight GPU debugger configuration file
339 | *.nvuser
340 |
341 | # MFractors (Xamarin productivity tool) working folder
342 | .mfractor/
343 |
344 | ### OSX ###
345 |
346 | # General
347 | .DS_Store
348 | .AppleDouble
349 | .LSOverride
350 |
351 | # Icon must end with two \r
352 | Icon
353 |
354 |
355 | # Thumbnails
356 | ._*
357 |
358 | # Files that might appear in the root of a volume
359 | .DocumentRevisions-V100
360 | .fseventsd
361 | .Spotlight-V100
362 | .TemporaryItems
363 | .Trashes
364 | .VolumeIcon.icns
365 | .com.apple.timemachine.donotpresent
366 |
367 | # Directories potentially created on remote AFP share
368 | .AppleDB
369 | .AppleDesktop
370 | Network Trash Folder
371 | Temporary Items
372 | .apdisk
373 |
374 | # Cake
375 | .cake
376 |
377 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "freetype"]
2 | path = freetype
3 | url = git@github.com:ryancheung/freetype.git
4 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | // Use IntelliSense to find out which attributes exist for C# debugging
6 | // Use hover for the description of the existing attributes
7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
8 | "name": "Launch Code Generator (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "buildGenerator",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/FreeTypeSharp.Generator/bin/Debug/net8.0/FreeTypeSharp.Generator.dll",
14 | "args": [
15 | "-o${workspaceFolder}/FreeTypeSharp/Generated",
16 | "-f${workspaceFolder}/FreeTypeSharp.Generator/main.h",
17 | "-i${workspaceFolder}/freetype/include",
18 | "-nFreeTypeSharp"
19 | ],
20 | "cwd": "${workspaceFolder}/FreeTypeSharp.Generator/bin/Debug/net8.0",
21 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
22 | "console": "internalConsole",
23 | "stopAtEntry": false
24 | },
25 | {
26 | // Use IntelliSense to find out which attributes exist for C# debugging
27 | // Use hover for the description of the existing attributes
28 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
29 | "name": "Launch SkiaDemo (console)",
30 | "type": "coreclr",
31 | "request": "launch",
32 | "preLaunchTask": "build",
33 | // If you have changed target frameworks, make sure to update the program path.
34 | "program": "${workspaceFolder}/FreeTypeSharp.SkiaDemo/bin/Debug/net8.0/FreeTypeSharp.SkiaDemo.dll",
35 | "args": [],
36 | "cwd": "${workspaceFolder}/FreeTypeSharp.SkiaDemo/bin/Debug/net8.0",
37 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
38 | "console": "internalConsole",
39 | "stopAtEntry": false
40 | },
41 | {
42 | "name": ".NET Core Attach",
43 | "type": "coreclr",
44 | "request": "attach"
45 | }
46 | ]
47 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/FreeTypeSharp.sln",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "buildGenerator",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "build",
22 | "${workspaceFolder}/FreeTypeSharp.Generator/FreeTypeSharp.Generator.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | ]
29 | }
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/FreeTypeSharp.Android.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0-android
4 | 21
5 | true
6 | Exe
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.OS;
3 | using Android.Runtime;
4 | using Android.Widget;
5 | using System;
6 | using static FreeTypeSharp.FT;
7 |
8 | namespace FreeTypeSharp.Android.Test
9 | {
10 | [Activity(Label = "@string/app_name", MainLauncher = true)]
11 | public class MainActivity : Activity
12 | {
13 | protected unsafe override void OnCreate(Bundle savedInstanceState)
14 | {
15 | base.OnCreate(savedInstanceState);
16 |
17 | // Set our view from the "main" layout resource
18 | SetContentView(Resource.Layout.activity_main);
19 |
20 | var textView1 = FindViewById(Resource.Id.textView1);
21 |
22 | var library = new FreeTypeLibrary();
23 | int major, minor, patch;
24 | FT_Library_Version(library.Native, &major, &minor, &patch);
25 | textView1.Text = $"FreeType version: {major}.{minor}.{patch}";
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.xml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable/
12 | icon.png
13 |
14 | layout/
15 | main.xml
16 |
17 | values/
18 | strings.xml
19 |
20 | In order to get the build system to recognize Android resources, set the build action to
21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
22 | instead operate on resource IDs. When you compile an Android application that uses resources,
23 | the build system will package the resources for distribution and generate a class called "Resource"
24 | (this is an Android convention) that contains the tokens for each one of the resources
25 | included. For example, for the above Resources layout, this is what the Resource class would expose:
26 |
27 | public class Resource {
28 | public class Drawable {
29 | public const int icon = 0x123;
30 | }
31 |
32 | public class Layout {
33 | public const int main = 0x456;
34 | }
35 |
36 | public class Strings {
37 | public const int first_string = 0xabc;
38 | public const int second_string = 0xbcd;
39 | }
40 | }
41 |
42 | You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or
43 | Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string
44 | to reference the first string in the dictionary file values/strings.xml.
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
14 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.Android.Test/Resources/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #2C3E50
4 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Android.Test/Resources/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FreeTypeSharp.Android.Test
3 | Hello, Android!
4 |
5 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Core.Test/FreeTypeSharp.Core.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Core.Test/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using static FreeTypeSharp.FT;
3 |
4 | namespace FreeTypeSharp.Core.Test
5 | {
6 | class Program
7 | {
8 | unsafe static void Main(string[] args)
9 | {
10 | var library = new FreeTypeLibrary();
11 | int major, minor, patch;
12 | FT_Library_Version(library.Native, &major, &minor, &patch);
13 | Console.WriteLine($"FreeType version: {major}.{minor}.{patch}");
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Generator/FreeTypeSharp.Generator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | disable
7 | disable
8 | en
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/FreeTypeSharp.Generator/Program.cs:
--------------------------------------------------------------------------------
1 | using System.CommandLine;
2 | using CppSharp;
3 | using CppSharp.AST;
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.CSharp;
6 | using Microsoft.CodeAnalysis.CSharp.Syntax;
7 | using System.Collections.Generic;
8 | using System.IO;
9 | using System.Linq;
10 |
11 | namespace FreeTypeSharp.Generator
12 | {
13 | public class Program
14 | {
15 | private static Dictionary primitiveTypes = new Dictionary()
16 | {
17 | { PrimitiveType.Int,"int"},
18 | { PrimitiveType.Long,"IntPtr"},
19 | { PrimitiveType.Float,"float"},
20 | { PrimitiveType.Double,"double"},
21 | { PrimitiveType.Bool,"bool"},
22 | { PrimitiveType.String,"string"},
23 | { PrimitiveType.ULong,"UIntPtr" },
24 | { PrimitiveType.UInt,"uint" },
25 | { PrimitiveType.Void,"void" },
26 | { PrimitiveType.UChar,"byte" },
27 | { PrimitiveType.UShort,"ushort" },
28 | { PrimitiveType.Short,"short" },
29 | { PrimitiveType.SChar,"sbyte" },
30 | { PrimitiveType.Char,"byte" },
31 | { PrimitiveType.ULongLong,"ulong" },
32 | { PrimitiveType.LongLong,"long" }
33 | };
34 |
35 | private static Dictionary classes= new Dictionary();
36 | private static Dictionary enumerations = new Dictionary();
37 | private static Dictionary enumerationBaseTypeOverrides = new Dictionary();
38 | private static Dictionary predefinedEnumerations = new Dictionary();
39 | private static Dictionary typeOverrides = new Dictionary();
40 |
41 | static string OutputDir = "";
42 | static string HeaderFile = "";
43 | static string IncludePath = "";
44 | static string OutNamespace = "";
45 |
46 | public static int Main(string[] args)
47 | {
48 | var rootCommand = new RootCommand("FreeTypeSharp Code Generator");
49 | var outputDirOption = new Option(
50 | new string[] { "--output", "-o" },
51 | getDefaultValue: () => "out",
52 | description: "Output directory");
53 | rootCommand.AddOption(outputDirOption);
54 | var headerFileOption = new Option(
55 | new string[] { "--file", "-f" },
56 | getDefaultValue: () => "",
57 | description: "Header file path");
58 | rootCommand.AddOption(headerFileOption);
59 | var includeDirOption = new Option(
60 | new string[] { "--include", "-i" },
61 | getDefaultValue: () => "",
62 | description: "Include directory");
63 | rootCommand.AddOption(includeDirOption);
64 | var namespaceOption = new Option(
65 | new string[] { "--namespace", "-n" },
66 | getDefaultValue: () => "",
67 | description: "Out namespace");
68 | rootCommand.AddOption(namespaceOption);
69 |
70 | rootCommand.SetHandler((outputDir, headerFile, includeDir, ns) =>
71 | {
72 | OutputDir = outputDir;
73 | HeaderFile = headerFile;
74 | IncludePath = includeDir;
75 | OutNamespace = ns;
76 | }, outputDirOption, headerFileOption, includeDirOption, namespaceOption);
77 |
78 | rootCommand.Invoke(args);
79 |
80 | var parserOptions = new CppSharp.Parser.ParserOptions();
81 | parserOptions.AddIncludeDirs(IncludePath);
82 | parserOptions.Setup(TargetPlatform.Windows);
83 | parserOptions.LanguageVersion = CppSharp.Parser.LanguageVersion.C99_GNU;
84 |
85 | var parseResult = ClangParser.ParseSourceFiles(
86 | new[] {
87 | HeaderFile
88 | }, parserOptions);
89 |
90 | Directory.CreateDirectory(OutputDir);
91 | foreach (var file in Directory.GetFiles(OutputDir).Where(t => t.EndsWith(".cs")))
92 | File.Delete(file);
93 |
94 | for (uint i = 0; i != parseResult.DiagnosticsCount; i++)
95 | {
96 | var diagnostic = parseResult.GetDiagnostics(i);
97 | }
98 | var context = ClangParser.ConvertASTContext(parserOptions.ASTContext);
99 |
100 | InitTypes(context);
101 |
102 | var namespaceNameSyntax = SyntaxFactory.IdentifierName(OutNamespace);
103 |
104 | var rootSyntax = SyntaxFactory.NamespaceDeclaration(
105 | namespaceNameSyntax,
106 | default,
107 | new SyntaxList().Add(SyntaxFactory.UsingDirective(SyntaxFactory.IdentifierName("System.Runtime.InteropServices")))
108 | .Add(SyntaxFactory.UsingDirective(SyntaxFactory.IdentifierName("System"))),
109 | default);
110 |
111 | var classSyntax = SyntaxFactory.ClassDeclaration("FT");
112 | classSyntax = classSyntax.AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword));
113 | classSyntax = classSyntax.AddModifiers(SyntaxFactory.Token(SyntaxKind.UnsafeKeyword));
114 | classSyntax = classSyntax.AddModifiers(SyntaxFactory.Token(SyntaxKind.StaticKeyword));
115 | classSyntax = classSyntax.AddModifiers(SyntaxFactory.Token(SyntaxKind.PartialKeyword));
116 |
117 |
118 | var attributesArgsList = new SeparatedSyntaxList();
119 | attributesArgsList = attributesArgsList.Add(
120 | SyntaxFactory.AttributeArgument(SyntaxFactory.ParseExpression("LibName")));
121 | attributesArgsList = attributesArgsList.Add(
122 | SyntaxFactory.AttributeArgument(SyntaxFactory.ParseExpression("CallingConvention = CallingConvention.Cdecl")));
123 |
124 |
125 | var dllImportAttribute = SyntaxFactory.Attribute(
126 | SyntaxFactory.IdentifierName("DllImport"),
127 | SyntaxFactory.AttributeArgumentList(attributesArgsList)
128 | );
129 |
130 | var funcSyntaxTypes = new List();
131 |
132 | using (var fileWriter = new StreamWriter(File.OpenWrite($"{OutputDir}/FT.cs")))
133 | {
134 | foreach (var translationUnit in context.TranslationUnits)
135 | {
136 | foreach (var _func in translationUnit.Functions)
137 | {
138 | if (_func.Name == "FTC_Manager_New") // Skip method has function pointer parameter
139 | continue;
140 | var modifiers = new SyntaxTokenList();
141 | modifiers = modifiers.Add(SyntaxFactory.Token(SyntaxKind.PublicKeyword));
142 | modifiers = modifiers.Add(SyntaxFactory.Token(SyntaxKind.StaticKeyword));
143 | modifiers = modifiers.Add(SyntaxFactory.Token(SyntaxKind.ExternKeyword));
144 |
145 | var attributes = new SyntaxList();
146 | attributes = attributes.Add(SyntaxFactory.AttributeList(new SeparatedSyntaxList().Add(dllImportAttribute)));
147 | var parameters = new SeparatedSyntaxList();
148 |
149 | foreach (var parameter in _func.Parameters)
150 | {
151 | TypeSyntax paramType;
152 | if (typeOverrides.ContainsKey(parameter.Name))
153 | paramType = GetTypeSyntax(context, new TagType()
154 | {
155 | Declaration = typeOverrides[parameter.Name]
156 | });
157 | else
158 | paramType = GetTypeSyntax(context, parameter.Type);
159 | if (parameter.Name == "params")
160 | parameter.Name = "@params";
161 | parameters = parameters.Add(SyntaxFactory.Parameter(default, default, paramType, SyntaxFactory.Identifier(parameter.Name), default));
162 | }
163 |
164 | var returnTypeSyntax = GetTypeSyntax(context, _func.ReturnType.Type);
165 | var funcSyntax = SyntaxFactory.MethodDeclaration(
166 | attributes,
167 | modifiers,
168 | returnTypeSyntax,
169 | null,
170 | SyntaxFactory.Identifier(_func.Name),
171 | null,
172 | SyntaxFactory.ParameterList(parameters),
173 | default,
174 | null,
175 | SyntaxFactory.Token(SyntaxKind.SemicolonToken));
176 |
177 |
178 | funcSyntaxTypes.Add(funcSyntax);
179 | }
180 | }
181 |
182 | classSyntax = classSyntax.AddMembers(funcSyntaxTypes.ToArray());
183 | rootSyntax = rootSyntax.AddMembers(classSyntax);
184 | fileWriter.Write(rootSyntax.NormalizeWhitespace().ToFullString());
185 | }
186 |
187 | System.Console.WriteLine("All done, code are saved to {0}", OutputDir);
188 |
189 | return 0;
190 | }
191 |
192 | private static List registeredTypes = new List();
193 | private static TypeSyntax GetTypeSyntax(ASTContext context, Type type)
194 | {
195 | var typedefType = type as TypedefType;
196 | var pointerType = type as PointerType;
197 | var builtInType = type as BuiltinType;
198 | var tagType = type as TagType;
199 | var functionType = type as FunctionType;
200 |
201 | if (typedefType != null)
202 | {
203 | if (typedefType.Declaration.Name == "FT_Error")
204 | return GetTypeSyntax(context, new TagType()
205 | {
206 | Declaration = new Enumeration()
207 | {
208 | Name = "FT_Error"
209 | }
210 | });
211 | return GetTypeSyntax(context, typedefType.Declaration.Type);
212 | }
213 |
214 | if (pointerType != null)
215 | return SyntaxFactory.PointerType(GetTypeSyntax(context, pointerType.Pointee));
216 |
217 | if (builtInType != null)
218 | return SyntaxFactory.ParseTypeName(primitiveTypes[builtInType.Type]);
219 |
220 | if (tagType != null)
221 | {
222 | if (!registeredTypes.Contains(tagType.Declaration.Name))
223 | RegisterType(context, tagType.Declaration.Name);
224 |
225 | return SyntaxFactory.ParseTypeName(tagType.Declaration.Name);
226 | }
227 |
228 | if (functionType != null)
229 | {
230 | return SyntaxFactory.ParseTypeName("void"); // use void* for function pointers
231 |
232 | //var parameters = new SeparatedSyntaxList();
233 |
234 | //foreach (var parameter in functionType.Parameters)
235 | // parameters = parameters.Add(SyntaxFactory.FunctionPointerParameter(GetTypeSyntax(context, parameter.Type)));
236 |
237 | //return SyntaxFactory.FunctionPointerType(
238 | // SyntaxFactory.FunctionPointerCallingConvention(SyntaxFactory.Token(SyntaxKind.UnmanagedKeyword)),
239 | // SyntaxFactory.FunctionPointerParameterList(parameters)
240 | // );
241 | }
242 |
243 | throw new System.Exception("type not handled");
244 | }
245 |
246 | private static void InitTypes(ASTContext context)
247 | {
248 | foreach (var translationUnit in context.TranslationUnits)
249 | {
250 | foreach (var _class in translationUnit.Classes)
251 | {
252 | classes.Add(_class.Name, _class);
253 | }
254 | }
255 |
256 | enumerationBaseTypeOverrides.Add("FT_Pixel_Mode_", new BuiltinType() { Type = PrimitiveType.UChar });
257 |
258 | var errCount = 0;
259 | foreach (var translationUnit in context.TranslationUnits)
260 | {
261 | foreach (var _enum in translationUnit.Enums)
262 | {
263 | if (_enum.Name == "")
264 | {
265 | if (errCount == 0)
266 | enumerations.Add($"", _enum);
267 | else
268 | {
269 | _enum.Name = "FT_Error";
270 | enumerations.Add("FT_Error", _enum);
271 | }
272 | errCount++;
273 | }
274 | else
275 | {
276 | if(enumerationBaseTypeOverrides.ContainsKey(_enum.Name))
277 | {
278 | _enum.Type = enumerationBaseTypeOverrides[_enum.Name];
279 | }
280 | enumerations.Add(_enum.Name, _enum);
281 | }
282 | }
283 | }
284 |
285 | AddPreprocessedEnumeration(context, "FT_LOAD", "FT_LOAD_TARGET");
286 | AddPreprocessedEnumeration(context, "FT_FACE_FLAG");
287 | AddPreprocessedEnumeration(context, "FT_STYLE_FLAG");
288 | AddPreprocessedEnumeration(context, "FT_Kerning_Mode_");
289 |
290 | typeOverrides.Add("load_flags", predefinedEnumerations["FT_LOAD"]);
291 | typeOverrides.Add("face_flags", predefinedEnumerations["FT_FACE_FLAG"]);
292 | typeOverrides.Add("style_flags", predefinedEnumerations["FT_STYLE_FLAG"]);
293 | typeOverrides.Add("pixel_mode", enumerations["FT_Pixel_Mode_"]);
294 | typeOverrides.Add("kern_mode", predefinedEnumerations["FT_Kerning_Mode_"]);
295 | }
296 |
297 | private static void AddPreprocessedEnumeration(ASTContext context, string startsWith, string notStartsWith = default)
298 | {
299 | if (!predefinedEnumerations.ContainsKey(startsWith))
300 | {
301 | var definations = new Dictionary();
302 | foreach (var translationUnit in context.TranslationUnits)
303 | {
304 | foreach (var _preprocessed in translationUnit.PreprocessedEntities)
305 | {
306 | var macroDefination = _preprocessed as MacroDefinition;
307 | if (macroDefination != default)
308 | {
309 | if (notStartsWith != default)
310 | {
311 | if (macroDefination.Name.StartsWith(startsWith) && !macroDefination.Name.StartsWith(notStartsWith))
312 | definations.Add(macroDefination.Name, macroDefination.Expression.Replace("L", ""));
313 | }
314 | else
315 | {
316 | if (macroDefination.Name.StartsWith(startsWith))
317 | definations.Add(macroDefination.Name, macroDefination.Expression.Replace("L", ""));
318 | }
319 | }
320 | }
321 | }
322 |
323 | predefinedEnumerations.Add(startsWith, new Enumeration()
324 | {
325 | Name = startsWith,
326 | Type = new BuiltinType() { Type = PrimitiveType.Int },
327 | Items = definations.Select(t => new Enumeration.Item() { Name = t.Key, Expression = t.Value }).ToList()
328 | });
329 | }
330 | }
331 |
332 | private static void RegisterType(ASTContext context, string typeName)
333 | {
334 | registeredTypes.Add(typeName);
335 |
336 | if (classes.ContainsKey(typeName))
337 | {
338 | var _class = classes[typeName];
339 | using (var fileWriter = new StreamWriter(File.OpenWrite($"{OutputDir}/{_class.Name}.cs")))
340 | {
341 | var namespaceNameSyntax = SyntaxFactory.IdentifierName(OutNamespace);
342 |
343 | var rootSyntax = SyntaxFactory.NamespaceDeclaration(
344 | namespaceNameSyntax,
345 | default,
346 | new SyntaxList().Add(SyntaxFactory.UsingDirective(SyntaxFactory.IdentifierName("System.Runtime.InteropServices")))
347 | .Add(SyntaxFactory.UsingDirective(SyntaxFactory.IdentifierName("System"))),
348 | default);
349 | var attribute = SyntaxFactory.Attribute(
350 | SyntaxFactory.IdentifierName("StructLayout"),
351 | SyntaxFactory.AttributeArgumentList(
352 | new SeparatedSyntaxList().Add(
353 | SyntaxFactory.AttributeArgument(SyntaxFactory.ParseExpression("LayoutKind.Sequential")))));
354 |
355 | var _struct = SyntaxFactory.StructDeclaration(_class.Name);
356 | _struct = _struct.AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword));
357 | _struct = _struct.AddModifiers(SyntaxFactory.Token(SyntaxKind.UnsafeKeyword));
358 | _struct = _struct.AddAttributeLists(SyntaxFactory.AttributeList(new SeparatedSyntaxList().Add(attribute)));
359 | foreach (var field in _class.Fields)
360 | {
361 | switch (typeName)
362 | {
363 | // Skip structs having unsupported fields, like union and function pointers
364 | case "FT_COLR_Paint_":
365 | continue;
366 | default:
367 | break;
368 | }
369 |
370 | TypeSyntax typeSyntax;
371 | if (typeOverrides.ContainsKey(field.Name))
372 | {
373 | typeSyntax = GetTypeSyntax(context, new TagType()
374 | {
375 | Declaration = typeOverrides[field.Name]
376 | });
377 | // These fields types should not be override
378 | if (field.Name == "face_flags" || field.Name == "style_flags")
379 | {
380 | typeSyntax = GetTypeSyntax(context, field.Type);
381 | }
382 | }
383 | else
384 | typeSyntax = GetTypeSyntax(context, field.Type);
385 | var variablesList = new SeparatedSyntaxList();
386 | var name = field.Name;
387 | if (name == "internal" || name == "base" || name == "params")
388 | name = "_" + name;
389 | variablesList = variablesList.Add(SyntaxFactory.VariableDeclarator(name));
390 | var fieldDeclaration = SyntaxFactory.FieldDeclaration(SyntaxFactory.VariableDeclaration(typeSyntax, variablesList));
391 |
392 | fieldDeclaration = fieldDeclaration.AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword));
393 | _struct = _struct.AddMembers(fieldDeclaration);
394 | }
395 |
396 | rootSyntax = rootSyntax.AddMembers(_struct);
397 |
398 | fileWriter.Write(rootSyntax.NormalizeWhitespace().ToFullString());
399 | }
400 | }
401 | else if (enumerations.ContainsKey(typeName))
402 | {
403 | var _enum = enumerations[typeName];
404 |
405 | if (string.IsNullOrEmpty(_enum.Name))
406 | _enum.Name = "FT_Mod_Err";
407 |
408 | using (var fileWriter = new StreamWriter(File.OpenWrite($"{OutputDir}/{_enum.Name}.cs")))
409 | {
410 | var namespaceNameSyntax = SyntaxFactory.IdentifierName(OutNamespace);
411 | var root = SyntaxFactory.NamespaceDeclaration(namespaceNameSyntax);
412 | var type = _enum.Type as BuiltinType;
413 |
414 | var _enumDeclaration = SyntaxFactory.EnumDeclaration(_enum.Name);
415 | _enumDeclaration = _enumDeclaration.AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword));
416 | _enumDeclaration = _enumDeclaration.WithBaseList(
417 | SyntaxFactory.BaseList(
418 | new SeparatedSyntaxList().Add(SyntaxFactory.SimpleBaseType(GetTypeSyntax(context, type)))));
419 |
420 | foreach (var item in _enum.Items)
421 | {
422 | var _enumMemberDeclaration = SyntaxFactory.EnumMemberDeclaration(item.Name);
423 | _enumMemberDeclaration = _enumMemberDeclaration.WithEqualsValue(
424 | SyntaxFactory.EqualsValueClause(SyntaxFactory.ParseExpression(item.Value.ToString())));
425 | _enumDeclaration = _enumDeclaration.AddMembers(_enumMemberDeclaration);
426 | }
427 |
428 | root = root.AddMembers(_enumDeclaration);
429 |
430 | fileWriter.Write(root.NormalizeWhitespace().ToFullString());
431 | }
432 | }
433 | else if (predefinedEnumerations.ContainsKey(typeName))
434 | {
435 | var _enum = predefinedEnumerations[typeName];
436 | using (var fileWriter = new StreamWriter(File.OpenWrite($"{OutputDir}/{_enum.Name}.cs")))
437 | {
438 | var namespaceNameSyntax = SyntaxFactory.IdentifierName(OutNamespace);
439 | var root = SyntaxFactory.NamespaceDeclaration(namespaceNameSyntax);
440 | var type = _enum.Type as BuiltinType;
441 |
442 | var _enumDeclaration = SyntaxFactory.EnumDeclaration(_enum.Name);
443 | _enumDeclaration = _enumDeclaration.AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword));
444 | _enumDeclaration = _enumDeclaration.WithBaseList(
445 | SyntaxFactory.BaseList(
446 | new SeparatedSyntaxList().Add(SyntaxFactory.SimpleBaseType(GetTypeSyntax(context, type)))));
447 |
448 | foreach (var item in _enum.Items)
449 | {
450 | var _enumMemberDeclaration = SyntaxFactory.EnumMemberDeclaration(item.Name);
451 | _enumMemberDeclaration = _enumMemberDeclaration.WithEqualsValue(
452 | SyntaxFactory.EqualsValueClause(SyntaxFactory.ParseExpression(item.Expression)));
453 | _enumDeclaration = _enumDeclaration.AddMembers(_enumMemberDeclaration);
454 | }
455 |
456 | root = root.AddMembers(_enumDeclaration);
457 |
458 | fileWriter.Write(root.NormalizeWhitespace().ToFullString());
459 | }
460 | }
461 | else
462 | {
463 | throw new System.Exception("not supproted type");
464 | }
465 | }
466 | }
467 | }
--------------------------------------------------------------------------------
/FreeTypeSharp.Generator/main.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include FT_FREETYPE_H
3 | #include FT_OUTLINE_H
4 | #include FT_SIZES_H
5 | #include FT_RENDER_H
6 | #include FT_GLYPH_H
7 | #include FT_BITMAP_H
8 | #include FT_BBOX_H
9 | #include FT_CACHE_H
10 | #include FT_STROKER_H
11 | #include FT_SYNTHESIS_H
12 | #include FT_TRIGONOMETRY_H
13 | #include FT_GASP_H
14 | #include FT_ADVANCES_H
--------------------------------------------------------------------------------
/FreeTypeSharp.SkiaDemo/FreeTypeSharp.SkiaDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0
6 | enable
7 | enable
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/FreeTypeSharp.SkiaDemo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using SkiaSharp;
4 | using SixLabors.Fonts;
5 | using System.Runtime.InteropServices;
6 | using System.Globalization;
7 |
8 | namespace FreeTypeSharp.Demo
9 | {
10 | public class Program
11 | {
12 | static string? GetSystemFont(string fontName)
13 | {
14 | FontFamily search = new();
15 | bool found = false;
16 | foreach (var fontFamily in SystemFonts.Families)
17 | {
18 | if (fontFamily.Name == fontName)
19 | {
20 | search = fontFamily;
21 | found = true;
22 | }
23 | else
24 | {
25 | if (fontFamily.TryGetMetrics(FontStyle.Regular, out var metrics))
26 | {
27 | if (metrics.Description.FontName(CultureInfo.CurrentCulture) == fontName)
28 | {
29 | search = fontFamily;
30 | found = true;
31 | }
32 | }
33 | }
34 | }
35 |
36 | if (found)
37 | {
38 | var font = search.CreateFont(0, FontStyle.Regular);
39 | if (font.TryGetPath(out var path))
40 | return path;
41 | }
42 |
43 | return null;
44 | }
45 | unsafe static void Main(string[] args)
46 | {
47 | var library = new FreeTypeLibrary();
48 | FT_FaceRec_* face;
49 |
50 | var fontPath = GetSystemFont("Microsoft Sans Serif");
51 | var error = FT.FT_New_Face(library.Native, (byte*)Marshal.StringToHGlobalAnsi(fontPath), 0, &face);
52 | error = FT.FT_Set_Char_Size(face, 0, 16 * 64, 300, 300);
53 | var glyphIndex = FT.FT_Get_Char_Index(face, 'я');
54 | error = FT.FT_Load_Glyph(face, glyphIndex, FT_LOAD.FT_LOAD_DEFAULT);
55 | error = FT.FT_Render_Glyph(face->glyph, FT_Render_Mode_.FT_RENDER_MODE_NORMAL);
56 | var bitmap = face->glyph->bitmap;
57 |
58 | var skBitmap = new SKBitmap((int)bitmap.width, (int)bitmap.rows);
59 | var canvas = new SKCanvas(skBitmap);
60 |
61 | for (var i = 0; i != bitmap.width; i++)
62 | {
63 | for (var j = 0; j != bitmap.rows; j++)
64 | {
65 | canvas.DrawPoint(new SKPoint(i, j), new SKColor(bitmap.buffer[j*bitmap.pitch+i], bitmap.buffer[j * bitmap.pitch + i], bitmap.buffer[j * bitmap.pitch + i], bitmap.buffer[j * bitmap.pitch + i]));
66 | }
67 | }
68 |
69 | using(var fileStream = File.OpenWrite("Test.jpg"))
70 | {
71 | using (var wstream = new SKManagedWStream(fileStream))
72 | {
73 | skBitmap.Encode(wstream, SKEncodedImageFormat.Png, 100);
74 | }
75 | }
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 | using UIKit;
3 | using static FreeTypeSharp.FT;
4 |
5 | namespace FreeTypeSharp.iOS.Test {
6 | [Register ("AppDelegate")]
7 | public class AppDelegate : UIApplicationDelegate {
8 | public override UIWindow Window {
9 | get;
10 | set;
11 | }
12 |
13 | public unsafe override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
14 | {
15 | // create a new window instance based on the screen size
16 | Window = new UIWindow (UIScreen.MainScreen.Bounds);
17 |
18 | var library = new FreeTypeLibrary();
19 | int major, minor, patch;
20 | FT_Library_Version(library.Native, &major, &minor, &patch);
21 |
22 | // create a UIViewController with a single UILabel
23 | var vc = new UIViewController ();
24 | vc.View.AddSubview (new UILabel (Window.Frame) {
25 | BackgroundColor = UIColor.White,
26 | TextAlignment = UITextAlignment.Center,
27 | Text = "Hello, iOS!" + $" FreeType version: {major}.{minor}.{patch}"
28 | });
29 | Window.RootViewController = vc;
30 |
31 | // make the window visible
32 | Window.MakeKeyAndVisible ();
33 |
34 | return true;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "scale": "2x",
5 | "size": "20x20",
6 | "idiom": "iphone",
7 | "filename": "Icon40.png"
8 | },
9 | {
10 | "scale": "3x",
11 | "size": "20x20",
12 | "idiom": "iphone",
13 | "filename": "Icon60.png"
14 | },
15 | {
16 | "scale": "2x",
17 | "size": "29x29",
18 | "idiom": "iphone",
19 | "filename": "Icon58.png"
20 | },
21 | {
22 | "scale": "3x",
23 | "size": "29x29",
24 | "idiom": "iphone",
25 | "filename": "Icon87.png"
26 | },
27 | {
28 | "scale": "2x",
29 | "size": "40x40",
30 | "idiom": "iphone",
31 | "filename": "Icon80.png"
32 | },
33 | {
34 | "scale": "3x",
35 | "size": "40x40",
36 | "idiom": "iphone",
37 | "filename": "Icon120.png"
38 | },
39 | {
40 | "scale": "2x",
41 | "size": "60x60",
42 | "idiom": "iphone",
43 | "filename": "Icon120.png"
44 | },
45 | {
46 | "scale": "3x",
47 | "size": "60x60",
48 | "idiom": "iphone",
49 | "filename": "Icon180.png"
50 | },
51 | {
52 | "scale": "1x",
53 | "size": "20x20",
54 | "idiom": "ipad",
55 | "filename": "Icon20.png"
56 | },
57 | {
58 | "scale": "2x",
59 | "size": "20x20",
60 | "idiom": "ipad",
61 | "filename": "Icon40.png"
62 | },
63 | {
64 | "scale": "1x",
65 | "size": "29x29",
66 | "idiom": "ipad",
67 | "filename": "Icon29.png"
68 | },
69 | {
70 | "scale": "2x",
71 | "size": "29x29",
72 | "idiom": "ipad",
73 | "filename": "Icon58.png"
74 | },
75 | {
76 | "scale": "1x",
77 | "size": "40x40",
78 | "idiom": "ipad",
79 | "filename": "Icon40.png"
80 | },
81 | {
82 | "scale": "2x",
83 | "size": "40x40",
84 | "idiom": "ipad",
85 | "filename": "Icon80.png"
86 | },
87 | {
88 | "scale": "1x",
89 | "size": "76x76",
90 | "idiom": "ipad",
91 | "filename": "Icon76.png"
92 | },
93 | {
94 | "scale": "2x",
95 | "size": "76x76",
96 | "idiom": "ipad",
97 | "filename": "Icon152.png"
98 | },
99 | {
100 | "scale": "2x",
101 | "size": "83.5x83.5",
102 | "idiom": "ipad",
103 | "filename": "Icon167.png"
104 | },
105 | {
106 | "scale": "1x",
107 | "size": "1024x1024",
108 | "idiom": "ios-marketing",
109 | "filename": "Icon1024.png"
110 | }
111 | ],
112 | "properties": {},
113 | "info": {
114 | "version": 1,
115 | "author": "xcode"
116 | }
117 | }
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon1024.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon120.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon152.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon167.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon180.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon20.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon29.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon40.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon58.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon60.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon76.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon80.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/FreeTypeSharp.iOS.Test/Assets.xcassets/AppIcon.appiconset/Icon87.png
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/FreeTypeSharp.iOS.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0-ios
4 | 11.0
5 | iossimulator-x64
6 | Exe
7 | SdkOnly
8 | true
9 | <_ExportSymbolsExplicitly>false
10 | -gcc_flags "-dlsym:false"
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDisplayName
6 | FreeTypeSharp.iOS.Test
7 | CFBundleIdentifier
8 | com.companyname.FreeTypeSharp.iOS.Test
9 | CFBundleShortVersionString
10 | 1.0
11 | CFBundleVersion
12 | 1.0
13 | LSRequiresIPhoneOS
14 |
15 | MinimumOSVersion
16 | 11.0
17 | UIDeviceFamily
18 |
19 | 1
20 | 2
21 |
22 | UILaunchStoryboardName
23 | LaunchScreen
24 | UIRequiredDeviceCapabilities
25 |
26 | armv7
27 |
28 | UISupportedInterfaceOrientations
29 |
30 | UIInterfaceOrientationPortrait
31 | UIInterfaceOrientationLandscapeLeft
32 | UIInterfaceOrientationLandscapeRight
33 |
34 | UISupportedInterfaceOrientations~ipad
35 |
36 | UIInterfaceOrientationPortrait
37 | UIInterfaceOrientationPortraitUpsideDown
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | XSAppIconAssets
42 | Assets.xcassets/AppIcon.appiconset
43 |
44 |
45 |
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Main.cs:
--------------------------------------------------------------------------------
1 | using UIKit;
2 | using System;
3 |
4 | namespace FreeTypeSharp.iOS.Test {
5 | public class Application {
6 | // This is the main entry point of the application.
7 | static void Main (string [] args)
8 | {
9 | // if you want to use a different Application Delegate class from "AppDelegate"
10 | // you can specify it here.
11 | UIApplication.Main (args, null, "AppDelegate");
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/Resources/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/FreeTypeSharp.iOS.Test/SceneDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Foundation;
3 | using UIKit;
4 |
5 | namespace FreeTypeSharp.iOS.Test {
6 | [Register ("SceneDelegate")]
7 | public class SceneDelegate : UIResponder, IUIWindowSceneDelegate {
8 |
9 | [Export ("window")]
10 | public UIWindow Window { get; set; }
11 |
12 | [Export ("scene:willConnectToSession:options:")]
13 | public void WillConnect (UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
14 | {
15 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
16 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
17 | // This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate `GetConfiguration` instead).
18 | }
19 |
20 | [Export ("sceneDidDisconnect:")]
21 | public void DidDisconnect (UIScene scene)
22 | {
23 | // Called as the scene is being released by the system.
24 | // This occurs shortly after the scene enters the background, or when its session is discarded.
25 | // Release any resources associated with this scene that can be re-created the next time the scene connects.
26 | // The scene may re-connect later, as its session was not neccessarily discarded (see UIApplicationDelegate `DidDiscardSceneSessions` instead).
27 | }
28 |
29 | [Export ("sceneDidBecomeActive:")]
30 | public void DidBecomeActive (UIScene scene)
31 | {
32 | // Called when the scene has moved from an inactive state to an active state.
33 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
34 | }
35 |
36 | [Export ("sceneWillResignActive:")]
37 | public void WillResignActive (UIScene scene)
38 | {
39 | // Called when the scene will move from an active state to an inactive state.
40 | // This may occur due to temporary interruptions (ex. an incoming phone call).
41 | }
42 |
43 | [Export ("sceneWillEnterForeground:")]
44 | public void WillEnterForeground (UIScene scene)
45 | {
46 | // Called as the scene transitions from the background to the foreground.
47 | // Use this method to undo the changes made on entering the background.
48 | }
49 |
50 | [Export ("sceneDidEnterBackground:")]
51 | public void DidEnterBackground (UIScene scene)
52 | {
53 | // Called as the scene transitions from the foreground to the background.
54 | // Use this method to save data, release shared resources, and store enough scene-specific state information
55 | // to restore the scene back to its current state.
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/FreeTypeSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30114.105
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeTypeSharp", "FreeTypeSharp\FreeTypeSharp.csproj", "{C2173775-7553-43AB-84BE-4B656D05C709}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeTypeSharp.Core.Test", "FreeTypeSharp.Core.Test\FreeTypeSharp.Core.Test.csproj", "{4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeTypeSharp.iOS.Test", "FreeTypeSharp.iOS.Test\FreeTypeSharp.iOS.Test.csproj", "{BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeTypeSharp.Android.Test", "FreeTypeSharp.Android.Test\FreeTypeSharp.Android.Test.csproj", "{916577B7-E0D2-45EC-B51C-A07AEA97C0F9}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeTypeSharp.Generator", "FreeTypeSharp.Generator\FreeTypeSharp.Generator.csproj", "{B94334B4-904F-401C-840E-EB52A62A1F5F}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeTypeSharp.SkiaDemo", "FreeTypeSharp.SkiaDemo\FreeTypeSharp.SkiaDemo.csproj", "{4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Debug|x64 = Debug|x64
22 | Debug|x86 = Debug|x86
23 | Release|Any CPU = Release|Any CPU
24 | Release|x64 = Release|x64
25 | Release|x86 = Release|x86
26 | EndGlobalSection
27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
28 | {C2173775-7553-43AB-84BE-4B656D05C709}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {C2173775-7553-43AB-84BE-4B656D05C709}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {C2173775-7553-43AB-84BE-4B656D05C709}.Debug|x64.ActiveCfg = Debug|Any CPU
31 | {C2173775-7553-43AB-84BE-4B656D05C709}.Debug|x64.Build.0 = Debug|Any CPU
32 | {C2173775-7553-43AB-84BE-4B656D05C709}.Debug|x86.ActiveCfg = Debug|Any CPU
33 | {C2173775-7553-43AB-84BE-4B656D05C709}.Debug|x86.Build.0 = Debug|Any CPU
34 | {C2173775-7553-43AB-84BE-4B656D05C709}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {C2173775-7553-43AB-84BE-4B656D05C709}.Release|Any CPU.Build.0 = Release|Any CPU
36 | {C2173775-7553-43AB-84BE-4B656D05C709}.Release|x64.ActiveCfg = Release|Any CPU
37 | {C2173775-7553-43AB-84BE-4B656D05C709}.Release|x64.Build.0 = Release|Any CPU
38 | {C2173775-7553-43AB-84BE-4B656D05C709}.Release|x86.ActiveCfg = Release|Any CPU
39 | {C2173775-7553-43AB-84BE-4B656D05C709}.Release|x86.Build.0 = Release|Any CPU
40 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Debug|x64.ActiveCfg = Debug|Any CPU
43 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Debug|x64.Build.0 = Debug|Any CPU
44 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Debug|x86.ActiveCfg = Debug|Any CPU
45 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Debug|x86.Build.0 = Debug|Any CPU
46 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Release|Any CPU.Build.0 = Release|Any CPU
48 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Release|x64.ActiveCfg = Release|Any CPU
49 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Release|x64.Build.0 = Release|Any CPU
50 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Release|x86.ActiveCfg = Release|Any CPU
51 | {4B0EA95A-687B-4D89-82FC-AB5F62AAF78C}.Release|x86.Build.0 = Release|Any CPU
52 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Debug|x64.ActiveCfg = Debug|Any CPU
55 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Debug|x64.Build.0 = Debug|Any CPU
56 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Debug|x86.ActiveCfg = Debug|Any CPU
57 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Debug|x86.Build.0 = Debug|Any CPU
58 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
59 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Release|Any CPU.Build.0 = Release|Any CPU
60 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Release|x64.ActiveCfg = Release|Any CPU
61 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Release|x64.Build.0 = Release|Any CPU
62 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Release|x86.ActiveCfg = Release|Any CPU
63 | {BA6BC6CE-C469-4D0A-8E2A-0F6EEB405FAC}.Release|x86.Build.0 = Release|Any CPU
64 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
66 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
67 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|x64.ActiveCfg = Debug|Any CPU
68 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|x64.Build.0 = Debug|Any CPU
69 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|x64.Deploy.0 = Debug|Any CPU
70 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|x86.ActiveCfg = Debug|Any CPU
71 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|x86.Build.0 = Debug|Any CPU
72 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Debug|x86.Deploy.0 = Debug|Any CPU
73 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
74 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|Any CPU.Build.0 = Release|Any CPU
75 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|Any CPU.Deploy.0 = Release|Any CPU
76 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|x64.ActiveCfg = Release|Any CPU
77 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|x64.Build.0 = Release|Any CPU
78 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|x64.Deploy.0 = Release|Any CPU
79 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|x86.ActiveCfg = Release|Any CPU
80 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|x86.Build.0 = Release|Any CPU
81 | {916577B7-E0D2-45EC-B51C-A07AEA97C0F9}.Release|x86.Deploy.0 = Release|Any CPU
82 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
84 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Debug|x64.ActiveCfg = Debug|Any CPU
85 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Debug|x64.Build.0 = Debug|Any CPU
86 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Debug|x86.ActiveCfg = Debug|Any CPU
87 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Debug|x86.Build.0 = Debug|Any CPU
88 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
89 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Release|Any CPU.Build.0 = Release|Any CPU
90 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Release|x64.ActiveCfg = Release|Any CPU
91 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Release|x64.Build.0 = Release|Any CPU
92 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Release|x86.ActiveCfg = Release|Any CPU
93 | {B94334B4-904F-401C-840E-EB52A62A1F5F}.Release|x86.Build.0 = Release|Any CPU
94 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
96 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Debug|x64.ActiveCfg = Debug|Any CPU
97 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Debug|x64.Build.0 = Debug|Any CPU
98 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Debug|x86.ActiveCfg = Debug|Any CPU
99 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Debug|x86.Build.0 = Debug|Any CPU
100 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
101 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Release|Any CPU.Build.0 = Release|Any CPU
102 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Release|x64.ActiveCfg = Release|Any CPU
103 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Release|x64.Build.0 = Release|Any CPU
104 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Release|x86.ActiveCfg = Release|Any CPU
105 | {4A9BCD45-6E9F-41CB-93CC-9F91E51311F1}.Release|x86.Build.0 = Release|Any CPU
106 | EndGlobalSection
107 | GlobalSection(SolutionProperties) = preSolution
108 | HideSolutionNode = FALSE
109 | EndGlobalSection
110 | GlobalSection(ExtensibilityGlobals) = postSolution
111 | SolutionGuid = {1DC6E40B-728F-4D0E-AC79-F6DA26CA79BF}
112 | EndGlobalSection
113 | EndGlobal
114 |
--------------------------------------------------------------------------------
/FreeTypeSharp/DummyApiDefinition.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | }
4 |
--------------------------------------------------------------------------------
/FreeTypeSharp/FT.Constants.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | static partial class FT
4 | {
5 | // glyph load target flags
6 | public const int FT_LOAD_TARGET_NORMAL = (0 & 15) << 16;
7 | public const int FT_LOAD_TARGET_LIGHT = (1 & 15) << 16;
8 | public const int FT_LOAD_TARGET_MONO = (2 & 15) << 16;
9 | public const int FT_LOAD_TARGET_LCD = (3 & 15) << 16;
10 | public const int FT_LOAD_TARGET_LCD_V = (4 & 15) << 16;
11 |
12 | // opentype validation flags
13 | public const uint FT_VALIDATE_BASE = 0x0100;
14 | public const uint FT_VALIDATE_GDEF = 0x0200;
15 | public const uint FT_VALIDATE_GPOS = 0x0400;
16 | public const uint FT_VALIDATE_GSUB = 0x0800;
17 | public const uint FT_VALIDATE_JSTF = 0x1000;
18 | public const uint FT_VALIDATE_MATH = 0x2000;
19 | public const uint FT_VALIDATE_OT = (FT_VALIDATE_BASE | FT_VALIDATE_GDEF | FT_VALIDATE_GPOS | FT_VALIDATE_GSUB | FT_VALIDATE_JSTF | FT_VALIDATE_MATH);
20 |
21 | // truetype validation flags
22 | public const uint FT_VALIDATE_feat = 0x4000 << 0;
23 | public const uint FT_VALIDATE_mort = 0x4000 << 1;
24 | public const uint FT_VALIDATE_morx = 0x4000 << 2;
25 | public const uint FT_VALIDATE_bsln = 0x4000 << 3;
26 | public const uint FT_VALIDATE_just = 0x4000 << 4;
27 | public const uint FT_VALIDATE_kern = 0x4000 << 5;
28 | public const uint FT_VALIDATE_opbd = 0x4000 << 6;
29 | public const uint FT_VALIDATE_trak = 0x4000 << 7;
30 | public const uint FT_VALIDATE_prop = 0x4000 << 8;
31 | public const uint FT_VALIDATE_lcar = 0x4000 << 9;
32 | public const uint FT_VALIDATE_GX = (FT_VALIDATE_feat | FT_VALIDATE_mort | FT_VALIDATE_morx | FT_VALIDATE_bsln | FT_VALIDATE_just | FT_VALIDATE_kern | FT_VALIDATE_opbd | FT_VALIDATE_trak | FT_VALIDATE_prop | FT_VALIDATE_lcar);
33 |
34 | // classic kern validation flags
35 | public const uint FT_VALIDATE_MS = 0x4000 << 0;
36 | public const uint FT_VALIDATE_APPLE = 0x4000 << 1;
37 | public const uint FT_VALIDATE_CKERN = (FT_VALIDATE_MS | FT_VALIDATE_APPLE);
38 |
39 | // subglyph flags
40 | public const uint FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS = 1;
41 | public const uint FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES = 2;
42 | public const uint FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID = 4;
43 | public const uint FT_SUBGLYPH_FLAG_SCALE = 8;
44 | public const uint FT_SUBGLYPH_FLAG_XY_SCALE = 0x40;
45 | public const uint FT_SUBGLYPH_FLAG_2X2 = 0x80;
46 | public const uint FT_SUBGLYPH_FLAG_USE_MY_METRICS = 0x200;
47 |
48 | // embedding types
49 | public const ushort FT_FSTYPE_INSTALLABLE_EMBEDDING = 0x0000;
50 | public const ushort FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING = 0x0002;
51 | public const ushort FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING = 0x0004;
52 | public const ushort FT_FSTYPE_EDITABLE_EMBEDDING = 0x0008;
53 | public const ushort FT_FSTYPE_NO_SUBSETTING = 0x0100;
54 | public const ushort FT_FSTYPE_BITMAP_EMBEDDING_ONLY = 0x0200;
55 | }
56 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/FT.DllMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 | using System.Runtime.InteropServices;
5 | using System.Runtime.CompilerServices;
6 |
7 | namespace FreeTypeSharp
8 | {
9 | public static partial class FT
10 | {
11 | #if __IOS__
12 | public const string LibName = "__Internal";
13 | #else
14 | public const string LibName = "freetype";
15 | #endif
16 |
17 | #if NETCOREAPP3_1_OR_GREATER && !__IOS__
18 | static FT()
19 | {
20 | NativeLibrary.SetDllImportResolver(typeof(FT).Assembly, ImportResolver);
21 | }
22 |
23 | private static IntPtr ImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
24 | {
25 | if (libraryName != LibName) return default;
26 |
27 | IntPtr handle = default;
28 | bool success = false;
29 |
30 | bool isWindows = false, isMacOS = false, isLinux = false, isAndroid = false;
31 | #if NETCOREAPP3_1
32 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
33 | isWindows = true;
34 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
35 | isMacOS = true;
36 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
37 | isLinux = true;
38 | #else
39 | if (OperatingSystem.IsWindows())
40 | isWindows = true;
41 | else if (OperatingSystem.IsMacOS())
42 | isMacOS = true;
43 | else if (OperatingSystem.IsLinux())
44 | isLinux = true;
45 | else if (OperatingSystem.IsAndroid())
46 | isAndroid = true;
47 | #endif
48 |
49 | string ActualLibraryName;
50 | if (isWindows)
51 | ActualLibraryName = "freetype.dll";
52 | else if (isMacOS)
53 | ActualLibraryName = "libfreetype.dylib";
54 | else if (isLinux)
55 | ActualLibraryName = "libfreetype.so";
56 | else if (isAndroid)
57 | ActualLibraryName = "libfreetype.so";
58 | else
59 | throw new PlatformNotSupportedException();
60 |
61 | string rootDirectory = AppContext.BaseDirectory;
62 |
63 | if (isWindows)
64 | {
65 | string arch = Environment.Is64BitProcess ? "win-x64" : "win-x86";
66 | var searchPaths = new[]
67 | {
68 | // This is where native libraries in our nupkg should end up
69 | Path.Combine(rootDirectory, "runtimes", arch, "native", ActualLibraryName),
70 | Path.Combine(rootDirectory, Environment.Is64BitProcess ? "x64" : "x86", ActualLibraryName),
71 | Path.Combine(rootDirectory, ActualLibraryName)
72 | };
73 |
74 | foreach (var path in searchPaths)
75 | {
76 | success = NativeLibrary.TryLoad(path, out handle);
77 |
78 | if (success)
79 | return handle;
80 | }
81 |
82 | // Fallback to system installed freetype
83 | success = NativeLibrary.TryLoad(libraryName, typeof(FT).Assembly,
84 | DllImportSearchPath.ApplicationDirectory | DllImportSearchPath.UserDirectories | DllImportSearchPath.UseDllDirectoryForDependencies,
85 | out handle);
86 |
87 | if (success)
88 | return handle;
89 |
90 | throw new FileLoadException("Failed to load native freetype library!");
91 | }
92 |
93 | if (isLinux || isMacOS)
94 | {
95 | string arch = isMacOS ? "osx" : "linux-" + (Environment.Is64BitProcess ? "x64" : "x86");
96 |
97 | var searchPaths = new[]
98 | {
99 | // This is where native libraries in our nupkg should end up
100 | Path.Combine(rootDirectory, "runtimes", arch, "native", ActualLibraryName),
101 | // The build output folder
102 | Path.Combine(rootDirectory, ActualLibraryName),
103 | Path.Combine("/usr/local/lib", ActualLibraryName),
104 | Path.Combine("/usr/lib", ActualLibraryName)
105 | };
106 |
107 | foreach (var path in searchPaths)
108 | {
109 | success = NativeLibrary.TryLoad(path, out handle);
110 |
111 | if (success)
112 | return handle;
113 | }
114 |
115 | // Fallback to system installed freetype
116 | success = NativeLibrary.TryLoad(libraryName, typeof(FT).Assembly,
117 | DllImportSearchPath.ApplicationDirectory | DllImportSearchPath.UserDirectories | DllImportSearchPath.UseDllDirectoryForDependencies,
118 | out handle);
119 |
120 | if (success)
121 | return handle;
122 |
123 | throw new FileLoadException("Failed to load native freetype library!");
124 | }
125 |
126 | if (isAndroid)
127 | {
128 | success = NativeLibrary.TryLoad(ActualLibraryName, typeof(FT).Assembly,
129 | DllImportSearchPath.ApplicationDirectory | DllImportSearchPath.UserDirectories | DllImportSearchPath.UseDllDirectoryForDependencies,
130 | out handle);
131 |
132 | if (!success)
133 | success = NativeLibrary.TryLoad(ActualLibraryName, out handle);
134 |
135 | if (success)
136 | return handle;
137 |
138 | // Fallback to system installed freetype
139 | success = NativeLibrary.TryLoad(libraryName, typeof(FT).Assembly,
140 | DllImportSearchPath.ApplicationDirectory | DllImportSearchPath.UserDirectories | DllImportSearchPath.UseDllDirectoryForDependencies,
141 | out handle);
142 |
143 | if (success)
144 | return handle;
145 |
146 | throw new FileLoadException("Failed to load native freetype library!");
147 | }
148 |
149 | return handle;
150 | }
151 | #endif
152 | }
153 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/FreeTypeCalc.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FreeTypeSharp
4 | {
5 | ///
6 | /// Contains utility methods for converting FreeType2 data types to CLR data types, and vice versa.
7 | ///
8 | public static class FreeTypeCalc
9 | {
10 | ///
11 | /// Converts a value to FreeType2 26.6 fixed point value.
12 | ///
13 | /// The value to convert.
14 | /// The converted value.
15 | public static int Int32ToF26Dot6(int x) { return x * 64; }
16 |
17 | ///
18 | /// Converts a FreeType 26.6 fixed point value to a value.
19 | ///
20 | /// The value to convert.
21 | /// The converted value.
22 | public static int F26Dot6ToInt32(int x) { return x / 64; }
23 | }
24 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/FreeTypeException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FreeTypeSharp
4 | {
5 | ///
6 | /// Represents an exception thrown as a result of a FreeType2 API error.
7 | ///
8 | public sealed class FreeTypeException : Exception
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public FreeTypeException(FT_Error err)
14 | : base(GetErrorString(err))
15 | {
16 |
17 | }
18 |
19 | ///
20 | /// Gets the error string for the specified error code.
21 | ///
22 | private static String GetErrorString(FT_Error err)
23 | {
24 | switch (err)
25 | {
26 | case FT_Error.FT_Err_Ok:
27 | return "no error";
28 |
29 | case FT_Error.FT_Err_Cannot_Open_Resource:
30 | return "cannot open resource";
31 |
32 | case FT_Error.FT_Err_Unknown_File_Format:
33 | return "unknown file format";
34 |
35 | case FT_Error.FT_Err_Invalid_File_Format:
36 | return "broken file";
37 |
38 | case FT_Error.FT_Err_Invalid_Version:
39 | return "invalid FreeType version";
40 |
41 | case FT_Error.FT_Err_Lower_Module_Version:
42 | return "module version is too low";
43 |
44 | case FT_Error.FT_Err_Invalid_Argument:
45 | return "invalid argument";
46 |
47 | case FT_Error.FT_Err_Unimplemented_Feature:
48 | return "unimplemented feature";
49 |
50 | case FT_Error.FT_Err_Invalid_Table:
51 | return "broken table";
52 |
53 | case FT_Error.FT_Err_Invalid_Offset:
54 | return "broken offset within table";
55 |
56 | case FT_Error.FT_Err_Array_Too_Large:
57 | return "array allocation size too large";
58 |
59 | case FT_Error.FT_Err_Missing_Module:
60 | return "missing module";
61 |
62 | case FT_Error.FT_Err_Missing_Property:
63 | return "missing property";
64 |
65 | case FT_Error.FT_Err_Invalid_Glyph_Index:
66 | return "invalid glyph index";
67 |
68 | case FT_Error.FT_Err_Invalid_Character_Code:
69 | return "invalid character code";
70 |
71 | case FT_Error.FT_Err_Invalid_Glyph_Format:
72 | return "invalid glyph format";
73 |
74 | case FT_Error.FT_Err_Cannot_Render_Glyph:
75 | return "cannot render this glyph format";
76 |
77 | case FT_Error.FT_Err_Invalid_Outline:
78 | return "invalid outline";
79 |
80 | case FT_Error.FT_Err_Invalid_Composite:
81 | return "invalid composite glyph";
82 |
83 | case FT_Error.FT_Err_Too_Many_Hints:
84 | return "too many hints";
85 |
86 | case FT_Error.FT_Err_Invalid_Pixel_Size:
87 | return "invalid pixel size";
88 |
89 | case FT_Error.FT_Err_Invalid_Handle:
90 | return "invalid object handle";
91 |
92 | case FT_Error.FT_Err_Invalid_Library_Handle:
93 | return "invalid library handle";
94 |
95 | case FT_Error.FT_Err_Invalid_Driver_Handle:
96 | return "invalid module handle";
97 |
98 | case FT_Error.FT_Err_Invalid_Face_Handle:
99 | return "invalid face handle";
100 |
101 | case FT_Error.FT_Err_Invalid_Size_Handle:
102 | return "invalid size handle";
103 |
104 | case FT_Error.FT_Err_Invalid_Slot_Handle:
105 | return "invalid glyph slot handle";
106 |
107 | case FT_Error.FT_Err_Invalid_CharMap_Handle:
108 | return "invalid charmap handle";
109 |
110 | case FT_Error.FT_Err_Invalid_Cache_Handle:
111 | return "invalid cache manager handle";
112 |
113 | case FT_Error.FT_Err_Invalid_Stream_Handle:
114 | return "invalid stream handle";
115 |
116 | case FT_Error.FT_Err_Too_Many_Drivers:
117 | return "too many modules";
118 |
119 | case FT_Error.FT_Err_Too_Many_Extensions:
120 | return "too many extensions";
121 |
122 | case FT_Error.FT_Err_Out_Of_Memory:
123 | return "out of memory";
124 |
125 | case FT_Error.FT_Err_Unlisted_Object:
126 | return "unlisted object";
127 |
128 | case FT_Error.FT_Err_Cannot_Open_Stream:
129 | return "cannot open stream";
130 |
131 | case FT_Error.FT_Err_Invalid_Stream_Seek:
132 | return "invalid stream seek";
133 |
134 | case FT_Error.FT_Err_Invalid_Stream_Skip:
135 | return "invalid stream skip";
136 |
137 | case FT_Error.FT_Err_Invalid_Stream_Read:
138 | return "invalid stream read";
139 |
140 | case FT_Error.FT_Err_Invalid_Stream_Operation:
141 | return "invalid stream operation";
142 |
143 | case FT_Error.FT_Err_Invalid_Frame_Operation:
144 | return "invalid frame operation";
145 |
146 | case FT_Error.FT_Err_Nested_Frame_Access:
147 | return "nested frame access";
148 |
149 | case FT_Error.FT_Err_Invalid_Frame_Read:
150 | return "invalid frame read";
151 |
152 | case FT_Error.FT_Err_Raster_Uninitialized:
153 | return "raster uninitialized";
154 |
155 | case FT_Error.FT_Err_Raster_Corrupted:
156 | return "raster corrupted";
157 |
158 | case FT_Error.FT_Err_Raster_Overflow:
159 | return "raster overflow";
160 |
161 | case FT_Error.FT_Err_Raster_Negative_Height:
162 | return "negative height while rastering";
163 |
164 | case FT_Error.FT_Err_Too_Many_Caches:
165 | return "too many registered caches";
166 |
167 | case FT_Error.FT_Err_Invalid_Opcode:
168 | return "invalid opcode";
169 |
170 | case FT_Error.FT_Err_Too_Few_Arguments:
171 | return "too few arguments";
172 |
173 | case FT_Error.FT_Err_Stack_Overflow:
174 | return "stack overflow";
175 |
176 | case FT_Error.FT_Err_Code_Overflow:
177 | return "code overflow";
178 |
179 | case FT_Error.FT_Err_Bad_Argument:
180 | return "bad argument";
181 |
182 | case FT_Error.FT_Err_Divide_By_Zero:
183 | return "division by zero";
184 |
185 | case FT_Error.FT_Err_Invalid_Reference:
186 | return "invalid reference";
187 |
188 | case FT_Error.FT_Err_Debug_OpCode:
189 | return "found debug opcode";
190 |
191 | case FT_Error.FT_Err_ENDF_In_Exec_Stream:
192 | return "found ENDF opcode in execution stream";
193 |
194 | case FT_Error.FT_Err_Nested_DEFS:
195 | return "nested DEFS";
196 |
197 | case FT_Error.FT_Err_Invalid_CodeRange:
198 | return "invalid code range";
199 |
200 | case FT_Error.FT_Err_Execution_Too_Long:
201 | return "execution context too long";
202 |
203 | case FT_Error.FT_Err_Too_Many_Function_Defs:
204 | return "too many function definitions";
205 |
206 | case FT_Error.FT_Err_Too_Many_Instruction_Defs:
207 | return "too many instruction definitions";
208 |
209 | case FT_Error.FT_Err_Table_Missing:
210 | return "SFNT font table missing";
211 |
212 | case FT_Error.FT_Err_Horiz_Header_Missing:
213 | return "horizontal header (hhea) table missing";
214 |
215 | case FT_Error.FT_Err_Locations_Missing:
216 | return "locations (loca) table missing";
217 |
218 | case FT_Error.FT_Err_Name_Table_Missing:
219 | return "name table missing";
220 |
221 | case FT_Error.FT_Err_CMap_Table_Missing:
222 | return "character map (cmap) table missing";
223 |
224 | case FT_Error.FT_Err_Hmtx_Table_Missing:
225 | return "horizontal metrics (hmtx) table missing";
226 |
227 | case FT_Error.FT_Err_Post_Table_Missing:
228 | return "PostScript (post) table missing";
229 |
230 | case FT_Error.FT_Err_Invalid_Horiz_Metrics:
231 | return "invalid horizontal metrics";
232 |
233 | case FT_Error.FT_Err_Invalid_CharMap_Format:
234 | return "invalid character map (cmap) format";
235 |
236 | case FT_Error.FT_Err_Invalid_PPem:
237 | return "invalid ppem value";
238 |
239 | case FT_Error.FT_Err_Invalid_Vert_Metrics:
240 | return "invalid vertical metrics";
241 |
242 | case FT_Error.FT_Err_Could_Not_Find_Context:
243 | return "could not find context";
244 |
245 | case FT_Error.FT_Err_Invalid_Post_Table_Format:
246 | return "invalid PostScript (post) table format";
247 |
248 | case FT_Error.FT_Err_Invalid_Post_Table:
249 | return "invalid PostScript (post) table";
250 |
251 | case FT_Error.FT_Err_DEF_In_Glyf_Bytecode:
252 | return "found FDEF or IDEF opcode in glyf bytecode";
253 |
254 | case FT_Error.FT_Err_Missing_Bitmap:
255 | return "missing bitmap in strike";
256 |
257 | case FT_Error.FT_Err_Syntax_Error:
258 | return "opcode syntax error";
259 |
260 | case FT_Error.FT_Err_Stack_Underflow:
261 | return "argument stack underflow";
262 |
263 | case FT_Error.FT_Err_Ignore:
264 | return "ignore";
265 |
266 | case FT_Error.FT_Err_No_Unicode_Glyph_Name:
267 | return "no Unicode glyph name found";
268 |
269 | case FT_Error.FT_Err_Glyph_Too_Big:
270 | return "glyph too big for hinting";
271 |
272 | case FT_Error.FT_Err_Missing_Startfont_Field:
273 | return "`STARTFONT' field missing";
274 |
275 | case FT_Error.FT_Err_Missing_Font_Field:
276 | return "`FONT' field missing";
277 |
278 | case FT_Error.FT_Err_Missing_Size_Field:
279 | return "`SIZE' field missing";
280 |
281 | case FT_Error.FT_Err_Missing_Fontboundingbox_Field:
282 | return "`FONTBOUNDINGBOX' field missing";
283 |
284 | case FT_Error.FT_Err_Missing_Chars_Field:
285 | return "`CHARS' field missing";
286 |
287 | case FT_Error.FT_Err_Missing_Startchar_Field:
288 | return "`STARTCHAR' field missing";
289 |
290 | case FT_Error.FT_Err_Missing_Encoding_Field:
291 | return "`ENCODING' field missing";
292 |
293 | case FT_Error.FT_Err_Missing_Bbx_Field:
294 | return "`BBX' field missing";
295 |
296 | case FT_Error.FT_Err_Bbx_Too_Big:
297 | return "`BBX' too big";
298 |
299 | case FT_Error.FT_Err_Corrupted_Font_Header:
300 | return "Font header corrupted or missing fields";
301 |
302 | case FT_Error.FT_Err_Corrupted_Font_Glyphs:
303 | return "Font glyphs corrupted or missing fields";
304 |
305 | default:
306 | return "unknown error";
307 | }
308 | }
309 | }
310 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/FreeTypeFaceFacade.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.Runtime.CompilerServices;
4 | using static FreeTypeSharp.FT_FACE_FLAG;
5 |
6 | namespace FreeTypeSharp
7 | {
8 | public unsafe class FreeTypeFaceFacade
9 | {
10 | // A pointer to the wrapped FreeType2 face object.
11 | private readonly FT_FaceRec_* _FaceRec;
12 | private readonly FreeTypeLibrary _Library;
13 |
14 | ///
15 | /// Initialize a FreeTypeFaceFacade instance with a pointer to the Face instance.
16 | ///
17 | public FreeTypeFaceFacade(FreeTypeLibrary library, FT_FaceRec_* face)
18 | {
19 | _Library = library;
20 | _FaceRec = face;
21 | }
22 |
23 | ///
24 | /// Initialize a FreeTypeFaceFacade instance with font data.
25 | ///
26 | public FreeTypeFaceFacade(FreeTypeLibrary library, IntPtr fontData, int dataLength, int faceIndex = 0)
27 | {
28 | _Library = library;
29 |
30 | FT_FaceRec_* face;
31 |
32 | var err = FT.FT_New_Memory_Face(_Library.Native, (byte*)fontData, (IntPtr)dataLength, (IntPtr)faceIndex, &face);
33 | if (err != FT_Error.FT_Err_Ok)
34 | throw new FreeTypeException(err);
35 |
36 | _FaceRec = face;
37 | }
38 |
39 | #region Properties
40 |
41 | public FT_FaceRec_* FaceRec { get { return _FaceRec; } }
42 |
43 | ///
44 | /// Gets a value indicating whether the face has the FT_FACE_FLAG_SCALABLE flag set.
45 | ///
46 | /// if the face has the FT_FACE_FLAG_SCALABLE flag defined; otherwise, .
47 | public bool HasScalableFlag { get { return HasFaceFlag(FT_FACE_FLAG_SCALABLE); } }
48 |
49 | ///
50 | /// Gets a value indicating whether the face has the FT_FACE_FLAG_FIXED_SIZES flag set.
51 | ///
52 | /// if the face has the FT_FACE_FLAG_FIXED_SIZES flag defined; otherwise, .
53 | public bool HasFixedSizes { get { return HasFaceFlag(FT_FACE_FLAG_FIXED_SIZES); } }
54 |
55 | ///
56 | /// Gets a value indicating whether the face has the FT_FACE_FLAG_COLOR flag set.
57 | ///
58 | /// if the face has the FT_FACE_FLAG_COLOR flag defined; otherwise, .
59 | public bool HasColorFlag { get { return HasFaceFlag(FT_FACE_FLAG_COLOR); } }
60 |
61 | ///
62 | /// Gets a value indicating whether the face has the FT_FACE_FLAG_KERNING flag set.
63 | ///
64 | /// if the face has the FT_FACE_FLAG_KERNING flag defined; otherwise, .
65 | public bool HasKerningFlag { get { return HasFaceFlag(FT_FACE_FLAG_KERNING); } }
66 |
67 | ///
68 | /// Gets a value indicating whether the face has any bitmap strikes with fixed sizes.
69 | ///
70 | public bool HasBitmapStrikes { get { return (_FaceRec->num_fixed_sizes) > 0; } }
71 |
72 | ///
73 | /// Gets the current glyph bitmap.
74 | ///
75 | public FT_Bitmap_ GlyphBitmap { get { return _FaceRec->glyph->bitmap; } }
76 | public FT_Bitmap_* GlyphBitmapPtr { get { return &_FaceRec->glyph->bitmap; } }
77 |
78 | ///
79 | /// Gets the left offset of the current glyph bitmap.
80 | ///
81 | public int GlyphBitmapLeft { get { return _FaceRec->glyph->bitmap_left; } }
82 |
83 | ///
84 | /// Gets the right offset of the current glyph bitmap.
85 | ///
86 | public int GlyphBitmapTop { get { return _FaceRec->glyph->bitmap_top; } }
87 |
88 | ///
89 | /// Gets the width in pixels of the current glyph.
90 | ///
91 | public int GlyphMetricWidth { get { return (int)_FaceRec->glyph->metrics.width >> 6; } }
92 |
93 | ///
94 | /// Gets the height in pixels of the current glyph.
95 | ///
96 | public int GlyphMetricHeight { get { return (int)_FaceRec->glyph->metrics.height >> 6; } }
97 |
98 | ///
99 | /// Gets the horizontal advance of the current glyph.
100 | ///
101 | public int GlyphMetricHorizontalAdvance { get { return (int)_FaceRec->glyph->metrics.horiAdvance >> 6; } }
102 |
103 | ///
104 | /// Gets the vertical advance of the current glyph.
105 | ///
106 | public int GlyphMetricVerticalAdvance { get { return (int)_FaceRec->glyph->metrics.vertAdvance >> 6; } }
107 |
108 | ///
109 | /// Gets the face's ascender size in pixels.
110 | ///
111 | public int Ascender { get { return (int)_FaceRec->size->metrics.ascender >> 6; } }
112 |
113 | ///
114 | /// Gets the face's descender size in pixels.
115 | ///
116 | public int Descender { get { return (int)_FaceRec->size->metrics.descender >> 6; } }
117 |
118 | ///
119 | /// Gets the face's line spacing in pixels.
120 | ///
121 | public int LineSpacing { get { return (int)_FaceRec->size->metrics.height >> 6; } }
122 |
123 | ///
124 | /// Gets the face's underline position.
125 | ///
126 | public int UnderlinePosition { get { return _FaceRec->underline_position >> 6; } }
127 |
128 | ///
129 | /// Gets a pointer to the face's glyph slot.
130 | ///
131 | public FT_GlyphSlotRec_* GlyphSlot { get { return _FaceRec->glyph; } }
132 |
133 | #endregion
134 |
135 | #region Methods
136 |
137 | ///
138 | /// Gets a value indicating whether the face has the specified flag defined.
139 | ///
140 | /// The flag to evaluate.
141 | /// if the face has the specified flag defined; otherwise, .
142 | public bool HasFaceFlag(FT_FACE_FLAG flag) { return (((int)_FaceRec->face_flags) & (int)flag) != 0; }
143 |
144 | ///
145 | /// Selects the specified character size for the font face.
146 | ///
147 | /// The size in points to select.
148 | /// The horizontal pixel density.
149 | /// The vertical pixel density.
150 | public void SelectCharSize(int sizeInPoints, uint dpiX, uint dpiY)
151 | {
152 | var size = (IntPtr)(sizeInPoints << 6);
153 | var err = FT.FT_Set_Char_Size(_FaceRec, size, size, dpiX, dpiY);
154 | if (err != FT_Error.FT_Err_Ok)
155 | throw new FreeTypeException(err);
156 | }
157 |
158 | ///
159 | /// Selects the specified fixed size for the font face.
160 | ///
161 | /// The index of the fixed size to select.
162 | public void SelectFixedSize(int ix)
163 | {
164 | var err = FT.FT_Select_Size(_FaceRec, ix);
165 | if (err != FT_Error.FT_Err_Ok)
166 | throw new FreeTypeException(err);
167 | }
168 |
169 | ///
170 | /// Gets the glyph index of the specified character, if it is defined by this face.
171 | ///
172 | /// The character code for which to retrieve a glyph index.
173 | /// The glyph index of the specified character, or 0 if the character is not defined by this face.
174 | public uint GetCharIndex(uint charCode) { return FT.FT_Get_Char_Index(_FaceRec, (UIntPtr)charCode); }
175 |
176 | ///
177 | /// Marshals the face's family name to a C# string.
178 | ///
179 | /// The marshalled string.
180 | public string MarshalFamilyName() { return Marshal.PtrToStringAnsi((IntPtr)_FaceRec->family_name); }
181 |
182 | ///
183 | /// Marshals the face's style name to a C# string.
184 | ///
185 | /// The marshalled string.
186 | public string MarshalStyleName() { return Marshal.PtrToStringAnsi((IntPtr)_FaceRec->style_name); }
187 |
188 | ///
189 | /// Returns the specified character if it is defined by this face; otherwise, returns .
190 | ///
191 | /// The character to evaluate.
192 | /// The specified character, if it is defined by this face; otherwise, .
193 | public char? GetCharIfDefined(char c) { return FT.FT_Get_Char_Index(_FaceRec, (UIntPtr)c) > 0 ? c : (char?)null; }
194 |
195 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
196 | private int GetFixedSizeInPixels(FT_FaceRec_* face, int ix)
197 | {
198 | return face->available_sizes[ix].height;
199 | }
200 |
201 | ///
202 | /// Returns the index of the fixed size which is the closest match to the specified pixel size.
203 | ///
204 | /// The desired size in pixels.
205 | /// A value indicating whether to require an exact match.
206 | /// The index of the closest matching fixed size.
207 | public int FindNearestMatchingPixelSize(int sizeInPixels, bool requireExactMatch = false)
208 | {
209 | var numFixedSizes = _FaceRec->num_fixed_sizes;
210 | if (numFixedSizes == 0)
211 | throw new InvalidOperationException("FONT_DOES_NOT_HAVE_BITMAP_STRIKES");
212 |
213 | var bestMatchIx = 0;
214 | var bestMatchDiff = Math.Abs(GetFixedSizeInPixels(_FaceRec, 0) - sizeInPixels);
215 |
216 | for (int i = 0; i < numFixedSizes; i++)
217 | {
218 | var size = GetFixedSizeInPixels(_FaceRec, i);
219 | var diff = Math.Abs(size - sizeInPixels);
220 | if (diff < bestMatchDiff)
221 | {
222 | bestMatchDiff = diff;
223 | bestMatchIx = i;
224 | }
225 | }
226 |
227 | if (bestMatchDiff != 0 && requireExactMatch)
228 | throw new InvalidOperationException(string.Format("NO_MATCHING_PIXEL_SIZE: {0}", sizeInPixels));
229 |
230 | return bestMatchIx;
231 | }
232 |
233 | public bool EmboldenGlyphBitmap(int xStrength, int yStrength)
234 | {
235 | var err = FT.FT_Bitmap_Embolden(_Library.Native, GlyphBitmapPtr, (IntPtr)xStrength, (IntPtr)yStrength);
236 | if (err != FT_Error.FT_Err_Ok)
237 | return false;
238 |
239 | if ((int)_FaceRec->glyph->advance.x > 0)
240 | _FaceRec->glyph->advance.x += xStrength;
241 | if ((int)_FaceRec->glyph->advance.y > 0)
242 | _FaceRec->glyph->advance.x += yStrength;
243 | _FaceRec->glyph->metrics.width += xStrength;
244 | _FaceRec->glyph->metrics.height += yStrength;
245 | _FaceRec->glyph->metrics.horiBearingY += yStrength;
246 | _FaceRec->glyph->metrics.horiAdvance += xStrength;
247 | _FaceRec->glyph->metrics.vertBearingX -= xStrength / 2;
248 | _FaceRec->glyph->metrics.vertBearingY += yStrength;
249 | _FaceRec->glyph->metrics.vertAdvance += yStrength;
250 |
251 | _FaceRec->glyph->bitmap_top += (yStrength >> 6);
252 |
253 | return true;
254 | }
255 |
256 | #endregion
257 | }
258 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/FreeTypeLibrary.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace FreeTypeSharp
4 | {
5 | ///
6 | /// Encapsulates the native FreeType2 library object.
7 | ///
8 | public sealed unsafe class FreeTypeLibrary : IDisposable
9 | {
10 | private bool disposed;
11 |
12 | ///
13 | /// Gets a value indicating whether the object has been disposed.
14 | ///
15 | public bool Disposed
16 | {
17 | get { return disposed; }
18 | }
19 |
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | public FreeTypeLibrary()
24 | {
25 | FT_LibraryRec_* lib;
26 | var err = FT.FT_Init_FreeType(&lib);
27 | if (err != FT_Error.FT_Err_Ok)
28 | throw new FreeTypeException(err);
29 |
30 | Native = lib;
31 | }
32 |
33 | ///
34 | /// Gets the native pointer to the FreeType2 library object.
35 | ///
36 | public FT_LibraryRec_* Native { get; private set; }
37 |
38 | public void Dispose()
39 | {
40 | Dispose(true);
41 | GC.SuppressFinalize(this);
42 | }
43 |
44 | ///
45 | void Dispose(bool disposing)
46 | {
47 | if (Native != default)
48 | {
49 | var err = FT.FT_Done_FreeType(Native);
50 | if (err != FT_Error.FT_Err_Ok)
51 | throw new FreeTypeException(err);
52 |
53 | Native = default;
54 | }
55 |
56 | disposed = true;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/FreeTypeSharp/FreeTypeSharp.UWP.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | uap10.0
5 |
6 |
7 |
8 | true
9 | FreeTypeSharp
10 | FreeTypeSharp
11 | 3.0.0
12 |
13 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
14 |
15 |
16 |
17 | https://github.com/ryancheung/FreeTypeSharp
18 | https://github.com/ryancheung/FreeTypeSharp
19 | ryancheung
20 | README.md
21 | MIT
22 | A modern cross-platform managed FreeType2 library.
23 | freetype2;netstandard2.0;.net8.0;
24 | FreeTypeSharp.UWP
25 | Copyright 2024 ryancheung
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | UAP
34 | 10.0.19041.0
35 | 10.0.16299.0
36 | .NETCore
37 | v5.0
38 | $(DefineConstants);WINDOWS_UWP
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | true
47 | runtimes\win10-x86\native\
48 | runtimes\win10-x86\native\freetype.dll
49 | PreserveNewest
50 |
51 |
52 |
53 | true
54 | runtimes\win10-x64\native\
55 | runtimes\win10-x64\native\freetype.dll
56 | PreserveNewest
57 |
58 |
59 |
60 | true
61 | runtimes\win10-arm64\native\
62 | runtimes\win10-arm64\native\freetype.dll
63 | PreserveNewest
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/FreeTypeSharp/FreeTypeSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0;netcoreapp3.1;net8.0
5 |
6 |
7 |
8 | netstandard2.0;netcoreapp3.1;net8.0;net8.0-android
9 |
10 |
11 |
12 | netstandard2.0;netcoreapp3.1;net8.0;net8.0-android;net8.0-ios;net8.0-tvos
13 |
14 |
15 |
16 | 21
17 |
18 |
19 |
20 | true
21 | FreeTypeSharp
22 | FreeTypeSharp
23 | 3.0.0
24 |
25 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
26 |
27 |
28 |
29 | https://github.com/ryancheung/FreeTypeSharp
30 | https://github.com/ryancheung/FreeTypeSharp
31 | ryancheung
32 | README.md
33 | MIT
34 | A modern cross-platform managed FreeType2 library.
35 | freetype2;netstandard2.0;.net8.0;
36 | FreeTypeSharp
37 | Copyright 2024 ryancheung
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | true
46 | 11.0
47 |
48 |
49 |
50 |
51 | true
52 | runtimes\win-x86\native\
53 | runtimes\win-x86\native\freetype.dll
54 | PreserveNewest
55 |
56 |
57 |
58 | true
59 | runtimes\win-x64\native\
60 | runtimes\win-x64\native\freetype.dll
61 | PreserveNewest
62 |
63 |
64 |
65 | true
66 | runtimes\win-arm64\native\
67 | runtimes\win-arm64\native\freetype.dll
68 | PreserveNewest
69 |
70 |
71 |
72 | true
73 | runtimes\linux-x64\native\
74 | runtimes\linux-x64\native\libfreetype.so
75 | PreserveNewest
76 |
77 |
78 |
79 | true
80 | runtimes\osx\native\
81 | runtimes\osx\native\libfreetype.dylib
82 | PreserveNewest
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | Static
101 | False
102 | True
103 |
104 |
105 |
106 |
107 |
108 | Static
109 | False
110 | True
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | public unsafe static partial class FT
7 | {
8 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
9 | public static extern FT_Error FT_Init_FreeType(FT_LibraryRec_** alibrary);
10 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
11 | public static extern FT_Error FT_Done_FreeType(FT_LibraryRec_* library);
12 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
13 | public static extern FT_Error FT_New_Face(FT_LibraryRec_* library, byte* filepathname, IntPtr face_index, FT_FaceRec_** aface);
14 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
15 | public static extern FT_Error FT_New_Memory_Face(FT_LibraryRec_* library, byte* file_base, IntPtr file_size, IntPtr face_index, FT_FaceRec_** aface);
16 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
17 | public static extern FT_Error FT_Open_Face(FT_LibraryRec_* library, FT_Open_Args_* args, IntPtr face_index, FT_FaceRec_** aface);
18 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern FT_Error FT_Attach_File(FT_FaceRec_* face, byte* filepathname);
20 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
21 | public static extern FT_Error FT_Attach_Stream(FT_FaceRec_* face, FT_Open_Args_* parameters);
22 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
23 | public static extern FT_Error FT_Reference_Face(FT_FaceRec_* face);
24 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern FT_Error FT_Done_Face(FT_FaceRec_* face);
26 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
27 | public static extern FT_Error FT_Select_Size(FT_FaceRec_* face, int strike_index);
28 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
29 | public static extern FT_Error FT_Request_Size(FT_FaceRec_* face, FT_Size_RequestRec_* req);
30 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern FT_Error FT_Set_Char_Size(FT_FaceRec_* face, IntPtr char_width, IntPtr char_height, uint horz_resolution, uint vert_resolution);
32 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
33 | public static extern FT_Error FT_Set_Pixel_Sizes(FT_FaceRec_* face, uint pixel_width, uint pixel_height);
34 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
35 | public static extern FT_Error FT_Load_Glyph(FT_FaceRec_* face, uint glyph_index, FT_LOAD load_flags);
36 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern FT_Error FT_Load_Char(FT_FaceRec_* face, UIntPtr char_code, FT_LOAD load_flags);
38 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
39 | public static extern void FT_Set_Transform(FT_FaceRec_* face, FT_Matrix_* matrix, FT_Vector_* delta);
40 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
41 | public static extern void FT_Get_Transform(FT_FaceRec_* face, FT_Matrix_* matrix, FT_Vector_* delta);
42 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
43 | public static extern FT_Error FT_Render_Glyph(FT_GlyphSlotRec_* slot, FT_Render_Mode_ render_mode);
44 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
45 | public static extern FT_Error FT_Get_Kerning(FT_FaceRec_* face, uint left_glyph, uint right_glyph, FT_Kerning_Mode_ kern_mode, FT_Vector_* akerning);
46 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
47 | public static extern FT_Error FT_Get_Track_Kerning(FT_FaceRec_* face, IntPtr point_size, int degree, IntPtr* akerning);
48 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
49 | public static extern FT_Error FT_Select_Charmap(FT_FaceRec_* face, FT_Encoding_ encoding);
50 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
51 | public static extern FT_Error FT_Set_Charmap(FT_FaceRec_* face, FT_CharMapRec_* charmap);
52 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
53 | public static extern int FT_Get_Charmap_Index(FT_CharMapRec_* charmap);
54 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
55 | public static extern uint FT_Get_Char_Index(FT_FaceRec_* face, UIntPtr charcode);
56 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
57 | public static extern UIntPtr FT_Get_First_Char(FT_FaceRec_* face, uint* agindex);
58 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
59 | public static extern UIntPtr FT_Get_Next_Char(FT_FaceRec_* face, UIntPtr char_code, uint* agindex);
60 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
61 | public static extern FT_Error FT_Face_Properties(FT_FaceRec_* face, uint num_properties, FT_Parameter_* properties);
62 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
63 | public static extern uint FT_Get_Name_Index(FT_FaceRec_* face, byte* glyph_name);
64 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
65 | public static extern FT_Error FT_Get_Glyph_Name(FT_FaceRec_* face, uint glyph_index, void* buffer, uint buffer_max);
66 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
67 | public static extern byte* FT_Get_Postscript_Name(FT_FaceRec_* face);
68 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
69 | public static extern FT_Error FT_Get_SubGlyph_Info(FT_GlyphSlotRec_* glyph, uint sub_index, int* p_index, uint* p_flags, int* p_arg1, int* p_arg2, FT_Matrix_* p_transform);
70 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
71 | public static extern ushort FT_Get_FSType_Flags(FT_FaceRec_* face);
72 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
73 | public static extern uint FT_Face_GetCharVariantIndex(FT_FaceRec_* face, UIntPtr charcode, UIntPtr variantSelector);
74 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
75 | public static extern int FT_Face_GetCharVariantIsDefault(FT_FaceRec_* face, UIntPtr charcode, UIntPtr variantSelector);
76 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
77 | public static extern uint* FT_Face_GetVariantSelectors(FT_FaceRec_* face);
78 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
79 | public static extern uint* FT_Face_GetVariantsOfChar(FT_FaceRec_* face, UIntPtr charcode);
80 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
81 | public static extern uint* FT_Face_GetCharsOfVariant(FT_FaceRec_* face, UIntPtr variantSelector);
82 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
83 | public static extern IntPtr FT_MulDiv(IntPtr a, IntPtr b, IntPtr c);
84 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
85 | public static extern IntPtr FT_MulFix(IntPtr a, IntPtr b);
86 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
87 | public static extern IntPtr FT_DivFix(IntPtr a, IntPtr b);
88 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
89 | public static extern IntPtr FT_RoundFix(IntPtr a);
90 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
91 | public static extern IntPtr FT_CeilFix(IntPtr a);
92 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
93 | public static extern IntPtr FT_FloorFix(IntPtr a);
94 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
95 | public static extern void FT_Vector_Transform(FT_Vector_* vector, FT_Matrix_* matrix);
96 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
97 | public static extern void FT_Library_Version(FT_LibraryRec_* library, int* amajor, int* aminor, int* apatch);
98 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
99 | public static extern byte FT_Face_CheckTrueTypePatents(FT_FaceRec_* face);
100 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
101 | public static extern byte FT_Face_SetUnpatentedHinting(FT_FaceRec_* face, byte value);
102 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
103 | public static extern byte* FT_Error_String(FT_Error error_code);
104 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
105 | public static extern FT_Error FT_Outline_Decompose(FT_Outline_* outline, FT_Outline_Funcs_* func_interface, void* user);
106 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
107 | public static extern FT_Error FT_Outline_New(FT_LibraryRec_* library, uint numPoints, int numContours, FT_Outline_* anoutline);
108 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
109 | public static extern FT_Error FT_Outline_Done(FT_LibraryRec_* library, FT_Outline_* outline);
110 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
111 | public static extern FT_Error FT_Outline_Check(FT_Outline_* outline);
112 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
113 | public static extern void FT_Outline_Get_CBox(FT_Outline_* outline, FT_BBox_* acbox);
114 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
115 | public static extern void FT_Outline_Translate(FT_Outline_* outline, IntPtr xOffset, IntPtr yOffset);
116 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
117 | public static extern FT_Error FT_Outline_Copy(FT_Outline_* source, FT_Outline_* target);
118 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
119 | public static extern void FT_Outline_Transform(FT_Outline_* outline, FT_Matrix_* matrix);
120 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
121 | public static extern FT_Error FT_Outline_Embolden(FT_Outline_* outline, IntPtr strength);
122 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
123 | public static extern FT_Error FT_Outline_EmboldenXY(FT_Outline_* outline, IntPtr xstrength, IntPtr ystrength);
124 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
125 | public static extern void FT_Outline_Reverse(FT_Outline_* outline);
126 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
127 | public static extern FT_Error FT_Outline_Get_Bitmap(FT_LibraryRec_* library, FT_Outline_* outline, FT_Bitmap_* abitmap);
128 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
129 | public static extern FT_Error FT_Outline_Render(FT_LibraryRec_* library, FT_Outline_* outline, FT_Raster_Params_* @params);
130 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
131 | public static extern FT_Orientation_ FT_Outline_Get_Orientation(FT_Outline_* outline);
132 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
133 | public static extern FT_Error FT_New_Size(FT_FaceRec_* face, FT_SizeRec_** size);
134 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
135 | public static extern FT_Error FT_Done_Size(FT_SizeRec_* size);
136 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
137 | public static extern FT_Error FT_Activate_Size(FT_SizeRec_* size);
138 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
139 | public static extern FT_Error FT_Add_Module(FT_LibraryRec_* library, FT_Module_Class_* clazz);
140 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
141 | public static extern FT_ModuleRec_* FT_Get_Module(FT_LibraryRec_* library, byte* module_name);
142 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
143 | public static extern FT_Error FT_Remove_Module(FT_LibraryRec_* library, FT_ModuleRec_* module);
144 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
145 | public static extern FT_Error FT_Property_Set(FT_LibraryRec_* library, byte* module_name, byte* property_name, void* value);
146 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
147 | public static extern FT_Error FT_Property_Get(FT_LibraryRec_* library, byte* module_name, byte* property_name, void* value);
148 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
149 | public static extern void FT_Set_Default_Properties(FT_LibraryRec_* library);
150 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
151 | public static extern FT_Error FT_Reference_Library(FT_LibraryRec_* library);
152 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
153 | public static extern FT_Error FT_New_Library(FT_MemoryRec_* memory, FT_LibraryRec_** alibrary);
154 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
155 | public static extern FT_Error FT_Done_Library(FT_LibraryRec_* library);
156 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
157 | public static extern void FT_Set_Debug_Hook(FT_LibraryRec_* library, uint hook_index, void* debug_hook);
158 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
159 | public static extern void FT_Add_Default_Modules(FT_LibraryRec_* library);
160 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
161 | public static extern FT_TrueTypeEngineType_ FT_Get_TrueType_Engine_Type(FT_LibraryRec_* library);
162 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
163 | public static extern FT_Error FT_New_Glyph(FT_LibraryRec_* library, FT_Glyph_Format_ format, FT_GlyphRec_** aglyph);
164 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
165 | public static extern FT_Error FT_Get_Glyph(FT_GlyphSlotRec_* slot, FT_GlyphRec_** aglyph);
166 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
167 | public static extern FT_Error FT_Glyph_Copy(FT_GlyphRec_* source, FT_GlyphRec_** target);
168 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
169 | public static extern FT_Error FT_Glyph_Transform(FT_GlyphRec_* glyph, FT_Matrix_* matrix, FT_Vector_* delta);
170 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
171 | public static extern void FT_Glyph_Get_CBox(FT_GlyphRec_* glyph, uint bbox_mode, FT_BBox_* acbox);
172 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
173 | public static extern FT_Error FT_Glyph_To_Bitmap(FT_GlyphRec_** the_glyph, FT_Render_Mode_ render_mode, FT_Vector_* origin, byte destroy);
174 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
175 | public static extern void FT_Done_Glyph(FT_GlyphRec_* glyph);
176 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
177 | public static extern void FT_Matrix_Multiply(FT_Matrix_* a, FT_Matrix_* b);
178 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
179 | public static extern FT_Error FT_Matrix_Invert(FT_Matrix_* matrix);
180 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
181 | public static extern FT_RendererRec_* FT_Get_Renderer(FT_LibraryRec_* library, FT_Glyph_Format_ format);
182 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
183 | public static extern FT_Error FT_Set_Renderer(FT_LibraryRec_* library, FT_RendererRec_* renderer, uint num_params, FT_Parameter_* parameters);
184 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
185 | public static extern FT_Error FT_Palette_Data_Get(FT_FaceRec_* face, FT_Palette_Data_* apalette);
186 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
187 | public static extern FT_Error FT_Palette_Select(FT_FaceRec_* face, ushort palette_index, FT_Color_** apalette);
188 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
189 | public static extern FT_Error FT_Palette_Set_Foreground_Color(FT_FaceRec_* face, FT_Color_ foreground_color);
190 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
191 | public static extern byte FT_Get_Color_Glyph_Layer(FT_FaceRec_* face, uint base_glyph, uint* aglyph_index, uint* acolor_index, FT_LayerIterator_* iterator);
192 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
193 | public static extern byte FT_Get_Color_Glyph_Paint(FT_FaceRec_* face, uint base_glyph, FT_Color_Root_Transform_ root_transform, FT_Opaque_Paint_* paint);
194 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
195 | public static extern byte FT_Get_Color_Glyph_ClipBox(FT_FaceRec_* face, uint base_glyph, FT_ClipBox_* clip_box);
196 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
197 | public static extern byte FT_Get_Paint_Layers(FT_FaceRec_* face, FT_LayerIterator_* iterator, FT_Opaque_Paint_* paint);
198 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
199 | public static extern byte FT_Get_Colorline_Stops(FT_FaceRec_* face, FT_ColorStop_* color_stop, FT_ColorStopIterator_* iterator);
200 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
201 | public static extern byte FT_Get_Paint(FT_FaceRec_* face, FT_Opaque_Paint_ opaque_paint, FT_COLR_Paint_* paint);
202 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
203 | public static extern void FT_Bitmap_Init(FT_Bitmap_* abitmap);
204 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
205 | public static extern void FT_Bitmap_New(FT_Bitmap_* abitmap);
206 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
207 | public static extern FT_Error FT_Bitmap_Copy(FT_LibraryRec_* library, FT_Bitmap_* source, FT_Bitmap_* target);
208 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
209 | public static extern FT_Error FT_Bitmap_Embolden(FT_LibraryRec_* library, FT_Bitmap_* bitmap, IntPtr xStrength, IntPtr yStrength);
210 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
211 | public static extern FT_Error FT_Bitmap_Convert(FT_LibraryRec_* library, FT_Bitmap_* source, FT_Bitmap_* target, int alignment);
212 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
213 | public static extern FT_Error FT_Bitmap_Blend(FT_LibraryRec_* library, FT_Bitmap_* source, FT_Vector_ source_offset, FT_Bitmap_* target, FT_Vector_* atarget_offset, FT_Color_ color);
214 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
215 | public static extern FT_Error FT_GlyphSlot_Own_Bitmap(FT_GlyphSlotRec_* slot);
216 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
217 | public static extern FT_Error FT_Bitmap_Done(FT_LibraryRec_* library, FT_Bitmap_* bitmap);
218 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
219 | public static extern FT_Error FT_Outline_Get_BBox(FT_Outline_* outline, FT_BBox_* abbox);
220 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
221 | public static extern void FTC_Manager_Reset(FTC_ManagerRec_* manager);
222 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
223 | public static extern void FTC_Manager_Done(FTC_ManagerRec_* manager);
224 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
225 | public static extern FT_Error FTC_Manager_LookupFace(FTC_ManagerRec_* manager, void* face_id, FT_FaceRec_** aface);
226 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
227 | public static extern FT_Error FTC_Manager_LookupSize(FTC_ManagerRec_* manager, FTC_ScalerRec_* scaler, FT_SizeRec_** asize);
228 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
229 | public static extern void FTC_Node_Unref(FTC_NodeRec_* node, FTC_ManagerRec_* manager);
230 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
231 | public static extern void FTC_Manager_RemoveFaceID(FTC_ManagerRec_* manager, void* face_id);
232 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
233 | public static extern FT_Error FTC_CMapCache_New(FTC_ManagerRec_* manager, FTC_CMapCacheRec_** acache);
234 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
235 | public static extern uint FTC_CMapCache_Lookup(FTC_CMapCacheRec_* cache, void* face_id, int cmap_index, uint char_code);
236 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
237 | public static extern FT_Error FTC_ImageCache_New(FTC_ManagerRec_* manager, FTC_ImageCacheRec_** acache);
238 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
239 | public static extern FT_Error FTC_ImageCache_Lookup(FTC_ImageCacheRec_* cache, FTC_ImageTypeRec_* type, uint gindex, FT_GlyphRec_** aglyph, FTC_NodeRec_** anode);
240 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
241 | public static extern FT_Error FTC_ImageCache_LookupScaler(FTC_ImageCacheRec_* cache, FTC_ScalerRec_* scaler, FT_LOAD load_flags, uint gindex, FT_GlyphRec_** aglyph, FTC_NodeRec_** anode);
242 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
243 | public static extern FT_Error FTC_SBitCache_New(FTC_ManagerRec_* manager, FTC_SBitCacheRec_** acache);
244 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
245 | public static extern FT_Error FTC_SBitCache_Lookup(FTC_SBitCacheRec_* cache, FTC_ImageTypeRec_* type, uint gindex, FTC_SBitRec_** sbit, FTC_NodeRec_** anode);
246 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
247 | public static extern FT_Error FTC_SBitCache_LookupScaler(FTC_SBitCacheRec_* cache, FTC_ScalerRec_* scaler, FT_LOAD load_flags, uint gindex, FTC_SBitRec_** sbit, FTC_NodeRec_** anode);
248 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
249 | public static extern FT_StrokerBorder_ FT_Outline_GetInsideBorder(FT_Outline_* outline);
250 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
251 | public static extern FT_StrokerBorder_ FT_Outline_GetOutsideBorder(FT_Outline_* outline);
252 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
253 | public static extern FT_Error FT_Stroker_New(FT_LibraryRec_* library, FT_StrokerRec_** astroker);
254 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
255 | public static extern void FT_Stroker_Set(FT_StrokerRec_* stroker, IntPtr radius, FT_Stroker_LineCap_ line_cap, FT_Stroker_LineJoin_ line_join, IntPtr miter_limit);
256 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
257 | public static extern void FT_Stroker_Rewind(FT_StrokerRec_* stroker);
258 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
259 | public static extern FT_Error FT_Stroker_ParseOutline(FT_StrokerRec_* stroker, FT_Outline_* outline, byte opened);
260 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
261 | public static extern FT_Error FT_Stroker_BeginSubPath(FT_StrokerRec_* stroker, FT_Vector_* to, byte open);
262 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
263 | public static extern FT_Error FT_Stroker_EndSubPath(FT_StrokerRec_* stroker);
264 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
265 | public static extern FT_Error FT_Stroker_LineTo(FT_StrokerRec_* stroker, FT_Vector_* to);
266 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
267 | public static extern FT_Error FT_Stroker_ConicTo(FT_StrokerRec_* stroker, FT_Vector_* control, FT_Vector_* to);
268 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
269 | public static extern FT_Error FT_Stroker_CubicTo(FT_StrokerRec_* stroker, FT_Vector_* control1, FT_Vector_* control2, FT_Vector_* to);
270 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
271 | public static extern FT_Error FT_Stroker_GetBorderCounts(FT_StrokerRec_* stroker, FT_StrokerBorder_ border, uint* anum_points, uint* anum_contours);
272 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
273 | public static extern void FT_Stroker_ExportBorder(FT_StrokerRec_* stroker, FT_StrokerBorder_ border, FT_Outline_* outline);
274 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
275 | public static extern FT_Error FT_Stroker_GetCounts(FT_StrokerRec_* stroker, uint* anum_points, uint* anum_contours);
276 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
277 | public static extern void FT_Stroker_Export(FT_StrokerRec_* stroker, FT_Outline_* outline);
278 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
279 | public static extern void FT_Stroker_Done(FT_StrokerRec_* stroker);
280 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
281 | public static extern FT_Error FT_Glyph_Stroke(FT_GlyphRec_** pglyph, FT_StrokerRec_* stroker, byte destroy);
282 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
283 | public static extern FT_Error FT_Glyph_StrokeBorder(FT_GlyphRec_** pglyph, FT_StrokerRec_* stroker, byte inside, byte destroy);
284 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
285 | public static extern void FT_GlyphSlot_Embolden(FT_GlyphSlotRec_* slot);
286 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
287 | public static extern void FT_GlyphSlot_AdjustWeight(FT_GlyphSlotRec_* slot, IntPtr xdelta, IntPtr ydelta);
288 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
289 | public static extern void FT_GlyphSlot_Oblique(FT_GlyphSlotRec_* slot);
290 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
291 | public static extern void FT_GlyphSlot_Slant(FT_GlyphSlotRec_* slot, IntPtr xslant, IntPtr yslant);
292 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
293 | public static extern IntPtr FT_Sin(IntPtr angle);
294 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
295 | public static extern IntPtr FT_Cos(IntPtr angle);
296 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
297 | public static extern IntPtr FT_Tan(IntPtr angle);
298 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
299 | public static extern IntPtr FT_Atan2(IntPtr x, IntPtr y);
300 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
301 | public static extern IntPtr FT_Angle_Diff(IntPtr angle1, IntPtr angle2);
302 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
303 | public static extern void FT_Vector_Unit(FT_Vector_* vec, IntPtr angle);
304 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
305 | public static extern void FT_Vector_Rotate(FT_Vector_* vec, IntPtr angle);
306 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
307 | public static extern IntPtr FT_Vector_Length(FT_Vector_* vec);
308 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
309 | public static extern void FT_Vector_Polarize(FT_Vector_* vec, IntPtr* length, IntPtr* angle);
310 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
311 | public static extern void FT_Vector_From_Polar(FT_Vector_* vec, IntPtr length, IntPtr angle);
312 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
313 | public static extern int FT_Get_Gasp(FT_FaceRec_* face, uint ppem);
314 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
315 | public static extern FT_Error FT_Get_Advance(FT_FaceRec_* face, uint gindex, FT_LOAD load_flags, IntPtr* padvance);
316 | [DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
317 | public static extern FT_Error FT_Get_Advances(FT_FaceRec_* face, uint start, uint count, FT_LOAD load_flags, IntPtr* padvances);
318 | }
319 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FTC_CMapCacheRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FTC_CMapCacheRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FTC_ImageCacheRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FTC_ImageCacheRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FTC_ImageTypeRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FTC_ImageTypeRec_
8 | {
9 | public void* face_id;
10 | public uint width;
11 | public uint height;
12 | public int flags;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FTC_ManagerRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FTC_ManagerRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FTC_NodeRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FTC_NodeRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FTC_SBitCacheRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FTC_SBitCacheRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FTC_SBitRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FTC_SBitRec_
8 | {
9 | public byte width;
10 | public byte height;
11 | public sbyte left;
12 | public sbyte top;
13 | public byte format;
14 | public byte max_grays;
15 | public short pitch;
16 | public sbyte xadvance;
17 | public sbyte yadvance;
18 | public byte* buffer;
19 | }
20 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FTC_ScalerRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FTC_ScalerRec_
8 | {
9 | public void* face_id;
10 | public uint width;
11 | public uint height;
12 | public int pixel;
13 | public uint x_res;
14 | public uint y_res;
15 | }
16 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_BBox_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_BBox_
8 | {
9 | public IntPtr xMin;
10 | public IntPtr yMin;
11 | public IntPtr xMax;
12 | public IntPtr yMax;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Bitmap_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Bitmap_
8 | {
9 | public uint rows;
10 | public uint width;
11 | public int pitch;
12 | public byte* buffer;
13 | public ushort num_grays;
14 | public FT_Pixel_Mode_ pixel_mode;
15 | public byte palette_mode;
16 | public void* palette;
17 | }
18 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Bitmap_Size_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Bitmap_Size_
8 | {
9 | public short height;
10 | public short width;
11 | public IntPtr size;
12 | public IntPtr x_ppem;
13 | public IntPtr y_ppem;
14 | }
15 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_COLR_Paint_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_COLR_Paint_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_CharMapRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_CharMapRec_
8 | {
9 | public FT_FaceRec_* face;
10 | public FT_Encoding_ encoding;
11 | public ushort platform_id;
12 | public ushort encoding_id;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_ClipBox_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_ClipBox_
8 | {
9 | public FT_Vector_ bottom_left;
10 | public FT_Vector_ top_left;
11 | public FT_Vector_ top_right;
12 | public FT_Vector_ bottom_right;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_ColorIndex_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_ColorIndex_
8 | {
9 | public ushort palette_index;
10 | public short alpha;
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_ColorStopIterator_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_ColorStopIterator_
8 | {
9 | public uint num_color_stops;
10 | public uint current_color_stop;
11 | public byte* p;
12 | public byte read_variable;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_ColorStop_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_ColorStop_
8 | {
9 | public IntPtr stop_offset;
10 | public FT_ColorIndex_ color;
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Color_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Color_
8 | {
9 | public byte blue;
10 | public byte green;
11 | public byte red;
12 | public byte alpha;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Color_Root_Transform_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Color_Root_Transform_ : int
4 | {
5 | FT_COLOR_INCLUDE_ROOT_TRANSFORM = 0,
6 | FT_COLOR_NO_ROOT_TRANSFORM = 1,
7 | FT_COLOR_ROOT_TRANSFORM_MAX = 2
8 | }
9 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_DriverRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_DriverRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Encoding_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Encoding_ : int
4 | {
5 | FT_ENCODING_NONE = 0,
6 | FT_ENCODING_MS_SYMBOL = 1937337698,
7 | FT_ENCODING_UNICODE = 1970170211,
8 | FT_ENCODING_SJIS = 1936353651,
9 | FT_ENCODING_PRC = 1734484000,
10 | FT_ENCODING_BIG5 = 1651074869,
11 | FT_ENCODING_WANSUNG = 2002873971,
12 | FT_ENCODING_JOHAB = 1785686113,
13 | FT_ENCODING_GB2312 = 1734484000,
14 | FT_ENCODING_MS_SJIS = 1936353651,
15 | FT_ENCODING_MS_GB2312 = 1734484000,
16 | FT_ENCODING_MS_BIG5 = 1651074869,
17 | FT_ENCODING_MS_WANSUNG = 2002873971,
18 | FT_ENCODING_MS_JOHAB = 1785686113,
19 | FT_ENCODING_ADOBE_STANDARD = 1094995778,
20 | FT_ENCODING_ADOBE_EXPERT = 1094992453,
21 | FT_ENCODING_ADOBE_CUSTOM = 1094992451,
22 | FT_ENCODING_ADOBE_LATIN_1 = 1818326065,
23 | FT_ENCODING_OLD_LATIN_2 = 1818326066,
24 | FT_ENCODING_APPLE_ROMAN = 1634889070
25 | }
26 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Error.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Error : int
4 | {
5 | FT_Err_Ok = 0,
6 | FT_Err_Cannot_Open_Resource = 1,
7 | FT_Err_Unknown_File_Format = 2,
8 | FT_Err_Invalid_File_Format = 3,
9 | FT_Err_Invalid_Version = 4,
10 | FT_Err_Lower_Module_Version = 5,
11 | FT_Err_Invalid_Argument = 6,
12 | FT_Err_Unimplemented_Feature = 7,
13 | FT_Err_Invalid_Table = 8,
14 | FT_Err_Invalid_Offset = 9,
15 | FT_Err_Array_Too_Large = 10,
16 | FT_Err_Missing_Module = 11,
17 | FT_Err_Missing_Property = 12,
18 | FT_Err_Invalid_Glyph_Index = 16,
19 | FT_Err_Invalid_Character_Code = 17,
20 | FT_Err_Invalid_Glyph_Format = 18,
21 | FT_Err_Cannot_Render_Glyph = 19,
22 | FT_Err_Invalid_Outline = 20,
23 | FT_Err_Invalid_Composite = 21,
24 | FT_Err_Too_Many_Hints = 22,
25 | FT_Err_Invalid_Pixel_Size = 23,
26 | FT_Err_Invalid_SVG_Document = 24,
27 | FT_Err_Invalid_Handle = 32,
28 | FT_Err_Invalid_Library_Handle = 33,
29 | FT_Err_Invalid_Driver_Handle = 34,
30 | FT_Err_Invalid_Face_Handle = 35,
31 | FT_Err_Invalid_Size_Handle = 36,
32 | FT_Err_Invalid_Slot_Handle = 37,
33 | FT_Err_Invalid_CharMap_Handle = 38,
34 | FT_Err_Invalid_Cache_Handle = 39,
35 | FT_Err_Invalid_Stream_Handle = 40,
36 | FT_Err_Too_Many_Drivers = 48,
37 | FT_Err_Too_Many_Extensions = 49,
38 | FT_Err_Out_Of_Memory = 64,
39 | FT_Err_Unlisted_Object = 65,
40 | FT_Err_Cannot_Open_Stream = 81,
41 | FT_Err_Invalid_Stream_Seek = 82,
42 | FT_Err_Invalid_Stream_Skip = 83,
43 | FT_Err_Invalid_Stream_Read = 84,
44 | FT_Err_Invalid_Stream_Operation = 85,
45 | FT_Err_Invalid_Frame_Operation = 86,
46 | FT_Err_Nested_Frame_Access = 87,
47 | FT_Err_Invalid_Frame_Read = 88,
48 | FT_Err_Raster_Uninitialized = 96,
49 | FT_Err_Raster_Corrupted = 97,
50 | FT_Err_Raster_Overflow = 98,
51 | FT_Err_Raster_Negative_Height = 99,
52 | FT_Err_Too_Many_Caches = 112,
53 | FT_Err_Invalid_Opcode = 128,
54 | FT_Err_Too_Few_Arguments = 129,
55 | FT_Err_Stack_Overflow = 130,
56 | FT_Err_Code_Overflow = 131,
57 | FT_Err_Bad_Argument = 132,
58 | FT_Err_Divide_By_Zero = 133,
59 | FT_Err_Invalid_Reference = 134,
60 | FT_Err_Debug_OpCode = 135,
61 | FT_Err_ENDF_In_Exec_Stream = 136,
62 | FT_Err_Nested_DEFS = 137,
63 | FT_Err_Invalid_CodeRange = 138,
64 | FT_Err_Execution_Too_Long = 139,
65 | FT_Err_Too_Many_Function_Defs = 140,
66 | FT_Err_Too_Many_Instruction_Defs = 141,
67 | FT_Err_Table_Missing = 142,
68 | FT_Err_Horiz_Header_Missing = 143,
69 | FT_Err_Locations_Missing = 144,
70 | FT_Err_Name_Table_Missing = 145,
71 | FT_Err_CMap_Table_Missing = 146,
72 | FT_Err_Hmtx_Table_Missing = 147,
73 | FT_Err_Post_Table_Missing = 148,
74 | FT_Err_Invalid_Horiz_Metrics = 149,
75 | FT_Err_Invalid_CharMap_Format = 150,
76 | FT_Err_Invalid_PPem = 151,
77 | FT_Err_Invalid_Vert_Metrics = 152,
78 | FT_Err_Could_Not_Find_Context = 153,
79 | FT_Err_Invalid_Post_Table_Format = 154,
80 | FT_Err_Invalid_Post_Table = 155,
81 | FT_Err_DEF_In_Glyf_Bytecode = 156,
82 | FT_Err_Missing_Bitmap = 157,
83 | FT_Err_Missing_SVG_Hooks = 158,
84 | FT_Err_Syntax_Error = 160,
85 | FT_Err_Stack_Underflow = 161,
86 | FT_Err_Ignore = 162,
87 | FT_Err_No_Unicode_Glyph_Name = 163,
88 | FT_Err_Glyph_Too_Big = 164,
89 | FT_Err_Missing_Startfont_Field = 176,
90 | FT_Err_Missing_Font_Field = 177,
91 | FT_Err_Missing_Size_Field = 178,
92 | FT_Err_Missing_Fontboundingbox_Field = 179,
93 | FT_Err_Missing_Chars_Field = 180,
94 | FT_Err_Missing_Startchar_Field = 181,
95 | FT_Err_Missing_Encoding_Field = 182,
96 | FT_Err_Missing_Bbx_Field = 183,
97 | FT_Err_Bbx_Too_Big = 184,
98 | FT_Err_Corrupted_Font_Header = 185,
99 | FT_Err_Corrupted_Font_Glyphs = 186,
100 | FT_Err_Max = 187
101 | }
102 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_FACE_FLAG.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_FACE_FLAG : int
4 | {
5 | FT_FACE_FLAG_SCALABLE = (1 << 0),
6 | FT_FACE_FLAG_FIXED_SIZES = (1 << 1),
7 | FT_FACE_FLAG_FIXED_WIDTH = (1 << 2),
8 | FT_FACE_FLAG_SFNT = (1 << 3),
9 | FT_FACE_FLAG_HORIZONTAL = (1 << 4),
10 | FT_FACE_FLAG_VERTICAL = (1 << 5),
11 | FT_FACE_FLAG_KERNING = (1 << 6),
12 | FT_FACE_FLAG_FAST_GLYPHS = (1 << 7),
13 | FT_FACE_FLAG_MULTIPLE_MASTERS = (1 << 8),
14 | FT_FACE_FLAG_GLYPH_NAMES = (1 << 9),
15 | FT_FACE_FLAG_EXTERNAL_STREAM = (1 << 10),
16 | FT_FACE_FLAG_HINTER = (1 << 11),
17 | FT_FACE_FLAG_CID_KEYED = (1 << 12),
18 | FT_FACE_FLAG_TRICKY = (1 << 13),
19 | FT_FACE_FLAG_COLOR = (1 << 14),
20 | FT_FACE_FLAG_VARIATION = (1 << 15),
21 | FT_FACE_FLAG_SVG = (1 << 16),
22 | FT_FACE_FLAG_SBIX = (1 << 17),
23 | FT_FACE_FLAG_SBIX_OVERLAY = (1 << 18)}
24 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_FaceRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_FaceRec_
8 | {
9 | public IntPtr num_faces;
10 | public IntPtr face_index;
11 | public IntPtr face_flags;
12 | public IntPtr style_flags;
13 | public IntPtr num_glyphs;
14 | public byte* family_name;
15 | public byte* style_name;
16 | public int num_fixed_sizes;
17 | public FT_Bitmap_Size_* available_sizes;
18 | public int num_charmaps;
19 | public FT_CharMapRec_** charmaps;
20 | public FT_Generic_ generic;
21 | public FT_BBox_ bbox;
22 | public ushort units_per_EM;
23 | public short ascender;
24 | public short descender;
25 | public short height;
26 | public short max_advance_width;
27 | public short max_advance_height;
28 | public short underline_position;
29 | public short underline_thickness;
30 | public FT_GlyphSlotRec_* glyph;
31 | public FT_SizeRec_* size;
32 | public FT_CharMapRec_* charmap;
33 | public FT_DriverRec_* driver;
34 | public FT_MemoryRec_* memory;
35 | public FT_StreamRec_* stream;
36 | public FT_ListRec_ sizes_list;
37 | public FT_Generic_ autohint;
38 | public void* extensions;
39 | public FT_Face_InternalRec_* _internal;
40 | }
41 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Face_InternalRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Face_InternalRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Generic_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Generic_
8 | {
9 | public void* data;
10 | public void* finalizer;
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_GlyphRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_GlyphRec_
8 | {
9 | public FT_LibraryRec_* library;
10 | public FT_Glyph_Class_* clazz;
11 | public FT_Glyph_Format_ format;
12 | public FT_Vector_ advance;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_GlyphSlotRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_GlyphSlotRec_
8 | {
9 | public FT_LibraryRec_* library;
10 | public FT_FaceRec_* face;
11 | public FT_GlyphSlotRec_* next;
12 | public uint glyph_index;
13 | public FT_Generic_ generic;
14 | public FT_Glyph_Metrics_ metrics;
15 | public IntPtr linearHoriAdvance;
16 | public IntPtr linearVertAdvance;
17 | public FT_Vector_ advance;
18 | public FT_Glyph_Format_ format;
19 | public FT_Bitmap_ bitmap;
20 | public int bitmap_left;
21 | public int bitmap_top;
22 | public FT_Outline_ outline;
23 | public uint num_subglyphs;
24 | public FT_SubGlyphRec_* subglyphs;
25 | public void* control_data;
26 | public IntPtr control_len;
27 | public IntPtr lsb_delta;
28 | public IntPtr rsb_delta;
29 | public void* other;
30 | public FT_Slot_InternalRec_* _internal;
31 | }
32 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Glyph_Class_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Glyph_Class_
8 | {
9 | public IntPtr glyph_size;
10 | public FT_Glyph_Format_ glyph_format;
11 | public void* glyph_init;
12 | public void* glyph_done;
13 | public void* glyph_copy;
14 | public void* glyph_transform;
15 | public void* glyph_bbox;
16 | public void* glyph_prepare;
17 | }
18 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Glyph_Format_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Glyph_Format_ : int
4 | {
5 | FT_GLYPH_FORMAT_NONE = 0,
6 | FT_GLYPH_FORMAT_COMPOSITE = 1668246896,
7 | FT_GLYPH_FORMAT_BITMAP = 1651078259,
8 | FT_GLYPH_FORMAT_OUTLINE = 1869968492,
9 | FT_GLYPH_FORMAT_PLOTTER = 1886154612,
10 | FT_GLYPH_FORMAT_SVG = 1398163232
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Glyph_Metrics_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Glyph_Metrics_
8 | {
9 | public IntPtr width;
10 | public IntPtr height;
11 | public IntPtr horiBearingX;
12 | public IntPtr horiBearingY;
13 | public IntPtr horiAdvance;
14 | public IntPtr vertBearingX;
15 | public IntPtr vertBearingY;
16 | public IntPtr vertAdvance;
17 | }
18 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Kerning_Mode_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Kerning_Mode_ : int
4 | {
5 | FT_KERNING_DEFAULT = 0,
6 | FT_KERNING_UNFITTED = 1,
7 | FT_KERNING_UNSCALED = 2
8 | }
9 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_LOAD.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_LOAD : int
4 | {
5 | FT_LOAD_DEFAULT = 0x0,
6 | FT_LOAD_NO_SCALE = (1 << 0),
7 | FT_LOAD_NO_HINTING = (1 << 1),
8 | FT_LOAD_RENDER = (1 << 2),
9 | FT_LOAD_NO_BITMAP = (1 << 3),
10 | FT_LOAD_VERTICAL_LAYOUT = (1 << 4),
11 | FT_LOAD_FORCE_AUTOHINT = (1 << 5),
12 | FT_LOAD_CROP_BITMAP = (1 << 6),
13 | FT_LOAD_PEDANTIC = (1 << 7),
14 | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH = (1 << 9),
15 | FT_LOAD_NO_RECURSE = (1 << 10),
16 | FT_LOAD_IGNORE_TRANSFORM = (1 << 11),
17 | FT_LOAD_MONOCHROME = (1 << 12),
18 | FT_LOAD_LINEAR_DESIGN = (1 << 13),
19 | FT_LOAD_SBITS_ONLY = (1 << 14),
20 | FT_LOAD_NO_AUTOHINT = (1 << 15),
21 | FT_LOAD_COLOR = (1 << 20),
22 | FT_LOAD_COMPUTE_METRICS = (1 << 21),
23 | FT_LOAD_BITMAP_METRICS_ONLY = (1 << 22),
24 | FT_LOAD_NO_SVG = (1 << 24),
25 | FT_LOAD_ADVANCE_ONLY = (1 << 8),
26 | FT_LOAD_SVG_ONLY = (1 << 23)}
27 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_LayerIterator_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_LayerIterator_
8 | {
9 | public uint num_layers;
10 | public uint layer;
11 | public byte* p;
12 | }
13 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_LibraryRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_LibraryRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_ListNodeRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_ListNodeRec_
8 | {
9 | public FT_ListNodeRec_* prev;
10 | public FT_ListNodeRec_* next;
11 | public void* data;
12 | }
13 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_ListRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_ListRec_
8 | {
9 | public FT_ListNodeRec_* head;
10 | public FT_ListNodeRec_* tail;
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Matrix_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Matrix_
8 | {
9 | public IntPtr xx;
10 | public IntPtr xy;
11 | public IntPtr yx;
12 | public IntPtr yy;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_MemoryRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_MemoryRec_
8 | {
9 | public void* user;
10 | public void* alloc;
11 | public void* free;
12 | public void* realloc;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_ModuleRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_ModuleRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Module_Class_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Module_Class_
8 | {
9 | public UIntPtr module_flags;
10 | public IntPtr module_size;
11 | public byte* module_name;
12 | public IntPtr module_version;
13 | public IntPtr module_requires;
14 | public void* module_interface;
15 | public void* module_init;
16 | public void* module_done;
17 | public void* get_interface;
18 | }
19 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Opaque_Paint_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Opaque_Paint_
8 | {
9 | public byte* p;
10 | public byte insert_root_transform;
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Open_Args_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Open_Args_
8 | {
9 | public uint flags;
10 | public byte* memory_base;
11 | public IntPtr memory_size;
12 | public byte* pathname;
13 | public FT_StreamRec_* stream;
14 | public FT_ModuleRec_* driver;
15 | public int num_params;
16 | public FT_Parameter_* _params;
17 | }
18 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Orientation_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Orientation_ : int
4 | {
5 | FT_ORIENTATION_TRUETYPE = 0,
6 | FT_ORIENTATION_POSTSCRIPT = 1,
7 | FT_ORIENTATION_FILL_RIGHT = 0,
8 | FT_ORIENTATION_FILL_LEFT = 1,
9 | FT_ORIENTATION_NONE = 2
10 | }
11 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Outline_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Outline_
8 | {
9 | public short n_contours;
10 | public short n_points;
11 | public FT_Vector_* points;
12 | public byte* tags;
13 | public short* contours;
14 | public int flags;
15 | }
16 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Outline_Funcs_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Outline_Funcs_
8 | {
9 | public void* move_to;
10 | public void* line_to;
11 | public void* conic_to;
12 | public void* cubic_to;
13 | public int shift;
14 | public IntPtr delta;
15 | }
16 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Palette_Data_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Palette_Data_
8 | {
9 | public ushort num_palettes;
10 | public ushort* palette_name_ids;
11 | public ushort* palette_flags;
12 | public ushort num_palette_entries;
13 | public ushort* palette_entry_name_ids;
14 | }
15 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Parameter_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Parameter_
8 | {
9 | public UIntPtr tag;
10 | public void* data;
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Pixel_Mode_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Pixel_Mode_ : byte
4 | {
5 | FT_PIXEL_MODE_NONE = 0,
6 | FT_PIXEL_MODE_MONO = 1,
7 | FT_PIXEL_MODE_GRAY = 2,
8 | FT_PIXEL_MODE_GRAY2 = 3,
9 | FT_PIXEL_MODE_GRAY4 = 4,
10 | FT_PIXEL_MODE_LCD = 5,
11 | FT_PIXEL_MODE_LCD_V = 6,
12 | FT_PIXEL_MODE_BGRA = 7,
13 | FT_PIXEL_MODE_MAX = 8
14 | }
15 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Raster_Params_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Raster_Params_
8 | {
9 | public FT_Bitmap_* target;
10 | public void* source;
11 | public int flags;
12 | public void* gray_spans;
13 | public void* black_spans;
14 | public void* bit_test;
15 | public void* bit_set;
16 | public void* user;
17 | public FT_BBox_ clip_box;
18 | }
19 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Render_Mode_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Render_Mode_ : int
4 | {
5 | FT_RENDER_MODE_NORMAL = 0,
6 | FT_RENDER_MODE_LIGHT = 1,
7 | FT_RENDER_MODE_MONO = 2,
8 | FT_RENDER_MODE_LCD = 3,
9 | FT_RENDER_MODE_LCD_V = 4,
10 | FT_RENDER_MODE_SDF = 5,
11 | FT_RENDER_MODE_MAX = 6
12 | }
13 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_RendererRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_RendererRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_STYLE_FLAG.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_STYLE_FLAG : int
4 | {
5 | FT_STYLE_FLAG_ITALIC = (1 << 0),
6 | FT_STYLE_FLAG_BOLD = (1 << 1)}
7 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_SizeRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_SizeRec_
8 | {
9 | public FT_FaceRec_* face;
10 | public FT_Generic_ generic;
11 | public FT_Size_Metrics_ metrics;
12 | public FT_Size_InternalRec_* _internal;
13 | }
14 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Size_InternalRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Size_InternalRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Size_Metrics_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Size_Metrics_
8 | {
9 | public ushort x_ppem;
10 | public ushort y_ppem;
11 | public IntPtr x_scale;
12 | public IntPtr y_scale;
13 | public IntPtr ascender;
14 | public IntPtr descender;
15 | public IntPtr height;
16 | public IntPtr max_advance;
17 | }
18 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Size_RequestRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Size_RequestRec_
8 | {
9 | public FT_Size_Request_Type_ type;
10 | public IntPtr width;
11 | public IntPtr height;
12 | public uint horiResolution;
13 | public uint vertResolution;
14 | }
15 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Size_Request_Type_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Size_Request_Type_ : int
4 | {
5 | FT_SIZE_REQUEST_TYPE_NOMINAL = 0,
6 | FT_SIZE_REQUEST_TYPE_REAL_DIM = 1,
7 | FT_SIZE_REQUEST_TYPE_BBOX = 2,
8 | FT_SIZE_REQUEST_TYPE_CELL = 3,
9 | FT_SIZE_REQUEST_TYPE_SCALES = 4,
10 | FT_SIZE_REQUEST_TYPE_MAX = 5
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Slot_InternalRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Slot_InternalRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_StreamDesc_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_StreamDesc_
8 | {
9 | public IntPtr value;
10 | public void* pointer;
11 | }
12 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_StreamRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_StreamRec_
8 | {
9 | public byte* _base;
10 | public UIntPtr size;
11 | public UIntPtr pos;
12 | public FT_StreamDesc_ descriptor;
13 | public FT_StreamDesc_ pathname;
14 | public void* read;
15 | public void* close;
16 | public FT_MemoryRec_* memory;
17 | public byte* cursor;
18 | public byte* limit;
19 | }
20 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_StrokerBorder_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_StrokerBorder_ : int
4 | {
5 | FT_STROKER_BORDER_LEFT = 0,
6 | FT_STROKER_BORDER_RIGHT = 1
7 | }
8 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_StrokerRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_StrokerRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Stroker_LineCap_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Stroker_LineCap_ : int
4 | {
5 | FT_STROKER_LINECAP_BUTT = 0,
6 | FT_STROKER_LINECAP_ROUND = 1,
7 | FT_STROKER_LINECAP_SQUARE = 2
8 | }
9 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Stroker_LineJoin_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_Stroker_LineJoin_ : int
4 | {
5 | FT_STROKER_LINEJOIN_ROUND = 0,
6 | FT_STROKER_LINEJOIN_BEVEL = 1,
7 | FT_STROKER_LINEJOIN_MITER_VARIABLE = 2,
8 | FT_STROKER_LINEJOIN_MITER = 2,
9 | FT_STROKER_LINEJOIN_MITER_FIXED = 3
10 | }
11 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_SubGlyphRec_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_SubGlyphRec_
8 | {
9 | }
10 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_TrueTypeEngineType_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | public enum FT_TrueTypeEngineType_ : int
4 | {
5 | FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
6 | FT_TRUETYPE_ENGINE_TYPE_UNPATENTED = 1,
7 | FT_TRUETYPE_ENGINE_TYPE_PATENTED = 2
8 | }
9 | }
--------------------------------------------------------------------------------
/FreeTypeSharp/Generated/FT_Vector_.cs:
--------------------------------------------------------------------------------
1 | namespace FreeTypeSharp
2 | {
3 | using System.Runtime.InteropServices;
4 | using System;
5 |
6 | [StructLayout(LayoutKind.Sequential)]
7 | public unsafe struct FT_Vector_
8 | {
9 | public IntPtr x;
10 | public IntPtr y;
11 | }
12 | }
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 ryancheung
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FreeTypeSharp
2 | [](https://www.nuget.org/packages/FreeTypeSharp/)
3 |
4 | A modern managed FreeType2 library which has source code generated from the original C headers.
5 |
6 | FreeTypeSharp v2+ provides cross-platform bindings for:
7 |
8 | - netcoreapp3.1;net8.0 (Windows, Linux, macOS)
9 | - net8.0-android
10 | - net8.0-ios
11 | - net8.0-tvos
12 | - netstandard2.0
13 | - uap10.0 (UWP)
14 |
15 | [README](https://github.com/ryancheung/FreeTypeSharp/tree/v1) for release v1.X
16 |
17 | ## FreeType Wrapped
18 |
19 | FreeType 2.13.2
20 |
21 | Native binaries are built by the CI in https://github.com/ryancheung/freetype/tree/csharp-patch
22 |
23 | # Installation
24 |
25 | `dotnet add package FreeTypeSharp`
26 |
27 | UWP target is in a seperate package
28 |
29 | `dotnet add package FreeTypeSharp.UWP`
30 |
31 | # Usage
32 |
33 | There's no magic(abstraction) based on the original C freetype API. All managed API are almost identical with the original freetype C API.
34 | Import the namespaces like `using FreeTypeSharp;` and `using static FreeTypeSharp.FT;`, then you can play the font rendering as what you do in C.
35 |
36 | Here are few sample code:
37 | ```csharp
38 | using static FreeTypeSharp.FT;
39 | using static FreeTypeSharp.FT_LOAD;
40 | using static FreeTypeSharp.FT_Render_Mode_;
41 |
42 | FT_LibraryRec_* lib;
43 | FT_FaceRec_* face;
44 | var error = FT_Init_FreeType(&lib);
45 |
46 | error = FT_New_Face(lib, (byte*)Marshal.StringToHGlobalAnsi("some_font_name.ttf"), 0, &face);
47 | error = FT_Set_Char_Size(face, 0, 16 * 64, 300, 300);
48 | var glyphIndex = FT_Get_Char_Index(face, 'F');
49 | error = FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT);
50 | error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
51 | ...
52 | ```
53 |
54 | More FreeType docs: https://freetype.org/freetype2/docs/documentation.html
55 |
56 | # Credits
57 |
58 | - https://github.com/tlgkccampbell/ultraviolet
59 | - https://github.com/Robmaister/SharpFont/
60 |
61 | Special thanks to https://github.com/tonisimakov99/FreeTypeBinding for source code generator.
62 |
--------------------------------------------------------------------------------
/runtimes/FreeType2/android/arm64-v8a/libfreetype.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/android/arm64-v8a/libfreetype.so
--------------------------------------------------------------------------------
/runtimes/FreeType2/android/armeabi-v7a/libfreetype.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/android/armeabi-v7a/libfreetype.so
--------------------------------------------------------------------------------
/runtimes/FreeType2/android/x86/libfreetype.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/android/x86/libfreetype.so
--------------------------------------------------------------------------------
/runtimes/FreeType2/android/x86_64/libfreetype.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/android/x86_64/libfreetype.so
--------------------------------------------------------------------------------
/runtimes/FreeType2/ios/FreeType2.xcframework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AvailableLibraries
6 |
7 |
8 | LibraryIdentifier
9 | ios-arm64_x86_64-simulator
10 | LibraryPath
11 | libfreetype.a
12 | SupportedArchitectures
13 |
14 | arm64
15 | x86_64
16 |
17 | SupportedPlatform
18 | ios
19 | SupportedPlatformVariant
20 | simulator
21 |
22 |
23 | LibraryIdentifier
24 | ios-arm64
25 | LibraryPath
26 | libfreetype.a
27 | SupportedArchitectures
28 |
29 | arm64
30 |
31 | SupportedPlatform
32 | ios
33 |
34 |
35 | CFBundlePackageType
36 | XFWK
37 | XCFrameworkFormatVersion
38 | 1.0
39 |
40 |
41 |
--------------------------------------------------------------------------------
/runtimes/FreeType2/ios/FreeType2.xcframework/ios-arm64/libfreetype.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/ios/FreeType2.xcframework/ios-arm64/libfreetype.a
--------------------------------------------------------------------------------
/runtimes/FreeType2/ios/FreeType2.xcframework/ios-arm64_x86_64-simulator/libfreetype.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/ios/FreeType2.xcframework/ios-arm64_x86_64-simulator/libfreetype.a
--------------------------------------------------------------------------------
/runtimes/FreeType2/linux-x64/libfreetype.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/linux-x64/libfreetype.so
--------------------------------------------------------------------------------
/runtimes/FreeType2/osx/libfreetype.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/osx/libfreetype.dylib
--------------------------------------------------------------------------------
/runtimes/FreeType2/tvos/FreeType2.xcframework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AvailableLibraries
6 |
7 |
8 | LibraryIdentifier
9 | tvos-arm64
10 | LibraryPath
11 | libfreetype.a
12 | SupportedArchitectures
13 |
14 | arm64
15 |
16 | SupportedPlatform
17 | tvos
18 |
19 |
20 | LibraryIdentifier
21 | tvos-arm64_x86_64-simulator
22 | LibraryPath
23 | libfreetype.a
24 | SupportedArchitectures
25 |
26 | arm64
27 | x86_64
28 |
29 | SupportedPlatform
30 | tvos
31 | SupportedPlatformVariant
32 | simulator
33 |
34 |
35 | CFBundlePackageType
36 | XFWK
37 | XCFrameworkFormatVersion
38 | 1.0
39 |
40 |
41 |
--------------------------------------------------------------------------------
/runtimes/FreeType2/tvos/FreeType2.xcframework/tvos-arm64/libfreetype.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/tvos/FreeType2.xcframework/tvos-arm64/libfreetype.a
--------------------------------------------------------------------------------
/runtimes/FreeType2/tvos/FreeType2.xcframework/tvos-arm64_x86_64-simulator/libfreetype.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/tvos/FreeType2.xcframework/tvos-arm64_x86_64-simulator/libfreetype.a
--------------------------------------------------------------------------------
/runtimes/FreeType2/win-arm64/freetype.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/win-arm64/freetype.dll
--------------------------------------------------------------------------------
/runtimes/FreeType2/win-x64/freetype.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/win-x64/freetype.dll
--------------------------------------------------------------------------------
/runtimes/FreeType2/win-x86/freetype.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/win-x86/freetype.dll
--------------------------------------------------------------------------------
/runtimes/FreeType2/win10-arm64/freetype.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/win10-arm64/freetype.dll
--------------------------------------------------------------------------------
/runtimes/FreeType2/win10-x64/freetype.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/win10-x64/freetype.dll
--------------------------------------------------------------------------------
/runtimes/FreeType2/win10-x86/freetype.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryancheung/FreeTypeSharp/fb6f244d7cf0cae44bfb0d52d02509a598de150b/runtimes/FreeType2/win10-x86/freetype.dll
--------------------------------------------------------------------------------