2015-03-21 00:33:51 +03:00
|
|
|
SharpFont [![NuGet Version](http://img.shields.io/nuget/vpre/SharpFont.svg)](https://www.nuget.org/packages/SharpFont) [![NuGet Downloads](http://img.shields.io/nuget/dt/SharpFont.svg)](https://www.nuget.org/packages/SharpFont) [![Gratipay Tips](https://img.shields.io/gratipay/Robmaister.svg)](https://gratipay.com/Robmaister)
|
2014-11-01 06:30:58 +03:00
|
|
|
=========
|
2012-09-09 02:13:57 +04:00
|
|
|
### Cross-platform FreeType bindings for .NET
|
2012-05-07 02:17:25 +04:00
|
|
|
|
2015-01-12 13:12:42 +03:00
|
|
|
SharpFont is a library that provides FreeType bindings for .NET. It's MIT
|
|
|
|
licensed to make sure licensing doesn't get in the way of using the library in
|
|
|
|
your own projects. Unlike [Tao.FreeType][1], SharpFont provides the full
|
|
|
|
public API and not just the basic methods needed to render simple text.
|
|
|
|
Everything from format-specific APIs to the caching subsystem are included.
|
2012-05-07 02:17:25 +04:00
|
|
|
|
|
|
|
SharpFont simplifies the FreeType API in a few ways:
|
|
|
|
|
2015-01-12 13:12:42 +03:00
|
|
|
- The error codes that most FreeType methods return are converted to
|
|
|
|
exceptions.
|
|
|
|
- Since the return values are no longer error codes, methods with a single
|
|
|
|
`out` parameter are returned instead.
|
|
|
|
- Most methods are instance methods instead of static methods. This avoids
|
|
|
|
unnecessary redundancy in method calls and creates an API with a .NET
|
|
|
|
look-and-feel.
|
2012-05-07 02:17:25 +04:00
|
|
|
|
2012-09-09 02:21:38 +04:00
|
|
|
For example, a regular FreeType method looks like this:
|
2012-05-07 02:17:25 +04:00
|
|
|
|
2012-09-09 02:13:57 +04:00
|
|
|
```C
|
|
|
|
Face face;
|
|
|
|
int err = FT_New_Face(library, "./myfont.ttf", 0, &face);
|
|
|
|
```
|
|
|
|
|
|
|
|
The equivalent code in C# with SharpFont is:
|
|
|
|
|
|
|
|
```CSharp
|
|
|
|
Face face = new Face(library, "./myfont.ttf");
|
|
|
|
```
|
|
|
|
|
|
|
|
##Quick Start
|
|
|
|
|
2013-06-06 04:18:22 +04:00
|
|
|
###NuGet
|
2015-01-12 13:12:42 +03:00
|
|
|
SharpFont is available on [NuGet][2]. It can be installed by issuing the
|
|
|
|
following command in the package manager console:
|
2013-06-06 04:18:22 +04:00
|
|
|
|
|
|
|
```
|
|
|
|
PM> Install-Package SharpFont
|
|
|
|
```
|
|
|
|
|
|
|
|
###From Source
|
2015-01-12 13:12:42 +03:00
|
|
|
Clone the repository and compile the solution. Copy `SharpFont.dll` to your
|
|
|
|
project and include it as a reference. On Windows, you must include a compiled
|
|
|
|
copy of FreeType2 as `freetype6.dll` in the project's output directory. It is
|
2012-09-09 02:18:11 +04:00
|
|
|
possible to rename the file by changing the filename constant in
|
2015-01-12 13:12:42 +03:00
|
|
|
[FT.Internal.cs][3] and recompile. On Linux and OSX (and any other Mono
|
|
|
|
supported platform), you must also copy `SharpFont.dll.config` to the
|
|
|
|
project's output directory.
|
2012-09-09 02:13:57 +04:00
|
|
|
|
2016-05-03 20:49:59 +03:00
|
|
|
Two extensions for Visual Studio make it easy to follow the coding format in
|
|
|
|
this project and prevent lots of spurious whitespace changes.
|
|
|
|
The [.editorconfig](http://editorconfig.org/) file in the project works with the
|
|
|
|
[EditorConfig](https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328)
|
|
|
|
extension and the [Format document on Save](https://visualstudiogallery.msdn.microsoft.com/3ea1c920-69c4-441f-9979-ccc2752dac56)
|
|
|
|
extension makes it basically automatic.
|
|
|
|
|
2013-10-18 22:34:30 +04:00
|
|
|
####Mono
|
2015-01-12 13:12:42 +03:00
|
|
|
With the removal of the `WIN64` configurations, the included `Makefile` is
|
|
|
|
effectively redundant. However, you can still build SharpFont by calling
|
|
|
|
`make` while in the root directory of this project.
|
2013-10-18 22:34:30 +04:00
|
|
|
|
|
|
|
####FreeType
|
2015-01-12 13:12:42 +03:00
|
|
|
A large number of FreeType builds for Windows are now available in the
|
|
|
|
[SharpFont.Dependencies][4] repository.
|
2012-09-09 02:13:57 +04:00
|
|
|
|
2015-01-12 13:12:42 +03:00
|
|
|
##Known Issues
|
2012-09-09 02:13:57 +04:00
|
|
|
|
2016-04-20 13:59:53 +03:00
|
|
|
While SharpFont is fully compatible with and runs on 64-bit Windows, it relies
|
|
|
|
on a patch for FreeType to do this. This patch is already included in
|
|
|
|
[SharpFont.Dependencies/freetype2][5]. You do not need to worry about this as
|
|
|
|
a user of the library. If you are compiling FreeType from source, you can find
|
|
|
|
the patch and instructions at the same location.
|
2012-09-09 02:13:57 +04:00
|
|
|
|
|
|
|
##License
|
|
|
|
|
2015-01-12 13:12:42 +03:00
|
|
|
As metioned earlier, SharpFont is licensed under the MIT License. The terms of
|
2015-07-12 21:17:04 +03:00
|
|
|
the MIT license are included in both the [LICENSE][6] file and below:
|
2012-09-09 02:13:57 +04:00
|
|
|
|
|
|
|
```
|
2016-01-05 12:36:09 +03:00
|
|
|
Copyright (c) 2012-2016 Robert Rouhani <robert.rouhani@gmail.com>
|
2012-09-09 02:13:57 +04:00
|
|
|
|
|
|
|
SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
|
|
|
|
|
2015-01-12 13:12:42 +03:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2012-09-09 02:13:57 +04:00
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
2012-05-07 02:17:25 +04:00
|
|
|
|
2012-09-09 02:13:57 +04:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
2013-06-06 04:18:22 +04:00
|
|
|
```
|
2013-06-06 06:32:26 +04:00
|
|
|
|
2015-01-12 13:12:42 +03:00
|
|
|
The Windows binary of FreeType that is included in the Examples project and in
|
|
|
|
the NuGet package is redistributed under the FreeType License (FTL).
|
2013-06-06 06:32:26 +04:00
|
|
|
|
|
|
|
```
|
2016-01-05 12:36:09 +03:00
|
|
|
Portions of this software are copyright (c) 2016 The FreeType Project
|
2013-06-06 06:32:26 +04:00
|
|
|
(www.freetype.org). All rights reserved.
|
|
|
|
```
|
2015-01-12 13:12:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
[1]: http://taoframework.svn.sourceforge.net/viewvc/taoframework/trunk/src/Tao.FreeType/
|
|
|
|
[2]: https://nuget.org/packages/SharpFont/
|
|
|
|
[3]: SharpFont/FT.Internal.cs
|
|
|
|
[4]: https://github.com/Robmaister/SharpFont.Dependencies
|
2015-07-12 21:17:04 +03:00
|
|
|
[5]: https://github.com/Robmaister/SharpFont.Dependencies/tree/master/freetype2
|
|
|
|
[6]: LICENSE
|