2013-04-03 16:15:53 +00:00
|
|
|
#region License
|
|
|
|
/* SDL2# - C# Wrapper for SDL2
|
|
|
|
*
|
|
|
|
* Copyright (c) 2013 Ethan Lee.
|
|
|
|
*
|
|
|
|
* This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
* In no event will the authors be held liable for any damages arising from
|
|
|
|
* the use of this software.
|
|
|
|
*
|
|
|
|
* Permission is granted to anyone to use this software for any purpose,
|
|
|
|
* including commercial applications, and to alter it and redistribute it
|
|
|
|
* freely, subject to the following restrictions:
|
|
|
|
*
|
|
|
|
* 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
* claim that you wrote the original software. If you use this software in a
|
|
|
|
* product, an acknowledgment in the product documentation would be
|
|
|
|
* appreciated but is not required.
|
|
|
|
*
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
* misrepresented as being the original software.
|
|
|
|
*
|
|
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*
|
|
|
|
* Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Using Statements
|
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace SDL2
|
|
|
|
{
|
2013-04-08 16:09:41 +00:00
|
|
|
public static class SDL_ttf
|
2013-04-03 16:15:53 +00:00
|
|
|
{
|
|
|
|
#region SDL2# Variables
|
|
|
|
|
|
|
|
/* Used by DllImport to load the native library. */
|
2013-04-08 02:41:22 +00:00
|
|
|
private const string nativeLibName = "SDL2_ttf.dll";
|
2013-04-03 16:15:53 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2013-04-07 13:12:02 +00:00
|
|
|
#region SDL_ttf.h
|
|
|
|
|
|
|
|
public const int UNICODE_BOM_NATIVE = 0xFEFF;
|
|
|
|
public const int UNICODE_BOM_SWAPPED = 0xFFFE;
|
|
|
|
|
2013-04-07 13:36:19 +00:00
|
|
|
public const int TTF_STYLE_NORMAL = 0x00;
|
|
|
|
public const int TTF_STYLE_BOLD = 0x01;
|
|
|
|
public const int TTF_STYLE_ITALIC = 0x02;
|
2013-04-07 13:12:02 +00:00
|
|
|
public const int TTF_STYLE_UNDERLINE = 0x04;
|
|
|
|
public const int TTF_STYLE_STRIKETHROUGH = 0x08;
|
|
|
|
|
|
|
|
public const int TTF_HINTING_NORMAL = 0;
|
|
|
|
public const int TTF_HINTING_LIGHT = 1;
|
2013-04-07 13:36:19 +00:00
|
|
|
public const int TTF_HINTING_MONO = 2;
|
|
|
|
public const int TTF_HINTING_NONE = 3;
|
2013-04-07 13:12:02 +00:00
|
|
|
|
|
|
|
[DllImport(nativeLibName, EntryPoint = "TTF_LinkedVersion")]
|
|
|
|
private static extern IntPtr INTERNAL_TTF_LinkedVersion();
|
2013-04-08 16:09:41 +00:00
|
|
|
public static SDL.SDL_version TTF_LinkedVersion()
|
2013-04-07 13:12:02 +00:00
|
|
|
{
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_version result;
|
2013-04-07 13:12:02 +00:00
|
|
|
IntPtr result_ptr = INTERNAL_TTF_LinkedVersion();
|
2013-04-08 16:09:41 +00:00
|
|
|
result = (SDL.SDL_version) Marshal.PtrToStructure(
|
2013-04-07 13:12:02 +00:00
|
|
|
result_ptr,
|
|
|
|
result.GetType()
|
|
|
|
);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern void TTF_ByteSwappedUNICODE(int swapped);
|
|
|
|
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_Init();
|
|
|
|
|
|
|
|
/* IntPtr refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_OpenFont(
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:12:02 +00:00
|
|
|
string file,
|
|
|
|
int ptsize
|
|
|
|
);
|
|
|
|
|
|
|
|
/* IntPtr refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_OpenFontIndex(
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:12:02 +00:00
|
|
|
string file,
|
|
|
|
int ptsize,
|
|
|
|
long index
|
|
|
|
);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_GetFontStyle(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern void TTF_SetFontStyle(IntPtr font, int style);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_GetFontOutline(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern void TTF_SetFontOutline(IntPtr font, int outline);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_GetFontHinting(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern void TTF_SetFontHinting(IntPtr font, int hinting);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_FontHeight(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_FontAscent(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_FontDescent(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_FontLineSkip(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_GetFontKerning(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern void TTF_SetFontKerning(IntPtr font, int allowed);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern long TTF_FontFaces(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_FontFaceIsFixedWidth(IntPtr font);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName, EntryPoint = "TTF_FontFaceFamilyName")]
|
|
|
|
private static extern IntPtr INTERNAL_TTF_FontFaceFamilyName(
|
|
|
|
IntPtr font
|
|
|
|
);
|
|
|
|
public static string TTF_FontFaceFamily(IntPtr font)
|
|
|
|
{
|
|
|
|
return Marshal.PtrToStringAnsi(
|
|
|
|
INTERNAL_TTF_FontFaceFamilyName(font)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName, EntryPoint = "TTF_FontFaceStyleName")]
|
|
|
|
private static extern IntPtr INTERNAL_TTF_FontFaceStyleName(
|
|
|
|
IntPtr font
|
|
|
|
);
|
|
|
|
public static string TTF_FontFaceStyleName(IntPtr font)
|
|
|
|
{
|
|
|
|
return Marshal.PtrToStringAnsi(
|
|
|
|
INTERNAL_TTF_FontFaceStyleName(font)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_GlyphIsProvided(IntPtr font, ushort ch);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_GlyphMetrics(
|
|
|
|
IntPtr font,
|
|
|
|
ushort ch,
|
|
|
|
ref int minx,
|
|
|
|
ref int maxx,
|
|
|
|
ref int miny,
|
|
|
|
ref int maxy,
|
|
|
|
ref int advance
|
|
|
|
);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_SizeText(
|
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:12:02 +00:00
|
|
|
string text,
|
|
|
|
ref int w,
|
|
|
|
ref int h
|
|
|
|
);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_SizeUTF8(
|
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:12:02 +00:00
|
|
|
string text,
|
|
|
|
ref int w,
|
|
|
|
ref int h
|
|
|
|
);
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_SizeUNICODE(
|
|
|
|
IntPtr font,
|
|
|
|
ushort[] text,
|
|
|
|
ref int w,
|
|
|
|
ref int h
|
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderText_Solid(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:36:19 +00:00
|
|
|
string text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderUTF8_Solid(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:36:19 +00:00
|
|
|
string text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderUNICODE_Solid(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
|
|
|
ushort[] text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderGlyph_Solid(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
|
|
|
ushort ch,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderText_Shaded(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:36:19 +00:00
|
|
|
string text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg,
|
|
|
|
SDL.SDL_Color bg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderUTF8_Shaded(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:36:19 +00:00
|
|
|
string text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg,
|
|
|
|
SDL.SDL_Color bg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderUNICODE_Shaded(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
|
|
|
ushort[] text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg,
|
|
|
|
SDL.SDL_Color bg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderGlyph_Shaded(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
|
|
|
ushort ch,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg,
|
|
|
|
SDL.SDL_Color bg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderText_Blended(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:36:19 +00:00
|
|
|
string text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderUTF8_Blended(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:36:19 +00:00
|
|
|
string text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderUNICODE_Blended(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
|
|
|
ushort[] text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderText_Blended_Wrapped(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:36:19 +00:00
|
|
|
string text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg,
|
2013-04-07 13:36:19 +00:00
|
|
|
uint wrapped
|
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderUTF8_Blended_Wrapped(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
2013-04-17 07:41:40 +00:00
|
|
|
[In()] [MarshalAs(UnmanagedType.LPStr)]
|
2013-04-07 13:36:19 +00:00
|
|
|
string text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg,
|
2013-04-07 13:36:19 +00:00
|
|
|
uint wrapped
|
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderUNICODE_Blended_Wrapped(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
|
|
|
ushort[] text,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg,
|
2013-04-07 13:36:19 +00:00
|
|
|
uint wrapped
|
|
|
|
);
|
|
|
|
|
2013-04-10 03:04:37 +00:00
|
|
|
/* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern IntPtr TTF_RenderGlyph_Blended(
|
2013-04-07 13:36:19 +00:00
|
|
|
IntPtr font,
|
|
|
|
ushort ch,
|
2013-04-08 16:09:41 +00:00
|
|
|
SDL.SDL_Color fg
|
2013-04-07 13:36:19 +00:00
|
|
|
);
|
2013-04-07 13:12:02 +00:00
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern void TTF_CloseFont(IntPtr font);
|
|
|
|
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern void TTF_Quit();
|
|
|
|
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int TTF_WasInit();
|
|
|
|
|
|
|
|
/* font refers to a TTF_Font* */
|
|
|
|
[DllImport(nativeLibName)]
|
|
|
|
public static extern int SDL_GetFontKerningSize(
|
|
|
|
IntPtr font,
|
|
|
|
int prev_index,
|
|
|
|
int index
|
|
|
|
);
|
|
|
|
|
|
|
|
#endregion
|
2013-04-03 16:15:53 +00:00
|
|
|
}
|
2013-04-17 07:41:40 +00:00
|
|
|
}
|