SDL_ttf.h 85 KB

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