Font.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Font.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho.Gui
  18. {
  19. /// <summary>
  20. /// %Font resource.
  21. /// </summary>
  22. public unsafe partial class Font : Resource
  23. {
  24. unsafe partial void OnFontCreated ();
  25. [Preserve]
  26. public Font (IntPtr handle) : base (handle)
  27. {
  28. OnFontCreated ();
  29. }
  30. [Preserve]
  31. protected Font (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnFontCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Font_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Font_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Font_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Font_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Font_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Font));
  54. return new StringHash (Font_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Font_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Font));
  61. return Marshal.PtrToStringAnsi (Font_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Font () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Font_Font (IntPtr context);
  69. [Preserve]
  70. public Font (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Font));
  73. handle = Font_Font ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnFontCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void Font_RegisterObject (IntPtr context);
  79. /// <summary>
  80. /// Register object factory.
  81. /// </summary>
  82. public static void RegisterObject (Context context)
  83. {
  84. Runtime.Validate (typeof(Font));
  85. Font_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern bool Font_BeginLoad_File (IntPtr handle, IntPtr source);
  89. /// <summary>
  90. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  91. /// </summary>
  92. public override bool BeginLoad (File source)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return Font_BeginLoad_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern bool Font_BeginLoad_MemoryBuffer (IntPtr handle, IntPtr source);
  99. /// <summary>
  100. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  101. /// </summary>
  102. public override bool BeginLoad (MemoryBuffer source)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. return Font_BeginLoad_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern bool Font_SaveXML_File (IntPtr handle, IntPtr dest, int pointSize, bool usedGlyphs, string indentation);
  109. /// <summary>
  110. /// Save resource as a new bitmap font type in XML format. Return true if successful.
  111. /// </summary>
  112. public bool SaveXml (File dest, int pointSize, bool usedGlyphs = false, string indentation = "\t")
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. return Font_SaveXML_File (handle, (object)dest == null ? IntPtr.Zero : dest.Handle, pointSize, usedGlyphs, indentation);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern bool Font_SaveXML_MemoryBuffer (IntPtr handle, IntPtr dest, int pointSize, bool usedGlyphs, string indentation);
  119. /// <summary>
  120. /// Save resource as a new bitmap font type in XML format. Return true if successful.
  121. /// </summary>
  122. public bool SaveXml (MemoryBuffer dest, int pointSize, bool usedGlyphs = false, string indentation = "\t")
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. return Font_SaveXML_MemoryBuffer (handle, (object)dest == null ? IntPtr.Zero : dest.Handle, pointSize, usedGlyphs, indentation);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern void Font_SetAbsoluteGlyphOffset (IntPtr handle, ref Urho.IntVector2 offset);
  129. /// <summary>
  130. /// Set absolute (in pixels) position adjustment for glyphs.
  131. /// </summary>
  132. private void SetAbsoluteGlyphOffset (Urho.IntVector2 offset)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. Font_SetAbsoluteGlyphOffset (handle, ref offset);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern void Font_SetScaledGlyphOffset (IntPtr handle, ref Urho.Vector2 offset);
  139. /// <summary>
  140. /// Set point size scaled position adjustment for glyphs.
  141. /// </summary>
  142. private void SetScaledGlyphOffset (Urho.Vector2 offset)
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. Font_SetScaledGlyphOffset (handle, ref offset);
  146. }
  147. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  148. internal static extern IntPtr Font_GetFace (IntPtr handle, float pointSize);
  149. /// <summary>
  150. /// Return font face. Pack and render to a texture if not rendered yet. Return null on error.
  151. /// </summary>
  152. public FontFace GetFace (float pointSize)
  153. {
  154. Runtime.ValidateRefCounted (this);
  155. return Runtime.LookupRefCounted<FontFace> (Font_GetFace (handle, pointSize));
  156. }
  157. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  158. internal static extern FontType Font_GetFontType (IntPtr handle);
  159. /// <summary>
  160. /// Return font type.
  161. /// </summary>
  162. private FontType GetFontType ()
  163. {
  164. Runtime.ValidateRefCounted (this);
  165. return Font_GetFontType (handle);
  166. }
  167. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  168. internal static extern bool Font_IsSDFFont (IntPtr handle);
  169. /// <summary>
  170. /// Is signed distance field font.
  171. /// </summary>
  172. private bool IsSDFFont ()
  173. {
  174. Runtime.ValidateRefCounted (this);
  175. return Font_IsSDFFont (handle);
  176. }
  177. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  178. internal static extern Urho.IntVector2 Font_GetAbsoluteGlyphOffset (IntPtr handle);
  179. /// <summary>
  180. /// Return absolute position adjustment for glyphs.
  181. /// </summary>
  182. private Urho.IntVector2 GetAbsoluteGlyphOffset ()
  183. {
  184. Runtime.ValidateRefCounted (this);
  185. return Font_GetAbsoluteGlyphOffset (handle);
  186. }
  187. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  188. internal static extern Urho.Vector2 Font_GetScaledGlyphOffset (IntPtr handle);
  189. /// <summary>
  190. /// Return point size scaled position adjustment for glyphs.
  191. /// </summary>
  192. private Urho.Vector2 GetScaledGlyphOffset ()
  193. {
  194. Runtime.ValidateRefCounted (this);
  195. return Font_GetScaledGlyphOffset (handle);
  196. }
  197. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  198. internal static extern Urho.IntVector2 Font_GetTotalGlyphOffset (IntPtr handle, float pointSize);
  199. /// <summary>
  200. /// Return the total effective offset for a point size.
  201. /// </summary>
  202. public Urho.IntVector2 GetTotalGlyphOffset (float pointSize)
  203. {
  204. Runtime.ValidateRefCounted (this);
  205. return Font_GetTotalGlyphOffset (handle, pointSize);
  206. }
  207. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  208. internal static extern void Font_ReleaseFaces (IntPtr handle);
  209. /// <summary>
  210. /// Release font faces and recreate them next time when requested. Called when font textures lost or global font properties change.
  211. /// </summary>
  212. public void ReleaseFaces ()
  213. {
  214. Runtime.ValidateRefCounted (this);
  215. Font_ReleaseFaces (handle);
  216. }
  217. public override StringHash Type {
  218. get {
  219. return UrhoGetType ();
  220. }
  221. }
  222. public override string TypeName {
  223. get {
  224. return GetTypeName ();
  225. }
  226. }
  227. [Preserve]
  228. public new static StringHash TypeStatic {
  229. get {
  230. return GetTypeStatic ();
  231. }
  232. }
  233. public new static string TypeNameStatic {
  234. get {
  235. return GetTypeNameStatic ();
  236. }
  237. }
  238. /// <summary>
  239. /// Return absolute position adjustment for glyphs.
  240. /// Or
  241. /// Set absolute (in pixels) position adjustment for glyphs.
  242. /// </summary>
  243. public Urho.IntVector2 AbsoluteGlyphOffset {
  244. get {
  245. return GetAbsoluteGlyphOffset ();
  246. }
  247. set {
  248. SetAbsoluteGlyphOffset (value);
  249. }
  250. }
  251. /// <summary>
  252. /// Return point size scaled position adjustment for glyphs.
  253. /// Or
  254. /// Set point size scaled position adjustment for glyphs.
  255. /// </summary>
  256. public Urho.Vector2 ScaledGlyphOffset {
  257. get {
  258. return GetScaledGlyphOffset ();
  259. }
  260. set {
  261. SetScaledGlyphOffset (value);
  262. }
  263. }
  264. /// <summary>
  265. /// Return font type.
  266. /// </summary>
  267. public FontType FontType {
  268. get {
  269. return GetFontType ();
  270. }
  271. }
  272. /// <summary>
  273. /// Is signed distance field font.
  274. /// </summary>
  275. public bool SDFFont {
  276. get {
  277. return IsSDFFont ();
  278. }
  279. }
  280. }
  281. }