sdl2_ttf.pas 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409
  1. unit sdl2_ttf;
  2. {*
  3. SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
  4. Copyright (C) 2001-2013 Sam Lantinga <[email protected]>
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any damages
  7. arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose,
  9. including commercial applications, and to alter it and redistribute it
  10. freely, subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software
  13. in a product, an acknowledgement in the product documentation would be
  14. appreciated but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. *}
  19. {*
  20. * \file SDL_ttf.h
  21. *
  22. * Header file for SDL_ttf library
  23. *
  24. * This library is a wrapper around the excellent FreeType 2.0 library,
  25. * available at: https://www.freetype.org/
  26. *
  27. * Note: In many places, SDL_ttf will say "glyph" when it means "code point."
  28. * Unicode is hard, we learn as we go, and we apologize for adding to the
  29. * confusion.
  30. *
  31. }
  32. interface
  33. {$I jedi.inc}
  34. uses
  35. {$IFDEF FPC}
  36. ctypes,
  37. {$ENDIF}
  38. SDL2;
  39. {$I ctypes.inc}
  40. const
  41. {$IFDEF WINDOWS}
  42. TTF_LibName = 'SDL2_ttf.dll';
  43. {$ENDIF}
  44. {$IFDEF UNIX}
  45. {$IFDEF DARWIN}
  46. TTF_LibName = 'libSDL2_tff.dylib';
  47. {$ELSE}
  48. {$IFDEF FPC}
  49. TTF_LibName = 'libSDL2_ttf.so';
  50. {$ELSE}
  51. TTF_LibName = 'libSDL2_ttf.so.0';
  52. {$ENDIF}
  53. {$ENDIF}
  54. {$ENDIF}
  55. {$IFDEF MACOS}
  56. TTF_LibName = 'SDL2_ttf';
  57. {$IFDEF FPC}
  58. {$linklib libSDL2_ttf}
  59. {$ENDIF}
  60. {$ENDIF}
  61. {* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *}
  62. const
  63. SDL_TTF_MAJOR_VERSION = 2;
  64. SDL_TTF_MINOR_VERSION = 21;
  65. SDL_TTF_PATCHLEVEL = 0;
  66. procedure SDL_TTF_VERSION(Out X: TSDL_Version);
  67. {* Backwards compatibility *}
  68. const
  69. TTF_MAJOR_VERSION = SDL_TTF_MAJOR_VERSION;
  70. TTF_MINOR_VERSION = SDL_TTF_MINOR_VERSION;
  71. TTF_PATCHLEVEL = SDL_TTF_PATCHLEVEL;
  72. procedure TTF_VERSION(Out X: TSDL_Version);
  73. {**
  74. * This is the version number macro for the current SDL_ttf version.
  75. *
  76. * In versions higher than 2.9.0, the minor version overflows into
  77. * the thousands digit: for example, 2.23.0 is encoded as 4300.
  78. * This macro will not be available in SDL 3.x or SDL_ttf 3.x.
  79. *
  80. * \deprecated, use SDL_TTF_VERSION_ATLEAST or SDL_TTF_VERSION instead.
  81. *}
  82. { SDL2-for-Pascal: This conditional and deprecated macro is not translated.
  83. It could be done easily but nobody ever asked for it and
  84. it is probably for little use. }
  85. // function SDL_TTF_COMPILEDVERSION: Integer;
  86. {**
  87. * This macro will evaluate to true if compiled with SDL_ttf at least X.Y.Z.
  88. *}
  89. function SDL_TTF_VERSION_ATLEAST(X, Y, Z: Integer): Boolean;
  90. {*
  91. * Query the version of SDL_ttf that the program is linked against.
  92. *
  93. * This function gets the version of the dynamically linked SDL_ttf library.
  94. * This is separate from the SDL_TTF_VERSION() macro, which tells you what
  95. * version of the SDL_ttf headers you compiled against.
  96. *
  97. * This returns static internal data; do not free or modify it!
  98. *
  99. * \returns a pointer to the version information.
  100. *
  101. * \since This function is available since SDL_ttf 2.0.12.
  102. }
  103. (* Const before type ignored *)
  104. function TTF_Linked_Version: PSDL_version; cdecl;
  105. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_Linked_Version' {$ENDIF} {$ENDIF};
  106. {*
  107. * Query the version of the FreeType library in use.
  108. *
  109. * TTF_Init() should be called before calling this function.
  110. *
  111. * \param major to be filled in with the major version number. Can be nil.
  112. * \param minor to be filled in with the minor version number. Can be nil.
  113. * \param patch to be filled in with the param version number. Can be nil.
  114. *
  115. * \since This function is available since SDL_ttf 2.0.18.
  116. *
  117. * \sa TTF_Init
  118. }
  119. procedure TTF_GetFreeTypeVersion(major: pcint; minor: pcint; patch: pcint); cdecl;
  120. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFreeTypeVersion' {$ENDIF} {$ENDIF};
  121. {*
  122. * Query the version of the HarfBuzz library in use.
  123. *
  124. * If HarfBuzz is not available, the version reported is 0.0.0.
  125. *
  126. * \param major to be filled in with the major version number. Can be nil.
  127. * \param minor to be filled in with the minor version number. Can be nil.
  128. * \param patch to be filled in with the param version number. Can be nil.
  129. *
  130. * \since This function is available since SDL_ttf 2.0.18.
  131. }
  132. procedure TTF_GetHarfBuzzVersion(major: pcint; minor: pcint; patch: pcint); cdecl;
  133. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetHarfBuzzVersion' {$ENDIF} {$ENDIF};
  134. {*
  135. * ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
  136. }
  137. const
  138. UNICODE_BOM_NATIVE = $FEFF;
  139. UNICODE_BOM_SWAPPED = $FFFE;
  140. {*
  141. * Tell SDL_ttf whether UNICODE text is generally byteswapped.
  142. *
  143. * A UNICODE BOM character in a string will override this setting for the
  144. * remainder of that string.
  145. *
  146. * \param swapped boolean to indicate whether text is byteswapped
  147. *
  148. * \since This function is available since SDL_ttf 2.0.12.
  149. }
  150. procedure TTF_ByteSwappedUNICODE(swapped: TSDL_bool); cdecl;
  151. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_ByteSwappedUNICODE' {$ENDIF} {$ENDIF};
  152. {* The internal structure containing font information *}
  153. type
  154. PPTTF_Font = ^PTTF_Font;
  155. PTTF_Font = ^TTTF_Font;
  156. TTTF_Font = record end; //todo?
  157. {*
  158. * Initialize SDL_ttf.
  159. *
  160. * You must successfully call this function before it is safe to call any
  161. * other function in this library, with one exception: a human-readable error
  162. * message can be retrieved from TTF_GetError() if this function fails.
  163. *
  164. * SDL must be initialized before calls to functions in this library, because
  165. * this library uses utility functions from the SDL library.
  166. *
  167. * It is safe to call this more than once; the library keeps a counter of init
  168. * calls, and decrements it on each call to TTF_Quit, so you must pair your
  169. * init and quit calls.
  170. *
  171. * \returns 0 on success, -1 on error.
  172. *
  173. * \since This function is available since SDL_ttf 2.0.12.
  174. *
  175. * \sa TTF_Quit
  176. }
  177. function TTF_Init(): cint; cdecl;
  178. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_Init' {$ENDIF} {$ENDIF};
  179. {*
  180. * Create a font from a file, using a specified point size.
  181. *
  182. * Some .fon fonts will have several sizes embedded in the file, so the point
  183. * size becomes the index of choosing which size. If the value is too high,
  184. * the last indexed size will be the default.
  185. *
  186. * When done with the returned TTF_Font, use TTF_CloseFont() to dispose of it.
  187. *
  188. * \param file path to font file.
  189. * \param ptsize point size to use for the newly-opened font.
  190. * \returns a valid TTF_Font, or nil on error.
  191. *
  192. * \since This function is available since SDL_ttf 2.0.12.
  193. *
  194. * \sa TTF_CloseFont
  195. }
  196. function TTF_OpenFont(file_: PAnsiChar; ptsize: cint): PTTF_Font; cdecl;
  197. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_OpenFont' {$ENDIF} {$ENDIF};
  198. {*
  199. * Create a font from a file, using a specified face index.
  200. *
  201. * Some .fon fonts will have several sizes embedded in the file, so the point
  202. * size becomes the index of choosing which size. If the value is too high,
  203. * the last indexed size will be the default.
  204. *
  205. * Some fonts have multiple "faces" included. The index specifies which face
  206. * to use from the font file. Font files with only one face should specify
  207. * zero for the index.
  208. *
  209. * When done with the returned TTF_Font, use TTF_CloseFont() to dispose of it.
  210. *
  211. * \param file path to font file.
  212. * \param ptsize point size to use for the newly-opened font.
  213. * \param index index of the face in the font file.
  214. * \returns a valid TTF_Font, or nil on error.
  215. *
  216. * \since This function is available since SDL_ttf 2.0.12.
  217. *
  218. * \sa TTF_CloseFont
  219. }
  220. function TTF_OpenFontIndex(file_: PAnsiChar; ptsize: cint; index: clong): PTTF_Font; cdecl;
  221. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_OpenFontIndex' {$ENDIF} {$ENDIF};
  222. {*
  223. * Create a font from an SDL_RWops, using a specified point size.
  224. *
  225. * Some .fon fonts will have several sizes embedded in the file, so the point
  226. * size becomes the index of choosing which size. If the value is too high,
  227. * the last indexed size will be the default.
  228. *
  229. * If `freesrc` is non-zero, the RWops will be closed before returning,
  230. * whether this function succeeds or not. SDL_ttf reads everything it needs
  231. * from the RWops during this call in any case.
  232. *
  233. * When done with the returned TTF_Font, use TTF_CloseFont() to dispose of it.
  234. *
  235. * \param src an SDL_RWops to provide a font file's data.
  236. * \param freesrc non-zero to close the RWops before returning, zero to leave
  237. * it open.
  238. * \param ptsize point size to use for the newly-opened font.
  239. * \returns a valid TTF_Font, or nil on error.
  240. *
  241. * \since This function is available since SDL_ttf 2.0.12.
  242. *
  243. * \sa TTF_CloseFont
  244. }
  245. function TTF_OpenFontRW(src: PSDL_RWops; freesrc: cint; ptsize: cint): PTTF_Font; cdecl;
  246. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_OpenFontRW' {$ENDIF} {$ENDIF};
  247. {*
  248. * Create a font from an SDL_RWops, using a specified face index.
  249. *
  250. * Some .fon fonts will have several sizes embedded in the file, so the point
  251. * size becomes the index of choosing which size. If the value is too high,
  252. * the last indexed size will be the default.
  253. *
  254. * If `freesrc` is non-zero, the RWops will be closed before returning,
  255. * whether this function succeeds or not. SDL_ttf reads everything it needs
  256. * from the RWops during this call in any case.
  257. *
  258. * Some fonts have multiple "faces" included. The index specifies which face
  259. * to use from the font file. Font files with only one face should specify
  260. * zero for the index.
  261. *
  262. * When done with the returned TTF_Font, use TTF_CloseFont() to dispose of it.
  263. *
  264. * \param src an SDL_RWops to provide a font file's data.
  265. * \param freesrc non-zero to close the RWops before returning, zero to leave
  266. * it open.
  267. * \param ptsize point size to use for the newly-opened font.
  268. * \param index index of the face in the font file.
  269. * \returns a valid TTF_Font, or nil on error.
  270. *
  271. * \since This function is available since SDL_ttf 2.0.12.
  272. *
  273. * \sa TTF_CloseFont
  274. }
  275. function TTF_OpenFontIndexRW(src: PSDL_RWops; freesrc: cint; ptsize: cint; index: clong): PTTF_Font; cdecl;
  276. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_OpenFontIndexRW' {$ENDIF} {$ENDIF};
  277. {*
  278. * Create a font from a file, using target resolutions (in DPI).
  279. *
  280. * DPI scaling only applies to scalable fonts (e.g. TrueType).
  281. *
  282. * Some .fon fonts will have several sizes embedded in the file, so the point
  283. * size becomes the index of choosing which size. If the value is too high,
  284. * the last indexed size will be the default.
  285. *
  286. * When done with the returned TTF_Font, use TTF_CloseFont() to dispose of it.
  287. *
  288. * \param file path to font file.
  289. * \param ptsize point size to use for the newly-opened font.
  290. * \param hdpi the target horizontal DPI.
  291. * \param vdpi the target vertical DPI.
  292. * \returns a valid TTF_Font, or nil on error.
  293. *
  294. * \since This function is available since SDL_ttf 2.0.18.
  295. *
  296. * \sa TTF_CloseFont
  297. }
  298. function TTF_OpenFontDPI(file_: PAnsiChar; ptsize: cint; hdpi: cuint; vdpi: cuint): PTTF_Font; cdecl;
  299. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_OpenFontDPI' {$ENDIF} {$ENDIF};
  300. {*
  301. * Create a font from a file, using target resolutions (in DPI).
  302. *
  303. * DPI scaling only applies to scalable fonts (e.g. TrueType).
  304. *
  305. * Some .fon fonts will have several sizes embedded in the file, so the point
  306. * size becomes the index of choosing which size. If the value is too high,
  307. * the last indexed size will be the default.
  308. *
  309. * Some fonts have multiple "faces" included. The index specifies which face
  310. * to use from the font file. Font files with only one face should specify
  311. * zero for the index.
  312. *
  313. * When done with the returned TTF_Font, use TTF_CloseFont() to dispose of it.
  314. *
  315. * \param file path to font file.
  316. * \param ptsize point size to use for the newly-opened font.
  317. * \param index index of the face in the font file.
  318. * \param hdpi the target horizontal DPI.
  319. * \param vdpi the target vertical DPI.
  320. * \returns a valid TTF_Font, or nil on error.
  321. *
  322. * \since This function is available since SDL_ttf 2.0.18.
  323. *
  324. * \sa TTF_CloseFont
  325. }
  326. function TTF_OpenFontIndexDPI(file_: PAnsiChar; ptsize: cint; index: clong; hdpi: cuint; vdpi: cuint): PTTF_Font; cdecl;
  327. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_OpenFontIndexDPI' {$ENDIF} {$ENDIF};
  328. {*
  329. * Opens a font from an SDL_RWops with target resolutions (in DPI).
  330. *
  331. * DPI scaling only applies to scalable fonts (e.g. TrueType).
  332. *
  333. * Some .fon fonts will have several sizes embedded in the file, so the point
  334. * size becomes the index of choosing which size. If the value is too high,
  335. * the last indexed size will be the default.
  336. *
  337. * If `freesrc` is non-zero, the RWops will be closed before returning,
  338. * whether this function succeeds or not. SDL_ttf reads everything it needs
  339. * from the RWops during this call in any case.
  340. *
  341. * When done with the returned TTF_Font, use TTF_CloseFont() to dispose of it.
  342. *
  343. * \param src an SDL_RWops to provide a font file's data.
  344. * \param freesrc non-zero to close the RWops before returning, zero to leave
  345. * it open.
  346. * \param ptsize point size to use for the newly-opened font.
  347. * \param hdpi the target horizontal DPI.
  348. * \param vdpi the target vertical DPI.
  349. * \returns a valid TTF_Font, or nil on error.
  350. *
  351. * \since This function is available since SDL_ttf 2.0.18.
  352. *
  353. * \sa TTF_CloseFont
  354. }
  355. function TTF_OpenFontDPIRW(src: PSDL_RWops; freesrc: cint; ptsize: cint; hdpi: cuint; vdpi: cuint): PTTF_Font; cdecl;
  356. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_OpenFontDPIRW' {$ENDIF} {$ENDIF};
  357. {*
  358. * Opens a font from an SDL_RWops with target resolutions (in DPI).
  359. *
  360. * DPI scaling only applies to scalable fonts (e.g. TrueType).
  361. *
  362. * Some .fon fonts will have several sizes embedded in the file, so the point
  363. * size becomes the index of choosing which size. If the value is too high,
  364. * the last indexed size will be the default.
  365. *
  366. * If `freesrc` is non-zero, the RWops will be closed before returning,
  367. * whether this function succeeds or not. SDL_ttf reads everything it needs
  368. * from the RWops during this call in any case.
  369. *
  370. * Some fonts have multiple "faces" included. The index specifies which face
  371. * to use from the font file. Font files with only one face should specify
  372. * zero for the index.
  373. *
  374. * When done with the returned TTF_Font, use TTF_CloseFont() to dispose of it.
  375. *
  376. * \param src an SDL_RWops to provide a font file's data.
  377. * \param freesrc non-zero to close the RWops before returning, zero to leave
  378. * it open.
  379. * \param ptsize point size to use for the newly-opened font.
  380. * \param index index of the face in the font file.
  381. * \param hdpi the target horizontal DPI.
  382. * \param vdpi the target vertical DPI.
  383. * \returns a valid TTF_Font, or nil on error.
  384. *
  385. * \since This function is available since SDL_ttf 2.0.18.
  386. *
  387. * \sa TTF_CloseFont
  388. }
  389. function TTF_OpenFontIndexDPIRW(src: PSDL_RWops; freesrc: cint; ptsize: cint; index: clong; hdpi: cuint; vdpi: cuint): PTTF_Font; cdecl;
  390. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_OpenFontIndexDPIRW' {$ENDIF} {$ENDIF};
  391. {*
  392. * Set a font's size dynamically.
  393. *
  394. * This clears already-generated glyphs, if any, from the cache.
  395. *
  396. * \param font the font to resize.
  397. * \param ptsize the new point size.
  398. * \returns 0 if successful, -1 on error
  399. *
  400. * \since This function is available since SDL_ttf 2.0.18.
  401. }
  402. function TTF_SetFontSize(font: PTTF_Font; ptsize: cint): cint; cdecl;
  403. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontSize' {$ENDIF} {$ENDIF};
  404. {*
  405. * Set font size dynamically with target resolutions (in DPI).
  406. *
  407. * This clears already-generated glyphs, if any, from the cache.
  408. *
  409. * \param font the font to resize.
  410. * \param ptsize the new point size.
  411. * \param hdpi the target horizontal DPI.
  412. * \param vdpi the target vertical DPI.
  413. * \returns 0 if successful, -1 on error.
  414. *
  415. * \since This function is available since SDL_ttf 2.0.18.
  416. }
  417. function TTF_SetFontSizeDPI(font: PTTF_Font; ptsize: cint; hdpi: cuint; vdpi: cuint): cint; cdecl;
  418. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontSizeDPI' {$ENDIF} {$ENDIF};
  419. {*
  420. * Font style flags
  421. }
  422. const
  423. TTF_STYLE_NORMAL = $00;
  424. TTF_STYLE_BOLD = $01;
  425. TTF_STYLE_ITALIC = $02;
  426. TTF_STYLE_UNDERLINE = $04;
  427. TTF_STYLE_STRIKETHROUGH = $08;
  428. {*
  429. * Query a font's current style.
  430. *
  431. * The font styles are a set of bit flags, OR'd together:
  432. *
  433. * - `TTF_STYLE_NORMAL` (is zero)
  434. * - `TTF_STYLE_BOLD`
  435. * - `TTF_STYLE_ITALIC`
  436. * - `TTF_STYLE_UNDERLINE`
  437. * - `TTF_STYLE_STRIKETHROUGH`
  438. *
  439. * \param font the font to query.
  440. * \returns the current font style, as a set of bit flags.
  441. *
  442. * \since This function is available since SDL_ttf 2.0.12.
  443. *
  444. * \sa TTF_SetFontStyle
  445. }
  446. function TTF_GetFontStyle(font: PTTF_Font): cint; cdecl;
  447. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontStyle' {$ENDIF} {$ENDIF};
  448. {*
  449. * Set a font's current style.
  450. *
  451. * Setting the style clears already-generated glyphs, if any, from the cache.
  452. *
  453. * The font styles are a set of bit flags, OR'd together:
  454. *
  455. * - `TTF_STYLE_NORMAL` (is zero)
  456. * - `TTF_STYLE_BOLD`
  457. * - `TTF_STYLE_ITALIC`
  458. * - `TTF_STYLE_UNDERLINE`
  459. * - `TTF_STYLE_STRIKETHROUGH`
  460. *
  461. * \param font the font to set a new style on.
  462. * \param style the new style values to set, OR'd together.
  463. *
  464. * \since This function is available since SDL_ttf 2.0.12.
  465. *
  466. * \sa TTF_GetFontStyle
  467. }
  468. procedure TTF_SetFontStyle(font: PTTF_Font; style: cint); cdecl;
  469. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontStyle' {$ENDIF} {$ENDIF};
  470. {*
  471. * Query a font's current outline.
  472. *
  473. * \param font the font to query.
  474. * \returns the font's current outline value.
  475. *
  476. * \since This function is available since SDL_ttf 2.0.12.
  477. *
  478. * \sa TTF_SetFontOutline
  479. }
  480. function TTF_GetFontOutline(font: PTTF_Font): cint; cdecl;
  481. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontOutline' {$ENDIF} {$ENDIF};
  482. {*
  483. * Set a font's current outline.
  484. *
  485. * \param font the font to set a new outline on.
  486. * \param outline positive outline value, 0 to default.
  487. *
  488. * \since This function is available since SDL_ttf 2.0.12.
  489. *
  490. * \sa TTF_GetFontOutline
  491. }
  492. procedure TTF_SetFontOutline(font: PTTF_Font; outline: cint); cdecl;
  493. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontOutline' {$ENDIF} {$ENDIF};
  494. {*
  495. * Hinting flags
  496. }
  497. const
  498. TTF_HINTING_NORMAL = 0;
  499. TTF_HINTING_LIGHT = 1;
  500. TTF_HINTING_MONO = 2;
  501. TTF_HINTING_NONE = 3;
  502. TTF_HINTING_LIGHT_SUBPIXEL = 4;
  503. {*
  504. * Query a font's current FreeType hinter setting.
  505. *
  506. * The hinter setting is a single value:
  507. *
  508. * - `TTF_HINTING_NORMAL`
  509. * - `TTF_HINTING_LIGHT`
  510. * - `TTF_HINTING_MONO`
  511. * - `TTF_HINTING_NONE`
  512. * - `TTF_HINTING_LIGHT_SUBPIXEL` (available in SDL_ttf 2.0.18 and later)
  513. *
  514. * \param font the font to query.
  515. * \returns the font's current hinter value.
  516. *
  517. * \since This function is available since SDL_ttf 2.0.12.
  518. *
  519. * \sa TTF_SetFontHinting
  520. }
  521. function TTF_GetFontHinting(font: PTTF_Font): cint; cdecl;
  522. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontHinting' {$ENDIF} {$ENDIF};
  523. {*
  524. * Set a font's current hinter setting.
  525. *
  526. * Setting it clears already-generated glyphs, if any, from the cache.
  527. *
  528. * The hinter setting is a single value:
  529. *
  530. * - `TTF_HINTING_NORMAL`
  531. * - `TTF_HINTING_LIGHT`
  532. * - `TTF_HINTING_MONO`
  533. * - `TTF_HINTING_NONE`
  534. * - `TTF_HINTING_LIGHT_SUBPIXEL` (available in SDL_ttf 2.0.18 and later)
  535. *
  536. * \param font the font to set a new hinter setting on.
  537. * \param hinting the new hinter setting.
  538. *
  539. * \since This function is available since SDL_ttf 2.0.12.
  540. *
  541. * \sa TTF_GetFontHinting
  542. }
  543. procedure TTF_SetFontHinting(font: PTTF_Font; hinting: cint); cdecl;
  544. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontHinting' {$ENDIF} {$ENDIF};
  545. {*
  546. * Special layout option for rendering wrapped text
  547. }
  548. const
  549. TTF_WRAPPED_ALIGN_LEFT = 0;
  550. TTF_WRAPPED_ALIGN_CENTER = 1;
  551. TTF_WRAPPED_ALIGN_RIGHT = 2;
  552. {*
  553. * Query a font's current wrap alignment option.
  554. *
  555. * The wrap alignment option can be one of the following:
  556. *
  557. * - `TTF_WRAPPED_ALIGN_LEFT`
  558. * - `TTF_WRAPPED_ALIGN_CENTER`
  559. * - `TTF_WRAPPED_ALIGN_RIGHT`
  560. *
  561. * \param font the font to query.
  562. * \returns the font's current wrap alignment option.
  563. *
  564. * \since This function is available since SDL_ttf 2.20.0.
  565. *
  566. * \sa TTF_SetFontWrappedAlign
  567. }
  568. function TTF_GetFontWrappedAlign(font: PTTF_Font): cint; cdecl;
  569. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontWrappedAlign' {$ENDIF} {$ENDIF};
  570. {*
  571. * Set a font's current wrap alignment option.
  572. *
  573. * The wrap alignment option can be one of the following:
  574. *
  575. * - `TTF_WRAPPED_ALIGN_LEFT`
  576. * - `TTF_WRAPPED_ALIGN_CENTER`
  577. * - `TTF_WRAPPED_ALIGN_RIGHT`
  578. *
  579. * \param font the font to set a new wrap alignment option on.
  580. * \param align the new wrap alignment option.
  581. *
  582. * \since This function is available since SDL_ttf 2.20.0.
  583. *
  584. * \sa TTF_GetFontWrappedAlign
  585. }
  586. procedure TTF_SetFontWrappedAlign(font: PTTF_Font; align: cint); cdecl;
  587. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontWrappedAlign' {$ENDIF} {$ENDIF};
  588. {*
  589. * Query the total height of a font.
  590. *
  591. * This is usually equal to point size.
  592. *
  593. * \param font the font to query.
  594. * \returns the font's height.
  595. *
  596. * \since This function is available since SDL_ttf 2.0.12.
  597. }
  598. function TTF_FontHeight(font: PTTF_Font): cint; cdecl;
  599. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_FontHeight' {$ENDIF} {$ENDIF};
  600. {*
  601. * Query the offset from the baseline to the top of a font.
  602. *
  603. * This is a positive value, relative to the baseline.
  604. *
  605. * \param font the font to query.
  606. * \returns the font's ascent.
  607. *
  608. * \since This function is available since SDL_ttf 2.0.12.
  609. }
  610. function TTF_FontAscent(font: PTTF_Font): cint; cdecl;
  611. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_FontAscent' {$ENDIF} {$ENDIF};
  612. {*
  613. * Query the offset from the baseline to the bottom of a font.
  614. *
  615. * This is a negative value, relative to the baseline.
  616. *
  617. * \param font the font to query.
  618. * \returns the font's descent.
  619. *
  620. * \since This function is available since SDL_ttf 2.0.12.
  621. }
  622. function TTF_FontDescent(font: PTTF_Font): cint; cdecl;
  623. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_FontDescent' {$ENDIF} {$ENDIF};
  624. {*
  625. * Query the recommended spacing between lines of text for a font.
  626. *
  627. * \param font the font to query.
  628. * \returns the font's recommended spacing.
  629. *
  630. * \since This function is available since SDL_ttf 2.0.12.
  631. }
  632. function TTF_FontLineSkip(font: PTTF_Font): cint; cdecl;
  633. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_FontLineSkip' {$ENDIF} {$ENDIF};
  634. {*
  635. * Query whether or not kerning is allowed for a font.
  636. *
  637. * \param font the font to query.
  638. * \returns non-zero if kerning is enabled, zero otherwise.
  639. *
  640. * \since This function is available since SDL_ttf 2.0.12.
  641. }
  642. function TTF_GetFontKerning(font: PTTF_Font): cint; cdecl;
  643. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontKerning' {$ENDIF} {$ENDIF};
  644. {*
  645. * Set if kerning is allowed for a font.
  646. *
  647. * Newly-opened fonts default to allowing kerning. This is generally a good
  648. * policy unless you have a strong reason to disable it, as it tends to
  649. * produce better rendering (with kerning disabled, some fonts might render
  650. * the word `kerning` as something that looks like `keming` for example).
  651. *
  652. * \param font the font to set kerning on.
  653. * \param allowed non-zero to allow kerning, zero to disallow.
  654. *
  655. * \since This function is available since SDL_ttf 2.0.12.
  656. }
  657. procedure TTF_SetFontKerning(font: PTTF_Font; allowed: cint); cdecl;
  658. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontKerning' {$ENDIF} {$ENDIF};
  659. {*
  660. * Query the number of faces of a font.
  661. *
  662. * \param font the font to query.
  663. * \returns the number of FreeType font faces.
  664. *
  665. * \since This function is available since SDL_ttf 2.0.12.
  666. }
  667. function TTF_FontFaces(font: PTTF_Font): clong; cdecl;
  668. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_FontFaces' {$ENDIF} {$ENDIF};
  669. {*
  670. * Query whether a font is fixed-width.
  671. *
  672. * A "fixed-width" font means all glyphs are the same width across; a
  673. * lowercase 'i' will be the same size across as a capital 'W', for example.
  674. * This is common for terminals and text editors, and other apps that treat
  675. * text as a grid. Most other things (WYSIWYG word processors, web pages, etc)
  676. * are more likely to not be fixed-width in most cases.
  677. *
  678. * \param font the font to query.
  679. * \returns non-zero if fixed-width, zero if not.
  680. *
  681. * \since This function is available since SDL_ttf 2.0.12.
  682. }
  683. function TTF_FontFaceIsFixedWidth(font: PTTF_Font): cint; cdecl;
  684. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_FontFaceIsFixedWidth' {$ENDIF} {$ENDIF};
  685. {*
  686. * Query a font's family name.
  687. *
  688. * This string is dictated by the contents of the font file.
  689. *
  690. * Note that the returned string is to internal storage, and should not be
  691. * modifed or free'd by the caller. The string becomes invalid, with the rest
  692. * of the font, when `font` is handed to TTF_CloseFont().
  693. *
  694. * \param font the font to query.
  695. * \returns the font's family name.
  696. *
  697. * \since This function is available since SDL_ttf 2.0.12.
  698. }
  699. function TTF_FontFaceFamilyName(font: PTTF_Font): PAnsiChar; cdecl;
  700. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_FontFaceFamilyName' {$ENDIF} {$ENDIF};
  701. {*
  702. * Query a font's style name.
  703. *
  704. * This string is dictated by the contents of the font file.
  705. *
  706. * Note that the returned string is to internal storage, and should not be
  707. * modifed or free'd by the caller. The string becomes invalid, with the rest
  708. * of the font, when `font` is handed to TTF_CloseFont().
  709. *
  710. * \param font the font to query.
  711. * \returns the font's style name.
  712. *
  713. * \since This function is available since SDL_ttf 2.0.12.
  714. }
  715. function TTF_FontFaceStyleName(font: PTTF_Font): PAnsiChar; cdecl;
  716. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_FontFaceStyleName' {$ENDIF} {$ENDIF};
  717. {*
  718. * Check whether a glyph is provided by the font for a 16-bit codepoint.
  719. *
  720. * Note that this version of the function takes a 16-bit character code, which
  721. * covers the Basic Multilingual Plane, but is insufficient to cover the
  722. * entire set of possible Unicode values, including emoji glyphs. You should
  723. * use TTF_GlyphIsProvided32() instead, which offers the same functionality
  724. * but takes a 32-bit codepoint instead.
  725. *
  726. * The only reason to use this function is that it was available since the
  727. * beginning of time, more or less.
  728. *
  729. * \param font the font to query.
  730. * \param ch the character code to check.
  731. * \returns non-zero if font provides a glyph for this character, zero if not.
  732. *
  733. * \since This function is available since SDL_ttf 2.0.12.
  734. *
  735. * \sa TTF_GlyphIsProvided32
  736. }
  737. function TTF_GlyphIsProvided(font: PTTF_Font; ch: cuint16): cint; cdecl;
  738. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GlyphIsProvided' {$ENDIF} {$ENDIF};
  739. {*
  740. * Check whether a glyph is provided by the font for a 32-bit codepoint.
  741. *
  742. * This is the same as TTF_GlyphIsProvided(), but takes a 32-bit character
  743. * instead of 16-bit, and thus can query a larger range. If you are sure
  744. * you'll have an SDL_ttf that's version 2.0.18 or newer, there's no reason
  745. * not to use this function exclusively.
  746. *
  747. * \param font the font to query.
  748. * \param ch the character code to check.
  749. * \returns non-zero if font provides a glyph for this character, zero if not.
  750. *
  751. * \since This function is available since SDL_ttf 2.0.18.
  752. }
  753. function TTF_GlyphIsProvided32(font: PTTF_Font; ch: cuint32): cint; cdecl;
  754. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GlyphIsProvided32' {$ENDIF} {$ENDIF};
  755. {*
  756. * Query the metrics (dimensions) of a font's 16-bit glyph.
  757. *
  758. * To understand what these metrics mean, here is a useful link:
  759. *
  760. * https://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
  761. *
  762. * Note that this version of the function takes a 16-bit character code, which
  763. * covers the Basic Multilingual Plane, but is insufficient to cover the
  764. * entire set of possible Unicode values, including emoji glyphs. You should
  765. * use TTF_GlyphMetrics32() instead, which offers the same functionality but
  766. * takes a 32-bit codepoint instead.
  767. *
  768. * The only reason to use this function is that it was available since the
  769. * beginning of time, more or less.
  770. *
  771. * \param font the font to query.
  772. * \param ch the character code to check.
  773. *
  774. * \since This function is available since SDL_ttf 2.0.12.
  775. *
  776. * \sa TTF_GlyphMetrics32
  777. }
  778. function TTF_GlyphMetrics(font: PTTF_Font; ch: cuint16; minx: pcint; maxx: pcint; miny: pcint; maxy: pcint; advance: pcint): cint; cdecl;
  779. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GlyphMetrics' {$ENDIF} {$ENDIF};
  780. {*
  781. * Query the metrics (dimensions) of a font's 32-bit glyph.
  782. *
  783. * To understand what these metrics mean, here is a useful link:
  784. *
  785. * https://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
  786. *
  787. * This is the same as TTF_GlyphMetrics(), but takes a 32-bit character
  788. * instead of 16-bit, and thus can query a larger range. If you are sure
  789. * you'll have an SDL_ttf that's version 2.0.18 or newer, there's no reason
  790. * not to use this function exclusively.
  791. *
  792. * \param font the font to query.
  793. * \param ch the character code to check.
  794. *
  795. * \since This function is available since SDL_ttf 2.0.18.
  796. }
  797. function TTF_GlyphMetrics32(font: PTTF_Font; ch: cuint32; minx: pcint; maxx: pcint; miny: pcint; maxy: pcint; advance: pcint): cint; cdecl;
  798. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GlyphMetrics32' {$ENDIF} {$ENDIF};
  799. {*
  800. * Calculate the dimensions of a rendered string of Latin1 text.
  801. *
  802. * This will report the width and height, in pixels, of the space that the
  803. * specified string will take to fully render.
  804. *
  805. * This does not need to render the string to do this calculation.
  806. *
  807. * You almost certainly want TTF_SizeUTF8() unless you're sure you have a
  808. * 1-byte Latin1 encoding. US ASCII characters will work with either function,
  809. * but most other Unicode characters packed into a `const char *` will need
  810. * UTF-8.
  811. *
  812. * \param font the font to query.
  813. * \param text text to calculate, in Latin1 encoding.
  814. * \param w will be filled with width, in pixels, on return.
  815. * \param h will be filled with height, in pixels, on return.
  816. * \returns 0 if successful, -1 on error.
  817. *
  818. * \since This function is available since SDL_ttf 2.0.12.
  819. *
  820. * \sa TTF_SizeUTF8
  821. * \sa TTF_SizeUNICODE
  822. }
  823. function TTF_SizeText(font: PTTF_Font; text: PAnsiChar; w: pcint; h: pcint): cint; cdecl;
  824. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SizeText' {$ENDIF} {$ENDIF};
  825. {*
  826. * Calculate the dimensions of a rendered string of UTF-8 text.
  827. *
  828. * This will report the width and height, in pixels, of the space that the
  829. * specified string will take to fully render.
  830. *
  831. * This does not need to render the string to do this calculation.
  832. *
  833. * \param font the font to query.
  834. * \param text text to calculate, in UTF-8 encoding.
  835. * \param w will be filled with width, in pixels, on return.
  836. * \param h will be filled with height, in pixels, on return.
  837. * \returns 0 if successful, -1 on error.
  838. *
  839. * \since This function is available since SDL_ttf 2.0.12.
  840. *
  841. * \sa TTF_SizeUNICODE
  842. }
  843. function TTF_SizeUTF8(font: PTTF_Font; text: PAnsiChar; w: pcint; h: pcint): cint; cdecl;
  844. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SizeUTF8' {$ENDIF} {$ENDIF};
  845. {*
  846. * Calculate the dimensions of a rendered string of UCS-2 text.
  847. *
  848. * This will report the width and height, in pixels, of the space that the
  849. * specified string will take to fully render.
  850. *
  851. * This does not need to render the string to do this calculation.
  852. *
  853. * Please note that this function is named "Unicode" but currently expects
  854. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  855. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  856. * through the UTF-8 version of this function.
  857. *
  858. * \param font the font to query.
  859. * \param text text to calculate, in UCS-2 encoding.
  860. * \param w will be filled with width, in pixels, on return.
  861. * \param h will be filled with height, in pixels, on return.
  862. * \returns 0 if successful, -1 on error.
  863. *
  864. * \since This function is available since SDL_ttf 2.0.12.
  865. *
  866. * \sa TTF_SizeUTF8
  867. }
  868. function TTF_SizeUNICODE(font: PTTF_Font; text: pcuint16; w: pcint; h: pcint): cint; cdecl;
  869. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SizeUNICODE' {$ENDIF} {$ENDIF};
  870. {*
  871. * Calculate how much of a Latin1 string will fit in a given width.
  872. *
  873. * This reports the number of characters that can be rendered before reaching
  874. * `measure_width`.
  875. *
  876. * This does not need to render the string to do this calculation.
  877. *
  878. * You almost certainly want TTF_MeasureUTF8() unless you're sure you have a
  879. * 1-byte Latin1 encoding. US ASCII characters will work with either function,
  880. * but most other Unicode characters packed into a `const char *` will need
  881. * UTF-8.
  882. *
  883. * \param font the font to query.
  884. * \param text text to calculate, in Latin1 encoding.
  885. * \param measure_width maximum width, in pixels, available for the string.
  886. * \param count on return, filled with number of characters that can be
  887. * rendered.
  888. * \param extent on return, filled with latest calculated width.
  889. * \returns 0 if successful, -1 on error.
  890. *
  891. * \since This function is available since SDL_ttf 2.0.18.
  892. *
  893. * \sa TTF_MeasureText
  894. * \sa TTF_MeasureUTF8
  895. * \sa TTF_MeasureUNICODE
  896. }
  897. function TTF_MeasureText(font: PTTF_Font; text: PAnsiChar; measure_width: cint; extent: pcint; count: pcint): cint; cdecl;
  898. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_MeasureText' {$ENDIF} {$ENDIF};
  899. {*
  900. * Calculate how much of a UTF-8 string will fit in a given width.
  901. *
  902. * This reports the number of characters that can be rendered before reaching
  903. * `measure_width`.
  904. *
  905. * This does not need to render the string to do this calculation.
  906. *
  907. * \param font the font to query.
  908. * \param text text to calculate, in UTF-8 encoding.
  909. * \param measure_width maximum width, in pixels, available for the string.
  910. * \param count on return, filled with number of characters that can be
  911. * rendered.
  912. * \param extent on return, filled with latest calculated width.
  913. * \returns 0 if successful, -1 on error.
  914. *
  915. * \since This function is available since SDL_ttf 2.0.18.
  916. *
  917. * \sa TTF_MeasureText
  918. * \sa TTF_MeasureUTF8
  919. * \sa TTF_MeasureUNICODE
  920. }
  921. function TTF_MeasureUTF8(font: PTTF_Font; text: PAnsiChar; measure_width: cint; extent: pcint; count: pcint): cint; cdecl;
  922. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_MeasureUTF8' {$ENDIF} {$ENDIF};
  923. {*
  924. * Calculate how much of a UCS-2 string will fit in a given width.
  925. *
  926. * This reports the number of characters that can be rendered before reaching
  927. * `measure_width`.
  928. *
  929. * This does not need to render the string to do this calculation.
  930. *
  931. * Please note that this function is named "Unicode" but currently expects
  932. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  933. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  934. * through the UTF-8 version of this function.
  935. *
  936. * \param font the font to query.
  937. * \param text text to calculate, in UCS-2 encoding.
  938. * \param measure_width maximum width, in pixels, available for the string.
  939. * \param count on return, filled with number of characters that can be
  940. * rendered.
  941. * \param extent on return, filled with latest calculated width.
  942. * \returns 0 if successful, -1 on error.
  943. *
  944. * \since This function is available since SDL_ttf 2.0.18.
  945. *
  946. * \sa TTF_MeasureText
  947. * \sa TTF_MeasureUTF8
  948. * \sa TTF_MeasureUNICODE
  949. }
  950. function TTF_MeasureUNICODE(font: PTTF_Font; text: pcuint16; measure_width: cint; extent: pcint; count: pcint): cint; cdecl;
  951. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_MeasureUNICODE' {$ENDIF} {$ENDIF};
  952. {*
  953. * Render Latin1 text at fast quality to a new 8-bit surface.
  954. *
  955. * This function will allocate a new 8-bit, palettized surface. The surface's
  956. * 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
  957. * will be set to the text color.
  958. *
  959. * This will not word-wrap the string; you'll get a surface with a single line
  960. * of text, as long as the string requires. You can use
  961. * TTF_RenderText_Solid_Wrapped() instead if you need to wrap the output to
  962. * multiple lines.
  963. *
  964. * This will not wrap on newline characters.
  965. *
  966. * You almost certainly want TTF_RenderUTF8_Solid() unless you're sure you
  967. * have a 1-byte Latin1 encoding. US ASCII characters will work with either
  968. * function, but most other Unicode characters packed into a `const char *`
  969. * will need UTF-8.
  970. *
  971. * You can render at other quality levels with TTF_RenderText_Shaded,
  972. * TTF_RenderText_Blended, and TTF_RenderText_LCD.
  973. *
  974. * \param font the font to render with.
  975. * \param text text to render, in Latin1 encoding.
  976. * \param fg the foreground color for the text.
  977. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  978. *
  979. * \since This function is available since SDL_ttf 2.0.12.
  980. *
  981. * \sa TTF_RenderUTF8_Solid
  982. * \sa TTF_RenderUNICODE_Solid
  983. }
  984. function TTF_RenderText_Solid(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color): PSDL_Surface; cdecl;
  985. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_Solid' {$ENDIF} {$ENDIF};
  986. {*
  987. * Render UTF-8 text at fast quality to a new 8-bit surface.
  988. *
  989. * This function will allocate a new 8-bit, palettized surface. The surface's
  990. * 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
  991. * will be set to the text color.
  992. *
  993. * This will not word-wrap the string; you'll get a surface with a single line
  994. * of text, as long as the string requires. You can use
  995. * TTF_RenderUTF8_Solid_Wrapped() instead if you need to wrap the output to
  996. * multiple lines.
  997. *
  998. * This will not wrap on newline characters.
  999. *
  1000. * You can render at other quality levels with TTF_RenderUTF8_Shaded,
  1001. * TTF_RenderUTF8_Blended, and TTF_RenderUTF8_LCD.
  1002. *
  1003. * \param font the font to render with.
  1004. * \param text text to render, in UTF-8 encoding.
  1005. * \param fg the foreground color for the text.
  1006. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1007. *
  1008. * \since This function is available since SDL_ttf 2.0.12.
  1009. *
  1010. * \sa TTF_RenderUTF8_Shaded
  1011. * \sa TTF_RenderUTF8_Blended
  1012. * \sa TTF_RenderUTF8_LCD
  1013. }
  1014. function TTF_RenderUTF8_Solid(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color): PSDL_Surface; cdecl;
  1015. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_Solid' {$ENDIF} {$ENDIF};
  1016. {*
  1017. * Render UCS-2 text at fast quality to a new 8-bit surface.
  1018. *
  1019. * This function will allocate a new 8-bit, palettized surface. The surface's
  1020. * 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
  1021. * will be set to the text color.
  1022. *
  1023. * This will not word-wrap the string; you'll get a surface with a single line
  1024. * of text, as long as the string requires. You can use
  1025. * TTF_RenderUNICODE_Solid_Wrapped() instead if you need to wrap the output to
  1026. * multiple lines.
  1027. *
  1028. * This will not wrap on newline characters.
  1029. *
  1030. * Please note that this function is named "Unicode" but currently expects
  1031. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  1032. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  1033. * through the UTF-8 version of this function.
  1034. *
  1035. * You can render at other quality levels with TTF_RenderUNICODE_Shaded,
  1036. * TTF_RenderUNICODE_Blended, and TTF_RenderUNICODE_LCD.
  1037. *
  1038. * \param font the font to render with.
  1039. * \param text text to render, in UCS-2 encoding.
  1040. * \param fg the foreground color for the text.
  1041. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1042. *
  1043. * \since This function is available since SDL_ttf 2.0.12.
  1044. *
  1045. * \sa TTF_RenderUTF8_Solid
  1046. }
  1047. function TTF_RenderUNICODE_Solid(font: PTTF_Font; text: pcuint16; fg: TSDL_Color): PSDL_Surface; cdecl;
  1048. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_Solid' {$ENDIF} {$ENDIF};
  1049. {*
  1050. * Render word-wrapped Latin1 text at fast quality to a new 8-bit surface.
  1051. *
  1052. * This function will allocate a new 8-bit, palettized surface. The surface's
  1053. * 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
  1054. * will be set to the text color.
  1055. *
  1056. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1057. * it extends beyond `wrapLength` in pixels.
  1058. *
  1059. * If wrapLength is 0, this function will only wrap on newline characters.
  1060. *
  1061. * You almost certainly want TTF_RenderUTF8_Solid_Wrapped() unless you're sure
  1062. * you have a 1-byte Latin1 encoding. US ASCII characters will work with
  1063. * either function, but most other Unicode characters packed into a `const
  1064. * char *` will need UTF-8.
  1065. *
  1066. * You can render at other quality levels with TTF_RenderText_Shaded_Wrapped,
  1067. * TTF_RenderText_Blended_Wrapped, and TTF_RenderText_LCD_Wrapped.
  1068. *
  1069. * \param font the font to render with.
  1070. * \param text text to render, in Latin1 encoding.
  1071. * \param fg the foreground color for the text.
  1072. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1073. *
  1074. * \since This function is available since SDL_ttf 2.0.18.
  1075. *
  1076. * \sa TTF_RenderUTF8_Solid_Wrapped
  1077. * \sa TTF_RenderUNICODE_Solid_Wrapped
  1078. }
  1079. function TTF_RenderText_Solid_Wrapped(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1080. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_Solid_Wrapped' {$ENDIF} {$ENDIF};
  1081. {*
  1082. * Render word-wrapped UTF-8 text at fast quality to a new 8-bit surface.
  1083. *
  1084. * This function will allocate a new 8-bit, palettized surface. The surface's
  1085. * 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
  1086. * will be set to the text color.
  1087. *
  1088. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1089. * it extends beyond `wrapLength` in pixels.
  1090. *
  1091. * If wrapLength is 0, this function will only wrap on newline characters.
  1092. *
  1093. * You can render at other quality levels with TTF_RenderUTF8_Shaded_Wrapped,
  1094. * TTF_RenderUTF8_Blended_Wrapped, and TTF_RenderUTF8_LCD_Wrapped.
  1095. *
  1096. * \param font the font to render with.
  1097. * \param text text to render, in UTF-8 encoding.
  1098. * \param fg the foreground color for the text.
  1099. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1100. *
  1101. * \since This function is available since SDL_ttf 2.0.18.
  1102. *
  1103. * \sa TTF_RenderUTF8_Shaded_Wrapped
  1104. * \sa TTF_RenderUTF8_Blended_Wrapped
  1105. * \sa TTF_RenderUTF8_LCD_Wrapped
  1106. }
  1107. function TTF_RenderUTF8_Solid_Wrapped(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1108. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_Solid_Wrapped' {$ENDIF} {$ENDIF};
  1109. {*
  1110. * Render word-wrapped UCS-2 text at fast quality to a new 8-bit surface.
  1111. *
  1112. * This function will allocate a new 8-bit, palettized surface. The surface's
  1113. * 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
  1114. * will be set to the text color.
  1115. *
  1116. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1117. * it extends beyond `wrapLength` in pixels.
  1118. *
  1119. * If wrapLength is 0, this function will only wrap on newline characters.
  1120. *
  1121. * Please note that this function is named "Unicode" but currently expects
  1122. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  1123. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  1124. * through the UTF-8 version of this function.
  1125. *
  1126. * You can render at other quality levels with
  1127. * TTF_RenderUNICODE_Shaded_Wrapped, TTF_RenderUNICODE_Blended_Wrapped, and
  1128. * TTF_RenderUNICODE_LCD_Wrapped.
  1129. *
  1130. * \param font the font to render with.
  1131. * \param text text to render, in UCS-2 encoding.
  1132. * \param fg the foreground color for the text.
  1133. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1134. *
  1135. * \since This function is available since SDL_ttf 2.0.18.
  1136. *
  1137. * \sa TTF_RenderUTF8_Solid_Wrapped
  1138. }
  1139. function TTF_RenderUNICODE_Solid_Wrapped(font: PTTF_Font; text: pcuint16; fg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1140. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_Solid_Wrapped' {$ENDIF} {$ENDIF};
  1141. {*
  1142. * Render a single 16-bit glyph at fast quality to a new 8-bit surface.
  1143. *
  1144. * This function will allocate a new 8-bit, palettized surface. The surface's
  1145. * 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
  1146. * will be set to the text color.
  1147. *
  1148. * The glyph is rendered without any padding or centering in the X direction,
  1149. * and aligned normally in the Y direction.
  1150. *
  1151. * Note that this version of the function takes a 16-bit character code, which
  1152. * covers the Basic Multilingual Plane, but is insufficient to cover the
  1153. * entire set of possible Unicode values, including emoji glyphs. You should
  1154. * use TTF_RenderGlyph32_Solid() instead, which offers the same functionality
  1155. * but takes a 32-bit codepoint instead.
  1156. *
  1157. * The only reason to use this function is that it was available since the
  1158. * beginning of time, more or less.
  1159. *
  1160. * You can render at other quality levels with TTF_RenderGlyph_Shaded,
  1161. * TTF_RenderGlyph_Blended, and TTF_RenderGlyph_LCD.
  1162. *
  1163. * \param font the font to render with.
  1164. * \param ch the character to render.
  1165. * \param fg the foreground color for the text.
  1166. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1167. *
  1168. * \since This function is available since SDL_ttf 2.0.12.
  1169. *
  1170. * \sa TTF_RenderGlyph32_Solid
  1171. }
  1172. function TTF_RenderGlyph_Solid(font: PTTF_Font; ch: cuint16; fg: TSDL_Color): PSDL_Surface; cdecl;
  1173. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderGlyph_Solid' {$ENDIF} {$ENDIF};
  1174. {*
  1175. * Render a single 32-bit glyph at fast quality to a new 8-bit surface.
  1176. *
  1177. * This function will allocate a new 8-bit, palettized surface. The surface's
  1178. * 0 pixel will be the colorkey, giving a transparent background. The 1 pixel
  1179. * will be set to the text color.
  1180. *
  1181. * The glyph is rendered without any padding or centering in the X direction,
  1182. * and aligned normally in the Y direction.
  1183. *
  1184. * This is the same as TTF_RenderGlyph_Solid(), but takes a 32-bit character
  1185. * instead of 16-bit, and thus can render a larger range. If you are sure
  1186. * you'll have an SDL_ttf that's version 2.0.18 or newer, there's no reason
  1187. * not to use this function exclusively.
  1188. *
  1189. * You can render at other quality levels with TTF_RenderGlyph32_Shaded,
  1190. * TTF_RenderGlyph32_Blended, and TTF_RenderGlyph32_LCD.
  1191. *
  1192. * \param font the font to render with.
  1193. * \param ch the character to render.
  1194. * \param fg the foreground color for the text.
  1195. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1196. *
  1197. * \since This function is available since SDL_ttf 2.0.18.
  1198. *
  1199. * \sa TTF_RenderGlyph32_Shaded
  1200. * \sa TTF_RenderGlyph32_Blended
  1201. * \sa TTF_RenderGlyph32_LCD
  1202. }
  1203. function TTF_RenderGlyph32_Solid(font: PTTF_Font; ch: cuint32; fg: TSDL_Color): PSDL_Surface; cdecl;
  1204. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderGlyph32_Solid' {$ENDIF} {$ENDIF};
  1205. {*
  1206. * Render Latin1 text at high quality to a new 8-bit surface.
  1207. *
  1208. * This function will allocate a new 8-bit, palettized surface. The surface's
  1209. * 0 pixel will be the specified background color, while other pixels have
  1210. * varying degrees of the foreground color. This function returns the new
  1211. * surface, or nil if there was an error.
  1212. *
  1213. * This will not word-wrap the string; you'll get a surface with a single line
  1214. * of text, as long as the string requires. You can use
  1215. * TTF_RenderText_Shaded_Wrapped() instead if you need to wrap the output to
  1216. * multiple lines.
  1217. *
  1218. * This will not wrap on newline characters.
  1219. *
  1220. * You almost certainly want TTF_RenderUTF8_Shaded() unless you're sure you
  1221. * have a 1-byte Latin1 encoding. US ASCII characters will work with either
  1222. * function, but most other Unicode characters packed into a `const char *`
  1223. * will need UTF-8.
  1224. *
  1225. * You can render at other quality levels with TTF_RenderText_Solid,
  1226. * TTF_RenderText_Blended, and TTF_RenderText_LCD.
  1227. *
  1228. * \param font the font to render with.
  1229. * \param text text to render, in Latin1 encoding.
  1230. * \param fg the foreground color for the text.
  1231. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1232. *
  1233. * \since This function is available since SDL_ttf 2.0.12.
  1234. *
  1235. * \sa TTF_RenderUTF8_Shaded
  1236. * \sa TTF_RenderUNICODE_Shaded
  1237. }
  1238. function TTF_RenderText_Shaded(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1239. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_Shaded' {$ENDIF} {$ENDIF};
  1240. {*
  1241. * Render UTF-8 text at high quality to a new 8-bit surface.
  1242. *
  1243. * This function will allocate a new 8-bit, palettized surface. The surface's
  1244. * 0 pixel will be the specified background color, while other pixels have
  1245. * varying degrees of the foreground color. This function returns the new
  1246. * surface, or nil if there was an error.
  1247. *
  1248. * This will not word-wrap the string; you'll get a surface with a single line
  1249. * of text, as long as the string requires. You can use
  1250. * TTF_RenderUTF8_Shaded_Wrapped() instead if you need to wrap the output to
  1251. * multiple lines.
  1252. *
  1253. * This will not wrap on newline characters.
  1254. *
  1255. * You can render at other quality levels with TTF_RenderUTF8_Solid,
  1256. * TTF_RenderUTF8_Blended, and TTF_RenderUTF8_LCD.
  1257. *
  1258. * \param font the font to render with.
  1259. * \param text text to render, in UTF-8 encoding.
  1260. * \param fg the foreground color for the text.
  1261. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1262. *
  1263. * \since This function is available since SDL_ttf 2.0.12.
  1264. *
  1265. * \sa TTF_RenderUNICODE_Shaded
  1266. }
  1267. function TTF_RenderUTF8_Shaded(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1268. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_Shaded' {$ENDIF} {$ENDIF};
  1269. {*
  1270. * Render UCS-2 text at high quality to a new 8-bit surface.
  1271. *
  1272. * This function will allocate a new 8-bit, palettized surface. The surface's
  1273. * 0 pixel will be the specified background color, while other pixels have
  1274. * varying degrees of the foreground color. This function returns the new
  1275. * surface, or nil if there was an error.
  1276. *
  1277. * This will not word-wrap the string; you'll get a surface with a single line
  1278. * of text, as long as the string requires. You can use
  1279. * TTF_RenderUNICODE_Shaded_Wrapped() instead if you need to wrap the output
  1280. * to multiple lines.
  1281. *
  1282. * This will not wrap on newline characters.
  1283. *
  1284. * Please note that this function is named "Unicode" but currently expects
  1285. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  1286. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  1287. * through the UTF-8 version of this function.
  1288. *
  1289. * You can render at other quality levels with TTF_RenderUNICODE_Solid,
  1290. * TTF_RenderUNICODE_Blended, and TTF_RenderUNICODE_LCD.
  1291. *
  1292. * \param font the font to render with.
  1293. * \param text text to render, in UCS-2 encoding.
  1294. * \param fg the foreground color for the text.
  1295. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1296. *
  1297. * \since This function is available since SDL_ttf 2.0.12.
  1298. *
  1299. * \sa TTF_RenderUTF8_Shaded
  1300. }
  1301. function TTF_RenderUNICODE_Shaded(font: PTTF_Font; text: pcuint16; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1302. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_Shaded' {$ENDIF} {$ENDIF};
  1303. {*
  1304. * Render word-wrapped Latin1 text at high quality to a new 8-bit surface.
  1305. *
  1306. * This function will allocate a new 8-bit, palettized surface. The surface's
  1307. * 0 pixel will be the specified background color, while other pixels have
  1308. * varying degrees of the foreground color. This function returns the new
  1309. * surface, or nil if there was an error.
  1310. *
  1311. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1312. * it extends beyond `wrapLength` in pixels.
  1313. *
  1314. * If wrapLength is 0, this function will only wrap on newline characters.
  1315. *
  1316. * You almost certainly want TTF_RenderUTF8_Shaded_Wrapped() unless you're
  1317. * sure you have a 1-byte Latin1 encoding. US ASCII characters will work with
  1318. * either function, but most other Unicode characters packed into a `const
  1319. * char *` will need UTF-8.
  1320. *
  1321. * You can render at other quality levels with TTF_RenderText_Solid_Wrapped,
  1322. * TTF_RenderText_Blended_Wrapped, and TTF_RenderText_LCD_Wrapped.
  1323. *
  1324. * \param font the font to render with.
  1325. * \param text text to render, in Latin1 encoding.
  1326. * \param fg the foreground color for the text.
  1327. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1328. *
  1329. * \since This function is available since SDL_ttf 2.0.18.
  1330. *
  1331. * \sa TTF_RenderUTF8_Shaded_Wrapped
  1332. * \sa TTF_RenderUNICODE_Shaded_Wrapped
  1333. }
  1334. function TTF_RenderText_Shaded_Wrapped(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; bg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1335. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_Shaded_Wrapped' {$ENDIF} {$ENDIF};
  1336. {*
  1337. * Render word-wrapped UTF-8 text at high quality to a new 8-bit surface.
  1338. *
  1339. * This function will allocate a new 8-bit, palettized surface. The surface's
  1340. * 0 pixel will be the specified background color, while other pixels have
  1341. * varying degrees of the foreground color. This function returns the new
  1342. * surface, or nil if there was an error.
  1343. *
  1344. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1345. * it extends beyond `wrapLength` in pixels.
  1346. *
  1347. * If wrapLength is 0, this function will only wrap on newline characters.
  1348. *
  1349. * You can render at other quality levels with TTF_RenderUTF8_Solid_Wrapped,
  1350. * TTF_RenderUTF8_Blended_Wrapped, and TTF_RenderUTF8_LCD_Wrapped.
  1351. *
  1352. * \param font the font to render with.
  1353. * \param text text to render, in UTF-8 encoding.
  1354. * \param fg the foreground color for the text.
  1355. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1356. *
  1357. * \since This function is available since SDL_ttf 2.0.18.
  1358. *
  1359. * \sa TTF_RenderUTF8_Solid_Wrapped
  1360. * \sa TTF_RenderUTF8_Blended_Wrapped
  1361. * \sa TTF_RenderUTF8_LCD_Wrapped
  1362. }
  1363. function TTF_RenderUTF8_Shaded_Wrapped(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; bg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1364. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_Shaded_Wrapped' {$ENDIF} {$ENDIF};
  1365. {*
  1366. * Render word-wrapped UCS-2 text at high quality to a new 8-bit surface.
  1367. *
  1368. * This function will allocate a new 8-bit, palettized surface. The surface's
  1369. * 0 pixel will be the specified background color, while other pixels have
  1370. * varying degrees of the foreground color. This function returns the new
  1371. * surface, or nil if there was an error.
  1372. *
  1373. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1374. * it extends beyond `wrapLength` in pixels.
  1375. *
  1376. * If wrapLength is 0, this function will only wrap on newline characters.
  1377. *
  1378. * Please note that this function is named "Unicode" but currently expects
  1379. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  1380. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  1381. * through the UTF-8 version of this function.
  1382. *
  1383. * You can render at other quality levels with
  1384. * TTF_RenderUNICODE_Solid_Wrapped, TTF_RenderUNICODE_Blended_Wrapped, and
  1385. * TTF_RenderUNICODE_LCD_Wrapped.
  1386. *
  1387. * \param font the font to render with.
  1388. * \param text text to render, in UCS-2 encoding.
  1389. * \param fg the foreground color for the text.
  1390. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1391. *
  1392. * \since This function is available since SDL_ttf 2.0.18.
  1393. *
  1394. * \sa TTF_RenderUTF8_Shaded_Wrapped
  1395. }
  1396. function TTF_RenderUNICODE_Shaded_Wrapped(font: PTTF_Font; text: pcuint16; fg: TSDL_Color; bg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1397. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_Shaded_Wrapped' {$ENDIF} {$ENDIF};
  1398. {*
  1399. * Render a single 16-bit glyph at high quality to a new 8-bit surface.
  1400. *
  1401. * This function will allocate a new 8-bit, palettized surface. The surface's
  1402. * 0 pixel will be the specified background color, while other pixels have
  1403. * varying degrees of the foreground color. This function returns the new
  1404. * surface, or nil if there was an error.
  1405. *
  1406. * The glyph is rendered without any padding or centering in the X direction,
  1407. * and aligned normally in the Y direction.
  1408. *
  1409. * Note that this version of the function takes a 16-bit character code, which
  1410. * covers the Basic Multilingual Plane, but is insufficient to cover the
  1411. * entire set of possible Unicode values, including emoji glyphs. You should
  1412. * use TTF_RenderGlyph32_Shaded() instead, which offers the same functionality
  1413. * but takes a 32-bit codepoint instead.
  1414. *
  1415. * The only reason to use this function is that it was available since the
  1416. * beginning of time, more or less.
  1417. *
  1418. * You can render at other quality levels with TTF_RenderGlyph_Solid,
  1419. * TTF_RenderGlyph_Blended, and TTF_RenderGlyph_LCD.
  1420. *
  1421. * \param font the font to render with.
  1422. * \param ch the character to render.
  1423. * \param fg the foreground color for the text.
  1424. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1425. *
  1426. * \since This function is available since SDL_ttf 2.0.12.
  1427. *
  1428. * \sa TTF_RenderGlyph32_Shaded
  1429. }
  1430. function TTF_RenderGlyph_Shaded(font: PTTF_Font; ch: cuint16; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1431. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderGlyph_Shaded' {$ENDIF} {$ENDIF};
  1432. {*
  1433. * Render a single 32-bit glyph at high quality to a new 8-bit surface.
  1434. *
  1435. * This function will allocate a new 8-bit, palettized surface. The surface's
  1436. * 0 pixel will be the specified background color, while other pixels have
  1437. * varying degrees of the foreground color. This function returns the new
  1438. * surface, or nil if there was an error.
  1439. *
  1440. * The glyph is rendered without any padding or centering in the X direction,
  1441. * and aligned normally in the Y direction.
  1442. *
  1443. * This is the same as TTF_RenderGlyph_Shaded(), but takes a 32-bit character
  1444. * instead of 16-bit, and thus can render a larger range. If you are sure
  1445. * you'll have an SDL_ttf that's version 2.0.18 or newer, there's no reason
  1446. * not to use this function exclusively.
  1447. *
  1448. * You can render at other quality levels with TTF_RenderGlyph32_Solid,
  1449. * TTF_RenderGlyph32_Blended, and TTF_RenderGlyph32_LCD.
  1450. *
  1451. * \param font the font to render with.
  1452. * \param ch the character to render.
  1453. * \param fg the foreground color for the text.
  1454. * \returns a new 8-bit, palettized surface, or nil if there was an error.
  1455. *
  1456. * \since This function is available since SDL_ttf 2.0.18.
  1457. *
  1458. * \sa TTF_RenderGlyph32_Solid
  1459. * \sa TTF_RenderGlyph32_Blended
  1460. * \sa TTF_RenderGlyph32_LCD
  1461. }
  1462. function TTF_RenderGlyph32_Shaded(font: PTTF_Font; ch: cuint32; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1463. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderGlyph32_Shaded' {$ENDIF} {$ENDIF};
  1464. {*
  1465. * Render Latin1 text at high quality to a new ARGB surface.
  1466. *
  1467. * This function will allocate a new 32-bit, ARGB surface, using alpha
  1468. * blending to dither the font with the given color. This function returns the
  1469. * new surface, or nil if there was an error.
  1470. *
  1471. * This will not word-wrap the string; you'll get a surface with a single line
  1472. * of text, as long as the string requires. You can use
  1473. * TTF_RenderText_Blended_Wrapped() instead if you need to wrap the output to
  1474. * multiple lines.
  1475. *
  1476. * This will not wrap on newline characters.
  1477. *
  1478. * You almost certainly want TTF_RenderUTF8_Blended() unless you're sure you
  1479. * have a 1-byte Latin1 encoding. US ASCII characters will work with either
  1480. * function, but most other Unicode characters packed into a `const char *`
  1481. * will need UTF-8.
  1482. *
  1483. * You can render at other quality levels with TTF_RenderText_Solid,
  1484. * TTF_RenderText_Blended, and TTF_RenderText_LCD.
  1485. *
  1486. * \param font the font to render with.
  1487. * \param text text to render, in Latin1 encoding.
  1488. * \param fg the foreground color for the text.
  1489. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1490. *
  1491. * \since This function is available since SDL_ttf 2.0.12.
  1492. *
  1493. * \sa TTF_RenderUTF8_Shaded
  1494. * \sa TTF_RenderUNICODE_Shaded
  1495. }
  1496. function TTF_RenderText_Blended(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color): PSDL_Surface; cdecl;
  1497. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_Blended' {$ENDIF} {$ENDIF};
  1498. {*
  1499. * Render UTF-8 text at high quality to a new ARGB surface.
  1500. *
  1501. * This function will allocate a new 32-bit, ARGB surface, using alpha
  1502. * blending to dither the font with the given color. This function returns the
  1503. * new surface, or nil if there was an error.
  1504. *
  1505. * This will not word-wrap the string; you'll get a surface with a single line
  1506. * of text, as long as the string requires. You can use
  1507. * TTF_RenderUTF8_Blended_Wrapped() instead if you need to wrap the output to
  1508. * multiple lines.
  1509. *
  1510. * This will not wrap on newline characters.
  1511. *
  1512. * You can render at other quality levels with TTF_RenderUTF8_Solid,
  1513. * TTF_RenderUTF8_Shaded, and TTF_RenderUTF8_LCD.
  1514. *
  1515. * \param font the font to render with.
  1516. * \param text text to render, in UTF-8 encoding.
  1517. * \param fg the foreground color for the text.
  1518. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1519. *
  1520. * \since This function is available since SDL_ttf 2.0.12.
  1521. *
  1522. * \sa TTF_RenderUNICODE_Blended
  1523. }
  1524. function TTF_RenderUTF8_Blended(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color): PSDL_Surface; cdecl;
  1525. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_Blended' {$ENDIF} {$ENDIF};
  1526. {*
  1527. * Render UCS-2 text at high quality to a new ARGB surface.
  1528. *
  1529. * This function will allocate a new 32-bit, ARGB surface, using alpha
  1530. * blending to dither the font with the given color. This function returns the
  1531. * new surface, or nil if there was an error.
  1532. *
  1533. * This will not word-wrap the string; you'll get a surface with a single line
  1534. * of text, as long as the string requires. You can use
  1535. * TTF_RenderUNICODE_Blended_Wrapped() instead if you need to wrap the output
  1536. * to multiple lines.
  1537. *
  1538. * This will not wrap on newline characters.
  1539. *
  1540. * Please note that this function is named "Unicode" but currently expects
  1541. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  1542. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  1543. * through the UTF-8 version of this function.
  1544. *
  1545. * You can render at other quality levels with TTF_RenderUNICODE_Solid,
  1546. * TTF_RenderUNICODE_Shaded, and TTF_RenderUNICODE_LCD.
  1547. *
  1548. * \param font the font to render with.
  1549. * \param text text to render, in UCS-2 encoding.
  1550. * \param fg the foreground color for the text.
  1551. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1552. *
  1553. * \since This function is available since SDL_ttf 2.0.12.
  1554. *
  1555. * \sa TTF_RenderUTF8_Blended
  1556. }
  1557. function TTF_RenderUNICODE_Blended(font: PTTF_Font; text: pcuint16; fg: TSDL_Color): PSDL_Surface; cdecl;
  1558. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_Blended' {$ENDIF} {$ENDIF};
  1559. {*
  1560. * Render word-wrapped Latin1 text at high quality to a new ARGB surface.
  1561. *
  1562. * This function will allocate a new 32-bit, ARGB surface, using alpha
  1563. * blending to dither the font with the given color. This function returns the
  1564. * new surface, or nil if there was an error.
  1565. *
  1566. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1567. * it extends beyond `wrapLength` in pixels.
  1568. *
  1569. * If wrapLength is 0, this function will only wrap on newline characters.
  1570. *
  1571. * You almost certainly want TTF_RenderUTF8_Blended_Wrapped() unless you're
  1572. * sure you have a 1-byte Latin1 encoding. US ASCII characters will work with
  1573. * either function, but most other Unicode characters packed into a `const
  1574. * char *` will need UTF-8.
  1575. *
  1576. * You can render at other quality levels with TTF_RenderText_Solid_Wrapped,
  1577. * TTF_RenderText_Shaded_Wrapped, and TTF_RenderText_LCD_Wrapped.
  1578. *
  1579. * \param font the font to render with.
  1580. * \param text text to render, in Latin1 encoding.
  1581. * \param fg the foreground color for the text.
  1582. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1583. *
  1584. * \since This function is available since SDL_ttf 2.0.18.
  1585. *
  1586. * \sa TTF_RenderUTF8_Blended_Wrapped
  1587. * \sa TTF_RenderUNICODE_Blended_Wrapped
  1588. }
  1589. function TTF_RenderText_Blended_Wrapped(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1590. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_Blended_Wrapped' {$ENDIF} {$ENDIF};
  1591. {*
  1592. * Render word-wrapped UTF-8 text at high quality to a new ARGB surface.
  1593. *
  1594. * This function will allocate a new 32-bit, ARGB surface, using alpha
  1595. * blending to dither the font with the given color. This function returns the
  1596. * new surface, or nil if there was an error.
  1597. *
  1598. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1599. * it extends beyond `wrapLength` in pixels.
  1600. *
  1601. * If wrapLength is 0, this function will only wrap on newline characters.
  1602. *
  1603. * You can render at other quality levels with TTF_RenderUTF8_Solid_Wrapped,
  1604. * TTF_RenderUTF8_Shaded_Wrapped, and TTF_RenderUTF8_LCD_Wrapped.
  1605. *
  1606. * \param font the font to render with.
  1607. * \param text text to render, in UTF-8 encoding.
  1608. * \param fg the foreground color for the text.
  1609. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1610. *
  1611. * \since This function is available since SDL_ttf 2.0.18.
  1612. *
  1613. * \sa TTF_RenderUTF8_Solid_Wrapped
  1614. * \sa TTF_RenderUTF8_Shaded_Wrapped
  1615. * \sa TTF_RenderUTF8_LCD_Wrapped
  1616. }
  1617. function TTF_RenderUTF8_Blended_Wrapped(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1618. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_Blended_Wrapped' {$ENDIF} {$ENDIF};
  1619. {*
  1620. * Render word-wrapped UCS-2 text at high quality to a new ARGB surface.
  1621. *
  1622. * This function will allocate a new 32-bit, ARGB surface, using alpha
  1623. * blending to dither the font with the given color. This function returns the
  1624. * new surface, or nil if there was an error.
  1625. *
  1626. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1627. * it extends beyond `wrapLength` in pixels.
  1628. *
  1629. * If wrapLength is 0, this function will only wrap on newline characters.
  1630. *
  1631. * Please note that this function is named "Unicode" but currently expects
  1632. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  1633. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  1634. * through the UTF-8 version of this function.
  1635. *
  1636. * You can render at other quality levels with
  1637. * TTF_RenderUNICODE_Solid_Wrapped, TTF_RenderUNICODE_Shaded_Wrapped, and
  1638. * TTF_RenderUNICODE_LCD_Wrapped.
  1639. *
  1640. * \param font the font to render with.
  1641. * \param text text to render, in UCS-2 encoding.
  1642. * \param fg the foreground color for the text.
  1643. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1644. *
  1645. * \since This function is available since SDL_ttf 2.0.18.
  1646. *
  1647. * \sa TTF_RenderUTF8_Blended_Wrapped
  1648. }
  1649. function TTF_RenderUNICODE_Blended_Wrapped(font: PTTF_Font; text: pcuint16; fg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1650. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_Blended_Wrapped' {$ENDIF} {$ENDIF};
  1651. {*
  1652. * Render a single 16-bit glyph at high quality to a new ARGB surface.
  1653. *
  1654. * This function will allocate a new 32-bit, ARGB surface, using alpha
  1655. * blending to dither the font with the given color. This function returns the
  1656. * new surface, or nil if there was an error.
  1657. *
  1658. * The glyph is rendered without any padding or centering in the X direction,
  1659. * and aligned normally in the Y direction.
  1660. *
  1661. * Note that this version of the function takes a 16-bit character code, which
  1662. * covers the Basic Multilingual Plane, but is insufficient to cover the
  1663. * entire set of possible Unicode values, including emoji glyphs. You should
  1664. * use TTF_RenderGlyph32_Blended() instead, which offers the same
  1665. * functionality but takes a 32-bit codepoint instead.
  1666. *
  1667. * The only reason to use this function is that it was available since the
  1668. * beginning of time, more or less.
  1669. *
  1670. * You can render at other quality levels with TTF_RenderGlyph_Solid,
  1671. * TTF_RenderGlyph_Shaded, and TTF_RenderGlyph_LCD.
  1672. *
  1673. * \param font the font to render with.
  1674. * \param ch the character to render.
  1675. * \param fg the foreground color for the text.
  1676. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1677. *
  1678. * \since This function is available since SDL_ttf 2.0.12.
  1679. *
  1680. * \sa TTF_RenderGlyph32_Blended
  1681. }
  1682. function TTF_RenderGlyph_Blended(font: PTTF_Font; ch: cuint16; fg: TSDL_Color): PSDL_Surface; cdecl;
  1683. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderGlyph_Blended' {$ENDIF} {$ENDIF};
  1684. {*
  1685. * Render a single 32-bit glyph at high quality to a new ARGB surface.
  1686. *
  1687. * This function will allocate a new 32-bit, ARGB surface, using alpha
  1688. * blending to dither the font with the given color. This function returns the
  1689. * new surface, or nil if there was an error.
  1690. *
  1691. * The glyph is rendered without any padding or centering in the X direction,
  1692. * and aligned normally in the Y direction.
  1693. *
  1694. * This is the same as TTF_RenderGlyph_Blended(), but takes a 32-bit character
  1695. * instead of 16-bit, and thus can render a larger range. If you are sure
  1696. * you'll have an SDL_ttf that's version 2.0.18 or newer, there's no reason
  1697. * not to use this function exclusively.
  1698. *
  1699. * You can render at other quality levels with TTF_RenderGlyph32_Solid,
  1700. * TTF_RenderGlyph32_Shaded, and TTF_RenderGlyph32_LCD.
  1701. *
  1702. * \param font the font to render with.
  1703. * \param ch the character to render.
  1704. * \param fg the foreground color for the text.
  1705. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1706. *
  1707. * \since This function is available since SDL_ttf 2.0.18.
  1708. *
  1709. * \sa TTF_RenderGlyph32_Solid
  1710. * \sa TTF_RenderGlyph32_Shaded
  1711. * \sa TTF_RenderGlyph32_LCD
  1712. }
  1713. function TTF_RenderGlyph32_Blended(font: PTTF_Font; ch: cuint32; fg: TSDL_Color): PSDL_Surface; cdecl;
  1714. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderGlyph32_Blended' {$ENDIF} {$ENDIF};
  1715. {*
  1716. * Render Latin1 text at LCD subpixel quality to a new ARGB surface.
  1717. *
  1718. * This function will allocate a new 32-bit, ARGB surface, and render
  1719. * alpha-blended text using FreeType's LCD subpixel rendering. This function
  1720. * returns the new surface, or nil if there was an error.
  1721. *
  1722. * This will not word-wrap the string; you'll get a surface with a single line
  1723. * of text, as long as the string requires. You can use
  1724. * TTF_RenderText_LCD_Wrapped() instead if you need to wrap the output to
  1725. * multiple lines.
  1726. *
  1727. * This will not wrap on newline characters.
  1728. *
  1729. * You almost certainly want TTF_RenderUTF8_LCD() unless you're sure you have
  1730. * a 1-byte Latin1 encoding. US ASCII characters will work with either
  1731. * function, but most other Unicode characters packed into a `const char *`
  1732. * will need UTF-8.
  1733. *
  1734. * You can render at other quality levels with TTF_RenderText_Solid,
  1735. * TTF_RenderText_Shaded, and TTF_RenderText_Blended.
  1736. *
  1737. * \param font the font to render with.
  1738. * \param text text to render, in Latin1 encoding.
  1739. * \param fg the foreground color for the text.
  1740. * \param bg the background color for the text.
  1741. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1742. *
  1743. * \since This function is available since SDL_ttf 2.20.0.
  1744. *
  1745. * \sa TTF_RenderUTF8_LCD
  1746. * \sa TTF_RenderUNICODE_LCD
  1747. }
  1748. function TTF_RenderText_LCD(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1749. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_LCD' {$ENDIF} {$ENDIF};
  1750. {*
  1751. * Render UTF-8 text at LCD subpixel quality to a new ARGB surface.
  1752. *
  1753. * This function will allocate a new 32-bit, ARGB surface, and render
  1754. * alpha-blended text using FreeType's LCD subpixel rendering. This function
  1755. * returns the new surface, or nil if there was an error.
  1756. *
  1757. * This will not word-wrap the string; you'll get a surface with a single line
  1758. * of text, as long as the string requires. You can use
  1759. * TTF_RenderUTF8_LCD_Wrapped() instead if you need to wrap the output to
  1760. * multiple lines.
  1761. *
  1762. * This will not wrap on newline characters.
  1763. *
  1764. * You can render at other quality levels with TTF_RenderUTF8_Solid,
  1765. * TTF_RenderUTF8_Shaded, and TTF_RenderUTF8_Blended.
  1766. *
  1767. * \param font the font to render with.
  1768. * \param text text to render, in UTF-8 encoding.
  1769. * \param fg the foreground color for the text.
  1770. * \param bg the background color for the text.
  1771. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1772. *
  1773. * \since This function is available since SDL_ttf 2.20.0.
  1774. *
  1775. * \sa TTF_RenderUNICODE_LCD
  1776. }
  1777. function TTF_RenderUTF8_LCD(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1778. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_LCD' {$ENDIF} {$ENDIF};
  1779. {*
  1780. * Render UCS-2 text at LCD subpixel quality to a new ARGB surface.
  1781. *
  1782. * This function will allocate a new 32-bit, ARGB surface, and render
  1783. * alpha-blended text using FreeType's LCD subpixel rendering. This function
  1784. * returns the new surface, or nil if there was an error.
  1785. *
  1786. * This will not word-wrap the string; you'll get a surface with a single line
  1787. * of text, as long as the string requires. You can use
  1788. * TTF_RenderUNICODE_LCD_Wrapped() instead if you need to wrap the output to
  1789. * multiple lines.
  1790. *
  1791. * This will not wrap on newline characters.
  1792. *
  1793. * Please note that this function is named "Unicode" but currently expects
  1794. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  1795. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  1796. * through the UTF-8 version of this function.
  1797. *
  1798. * You can render at other quality levels with TTF_RenderUNICODE_Solid,
  1799. * TTF_RenderUNICODE_Shaded, and TTF_RenderUNICODE_Blended.
  1800. *
  1801. * \param font the font to render with.
  1802. * \param text text to render, in UCS-2 encoding.
  1803. * \param fg the foreground color for the text.
  1804. * \param bg the background color for the text.
  1805. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1806. *
  1807. * \since This function is available since SDL_ttf 2.20.0.
  1808. *
  1809. * \sa TTF_RenderUTF8_LCD
  1810. }
  1811. function TTF_RenderUNICODE_LCD(font: PTTF_Font; text: pcuint16; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1812. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_LCD' {$ENDIF} {$ENDIF};
  1813. {*
  1814. * Render word-wrapped Latin1 text at LCD subpixel quality to a new ARGB
  1815. * surface.
  1816. *
  1817. * This function will allocate a new 32-bit, ARGB surface, and render
  1818. * alpha-blended text using FreeType's LCD subpixel rendering. This function
  1819. * returns the new surface, or nil if there was an error.
  1820. *
  1821. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1822. * it extends beyond `wrapLength` in pixels.
  1823. *
  1824. * If wrapLength is 0, this function will only wrap on newline characters.
  1825. *
  1826. * You almost certainly want TTF_RenderUTF8_LCD_Wrapped() unless you're sure
  1827. * you have a 1-byte Latin1 encoding. US ASCII characters will work with
  1828. * either function, but most other Unicode characters packed into a `const
  1829. * char *` will need UTF-8.
  1830. *
  1831. * You can render at other quality levels with TTF_RenderText_Solid_Wrapped,
  1832. * TTF_RenderText_Shaded_Wrapped, and TTF_RenderText_Blended_Wrapped.
  1833. *
  1834. * \param font the font to render with.
  1835. * \param text text to render, in Latin1 encoding.
  1836. * \param fg the foreground color for the text.
  1837. * \param bg the background color for the text.
  1838. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1839. *
  1840. * \since This function is available since SDL_ttf 2.20.0.
  1841. *
  1842. * \sa TTF_RenderUTF8_LCD_Wrapped
  1843. * \sa TTF_RenderUNICODE_LCD_Wrapped
  1844. }
  1845. function TTF_RenderText_LCD_Wrapped(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; bg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1846. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_LCD_Wrapped' {$ENDIF} {$ENDIF};
  1847. {*
  1848. * Render word-wrapped UTF-8 text at LCD subpixel quality to a new ARGB
  1849. * surface.
  1850. *
  1851. * This function will allocate a new 32-bit, ARGB surface, and render
  1852. * alpha-blended text using FreeType's LCD subpixel rendering. This function
  1853. * returns the new surface, or nil if there was an error.
  1854. *
  1855. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1856. * it extends beyond `wrapLength` in pixels.
  1857. *
  1858. * If wrapLength is 0, this function will only wrap on newline characters.
  1859. *
  1860. * You can render at other quality levels with TTF_RenderUTF8_Solid_Wrapped,
  1861. * TTF_RenderUTF8_Shaded_Wrapped, and TTF_RenderUTF8_Blended_Wrapped.
  1862. *
  1863. * \param font the font to render with.
  1864. * \param text text to render, in UTF-8 encoding.
  1865. * \param fg the foreground color for the text.
  1866. * \param bg the background color for the text.
  1867. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1868. *
  1869. * \since This function is available since SDL_ttf 2.20.0.
  1870. *
  1871. * \sa TTF_RenderUTF8_Solid_Wrapped
  1872. * \sa TTF_RenderUTF8_Shaded_Wrapped
  1873. * \sa TTF_RenderUTF8_Blended_Wrapped
  1874. }
  1875. function TTF_RenderUTF8_LCD_Wrapped(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color; bg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1876. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_LCD_Wrapped' {$ENDIF} {$ENDIF};
  1877. {*
  1878. * Render word-wrapped UCS-2 text at LCD subpixel quality to a new ARGB
  1879. * surface.
  1880. *
  1881. * This function will allocate a new 32-bit, ARGB surface, and render
  1882. * alpha-blended text using FreeType's LCD subpixel rendering. This function
  1883. * returns the new surface, or nil if there was an error.
  1884. *
  1885. * Text is wrapped to multiple lines on line endings and on word boundaries if
  1886. * it extends beyond `wrapLength` in pixels.
  1887. *
  1888. * If wrapLength is 0, this function will only wrap on newline characters.
  1889. *
  1890. * Please note that this function is named "Unicode" but currently expects
  1891. * UCS-2 encoding (16 bits per codepoint). This does not give you access to
  1892. * large Unicode values, such as emoji glyphs. These codepoints are accessible
  1893. * through the UTF-8 version of this function.
  1894. *
  1895. * You can render at other quality levels with
  1896. * TTF_RenderUNICODE_Solid_Wrapped, TTF_RenderUNICODE_Shaded_Wrapped, and
  1897. * TTF_RenderUNICODE_Blended_Wrapped.
  1898. *
  1899. * \param font the font to render with.
  1900. * \param text text to render, in UCS-2 encoding.
  1901. * \param fg the foreground color for the text.
  1902. * \param bg the background color for the text.
  1903. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1904. *
  1905. * \since This function is available since SDL_ttf 2.20.0.
  1906. *
  1907. * \sa TTF_RenderUTF8_LCD_Wrapped
  1908. }
  1909. function TTF_RenderUNICODE_LCD_Wrapped(font: PTTF_Font; text: pcuint16; fg: TSDL_Color; bg: TSDL_Color; wrapLength: cuint32): PSDL_Surface; cdecl;
  1910. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_LCD_Wrapped' {$ENDIF} {$ENDIF};
  1911. {*
  1912. * Render a single 16-bit glyph at LCD subpixel quality to a new ARGB surface.
  1913. *
  1914. * This function will allocate a new 32-bit, ARGB surface, and render
  1915. * alpha-blended text using FreeType's LCD subpixel rendering. This function
  1916. * returns the new surface, or nil if there was an error.
  1917. *
  1918. * The glyph is rendered without any padding or centering in the X direction,
  1919. * and aligned normally in the Y direction.
  1920. *
  1921. * Note that this version of the function takes a 16-bit character code, which
  1922. * covers the Basic Multilingual Plane, but is insufficient to cover the
  1923. * entire set of possible Unicode values, including emoji glyphs. You should
  1924. * use TTF_RenderGlyph32_LCD() instead, which offers the same functionality
  1925. * but takes a 32-bit codepoint instead.
  1926. *
  1927. * This function only exists for consistency with the existing API at the time
  1928. * of its addition.
  1929. *
  1930. * You can render at other quality levels with TTF_RenderGlyph_Solid,
  1931. * TTF_RenderGlyph_Shaded, and TTF_RenderGlyph_Blended.
  1932. *
  1933. * \param font the font to render with.
  1934. * \param ch the character to render.
  1935. * \param fg the foreground color for the text.
  1936. * \param bg the background color for the text.
  1937. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1938. *
  1939. * \since This function is available since SDL_ttf 2.20.0.
  1940. *
  1941. * \sa TTF_RenderGlyph32_LCD
  1942. }
  1943. function TTF_RenderGlyph_LCD(font: PTTF_Font; ch: cuint16; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1944. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderGlyph_LCD' {$ENDIF} {$ENDIF};
  1945. {*
  1946. * Render a single 32-bit glyph at LCD subpixel quality to a new ARGB surface.
  1947. *
  1948. * This function will allocate a new 32-bit, ARGB surface, and render
  1949. * alpha-blended text using FreeType's LCD subpixel rendering. This function
  1950. * returns the new surface, or nil if there was an error.
  1951. *
  1952. * The glyph is rendered without any padding or centering in the X direction,
  1953. * and aligned normally in the Y direction.
  1954. *
  1955. * This is the same as TTF_RenderGlyph_LCD(), but takes a 32-bit character
  1956. * instead of 16-bit, and thus can render a larger range. Between the two, you
  1957. * should always use this function.
  1958. *
  1959. * You can render at other quality levels with TTF_RenderGlyph32_Solid,
  1960. * TTF_RenderGlyph32_Shaded, and TTF_RenderGlyph32_Blended.
  1961. *
  1962. * \param font the font to render with.
  1963. * \param ch the character to render.
  1964. * \param fg the foreground color for the text.
  1965. * \param bg the background color for the text.
  1966. * \returns a new 32-bit, ARGB surface, or nil if there was an error.
  1967. *
  1968. * \since This function is available since SDL_ttf 2.20.0.
  1969. *
  1970. * \sa TTF_RenderGlyph32_Solid
  1971. * \sa TTF_RenderGlyph32_Shaded
  1972. * \sa TTF_RenderGlyph32_Blended
  1973. }
  1974. function TTF_RenderGlyph32_LCD(font: PTTF_Font; ch: cuint32; fg: TSDL_Color; bg: TSDL_Color): PSDL_Surface; cdecl;
  1975. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderGlyph32_LCD' {$ENDIF} {$ENDIF};
  1976. {* For compatibility with previous versions, here are the old functions *}
  1977. function TTF_RenderText(font: PTTF_Font; text: PAnsiChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl;
  1978. external TTF_LibName
  1979. name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_TTF_RenderText_Shaded' {$ELSE} 'TTF_RenderText_Shaded' {$ENDIF};
  1980. function TTF_RenderUTF8(font: PTTF_Font; text: PAnsiChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl;
  1981. external TTF_LibName
  1982. name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_TTF_RenderUTF8_Shaded' {$ELSE} 'TTF_RenderUTF8_Shaded' {$ENDIF};
  1983. function TTF_RenderUNICODE(font: PTTF_Font; text: pcuint16; fg, bg: TSDL_Color): PSDL_Surface; cdecl;
  1984. external TTF_LibName
  1985. name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_TTF_RenderUNICODE_Shaded' {$ELSE} 'TTF_RenderUNICODE_Shaded' {$ENDIF};
  1986. {*
  1987. * Dispose of a previously-created font.
  1988. *
  1989. * Call this when done with a font. This function will free any resources
  1990. * associated with it. It is safe to call this function on nil, for example
  1991. * on the result of a failed call to TTF_OpenFont().
  1992. *
  1993. * The font is not valid after being passed to this function. String pointers
  1994. * from functions that return information on this font, such as
  1995. * TTF_FontFaceFamilyName() and TTF_FontFaceStyleName(), are no longer valid
  1996. * after this call, as well.
  1997. *
  1998. * \param font the font to dispose of.
  1999. *
  2000. * \since This function is available since SDL_ttf 2.0.12.
  2001. *
  2002. * \sa TTF_OpenFontIndexDPIRW
  2003. * \sa TTF_OpenFontRW
  2004. * \sa TTF_OpenFontDPI
  2005. * \sa TTF_OpenFontDPIRW
  2006. * \sa TTF_OpenFontIndex
  2007. * \sa TTF_OpenFontIndexDPI
  2008. * \sa TTF_OpenFontIndexDPIRW
  2009. * \sa TTF_OpenFontIndexRW
  2010. }
  2011. procedure TTF_CloseFont(font: PTTF_Font); cdecl;
  2012. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_CloseFont' {$ENDIF} {$ENDIF};
  2013. {*
  2014. * Deinitialize SDL_ttf.
  2015. *
  2016. * You must call this when done with the library, to free internal resources.
  2017. * It is safe to call this when the library isn't initialized, as it will just
  2018. * return immediately.
  2019. *
  2020. * Once you have as many quit calls as you have had successful calls to
  2021. * TTF_Init, the library will actually deinitialize.
  2022. *
  2023. * Please note that this does not automatically close any fonts that are still
  2024. * open at the time of deinitialization, and it is possibly not safe to close
  2025. * them afterwards, as parts of the library will no longer be initialized to
  2026. * deal with it. A well-written program should call TTF_CloseFont() on any
  2027. * open fonts before calling this function!
  2028. *
  2029. * \since This function is available since SDL_ttf 2.0.12.
  2030. }
  2031. procedure TTF_Quit(); cdecl;
  2032. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_Quit' {$ENDIF} {$ENDIF};
  2033. {*
  2034. * Check if SDL_ttf is initialized.
  2035. *
  2036. * This reports the number of times the library has been initialized by a call
  2037. * to TTF_Init(), without a paired deinitialization request from TTF_Quit().
  2038. *
  2039. * In short: if it's greater than zero, the library is currently initialized
  2040. * and ready to work. If zero, it is not initialized.
  2041. *
  2042. * Despite the return value being a signed integer, this function should not
  2043. * return a negative number.
  2044. *
  2045. * \returns the current number of initialization calls, that need to
  2046. * eventually be paired with this many calls to TTF_Quit().
  2047. *
  2048. * \since This function is available since SDL_ttf 2.0.12.
  2049. *
  2050. * \sa TTF_Init
  2051. * \sa TTF_Quit
  2052. }
  2053. function TTF_WasInit: cint; cdecl;
  2054. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_WasInit' {$ENDIF} {$ENDIF};
  2055. {*
  2056. * Query the kerning size of two glyphs indices.
  2057. *
  2058. * \deprecated This function accidentally requires FreeType font indexes,
  2059. * not codepoints, which we don't expose through this API, so
  2060. * it could give wildly incorrect results, especially with
  2061. * non-ASCII values. Going forward, please use
  2062. * TTF_GetFontKerningSizeGlyphs() instead, which does what you
  2063. * probably expected this function to do.
  2064. *
  2065. * \param font the font to query.
  2066. * \param prev_index the font index, NOT codepoint, of the previous character.
  2067. * \param index the font index, NOT codepoint, of the current character.
  2068. * \returns The kerning size between the two specified characters, in pixels, or -1 on error.
  2069. *
  2070. * \since This function is available since SDL_ttf 2.0.12.
  2071. *
  2072. * \sa TTF_GetFontKerningSizeGlyphs
  2073. }
  2074. function TTF_GetFontKerningSize(font: PTTF_Font; prev_index: cint; index: cint): cint; cdecl;
  2075. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontKerningSize' {$ENDIF} {$ENDIF};
  2076. deprecated 'This function requires FreeType font indexes, not glyphs. Use TTF_GetFontKerningSizeGlyphs() instead';
  2077. {*
  2078. * Query the kerning size of two 16-bit glyphs.
  2079. *
  2080. * Note that this version of the function takes 16-bit character
  2081. * codes, which covers the Basic Multilingual Plane, but is insufficient
  2082. * to cover the entire set of possible Unicode values, including emoji
  2083. * glyphs. You should use TTF_GetFontKerningSizeGlyphs32() instead, which
  2084. * offers the same functionality but takes a 32-bit codepoints instead.
  2085. *
  2086. * The only reason to use this function is that it was available since
  2087. * the beginning of time, more or less.
  2088. *
  2089. * \param font the font to query.
  2090. * \param previous_ch the previous character's code, 16 bits.
  2091. * \param ch the current character's code, 16 bits.
  2092. * \returns The kerning size between the two specified characters, in pixels, or -1 on error.
  2093. *
  2094. * \since This function is available since SDL_ttf 2.0.14.
  2095. *
  2096. * \sa TTF_GetFontKerningSizeGlyphs32
  2097. }
  2098. function TTF_GetFontKerningSizeGlyphs(font: PTTF_Font; previous_ch: cuint16; ch: cuint16): cint; cdecl;
  2099. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontKerningSizeGlyphs' {$ENDIF} {$ENDIF};
  2100. {*
  2101. * Query the kerning size of two 32-bit glyphs.
  2102. *
  2103. * This is the same as TTF_GetFontKerningSizeGlyphs(), but takes 32-bit
  2104. * characters instead of 16-bit, and thus can manage a larger range. If
  2105. * you are sure you'll have an SDL_ttf that's version 2.0.18 or newer,
  2106. * there's no reason not to use this function exclusively.
  2107. *
  2108. * \param font the font to query.
  2109. * \param previous_ch the previous character's code, 32 bits.
  2110. * \param ch the current character's code, 32 bits.
  2111. * \returns The kerning size between the two specified characters, in pixels, or -1 on error.
  2112. *
  2113. * \since This function is available since SDL_ttf 2.0.18.
  2114. }
  2115. function TTF_GetFontKerningSizeGlyphs32(font: PTTF_Font; previous_ch: cuint32; ch: cuint32): cint; cdecl;
  2116. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontKerningSizeGlyphs32' {$ENDIF} {$ENDIF};
  2117. {*
  2118. * Enable Signed Distance Field rendering for a font.
  2119. *
  2120. * This works with the Blended APIs. SDF is a technique that
  2121. * helps fonts look sharp even when scaling and rotating.
  2122. *
  2123. * This clears already-generated glyphs, if any, from the cache.
  2124. *
  2125. * \param font the font to set SDF support on.
  2126. * \param on_off SDL_TRUE to enable SDF, SDL_FALSE to disable.
  2127. *
  2128. * \returns 0 on success, -1 on error.
  2129. *
  2130. * \since This function is available since SDL_ttf 2.0.18.
  2131. *
  2132. * \sa TTF_GetFontSDF
  2133. }
  2134. function TTF_SetFontSDF(font: PTTF_Font; on_off: TSDL_bool): cint; cdecl;
  2135. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontSDF' {$ENDIF} {$ENDIF};
  2136. {*
  2137. * Query whether Signed Distance Field rendering is enabled for a font.
  2138. *
  2139. * \param font the font to query
  2140. *
  2141. * \returns SDL_TRUE if enabled, SDL_FALSE otherwise.
  2142. *
  2143. * \since This function is available since SDL_ttf 2.0.18.
  2144. *
  2145. * \sa TTF_SetFontSDF
  2146. }
  2147. (* Const before type ignored *)
  2148. function TTF_GetFontSDF(font: PTTF_Font): TSDL_bool; cdecl;
  2149. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_GetFontSDF' {$ENDIF} {$ENDIF};
  2150. {*
  2151. * Report SDL_ttf errors
  2152. *
  2153. * \sa TTF_GetError
  2154. }
  2155. function TTF_SetError(const fmt: PAnsiChar; args: array of const): cint; cdecl;
  2156. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF}
  2157. name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_SDL_SetError' {$ELSE} 'SDL_SetError' {$ENDIF};
  2158. {*
  2159. * Get last SDL_ttf error
  2160. *
  2161. * \sa TTF_SetError
  2162. }
  2163. function TTF_GetError: PAnsiChar; cdecl;
  2164. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF}
  2165. name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_SDL_GetError' {$ELSE} 'SDL_GetError' {$ENDIF};
  2166. {*
  2167. * Direction flags
  2168. *
  2169. * \sa TTF_SetFontDirection
  2170. }
  2171. type
  2172. PPTTF_Direction = ^PTTF_Direction;
  2173. PTTF_Direction = ^TTTF_Direction;
  2174. TTTF_Direction = type Integer;
  2175. const
  2176. TTF_DIRECTION_LTR = TTTF_Direction(0); { Left to Right }
  2177. TTF_DIRECTION_RTL = TTTF_Direction(1); { Right to Left }
  2178. TTF_DIRECTION_TTB = TTTF_Direction(2); { Top to Bottom }
  2179. TTF_DIRECTION_BTT = TTTF_Direction(3); { Bottom to Top }
  2180. {*
  2181. * Set a global direction to be used for text shaping.
  2182. *
  2183. * \deprecated This function expects an hb_direction_t value, from HarfBuzz,
  2184. * cast to an int, and affects all fonts globally. Please use
  2185. * TTF_SetFontDirection() instead, which uses an enum supplied by
  2186. * SDL_ttf itself and operates on a per-font basis.
  2187. *
  2188. * This is a global setting; fonts will favor a value set with
  2189. * TTF_SetFontDirection(), but if they have not had one explicitly
  2190. * set, they will use the value specified here.
  2191. *
  2192. * The default value is `HB_DIRECTION_LTR` (left-to-right text
  2193. * flow).
  2194. *
  2195. * \param direction an hb_direction_t value.
  2196. * \returns 0, or -1 if SDL_ttf is not compiled with HarfBuzz support.
  2197. *
  2198. * \since This function is available since SDL_ttf 2.0.18.
  2199. *
  2200. * \sa TTF_SetFontDirection
  2201. }
  2202. function TTF_SetDirection(direction: cint): cint; cdecl;
  2203. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetDirection' {$ENDIF} {$ENDIF};
  2204. deprecated; { hb_direction_t }
  2205. {*
  2206. * Set a global script to be used for text shaping.
  2207. *
  2208. * \deprecated This function expects an hb_script_t value, from HarfBuzz, cast
  2209. * to an int, and affects all fonts globally. Please use
  2210. * TTF_SetFontScriptName() instead, which accepts a string that is
  2211. * converted to an equivalent int internally, and operates on a
  2212. * per-font basis.
  2213. *
  2214. * This is a global setting; fonts will favor a value set with
  2215. * TTF_SetFontScriptName(), but if they have not had one
  2216. * explicitly set, they will use the value specified here.
  2217. *
  2218. * The default value is `HB_SCRIPT_UNKNOWN`.
  2219. *
  2220. * \returns 0, or -1 if SDL_ttf is not compiled with HarfBuzz support.
  2221. *
  2222. * \since This function is available since SDL_ttf 2.0.18.
  2223. *
  2224. * \sa TTF_SetFontScriptName
  2225. }
  2226. function TTF_SetScript(script: cint): cint; cdecl;
  2227. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetScript' {$ENDIF} {$ENDIF};
  2228. deprecated; { hb_script_t }
  2229. {*
  2230. * Set direction to be used for text shaping by a font.
  2231. *
  2232. * Any value supplied here will override the global direction set with the
  2233. * deprecated TTF_SetDirection().
  2234. *
  2235. * Possible direction values are:
  2236. *
  2237. * - `TTF_DIRECTION_LTR` (Left to Right)
  2238. * - `TTF_DIRECTION_RTL` (Right to Left)
  2239. * - `TTF_DIRECTION_TTB` (Top to Bottom)
  2240. * - `TTF_DIRECTION_BTT` (Bottom to Top)
  2241. *
  2242. * If SDL_ttf was not built with HarfBuzz support, this function returns -1.
  2243. *
  2244. * \param font the font to specify a direction for.
  2245. * \param direction the new direction for text to flow.
  2246. * \returns 0 on success, or -1 on error.
  2247. *
  2248. * \since This function is available since SDL_ttf 2.20.0.
  2249. }
  2250. function TTF_SetFontDirection(font: PTTF_Font; direction: TTTF_Direction): cint; cdecl;
  2251. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontDirection' {$ENDIF} {$ENDIF};
  2252. {*
  2253. * Set script to be used for text shaping by a font.
  2254. *
  2255. * Any value supplied here will override the global script set with the
  2256. * deprecated TTF_SetScript().
  2257. *
  2258. * The supplied script value must be a null-terminated string of exactly four
  2259. * characters.
  2260. *
  2261. * If SDL_ttf was not built with HarfBuzz support, this function returns -1.
  2262. *
  2263. * \param font the font to specify a direction for.
  2264. * \param script null-terminated string of exactly 4 characters.
  2265. * \returns 0 on success, or -1 on error.
  2266. *
  2267. * \since This function is available since SDL_ttf 2.20.0.
  2268. }
  2269. function TTF_SetFontScriptName(font: PTTF_Font; script: PAnsiChar): cint; cdecl;
  2270. external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_SetFontScriptName' {$ENDIF} {$ENDIF};
  2271. implementation
  2272. procedure SDL_TTF_VERSION(out X: TSDL_Version);
  2273. begin
  2274. x.major := SDL_TTF_MAJOR_VERSION;
  2275. x.minor := SDL_TTF_MINOR_VERSION;
  2276. x.patch := SDL_TTF_PATCHLEVEL;
  2277. end;
  2278. procedure TTF_VERSION(out X: TSDL_Version);
  2279. begin
  2280. SDL_TTF_VERSION(X);
  2281. end;
  2282. function SDL_TTF_VERSION_ATLEAST(X, Y, Z: Integer): Boolean;
  2283. begin
  2284. Result := (SDL_TTF_MAJOR_VERSION >= X) and
  2285. ((SDL_TTF_MAJOR_VERSION > X) or (SDL_TTF_MINOR_VERSION >= Y)) and
  2286. ((SDL_TTF_MAJOR_VERSION > X) or (SDL_TTF_MINOR_VERSION > Y) or (SDL_TTF_PATCHLEVEL >= Z));
  2287. end;
  2288. end.