freetype.h 169 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058
  1. /****************************************************************************
  2. *
  3. * freetype.h
  4. *
  5. * FreeType high-level API and common types (specification only).
  6. *
  7. * Copyright (C) 1996-2023 by
  8. * David Turner, Robert Wilhelm, and Werner Lemberg.
  9. *
  10. * This file is part of the FreeType project, and may only be used,
  11. * modified, and distributed under the terms of the FreeType project
  12. * license, LICENSE.TXT. By continuing to use, modify, or distribute
  13. * this file you indicate that you have read the license and
  14. * understand and accept it fully.
  15. *
  16. */
  17. #ifndef FREETYPE_H_
  18. #define FREETYPE_H_
  19. #include <ft2build.h>
  20. #include FT_CONFIG_CONFIG_H
  21. #include <freetype/fttypes.h>
  22. #include <freetype/fterrors.h>
  23. FT_BEGIN_HEADER
  24. /**************************************************************************
  25. *
  26. * @section:
  27. * preamble
  28. *
  29. * @title:
  30. * Preamble
  31. *
  32. * @abstract:
  33. * What FreeType is and isn't
  34. *
  35. * @description:
  36. * FreeType is a library that provides access to glyphs in font files. It
  37. * scales the glyph images and their metrics to a requested size, and it
  38. * rasterizes the glyph images to produce pixel or subpixel alpha coverage
  39. * bitmaps.
  40. *
  41. * Note that FreeType is _not_ a text layout engine. You have to use
  42. * higher-level libraries like HarfBuzz, Pango, or ICU for that.
  43. *
  44. * Note also that FreeType does _not_ perform alpha blending or
  45. * compositing the resulting bitmaps or pixmaps by itself. Use your
  46. * favourite graphics library (for example, Cairo or Skia) to further
  47. * process FreeType's output.
  48. *
  49. */
  50. /**************************************************************************
  51. *
  52. * @section:
  53. * header_inclusion
  54. *
  55. * @title:
  56. * FreeType's header inclusion scheme
  57. *
  58. * @abstract:
  59. * How client applications should include FreeType header files.
  60. *
  61. * @description:
  62. * To be as flexible as possible (and for historical reasons), you must
  63. * load file `ft2build.h` first before other header files, for example
  64. *
  65. * ```
  66. * #include <ft2build.h>
  67. *
  68. * #include <freetype/freetype.h>
  69. * #include <freetype/ftoutln.h>
  70. * ```
  71. */
  72. /**************************************************************************
  73. *
  74. * @section:
  75. * user_allocation
  76. *
  77. * @title:
  78. * User allocation
  79. *
  80. * @abstract:
  81. * How client applications should allocate FreeType data structures.
  82. *
  83. * @description:
  84. * FreeType assumes that structures allocated by the user and passed as
  85. * arguments are zeroed out except for the actual data. In other words,
  86. * it is recommended to use `calloc` (or variants of it) instead of
  87. * `malloc` for allocation.
  88. *
  89. */
  90. /*************************************************************************/
  91. /*************************************************************************/
  92. /* */
  93. /* B A S I C T Y P E S */
  94. /* */
  95. /*************************************************************************/
  96. /*************************************************************************/
  97. /**************************************************************************
  98. *
  99. * @section:
  100. * base_interface
  101. *
  102. * @title:
  103. * Base Interface
  104. *
  105. * @abstract:
  106. * The FreeType~2 base font interface.
  107. *
  108. * @description:
  109. * This section describes the most important public high-level API
  110. * functions of FreeType~2.
  111. *
  112. * @order:
  113. * FT_Library
  114. * FT_Face
  115. * FT_Size
  116. * FT_GlyphSlot
  117. * FT_CharMap
  118. * FT_Encoding
  119. * FT_ENC_TAG
  120. *
  121. * FT_FaceRec
  122. *
  123. * FT_FACE_FLAG_SCALABLE
  124. * FT_FACE_FLAG_FIXED_SIZES
  125. * FT_FACE_FLAG_FIXED_WIDTH
  126. * FT_FACE_FLAG_HORIZONTAL
  127. * FT_FACE_FLAG_VERTICAL
  128. * FT_FACE_FLAG_COLOR
  129. * FT_FACE_FLAG_SFNT
  130. * FT_FACE_FLAG_CID_KEYED
  131. * FT_FACE_FLAG_TRICKY
  132. * FT_FACE_FLAG_KERNING
  133. * FT_FACE_FLAG_MULTIPLE_MASTERS
  134. * FT_FACE_FLAG_VARIATION
  135. * FT_FACE_FLAG_GLYPH_NAMES
  136. * FT_FACE_FLAG_EXTERNAL_STREAM
  137. * FT_FACE_FLAG_HINTER
  138. * FT_FACE_FLAG_SVG
  139. * FT_FACE_FLAG_SBIX
  140. * FT_FACE_FLAG_SBIX_OVERLAY
  141. *
  142. * FT_HAS_HORIZONTAL
  143. * FT_HAS_VERTICAL
  144. * FT_HAS_KERNING
  145. * FT_HAS_FIXED_SIZES
  146. * FT_HAS_GLYPH_NAMES
  147. * FT_HAS_COLOR
  148. * FT_HAS_MULTIPLE_MASTERS
  149. * FT_HAS_SVG
  150. * FT_HAS_SBIX
  151. * FT_HAS_SBIX_OVERLAY
  152. *
  153. * FT_IS_SFNT
  154. * FT_IS_SCALABLE
  155. * FT_IS_FIXED_WIDTH
  156. * FT_IS_CID_KEYED
  157. * FT_IS_TRICKY
  158. * FT_IS_NAMED_INSTANCE
  159. * FT_IS_VARIATION
  160. *
  161. * FT_STYLE_FLAG_BOLD
  162. * FT_STYLE_FLAG_ITALIC
  163. *
  164. * FT_SizeRec
  165. * FT_Size_Metrics
  166. *
  167. * FT_GlyphSlotRec
  168. * FT_Glyph_Metrics
  169. * FT_SubGlyph
  170. *
  171. * FT_Bitmap_Size
  172. *
  173. * FT_Init_FreeType
  174. * FT_Done_FreeType
  175. *
  176. * FT_New_Face
  177. * FT_Done_Face
  178. * FT_Reference_Face
  179. * FT_New_Memory_Face
  180. * FT_Face_Properties
  181. * FT_Open_Face
  182. * FT_Open_Args
  183. * FT_Parameter
  184. * FT_Attach_File
  185. * FT_Attach_Stream
  186. *
  187. * FT_Set_Char_Size
  188. * FT_Set_Pixel_Sizes
  189. * FT_Request_Size
  190. * FT_Select_Size
  191. * FT_Size_Request_Type
  192. * FT_Size_RequestRec
  193. * FT_Size_Request
  194. * FT_Set_Transform
  195. * FT_Get_Transform
  196. * FT_Load_Glyph
  197. * FT_Get_Char_Index
  198. * FT_Get_First_Char
  199. * FT_Get_Next_Char
  200. * FT_Load_Char
  201. *
  202. * FT_OPEN_MEMORY
  203. * FT_OPEN_STREAM
  204. * FT_OPEN_PATHNAME
  205. * FT_OPEN_DRIVER
  206. * FT_OPEN_PARAMS
  207. *
  208. * FT_LOAD_DEFAULT
  209. * FT_LOAD_RENDER
  210. * FT_LOAD_MONOCHROME
  211. * FT_LOAD_LINEAR_DESIGN
  212. * FT_LOAD_NO_SCALE
  213. * FT_LOAD_NO_HINTING
  214. * FT_LOAD_NO_BITMAP
  215. * FT_LOAD_SBITS_ONLY
  216. * FT_LOAD_NO_AUTOHINT
  217. * FT_LOAD_COLOR
  218. *
  219. * FT_LOAD_VERTICAL_LAYOUT
  220. * FT_LOAD_IGNORE_TRANSFORM
  221. * FT_LOAD_FORCE_AUTOHINT
  222. * FT_LOAD_NO_RECURSE
  223. * FT_LOAD_PEDANTIC
  224. *
  225. * FT_LOAD_TARGET_NORMAL
  226. * FT_LOAD_TARGET_LIGHT
  227. * FT_LOAD_TARGET_MONO
  228. * FT_LOAD_TARGET_LCD
  229. * FT_LOAD_TARGET_LCD_V
  230. *
  231. * FT_LOAD_TARGET_MODE
  232. *
  233. * FT_Render_Glyph
  234. * FT_Render_Mode
  235. * FT_Get_Kerning
  236. * FT_Kerning_Mode
  237. * FT_Get_Track_Kerning
  238. *
  239. * FT_CharMapRec
  240. * FT_Select_Charmap
  241. * FT_Set_Charmap
  242. * FT_Get_Charmap_Index
  243. *
  244. * FT_Get_Name_Index
  245. * FT_Get_Glyph_Name
  246. * FT_Get_Postscript_Name
  247. * FT_Get_FSType_Flags
  248. * FT_Get_SubGlyph_Info
  249. *
  250. * FT_Face_Internal
  251. * FT_Size_Internal
  252. * FT_Slot_Internal
  253. *
  254. * FT_FACE_FLAG_XXX
  255. * FT_STYLE_FLAG_XXX
  256. * FT_OPEN_XXX
  257. * FT_LOAD_XXX
  258. * FT_LOAD_TARGET_XXX
  259. * FT_SUBGLYPH_FLAG_XXX
  260. * FT_FSTYPE_XXX
  261. *
  262. * FT_HAS_FAST_GLYPHS
  263. *
  264. */
  265. /**************************************************************************
  266. *
  267. * @struct:
  268. * FT_Glyph_Metrics
  269. *
  270. * @description:
  271. * A structure to model the metrics of a single glyph. The values are
  272. * expressed in 26.6 fractional pixel format; if the flag
  273. * @FT_LOAD_NO_SCALE has been used while loading the glyph, values are
  274. * expressed in font units instead.
  275. *
  276. * @fields:
  277. * width ::
  278. * The glyph's width.
  279. *
  280. * height ::
  281. * The glyph's height.
  282. *
  283. * horiBearingX ::
  284. * Left side bearing for horizontal layout.
  285. *
  286. * horiBearingY ::
  287. * Top side bearing for horizontal layout.
  288. *
  289. * horiAdvance ::
  290. * Advance width for horizontal layout.
  291. *
  292. * vertBearingX ::
  293. * Left side bearing for vertical layout.
  294. *
  295. * vertBearingY ::
  296. * Top side bearing for vertical layout. Larger positive values mean
  297. * further below the vertical glyph origin.
  298. *
  299. * vertAdvance ::
  300. * Advance height for vertical layout. Positive values mean the glyph
  301. * has a positive advance downward.
  302. *
  303. * @note:
  304. * If not disabled with @FT_LOAD_NO_HINTING, the values represent
  305. * dimensions of the hinted glyph (in case hinting is applicable).
  306. *
  307. * Stroking a glyph with an outside border does not increase
  308. * `horiAdvance` or `vertAdvance`; you have to manually adjust these
  309. * values to account for the added width and height.
  310. *
  311. * FreeType doesn't use the 'VORG' table data for CFF fonts because it
  312. * doesn't have an interface to quickly retrieve the glyph height. The
  313. * y~coordinate of the vertical origin can be simply computed as
  314. * `vertBearingY + height` after loading a glyph.
  315. */
  316. typedef struct FT_Glyph_Metrics_
  317. {
  318. FT_Pos width;
  319. FT_Pos height;
  320. FT_Pos horiBearingX;
  321. FT_Pos horiBearingY;
  322. FT_Pos horiAdvance;
  323. FT_Pos vertBearingX;
  324. FT_Pos vertBearingY;
  325. FT_Pos vertAdvance;
  326. } FT_Glyph_Metrics;
  327. /**************************************************************************
  328. *
  329. * @struct:
  330. * FT_Bitmap_Size
  331. *
  332. * @description:
  333. * This structure models the metrics of a bitmap strike (i.e., a set of
  334. * glyphs for a given point size and resolution) in a bitmap font. It is
  335. * used for the `available_sizes` field of @FT_Face.
  336. *
  337. * @fields:
  338. * height ::
  339. * The vertical distance, in pixels, between two consecutive baselines.
  340. * It is always positive.
  341. *
  342. * width ::
  343. * The average width, in pixels, of all glyphs in the strike.
  344. *
  345. * size ::
  346. * The nominal size of the strike in 26.6 fractional points. This
  347. * field is not very useful.
  348. *
  349. * x_ppem ::
  350. * The horizontal ppem (nominal width) in 26.6 fractional pixels.
  351. *
  352. * y_ppem ::
  353. * The vertical ppem (nominal height) in 26.6 fractional pixels.
  354. *
  355. * @note:
  356. * Windows FNT:
  357. * The nominal size given in a FNT font is not reliable. If the driver
  358. * finds it incorrect, it sets `size` to some calculated values, and
  359. * `x_ppem` and `y_ppem` to the pixel width and height given in the
  360. * font, respectively.
  361. *
  362. * TrueType embedded bitmaps:
  363. * `size`, `width`, and `height` values are not contained in the bitmap
  364. * strike itself. They are computed from the global font parameters.
  365. */
  366. typedef struct FT_Bitmap_Size_
  367. {
  368. FT_Short height;
  369. FT_Short width;
  370. FT_Pos size;
  371. FT_Pos x_ppem;
  372. FT_Pos y_ppem;
  373. } FT_Bitmap_Size;
  374. /*************************************************************************/
  375. /*************************************************************************/
  376. /* */
  377. /* O B J E C T C L A S S E S */
  378. /* */
  379. /*************************************************************************/
  380. /*************************************************************************/
  381. /**************************************************************************
  382. *
  383. * @type:
  384. * FT_Library
  385. *
  386. * @description:
  387. * A handle to a FreeType library instance. Each 'library' is completely
  388. * independent from the others; it is the 'root' of a set of objects like
  389. * fonts, faces, sizes, etc.
  390. *
  391. * It also embeds a memory manager (see @FT_Memory), as well as a
  392. * scan-line converter object (see @FT_Raster).
  393. *
  394. * [Since 2.5.6] In multi-threaded applications it is easiest to use one
  395. * `FT_Library` object per thread. In case this is too cumbersome, a
  396. * single `FT_Library` object across threads is possible also, as long as
  397. * a mutex lock is used around @FT_New_Face and @FT_Done_Face.
  398. *
  399. * @note:
  400. * Library objects are normally created by @FT_Init_FreeType, and
  401. * destroyed with @FT_Done_FreeType. If you need reference-counting
  402. * (cf. @FT_Reference_Library), use @FT_New_Library and @FT_Done_Library.
  403. */
  404. typedef struct FT_LibraryRec_ *FT_Library;
  405. /**************************************************************************
  406. *
  407. * @section:
  408. * module_management
  409. *
  410. */
  411. /**************************************************************************
  412. *
  413. * @type:
  414. * FT_Module
  415. *
  416. * @description:
  417. * A handle to a given FreeType module object. A module can be a font
  418. * driver, a renderer, or anything else that provides services to the
  419. * former.
  420. */
  421. typedef struct FT_ModuleRec_* FT_Module;
  422. /**************************************************************************
  423. *
  424. * @type:
  425. * FT_Driver
  426. *
  427. * @description:
  428. * A handle to a given FreeType font driver object. A font driver is a
  429. * module capable of creating faces from font files.
  430. */
  431. typedef struct FT_DriverRec_* FT_Driver;
  432. /**************************************************************************
  433. *
  434. * @type:
  435. * FT_Renderer
  436. *
  437. * @description:
  438. * A handle to a given FreeType renderer. A renderer is a module in
  439. * charge of converting a glyph's outline image to a bitmap. It supports
  440. * a single glyph image format, and one or more target surface depths.
  441. */
  442. typedef struct FT_RendererRec_* FT_Renderer;
  443. /**************************************************************************
  444. *
  445. * @section:
  446. * base_interface
  447. *
  448. */
  449. /**************************************************************************
  450. *
  451. * @type:
  452. * FT_Face
  453. *
  454. * @description:
  455. * A handle to a typographic face object. A face object models a given
  456. * typeface, in a given style.
  457. *
  458. * @note:
  459. * A face object also owns a single @FT_GlyphSlot object, as well as one
  460. * or more @FT_Size objects.
  461. *
  462. * Use @FT_New_Face or @FT_Open_Face to create a new face object from a
  463. * given filepath or a custom input stream.
  464. *
  465. * Use @FT_Done_Face to destroy it (along with its slot and sizes).
  466. *
  467. * An `FT_Face` object can only be safely used from one thread at a time.
  468. * Similarly, creation and destruction of `FT_Face` with the same
  469. * @FT_Library object can only be done from one thread at a time. On the
  470. * other hand, functions like @FT_Load_Glyph and its siblings are
  471. * thread-safe and do not need the lock to be held as long as the same
  472. * `FT_Face` object is not used from multiple threads at the same time.
  473. *
  474. * @also:
  475. * See @FT_FaceRec for the publicly accessible fields of a given face
  476. * object.
  477. */
  478. typedef struct FT_FaceRec_* FT_Face;
  479. /**************************************************************************
  480. *
  481. * @type:
  482. * FT_Size
  483. *
  484. * @description:
  485. * A handle to an object that models a face scaled to a given character
  486. * size.
  487. *
  488. * @note:
  489. * An @FT_Face has one _active_ `FT_Size` object that is used by
  490. * functions like @FT_Load_Glyph to determine the scaling transformation
  491. * that in turn is used to load and hint glyphs and metrics.
  492. *
  493. * A newly created `FT_Size` object contains only meaningless zero values.
  494. * You must use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, @FT_Request_Size
  495. * or even @FT_Select_Size to change the content (i.e., the scaling
  496. * values) of the active `FT_Size`. Otherwise, the scaling and hinting
  497. * will not be performed.
  498. *
  499. * You can use @FT_New_Size to create additional size objects for a given
  500. * @FT_Face, but they won't be used by other functions until you activate
  501. * it through @FT_Activate_Size. Only one size can be activated at any
  502. * given time per face.
  503. *
  504. * @also:
  505. * See @FT_SizeRec for the publicly accessible fields of a given size
  506. * object.
  507. */
  508. typedef struct FT_SizeRec_* FT_Size;
  509. /**************************************************************************
  510. *
  511. * @type:
  512. * FT_GlyphSlot
  513. *
  514. * @description:
  515. * A handle to a given 'glyph slot'. A slot is a container that can hold
  516. * any of the glyphs contained in its parent face.
  517. *
  518. * In other words, each time you call @FT_Load_Glyph or @FT_Load_Char,
  519. * the slot's content is erased by the new glyph data, i.e., the glyph's
  520. * metrics, its image (bitmap or outline), and other control information.
  521. *
  522. * @also:
  523. * See @FT_GlyphSlotRec for the publicly accessible glyph fields.
  524. */
  525. typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
  526. /**************************************************************************
  527. *
  528. * @type:
  529. * FT_CharMap
  530. *
  531. * @description:
  532. * A handle to a character map (usually abbreviated to 'charmap'). A
  533. * charmap is used to translate character codes in a given encoding into
  534. * glyph indexes for its parent's face. Some font formats may provide
  535. * several charmaps per font.
  536. *
  537. * Each face object owns zero or more charmaps, but only one of them can
  538. * be 'active', providing the data used by @FT_Get_Char_Index or
  539. * @FT_Load_Char.
  540. *
  541. * The list of available charmaps in a face is available through the
  542. * `face->num_charmaps` and `face->charmaps` fields of @FT_FaceRec.
  543. *
  544. * The currently active charmap is available as `face->charmap`. You
  545. * should call @FT_Set_Charmap to change it.
  546. *
  547. * @note:
  548. * When a new face is created (either through @FT_New_Face or
  549. * @FT_Open_Face), the library looks for a Unicode charmap within the
  550. * list and automatically activates it. If there is no Unicode charmap,
  551. * FreeType doesn't set an 'active' charmap.
  552. *
  553. * @also:
  554. * See @FT_CharMapRec for the publicly accessible fields of a given
  555. * character map.
  556. */
  557. typedef struct FT_CharMapRec_* FT_CharMap;
  558. /**************************************************************************
  559. *
  560. * @macro:
  561. * FT_ENC_TAG
  562. *
  563. * @description:
  564. * This macro converts four-letter tags into an unsigned long. It is
  565. * used to define 'encoding' identifiers (see @FT_Encoding).
  566. *
  567. * @note:
  568. * Since many 16-bit compilers don't like 32-bit enumerations, you should
  569. * redefine this macro in case of problems to something like this:
  570. *
  571. * ```
  572. * #define FT_ENC_TAG( value, a, b, c, d ) value
  573. * ```
  574. *
  575. * to get a simple enumeration without assigning special numbers.
  576. */
  577. #ifndef FT_ENC_TAG
  578. #define FT_ENC_TAG( value, a, b, c, d ) \
  579. value = ( ( FT_STATIC_BYTE_CAST( FT_UInt32, a ) << 24 ) | \
  580. ( FT_STATIC_BYTE_CAST( FT_UInt32, b ) << 16 ) | \
  581. ( FT_STATIC_BYTE_CAST( FT_UInt32, c ) << 8 ) | \
  582. FT_STATIC_BYTE_CAST( FT_UInt32, d ) )
  583. #endif /* FT_ENC_TAG */
  584. /**************************************************************************
  585. *
  586. * @enum:
  587. * FT_Encoding
  588. *
  589. * @description:
  590. * An enumeration to specify character sets supported by charmaps. Used
  591. * in the @FT_Select_Charmap API function.
  592. *
  593. * @note:
  594. * Despite the name, this enumeration lists specific character
  595. * repertoires (i.e., charsets), and not text encoding methods (e.g.,
  596. * UTF-8, UTF-16, etc.).
  597. *
  598. * Other encodings might be defined in the future.
  599. *
  600. * @values:
  601. * FT_ENCODING_NONE ::
  602. * The encoding value~0 is reserved for all formats except BDF, PCF,
  603. * and Windows FNT; see below for more information.
  604. *
  605. * FT_ENCODING_UNICODE ::
  606. * The Unicode character set. This value covers all versions of the
  607. * Unicode repertoire, including ASCII and Latin-1. Most fonts include
  608. * a Unicode charmap, but not all of them.
  609. *
  610. * For example, if you want to access Unicode value U+1F028 (and the
  611. * font contains it), use value 0x1F028 as the input value for
  612. * @FT_Get_Char_Index.
  613. *
  614. * FT_ENCODING_MS_SYMBOL ::
  615. * Microsoft Symbol encoding, used to encode mathematical symbols and
  616. * wingdings. For more information, see
  617. * 'https://www.microsoft.com/typography/otspec/recom.htm#non-standard-symbol-fonts',
  618. * 'http://www.kostis.net/charsets/symbol.htm', and
  619. * 'http://www.kostis.net/charsets/wingding.htm'.
  620. *
  621. * This encoding uses character codes from the PUA (Private Unicode
  622. * Area) in the range U+F020-U+F0FF.
  623. *
  624. * FT_ENCODING_SJIS ::
  625. * Shift JIS encoding for Japanese. More info at
  626. * 'https://en.wikipedia.org/wiki/Shift_JIS'. See note on multi-byte
  627. * encodings below.
  628. *
  629. * FT_ENCODING_PRC ::
  630. * Corresponds to encoding systems mainly for Simplified Chinese as
  631. * used in People's Republic of China (PRC). The encoding layout is
  632. * based on GB~2312 and its supersets GBK and GB~18030.
  633. *
  634. * FT_ENCODING_BIG5 ::
  635. * Corresponds to an encoding system for Traditional Chinese as used in
  636. * Taiwan and Hong Kong.
  637. *
  638. * FT_ENCODING_WANSUNG ::
  639. * Corresponds to the Korean encoding system known as Extended Wansung
  640. * (MS Windows code page 949). For more information see
  641. * 'https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'.
  642. *
  643. * FT_ENCODING_JOHAB ::
  644. * The Korean standard character set (KS~C 5601-1992), which
  645. * corresponds to MS Windows code page 1361. This character set
  646. * includes all possible Hangul character combinations.
  647. *
  648. * FT_ENCODING_ADOBE_LATIN_1 ::
  649. * Corresponds to a Latin-1 encoding as defined in a Type~1 PostScript
  650. * font. It is limited to 256 character codes.
  651. *
  652. * FT_ENCODING_ADOBE_STANDARD ::
  653. * Adobe Standard encoding, as found in Type~1, CFF, and OpenType/CFF
  654. * fonts. It is limited to 256 character codes.
  655. *
  656. * FT_ENCODING_ADOBE_EXPERT ::
  657. * Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF
  658. * fonts. It is limited to 256 character codes.
  659. *
  660. * FT_ENCODING_ADOBE_CUSTOM ::
  661. * Corresponds to a custom encoding, as found in Type~1, CFF, and
  662. * OpenType/CFF fonts. It is limited to 256 character codes.
  663. *
  664. * FT_ENCODING_APPLE_ROMAN ::
  665. * Apple roman encoding. Many TrueType and OpenType fonts contain a
  666. * charmap for this 8-bit encoding, since older versions of Mac OS are
  667. * able to use it.
  668. *
  669. * FT_ENCODING_OLD_LATIN_2 ::
  670. * This value is deprecated and was neither used nor reported by
  671. * FreeType. Don't use or test for it.
  672. *
  673. * FT_ENCODING_MS_SJIS ::
  674. * Same as FT_ENCODING_SJIS. Deprecated.
  675. *
  676. * FT_ENCODING_MS_GB2312 ::
  677. * Same as FT_ENCODING_PRC. Deprecated.
  678. *
  679. * FT_ENCODING_MS_BIG5 ::
  680. * Same as FT_ENCODING_BIG5. Deprecated.
  681. *
  682. * FT_ENCODING_MS_WANSUNG ::
  683. * Same as FT_ENCODING_WANSUNG. Deprecated.
  684. *
  685. * FT_ENCODING_MS_JOHAB ::
  686. * Same as FT_ENCODING_JOHAB. Deprecated.
  687. *
  688. * @note:
  689. * When loading a font, FreeType makes a Unicode charmap active if
  690. * possible (either if the font provides such a charmap, or if FreeType
  691. * can synthesize one from PostScript glyph name dictionaries; in either
  692. * case, the charmap is tagged with `FT_ENCODING_UNICODE`). If such a
  693. * charmap is synthesized, it is placed at the first position of the
  694. * charmap array.
  695. *
  696. * All other encodings are considered legacy and tagged only if
  697. * explicitly defined in the font file. Otherwise, `FT_ENCODING_NONE` is
  698. * used.
  699. *
  700. * `FT_ENCODING_NONE` is set by the BDF and PCF drivers if the charmap is
  701. * neither Unicode nor ISO-8859-1 (otherwise it is set to
  702. * `FT_ENCODING_UNICODE`). Use @FT_Get_BDF_Charset_ID to find out which
  703. * encoding is really present. If, for example, the `cs_registry` field
  704. * is 'KOI8' and the `cs_encoding` field is 'R', the font is encoded in
  705. * KOI8-R.
  706. *
  707. * `FT_ENCODING_NONE` is always set (with a single exception) by the
  708. * winfonts driver. Use @FT_Get_WinFNT_Header and examine the `charset`
  709. * field of the @FT_WinFNT_HeaderRec structure to find out which encoding
  710. * is really present. For example, @FT_WinFNT_ID_CP1251 (204) means
  711. * Windows code page 1251 (for Russian).
  712. *
  713. * `FT_ENCODING_NONE` is set if `platform_id` is @TT_PLATFORM_MACINTOSH
  714. * and `encoding_id` is not `TT_MAC_ID_ROMAN` (otherwise it is set to
  715. * `FT_ENCODING_APPLE_ROMAN`).
  716. *
  717. * If `platform_id` is @TT_PLATFORM_MACINTOSH, use the function
  718. * @FT_Get_CMap_Language_ID to query the Mac language ID that may be
  719. * needed to be able to distinguish Apple encoding variants. See
  720. *
  721. * https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt
  722. *
  723. * to get an idea how to do that. Basically, if the language ID is~0,
  724. * don't use it, otherwise subtract 1 from the language ID. Then examine
  725. * `encoding_id`. If, for example, `encoding_id` is `TT_MAC_ID_ROMAN`
  726. * and the language ID (minus~1) is `TT_MAC_LANGID_GREEK`, it is the
  727. * Greek encoding, not Roman. `TT_MAC_ID_ARABIC` with
  728. * `TT_MAC_LANGID_FARSI` means the Farsi variant of the Arabic encoding.
  729. */
  730. typedef enum FT_Encoding_
  731. {
  732. FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
  733. FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
  734. FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
  735. FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
  736. FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ),
  737. FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
  738. FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
  739. FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
  740. /* for backward compatibility */
  741. FT_ENCODING_GB2312 = FT_ENCODING_PRC,
  742. FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
  743. FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
  744. FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
  745. FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
  746. FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
  747. FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
  748. FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
  749. FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
  750. FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
  751. FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
  752. FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
  753. } FT_Encoding;
  754. /* these constants are deprecated; use the corresponding `FT_Encoding` */
  755. /* values instead */
  756. #define ft_encoding_none FT_ENCODING_NONE
  757. #define ft_encoding_unicode FT_ENCODING_UNICODE
  758. #define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
  759. #define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
  760. #define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
  761. #define ft_encoding_sjis FT_ENCODING_SJIS
  762. #define ft_encoding_gb2312 FT_ENCODING_PRC
  763. #define ft_encoding_big5 FT_ENCODING_BIG5
  764. #define ft_encoding_wansung FT_ENCODING_WANSUNG
  765. #define ft_encoding_johab FT_ENCODING_JOHAB
  766. #define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
  767. #define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
  768. #define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
  769. #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
  770. /**************************************************************************
  771. *
  772. * @struct:
  773. * FT_CharMapRec
  774. *
  775. * @description:
  776. * The base charmap structure.
  777. *
  778. * @fields:
  779. * face ::
  780. * A handle to the parent face object.
  781. *
  782. * encoding ::
  783. * An @FT_Encoding tag identifying the charmap. Use this with
  784. * @FT_Select_Charmap.
  785. *
  786. * platform_id ::
  787. * An ID number describing the platform for the following encoding ID.
  788. * This comes directly from the TrueType specification and gets
  789. * emulated for other formats.
  790. *
  791. * encoding_id ::
  792. * A platform-specific encoding number. This also comes from the
  793. * TrueType specification and gets emulated similarly.
  794. */
  795. typedef struct FT_CharMapRec_
  796. {
  797. FT_Face face;
  798. FT_Encoding encoding;
  799. FT_UShort platform_id;
  800. FT_UShort encoding_id;
  801. } FT_CharMapRec;
  802. /*************************************************************************/
  803. /*************************************************************************/
  804. /* */
  805. /* B A S E O B J E C T C L A S S E S */
  806. /* */
  807. /*************************************************************************/
  808. /*************************************************************************/
  809. /**************************************************************************
  810. *
  811. * @type:
  812. * FT_Face_Internal
  813. *
  814. * @description:
  815. * An opaque handle to an `FT_Face_InternalRec` structure that models the
  816. * private data of a given @FT_Face object.
  817. *
  818. * This structure might change between releases of FreeType~2 and is not
  819. * generally available to client applications.
  820. */
  821. typedef struct FT_Face_InternalRec_* FT_Face_Internal;
  822. /**************************************************************************
  823. *
  824. * @struct:
  825. * FT_FaceRec
  826. *
  827. * @description:
  828. * FreeType root face class structure. A face object models a typeface
  829. * in a font file.
  830. *
  831. * @fields:
  832. * num_faces ::
  833. * The number of faces in the font file. Some font formats can have
  834. * multiple faces in a single font file.
  835. *
  836. * face_index ::
  837. * This field holds two different values. Bits 0-15 are the index of
  838. * the face in the font file (starting with value~0). They are set
  839. * to~0 if there is only one face in the font file.
  840. *
  841. * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
  842. * fonts only, holding the named instance index for the current face
  843. * index (starting with value~1; value~0 indicates font access without
  844. * a named instance). For non-variation fonts, bits 16-30 are ignored.
  845. * If we have the third named instance of face~4, say, `face_index` is
  846. * set to 0x00030004.
  847. *
  848. * Bit 31 is always zero (this is, `face_index` is always a positive
  849. * value).
  850. *
  851. * [Since 2.9] Changing the design coordinates with
  852. * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
  853. * not influence the named instance index value (only
  854. * @FT_Set_Named_Instance does that).
  855. *
  856. * face_flags ::
  857. * A set of bit flags that give important information about the face;
  858. * see @FT_FACE_FLAG_XXX for the details.
  859. *
  860. * style_flags ::
  861. * The lower 16~bits contain a set of bit flags indicating the style of
  862. * the face; see @FT_STYLE_FLAG_XXX for the details.
  863. *
  864. * [Since 2.6.1] Bits 16-30 hold the number of named instances
  865. * available for the current face if we have a GX or OpenType variation
  866. * (sub)font. Bit 31 is always zero (this is, `style_flags` is always
  867. * a positive value). Note that a variation font has always at least
  868. * one named instance, namely the default instance.
  869. *
  870. * num_glyphs ::
  871. * The number of glyphs in the face. If the face is scalable and has
  872. * sbits (see `num_fixed_sizes`), it is set to the number of outline
  873. * glyphs.
  874. *
  875. * For CID-keyed fonts (not in an SFNT wrapper) this value gives the
  876. * highest CID used in the font.
  877. *
  878. * family_name ::
  879. * The face's family name. This is an ASCII string, usually in
  880. * English, that describes the typeface's family (like 'Times New
  881. * Roman', 'Bodoni', 'Garamond', etc). This is a least common
  882. * denominator used to list fonts. Some formats (TrueType & OpenType)
  883. * provide localized and Unicode versions of this string. Applications
  884. * should use the format-specific interface to access them. Can be
  885. * `NULL` (e.g., in fonts embedded in a PDF file).
  886. *
  887. * In case the font doesn't provide a specific family name entry,
  888. * FreeType tries to synthesize one, deriving it from other name
  889. * entries.
  890. *
  891. * style_name ::
  892. * The face's style name. This is an ASCII string, usually in English,
  893. * that describes the typeface's style (like 'Italic', 'Bold',
  894. * 'Condensed', etc). Not all font formats provide a style name, so
  895. * this field is optional, and can be set to `NULL`. As for
  896. * `family_name`, some formats provide localized and Unicode versions
  897. * of this string. Applications should use the format-specific
  898. * interface to access them.
  899. *
  900. * num_fixed_sizes ::
  901. * The number of bitmap strikes in the face. Even if the face is
  902. * scalable, there might still be bitmap strikes, which are called
  903. * 'sbits' in that case.
  904. *
  905. * available_sizes ::
  906. * An array of @FT_Bitmap_Size for all bitmap strikes in the face. It
  907. * is set to `NULL` if there is no bitmap strike.
  908. *
  909. * Note that FreeType tries to sanitize the strike data since they are
  910. * sometimes sloppy or incorrect, but this can easily fail.
  911. *
  912. * num_charmaps ::
  913. * The number of charmaps in the face.
  914. *
  915. * charmaps ::
  916. * An array of the charmaps of the face.
  917. *
  918. * generic ::
  919. * A field reserved for client uses. See the @FT_Generic type
  920. * description.
  921. *
  922. * bbox ::
  923. * The font bounding box. Coordinates are expressed in font units (see
  924. * `units_per_EM`). The box is large enough to contain any glyph from
  925. * the font. Thus, `bbox.yMax` can be seen as the 'maximum ascender',
  926. * and `bbox.yMin` as the 'minimum descender'. Only relevant for
  927. * scalable formats.
  928. *
  929. * Note that the bounding box might be off by (at least) one pixel for
  930. * hinted fonts. See @FT_Size_Metrics for further discussion.
  931. *
  932. * Note that the bounding box does not vary in OpenType variable fonts
  933. * and should only be used in relation to the default instance.
  934. *
  935. * units_per_EM ::
  936. * The number of font units per EM square for this face. This is
  937. * typically 2048 for TrueType fonts, and 1000 for Type~1 fonts. Only
  938. * relevant for scalable formats.
  939. *
  940. * ascender ::
  941. * The typographic ascender of the face, expressed in font units. For
  942. * font formats not having this information, it is set to `bbox.yMax`.
  943. * Only relevant for scalable formats.
  944. *
  945. * descender ::
  946. * The typographic descender of the face, expressed in font units. For
  947. * font formats not having this information, it is set to `bbox.yMin`.
  948. * Note that this field is negative for values below the baseline.
  949. * Only relevant for scalable formats.
  950. *
  951. * height ::
  952. * This value is the vertical distance between two consecutive
  953. * baselines, expressed in font units. It is always positive. Only
  954. * relevant for scalable formats.
  955. *
  956. * If you want the global glyph height, use `ascender - descender`.
  957. *
  958. * max_advance_width ::
  959. * The maximum advance width, in font units, for all glyphs in this
  960. * face. This can be used to make word wrapping computations faster.
  961. * Only relevant for scalable formats.
  962. *
  963. * max_advance_height ::
  964. * The maximum advance height, in font units, for all glyphs in this
  965. * face. This is only relevant for vertical layouts, and is set to
  966. * `height` for fonts that do not provide vertical metrics. Only
  967. * relevant for scalable formats.
  968. *
  969. * underline_position ::
  970. * The position, in font units, of the underline line for this face.
  971. * It is the center of the underlining stem. Only relevant for
  972. * scalable formats.
  973. *
  974. * underline_thickness ::
  975. * The thickness, in font units, of the underline for this face. Only
  976. * relevant for scalable formats.
  977. *
  978. * glyph ::
  979. * The face's associated glyph slot(s).
  980. *
  981. * size ::
  982. * The current active size for this face.
  983. *
  984. * charmap ::
  985. * The current active charmap for this face.
  986. *
  987. * @note:
  988. * Fields may be changed after a call to @FT_Attach_File or
  989. * @FT_Attach_Stream.
  990. *
  991. * For an OpenType variation font, the values of the following fields can
  992. * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
  993. * the font contains an 'MVAR' table: `ascender`, `descender`, `height`,
  994. * `underline_position`, and `underline_thickness`.
  995. *
  996. * Especially for TrueType fonts see also the documentation for
  997. * @FT_Size_Metrics.
  998. */
  999. typedef struct FT_FaceRec_
  1000. {
  1001. FT_Long num_faces;
  1002. FT_Long face_index;
  1003. FT_Long face_flags;
  1004. FT_Long style_flags;
  1005. FT_Long num_glyphs;
  1006. FT_String* family_name;
  1007. FT_String* style_name;
  1008. FT_Int num_fixed_sizes;
  1009. FT_Bitmap_Size* available_sizes;
  1010. FT_Int num_charmaps;
  1011. FT_CharMap* charmaps;
  1012. FT_Generic generic;
  1013. /*# The following member variables (down to `underline_thickness`) */
  1014. /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
  1015. /*# for bitmap fonts. */
  1016. FT_BBox bbox;
  1017. FT_UShort units_per_EM;
  1018. FT_Short ascender;
  1019. FT_Short descender;
  1020. FT_Short height;
  1021. FT_Short max_advance_width;
  1022. FT_Short max_advance_height;
  1023. FT_Short underline_position;
  1024. FT_Short underline_thickness;
  1025. FT_GlyphSlot glyph;
  1026. FT_Size size;
  1027. FT_CharMap charmap;
  1028. /*@private begin */
  1029. FT_Driver driver;
  1030. FT_Memory memory;
  1031. FT_Stream stream;
  1032. FT_ListRec sizes_list;
  1033. FT_Generic autohint; /* face-specific auto-hinter data */
  1034. void* extensions; /* unused */
  1035. FT_Face_Internal internal;
  1036. /*@private end */
  1037. } FT_FaceRec;
  1038. /**************************************************************************
  1039. *
  1040. * @enum:
  1041. * FT_FACE_FLAG_XXX
  1042. *
  1043. * @description:
  1044. * A list of bit flags used in the `face_flags` field of the @FT_FaceRec
  1045. * structure. They inform client applications of properties of the
  1046. * corresponding face.
  1047. *
  1048. * @values:
  1049. * FT_FACE_FLAG_SCALABLE ::
  1050. * The face contains outline glyphs. Note that a face can contain
  1051. * bitmap strikes also, i.e., a face can have both this flag and
  1052. * @FT_FACE_FLAG_FIXED_SIZES set.
  1053. *
  1054. * FT_FACE_FLAG_FIXED_SIZES ::
  1055. * The face contains bitmap strikes. See also the `num_fixed_sizes`
  1056. * and `available_sizes` fields of @FT_FaceRec.
  1057. *
  1058. * FT_FACE_FLAG_FIXED_WIDTH ::
  1059. * The face contains fixed-width characters (like Courier, Lucida,
  1060. * MonoType, etc.).
  1061. *
  1062. * FT_FACE_FLAG_SFNT ::
  1063. * The face uses the SFNT storage scheme. For now, this means TrueType
  1064. * and OpenType.
  1065. *
  1066. * FT_FACE_FLAG_HORIZONTAL ::
  1067. * The face contains horizontal glyph metrics. This should be set for
  1068. * all common formats.
  1069. *
  1070. * FT_FACE_FLAG_VERTICAL ::
  1071. * The face contains vertical glyph metrics. This is only available in
  1072. * some formats, not all of them.
  1073. *
  1074. * FT_FACE_FLAG_KERNING ::
  1075. * The face contains kerning information. If set, the kerning distance
  1076. * can be retrieved using the function @FT_Get_Kerning. Otherwise the
  1077. * function always returns the vector (0,0). Note that FreeType
  1078. * doesn't handle kerning data from the SFNT 'GPOS' table (as present
  1079. * in many OpenType fonts).
  1080. *
  1081. * FT_FACE_FLAG_FAST_GLYPHS ::
  1082. * THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT.
  1083. *
  1084. * FT_FACE_FLAG_MULTIPLE_MASTERS ::
  1085. * The face contains multiple masters and is capable of interpolating
  1086. * between them. Supported formats are Adobe MM, TrueType GX, and
  1087. * OpenType variation fonts.
  1088. *
  1089. * See section @multiple_masters for API details.
  1090. *
  1091. * FT_FACE_FLAG_GLYPH_NAMES ::
  1092. * The face contains glyph names, which can be retrieved using
  1093. * @FT_Get_Glyph_Name. Note that some TrueType fonts contain broken
  1094. * glyph name tables. Use the function @FT_Has_PS_Glyph_Names when
  1095. * needed.
  1096. *
  1097. * FT_FACE_FLAG_EXTERNAL_STREAM ::
  1098. * Used internally by FreeType to indicate that a face's stream was
  1099. * provided by the client application and should not be destroyed when
  1100. * @FT_Done_Face is called. Don't read or test this flag.
  1101. *
  1102. * FT_FACE_FLAG_HINTER ::
  1103. * The font driver has a hinting machine of its own. For example, with
  1104. * TrueType fonts, it makes sense to use data from the SFNT 'gasp'
  1105. * table only if the native TrueType hinting engine (with the bytecode
  1106. * interpreter) is available and active.
  1107. *
  1108. * FT_FACE_FLAG_CID_KEYED ::
  1109. * The face is CID-keyed. In that case, the face is not accessed by
  1110. * glyph indices but by CID values. For subsetted CID-keyed fonts this
  1111. * has the consequence that not all index values are a valid argument
  1112. * to @FT_Load_Glyph. Only the CID values for which corresponding
  1113. * glyphs in the subsetted font exist make `FT_Load_Glyph` return
  1114. * successfully; in all other cases you get an
  1115. * `FT_Err_Invalid_Argument` error.
  1116. *
  1117. * Note that CID-keyed fonts that are in an SFNT wrapper (this is, all
  1118. * OpenType/CFF fonts) don't have this flag set since the glyphs are
  1119. * accessed in the normal way (using contiguous indices); the
  1120. * 'CID-ness' isn't visible to the application.
  1121. *
  1122. * FT_FACE_FLAG_TRICKY ::
  1123. * The face is 'tricky', this is, it always needs the font format's
  1124. * native hinting engine to get a reasonable result. A typical example
  1125. * is the old Chinese font `mingli.ttf` (but not `mingliu.ttc`) that
  1126. * uses TrueType bytecode instructions to move and scale all of its
  1127. * subglyphs.
  1128. *
  1129. * It is not possible to auto-hint such fonts using
  1130. * @FT_LOAD_FORCE_AUTOHINT; it will also ignore @FT_LOAD_NO_HINTING.
  1131. * You have to set both @FT_LOAD_NO_HINTING and @FT_LOAD_NO_AUTOHINT to
  1132. * really disable hinting; however, you probably never want this except
  1133. * for demonstration purposes.
  1134. *
  1135. * Currently, there are about a dozen TrueType fonts in the list of
  1136. * tricky fonts; they are hard-coded in file `ttobjs.c`.
  1137. *
  1138. * FT_FACE_FLAG_COLOR ::
  1139. * [Since 2.5.1] The face has color glyph tables. See @FT_LOAD_COLOR
  1140. * for more information.
  1141. *
  1142. * FT_FACE_FLAG_VARIATION ::
  1143. * [Since 2.9] Set if the current face (or named instance) has been
  1144. * altered with @FT_Set_MM_Design_Coordinates,
  1145. * @FT_Set_Var_Design_Coordinates, or @FT_Set_Var_Blend_Coordinates.
  1146. * This flag is unset by a call to @FT_Set_Named_Instance.
  1147. *
  1148. * FT_FACE_FLAG_SVG ::
  1149. * [Since 2.12] The face has an 'SVG~' OpenType table.
  1150. *
  1151. * FT_FACE_FLAG_SBIX ::
  1152. * [Since 2.12] The face has an 'sbix' OpenType table *and* outlines.
  1153. * For such fonts, @FT_FACE_FLAG_SCALABLE is not set by default to
  1154. * retain backward compatibility.
  1155. *
  1156. * FT_FACE_FLAG_SBIX_OVERLAY ::
  1157. * [Since 2.12] The face has an 'sbix' OpenType table where outlines
  1158. * should be drawn on top of bitmap strikes.
  1159. *
  1160. */
  1161. #define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
  1162. #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
  1163. #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
  1164. #define FT_FACE_FLAG_SFNT ( 1L << 3 )
  1165. #define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
  1166. #define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
  1167. #define FT_FACE_FLAG_KERNING ( 1L << 6 )
  1168. #define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
  1169. #define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
  1170. #define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
  1171. #define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
  1172. #define FT_FACE_FLAG_HINTER ( 1L << 11 )
  1173. #define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
  1174. #define FT_FACE_FLAG_TRICKY ( 1L << 13 )
  1175. #define FT_FACE_FLAG_COLOR ( 1L << 14 )
  1176. #define FT_FACE_FLAG_VARIATION ( 1L << 15 )
  1177. #define FT_FACE_FLAG_SVG ( 1L << 16 )
  1178. #define FT_FACE_FLAG_SBIX ( 1L << 17 )
  1179. #define FT_FACE_FLAG_SBIX_OVERLAY ( 1L << 18 )
  1180. /**************************************************************************
  1181. *
  1182. * @macro:
  1183. * FT_HAS_HORIZONTAL
  1184. *
  1185. * @description:
  1186. * A macro that returns true whenever a face object contains horizontal
  1187. * metrics (this is true for all font formats though).
  1188. *
  1189. * @also:
  1190. * @FT_HAS_VERTICAL can be used to check for vertical metrics.
  1191. *
  1192. */
  1193. #define FT_HAS_HORIZONTAL( face ) \
  1194. ( !!( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) )
  1195. /**************************************************************************
  1196. *
  1197. * @macro:
  1198. * FT_HAS_VERTICAL
  1199. *
  1200. * @description:
  1201. * A macro that returns true whenever a face object contains real
  1202. * vertical metrics (and not only synthesized ones).
  1203. *
  1204. */
  1205. #define FT_HAS_VERTICAL( face ) \
  1206. ( !!( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) )
  1207. /**************************************************************************
  1208. *
  1209. * @macro:
  1210. * FT_HAS_KERNING
  1211. *
  1212. * @description:
  1213. * A macro that returns true whenever a face object contains kerning data
  1214. * that can be accessed with @FT_Get_Kerning.
  1215. *
  1216. */
  1217. #define FT_HAS_KERNING( face ) \
  1218. ( !!( (face)->face_flags & FT_FACE_FLAG_KERNING ) )
  1219. /**************************************************************************
  1220. *
  1221. * @macro:
  1222. * FT_IS_SCALABLE
  1223. *
  1224. * @description:
  1225. * A macro that returns true whenever a face object contains a scalable
  1226. * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, and
  1227. * PFR font formats).
  1228. *
  1229. */
  1230. #define FT_IS_SCALABLE( face ) \
  1231. ( !!( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) )
  1232. /**************************************************************************
  1233. *
  1234. * @macro:
  1235. * FT_IS_SFNT
  1236. *
  1237. * @description:
  1238. * A macro that returns true whenever a face object contains a font whose
  1239. * format is based on the SFNT storage scheme. This usually means:
  1240. * TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap
  1241. * fonts.
  1242. *
  1243. * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
  1244. * @FT_TRUETYPE_TABLES_H are available.
  1245. *
  1246. */
  1247. #define FT_IS_SFNT( face ) \
  1248. ( !!( (face)->face_flags & FT_FACE_FLAG_SFNT ) )
  1249. /**************************************************************************
  1250. *
  1251. * @macro:
  1252. * FT_IS_FIXED_WIDTH
  1253. *
  1254. * @description:
  1255. * A macro that returns true whenever a face object contains a font face
  1256. * that contains fixed-width (or 'monospace', 'fixed-pitch', etc.)
  1257. * glyphs.
  1258. *
  1259. */
  1260. #define FT_IS_FIXED_WIDTH( face ) \
  1261. ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) )
  1262. /**************************************************************************
  1263. *
  1264. * @macro:
  1265. * FT_HAS_FIXED_SIZES
  1266. *
  1267. * @description:
  1268. * A macro that returns true whenever a face object contains some
  1269. * embedded bitmaps. See the `available_sizes` field of the @FT_FaceRec
  1270. * structure.
  1271. *
  1272. */
  1273. #define FT_HAS_FIXED_SIZES( face ) \
  1274. ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) )
  1275. /**************************************************************************
  1276. *
  1277. * @macro:
  1278. * FT_HAS_FAST_GLYPHS
  1279. *
  1280. * @description:
  1281. * Deprecated.
  1282. *
  1283. */
  1284. #define FT_HAS_FAST_GLYPHS( face ) 0
  1285. /**************************************************************************
  1286. *
  1287. * @macro:
  1288. * FT_HAS_GLYPH_NAMES
  1289. *
  1290. * @description:
  1291. * A macro that returns true whenever a face object contains some glyph
  1292. * names that can be accessed through @FT_Get_Glyph_Name.
  1293. *
  1294. */
  1295. #define FT_HAS_GLYPH_NAMES( face ) \
  1296. ( !!( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) )
  1297. /**************************************************************************
  1298. *
  1299. * @macro:
  1300. * FT_HAS_MULTIPLE_MASTERS
  1301. *
  1302. * @description:
  1303. * A macro that returns true whenever a face object contains some
  1304. * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
  1305. * are then available to choose the exact design you want.
  1306. *
  1307. */
  1308. #define FT_HAS_MULTIPLE_MASTERS( face ) \
  1309. ( !!( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) )
  1310. /**************************************************************************
  1311. *
  1312. * @macro:
  1313. * FT_IS_NAMED_INSTANCE
  1314. *
  1315. * @description:
  1316. * A macro that returns true whenever a face object is a named instance
  1317. * of a GX or OpenType variation font.
  1318. *
  1319. * [Since 2.9] Changing the design coordinates with
  1320. * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
  1321. * not influence the return value of this macro (only
  1322. * @FT_Set_Named_Instance does that).
  1323. *
  1324. * @since:
  1325. * 2.7
  1326. *
  1327. */
  1328. #define FT_IS_NAMED_INSTANCE( face ) \
  1329. ( !!( (face)->face_index & 0x7FFF0000L ) )
  1330. /**************************************************************************
  1331. *
  1332. * @macro:
  1333. * FT_IS_VARIATION
  1334. *
  1335. * @description:
  1336. * A macro that returns true whenever a face object has been altered by
  1337. * @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or
  1338. * @FT_Set_Var_Blend_Coordinates.
  1339. *
  1340. * @since:
  1341. * 2.9
  1342. *
  1343. */
  1344. #define FT_IS_VARIATION( face ) \
  1345. ( !!( (face)->face_flags & FT_FACE_FLAG_VARIATION ) )
  1346. /**************************************************************************
  1347. *
  1348. * @macro:
  1349. * FT_IS_CID_KEYED
  1350. *
  1351. * @description:
  1352. * A macro that returns true whenever a face object contains a CID-keyed
  1353. * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more details.
  1354. *
  1355. * If this macro is true, all functions defined in @FT_CID_H are
  1356. * available.
  1357. *
  1358. */
  1359. #define FT_IS_CID_KEYED( face ) \
  1360. ( !!( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) )
  1361. /**************************************************************************
  1362. *
  1363. * @macro:
  1364. * FT_IS_TRICKY
  1365. *
  1366. * @description:
  1367. * A macro that returns true whenever a face represents a 'tricky' font.
  1368. * See the discussion of @FT_FACE_FLAG_TRICKY for more details.
  1369. *
  1370. */
  1371. #define FT_IS_TRICKY( face ) \
  1372. ( !!( (face)->face_flags & FT_FACE_FLAG_TRICKY ) )
  1373. /**************************************************************************
  1374. *
  1375. * @macro:
  1376. * FT_HAS_COLOR
  1377. *
  1378. * @description:
  1379. * A macro that returns true whenever a face object contains tables for
  1380. * color glyphs.
  1381. *
  1382. * @since:
  1383. * 2.5.1
  1384. *
  1385. */
  1386. #define FT_HAS_COLOR( face ) \
  1387. ( !!( (face)->face_flags & FT_FACE_FLAG_COLOR ) )
  1388. /**************************************************************************
  1389. *
  1390. * @macro:
  1391. * FT_HAS_SVG
  1392. *
  1393. * @description:
  1394. * A macro that returns true whenever a face object contains an 'SVG~'
  1395. * OpenType table.
  1396. *
  1397. * @since:
  1398. * 2.12
  1399. */
  1400. #define FT_HAS_SVG( face ) \
  1401. ( !!( (face)->face_flags & FT_FACE_FLAG_SVG ) )
  1402. /**************************************************************************
  1403. *
  1404. * @macro:
  1405. * FT_HAS_SBIX
  1406. *
  1407. * @description:
  1408. * A macro that returns true whenever a face object contains an 'sbix'
  1409. * OpenType table *and* outline glyphs.
  1410. *
  1411. * Currently, FreeType only supports bitmap glyphs in PNG format for this
  1412. * table (i.e., JPEG and TIFF formats are unsupported, as are
  1413. * Apple-specific formats not part of the OpenType specification).
  1414. *
  1415. * @note:
  1416. * For backward compatibility, a font with an 'sbix' table is treated as
  1417. * a bitmap-only face. Using @FT_Open_Face with
  1418. * @FT_PARAM_TAG_IGNORE_SBIX, an application can switch off 'sbix'
  1419. * handling so that the face is treated as an ordinary outline font with
  1420. * scalable outlines.
  1421. *
  1422. * Here is some pseudo code that roughly illustrates how to implement
  1423. * 'sbix' handling according to the OpenType specification.
  1424. *
  1425. * ```
  1426. * if ( FT_HAS_SBIX( face ) )
  1427. * {
  1428. * // open font as a scalable one without sbix handling
  1429. * FT_Face face2;
  1430. * FT_Parameter param = { FT_PARAM_TAG_IGNORE_SBIX, NULL };
  1431. * FT_Open_Args args = { FT_OPEN_PARAMS | ...,
  1432. * ...,
  1433. * 1, &param };
  1434. *
  1435. *
  1436. * FT_Open_Face( library, &args, 0, &face2 );
  1437. *
  1438. * <sort `face->available_size` as necessary into
  1439. * `preferred_sizes`[*]>
  1440. *
  1441. * for ( i = 0; i < face->num_fixed_sizes; i++ )
  1442. * {
  1443. * size = preferred_sizes[i].size;
  1444. *
  1445. * error = FT_Set_Pixel_Sizes( face, size, size );
  1446. * <error handling omitted>
  1447. *
  1448. * // check whether we have a glyph in a bitmap strike
  1449. * error = FT_Load_Glyph( face,
  1450. * glyph_index,
  1451. * FT_LOAD_SBITS_ONLY |
  1452. * FT_LOAD_BITMAP_METRICS_ONLY );
  1453. * if ( error == FT_Err_Invalid_Argument )
  1454. * continue;
  1455. * else if ( error )
  1456. * <other error handling omitted>
  1457. * else
  1458. * break;
  1459. * }
  1460. *
  1461. * if ( i != face->num_fixed_sizes )
  1462. * <load embedded bitmap with `FT_Load_Glyph`,
  1463. * scale it, display it, etc.>
  1464. *
  1465. * if ( i == face->num_fixed_sizes ||
  1466. * FT_HAS_SBIX_OVERLAY( face ) )
  1467. * <use `face2` to load outline glyph with `FT_Load_Glyph`,
  1468. * scale it, display it on top of the bitmap, etc.>
  1469. * }
  1470. * ```
  1471. *
  1472. * [*] Assuming a target value of 400dpi and available strike sizes 100,
  1473. * 200, 300, and 400dpi, a possible order might be [400, 200, 300, 100]:
  1474. * scaling 200dpi to 400dpi usually gives better results than scaling
  1475. * 300dpi to 400dpi; it is also much faster. However, scaling 100dpi to
  1476. * 400dpi can yield a too pixelated result, thus the preference might be
  1477. * 300dpi over 100dpi.
  1478. *
  1479. * @since:
  1480. * 2.12
  1481. */
  1482. #define FT_HAS_SBIX( face ) \
  1483. ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX ) )
  1484. /**************************************************************************
  1485. *
  1486. * @macro:
  1487. * FT_HAS_SBIX_OVERLAY
  1488. *
  1489. * @description:
  1490. * A macro that returns true whenever a face object contains an 'sbix'
  1491. * OpenType table with bit~1 in its `flags` field set, instructing the
  1492. * application to overlay the bitmap strike with the corresponding
  1493. * outline glyph. See @FT_HAS_SBIX for pseudo code how to use it.
  1494. *
  1495. * @since:
  1496. * 2.12
  1497. */
  1498. #define FT_HAS_SBIX_OVERLAY( face ) \
  1499. ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX_OVERLAY ) )
  1500. /**************************************************************************
  1501. *
  1502. * @enum:
  1503. * FT_STYLE_FLAG_XXX
  1504. *
  1505. * @description:
  1506. * A list of bit flags to indicate the style of a given face. These are
  1507. * used in the `style_flags` field of @FT_FaceRec.
  1508. *
  1509. * @values:
  1510. * FT_STYLE_FLAG_ITALIC ::
  1511. * The face style is italic or oblique.
  1512. *
  1513. * FT_STYLE_FLAG_BOLD ::
  1514. * The face is bold.
  1515. *
  1516. * @note:
  1517. * The style information as provided by FreeType is very basic. More
  1518. * details are beyond the scope and should be done on a higher level (for
  1519. * example, by analyzing various fields of the 'OS/2' table in SFNT based
  1520. * fonts).
  1521. */
  1522. #define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
  1523. #define FT_STYLE_FLAG_BOLD ( 1 << 1 )
  1524. /**************************************************************************
  1525. *
  1526. * @type:
  1527. * FT_Size_Internal
  1528. *
  1529. * @description:
  1530. * An opaque handle to an `FT_Size_InternalRec` structure, used to model
  1531. * private data of a given @FT_Size object.
  1532. */
  1533. typedef struct FT_Size_InternalRec_* FT_Size_Internal;
  1534. /**************************************************************************
  1535. *
  1536. * @struct:
  1537. * FT_Size_Metrics
  1538. *
  1539. * @description:
  1540. * The size metrics structure gives the metrics of a size object.
  1541. *
  1542. * @fields:
  1543. * x_ppem ::
  1544. * The width of the scaled EM square in pixels, hence the term 'ppem'
  1545. * (pixels per EM). It is also referred to as 'nominal width'.
  1546. *
  1547. * y_ppem ::
  1548. * The height of the scaled EM square in pixels, hence the term 'ppem'
  1549. * (pixels per EM). It is also referred to as 'nominal height'.
  1550. *
  1551. * x_scale ::
  1552. * A 16.16 fractional scaling value to convert horizontal metrics from
  1553. * font units to 26.6 fractional pixels. Only relevant for scalable
  1554. * font formats.
  1555. *
  1556. * y_scale ::
  1557. * A 16.16 fractional scaling value to convert vertical metrics from
  1558. * font units to 26.6 fractional pixels. Only relevant for scalable
  1559. * font formats.
  1560. *
  1561. * ascender ::
  1562. * The ascender in 26.6 fractional pixels, rounded up to an integer
  1563. * value. See @FT_FaceRec for the details.
  1564. *
  1565. * descender ::
  1566. * The descender in 26.6 fractional pixels, rounded down to an integer
  1567. * value. See @FT_FaceRec for the details.
  1568. *
  1569. * height ::
  1570. * The height in 26.6 fractional pixels, rounded to an integer value.
  1571. * See @FT_FaceRec for the details.
  1572. *
  1573. * max_advance ::
  1574. * The maximum advance width in 26.6 fractional pixels, rounded to an
  1575. * integer value. See @FT_FaceRec for the details.
  1576. *
  1577. * @note:
  1578. * The scaling values, if relevant, are determined first during a size
  1579. * changing operation. The remaining fields are then set by the driver.
  1580. * For scalable formats, they are usually set to scaled values of the
  1581. * corresponding fields in @FT_FaceRec. Some values like ascender or
  1582. * descender are rounded for historical reasons; more precise values (for
  1583. * outline fonts) can be derived by scaling the corresponding @FT_FaceRec
  1584. * values manually, with code similar to the following.
  1585. *
  1586. * ```
  1587. * scaled_ascender = FT_MulFix( face->ascender,
  1588. * size_metrics->y_scale );
  1589. * ```
  1590. *
  1591. * Note that due to glyph hinting and the selected rendering mode these
  1592. * values are usually not exact; consequently, they must be treated as
  1593. * unreliable with an error margin of at least one pixel!
  1594. *
  1595. * Indeed, the only way to get the exact metrics is to render _all_
  1596. * glyphs. As this would be a definite performance hit, it is up to
  1597. * client applications to perform such computations.
  1598. *
  1599. * The `FT_Size_Metrics` structure is valid for bitmap fonts also.
  1600. *
  1601. *
  1602. * **TrueType fonts with native bytecode hinting**
  1603. *
  1604. * All applications that handle TrueType fonts with native hinting must
  1605. * be aware that TTFs expect different rounding of vertical font
  1606. * dimensions. The application has to cater for this, especially if it
  1607. * wants to rely on a TTF's vertical data (for example, to properly align
  1608. * box characters vertically).
  1609. *
  1610. * Only the application knows _in advance_ that it is going to use native
  1611. * hinting for TTFs! FreeType, on the other hand, selects the hinting
  1612. * mode not at the time of creating an @FT_Size object but much later,
  1613. * namely while calling @FT_Load_Glyph.
  1614. *
  1615. * Here is some pseudo code that illustrates a possible solution.
  1616. *
  1617. * ```
  1618. * font_format = FT_Get_Font_Format( face );
  1619. *
  1620. * if ( !strcmp( font_format, "TrueType" ) &&
  1621. * do_native_bytecode_hinting )
  1622. * {
  1623. * ascender = ROUND( FT_MulFix( face->ascender,
  1624. * size_metrics->y_scale ) );
  1625. * descender = ROUND( FT_MulFix( face->descender,
  1626. * size_metrics->y_scale ) );
  1627. * }
  1628. * else
  1629. * {
  1630. * ascender = size_metrics->ascender;
  1631. * descender = size_metrics->descender;
  1632. * }
  1633. *
  1634. * height = size_metrics->height;
  1635. * max_advance = size_metrics->max_advance;
  1636. * ```
  1637. */
  1638. typedef struct FT_Size_Metrics_
  1639. {
  1640. FT_UShort x_ppem; /* horizontal pixels per EM */
  1641. FT_UShort y_ppem; /* vertical pixels per EM */
  1642. FT_Fixed x_scale; /* scaling values used to convert font */
  1643. FT_Fixed y_scale; /* units to 26.6 fractional pixels */
  1644. FT_Pos ascender; /* ascender in 26.6 frac. pixels */
  1645. FT_Pos descender; /* descender in 26.6 frac. pixels */
  1646. FT_Pos height; /* text height in 26.6 frac. pixels */
  1647. FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
  1648. } FT_Size_Metrics;
  1649. /**************************************************************************
  1650. *
  1651. * @struct:
  1652. * FT_SizeRec
  1653. *
  1654. * @description:
  1655. * FreeType root size class structure. A size object models a face
  1656. * object at a given size.
  1657. *
  1658. * @fields:
  1659. * face ::
  1660. * Handle to the parent face object.
  1661. *
  1662. * generic ::
  1663. * A typeless pointer, unused by the FreeType library or any of its
  1664. * drivers. It can be used by client applications to link their own
  1665. * data to each size object.
  1666. *
  1667. * metrics ::
  1668. * Metrics for this size object. This field is read-only.
  1669. */
  1670. typedef struct FT_SizeRec_
  1671. {
  1672. FT_Face face; /* parent face object */
  1673. FT_Generic generic; /* generic pointer for client uses */
  1674. FT_Size_Metrics metrics; /* size metrics */
  1675. FT_Size_Internal internal;
  1676. } FT_SizeRec;
  1677. /**************************************************************************
  1678. *
  1679. * @struct:
  1680. * FT_SubGlyph
  1681. *
  1682. * @description:
  1683. * The subglyph structure is an internal object used to describe
  1684. * subglyphs (for example, in the case of composites).
  1685. *
  1686. * @note:
  1687. * The subglyph implementation is not part of the high-level API, hence
  1688. * the forward structure declaration.
  1689. *
  1690. * You can however retrieve subglyph information with
  1691. * @FT_Get_SubGlyph_Info.
  1692. */
  1693. typedef struct FT_SubGlyphRec_* FT_SubGlyph;
  1694. /**************************************************************************
  1695. *
  1696. * @type:
  1697. * FT_Slot_Internal
  1698. *
  1699. * @description:
  1700. * An opaque handle to an `FT_Slot_InternalRec` structure, used to model
  1701. * private data of a given @FT_GlyphSlot object.
  1702. */
  1703. typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
  1704. /**************************************************************************
  1705. *
  1706. * @struct:
  1707. * FT_GlyphSlotRec
  1708. *
  1709. * @description:
  1710. * FreeType root glyph slot class structure. A glyph slot is a container
  1711. * where individual glyphs can be loaded, be they in outline or bitmap
  1712. * format.
  1713. *
  1714. * @fields:
  1715. * library ::
  1716. * A handle to the FreeType library instance this slot belongs to.
  1717. *
  1718. * face ::
  1719. * A handle to the parent face object.
  1720. *
  1721. * next ::
  1722. * In some cases (like some font tools), several glyph slots per face
  1723. * object can be a good thing. As this is rare, the glyph slots are
  1724. * listed through a direct, single-linked list using its `next` field.
  1725. *
  1726. * glyph_index ::
  1727. * [Since 2.10] The glyph index passed as an argument to @FT_Load_Glyph
  1728. * while initializing the glyph slot.
  1729. *
  1730. * generic ::
  1731. * A typeless pointer unused by the FreeType library or any of its
  1732. * drivers. It can be used by client applications to link their own
  1733. * data to each glyph slot object.
  1734. *
  1735. * metrics ::
  1736. * The metrics of the last loaded glyph in the slot. The returned
  1737. * values depend on the last load flags (see the @FT_Load_Glyph API
  1738. * function) and can be expressed either in 26.6 fractional pixels or
  1739. * font units.
  1740. *
  1741. * Note that even when the glyph image is transformed, the metrics are
  1742. * not.
  1743. *
  1744. * linearHoriAdvance ::
  1745. * The advance width of the unhinted glyph. Its value is expressed in
  1746. * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when
  1747. * loading the glyph. This field can be important to perform correct
  1748. * WYSIWYG layout. Only relevant for scalable glyphs.
  1749. *
  1750. * linearVertAdvance ::
  1751. * The advance height of the unhinted glyph. Its value is expressed in
  1752. * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when
  1753. * loading the glyph. This field can be important to perform correct
  1754. * WYSIWYG layout. Only relevant for scalable glyphs.
  1755. *
  1756. * advance ::
  1757. * This shorthand is, depending on @FT_LOAD_IGNORE_TRANSFORM, the
  1758. * transformed (hinted) advance width for the glyph, in 26.6 fractional
  1759. * pixel format. As specified with @FT_LOAD_VERTICAL_LAYOUT, it uses
  1760. * either the `horiAdvance` or the `vertAdvance` value of `metrics`
  1761. * field.
  1762. *
  1763. * format ::
  1764. * This field indicates the format of the image contained in the glyph
  1765. * slot. Typically @FT_GLYPH_FORMAT_BITMAP, @FT_GLYPH_FORMAT_OUTLINE,
  1766. * or @FT_GLYPH_FORMAT_COMPOSITE, but other values are possible.
  1767. *
  1768. * bitmap ::
  1769. * This field is used as a bitmap descriptor. Note that the address
  1770. * and content of the bitmap buffer can change between calls of
  1771. * @FT_Load_Glyph and a few other functions.
  1772. *
  1773. * bitmap_left ::
  1774. * The bitmap's left bearing expressed in integer pixels.
  1775. *
  1776. * bitmap_top ::
  1777. * The bitmap's top bearing expressed in integer pixels. This is the
  1778. * distance from the baseline to the top-most glyph scanline, upwards
  1779. * y~coordinates being **positive**.
  1780. *
  1781. * outline ::
  1782. * The outline descriptor for the current glyph image if its format is
  1783. * @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is loaded, `outline` can be
  1784. * transformed, distorted, emboldened, etc. However, it must not be
  1785. * freed.
  1786. *
  1787. * [Since 2.10.1] If @FT_LOAD_NO_SCALE is set, outline coordinates of
  1788. * OpenType variation fonts for a selected instance are internally
  1789. * handled as 26.6 fractional font units but returned as (rounded)
  1790. * integers, as expected. To get unrounded font units, don't use
  1791. * @FT_LOAD_NO_SCALE but load the glyph with @FT_LOAD_NO_HINTING and
  1792. * scale it, using the font's `units_per_EM` value as the ppem.
  1793. *
  1794. * num_subglyphs ::
  1795. * The number of subglyphs in a composite glyph. This field is only
  1796. * valid for the composite glyph format that should normally only be
  1797. * loaded with the @FT_LOAD_NO_RECURSE flag.
  1798. *
  1799. * subglyphs ::
  1800. * An array of subglyph descriptors for composite glyphs. There are
  1801. * `num_subglyphs` elements in there. Currently internal to FreeType.
  1802. *
  1803. * control_data ::
  1804. * Certain font drivers can also return the control data for a given
  1805. * glyph image (e.g. TrueType bytecode, Type~1 charstrings, etc.).
  1806. * This field is a pointer to such data; it is currently internal to
  1807. * FreeType.
  1808. *
  1809. * control_len ::
  1810. * This is the length in bytes of the control data. Currently internal
  1811. * to FreeType.
  1812. *
  1813. * other ::
  1814. * Reserved.
  1815. *
  1816. * lsb_delta ::
  1817. * The difference between hinted and unhinted left side bearing while
  1818. * auto-hinting is active. Zero otherwise.
  1819. *
  1820. * rsb_delta ::
  1821. * The difference between hinted and unhinted right side bearing while
  1822. * auto-hinting is active. Zero otherwise.
  1823. *
  1824. * @note:
  1825. * If @FT_Load_Glyph is called with default flags (see @FT_LOAD_DEFAULT)
  1826. * the glyph image is loaded in the glyph slot in its native format
  1827. * (e.g., an outline glyph for TrueType and Type~1 formats). [Since 2.9]
  1828. * The prospective bitmap metrics are calculated according to
  1829. * @FT_LOAD_TARGET_XXX and other flags even for the outline glyph, even
  1830. * if @FT_LOAD_RENDER is not set.
  1831. *
  1832. * This image can later be converted into a bitmap by calling
  1833. * @FT_Render_Glyph. This function searches the current renderer for the
  1834. * native image's format, then invokes it.
  1835. *
  1836. * The renderer is in charge of transforming the native image through the
  1837. * slot's face transformation fields, then converting it into a bitmap
  1838. * that is returned in `slot->bitmap`.
  1839. *
  1840. * Note that `slot->bitmap_left` and `slot->bitmap_top` are also used to
  1841. * specify the position of the bitmap relative to the current pen
  1842. * position (e.g., coordinates (0,0) on the baseline). Of course,
  1843. * `slot->format` is also changed to @FT_GLYPH_FORMAT_BITMAP.
  1844. *
  1845. * Here is a small pseudo code fragment that shows how to use `lsb_delta`
  1846. * and `rsb_delta` to do fractional positioning of glyphs:
  1847. *
  1848. * ```
  1849. * FT_GlyphSlot slot = face->glyph;
  1850. * FT_Pos origin_x = 0;
  1851. *
  1852. *
  1853. * for all glyphs do
  1854. * <load glyph with `FT_Load_Glyph'>
  1855. *
  1856. * FT_Outline_Translate( slot->outline, origin_x & 63, 0 );
  1857. *
  1858. * <save glyph image, or render glyph, or ...>
  1859. *
  1860. * <compute kern between current and next glyph
  1861. * and add it to `origin_x'>
  1862. *
  1863. * origin_x += slot->advance.x;
  1864. * origin_x += slot->lsb_delta - slot->rsb_delta;
  1865. * endfor
  1866. * ```
  1867. *
  1868. * Here is another small pseudo code fragment that shows how to use
  1869. * `lsb_delta` and `rsb_delta` to improve integer positioning of glyphs:
  1870. *
  1871. * ```
  1872. * FT_GlyphSlot slot = face->glyph;
  1873. * FT_Pos origin_x = 0;
  1874. * FT_Pos prev_rsb_delta = 0;
  1875. *
  1876. *
  1877. * for all glyphs do
  1878. * <compute kern between current and previous glyph
  1879. * and add it to `origin_x'>
  1880. *
  1881. * <load glyph with `FT_Load_Glyph'>
  1882. *
  1883. * if ( prev_rsb_delta - slot->lsb_delta > 32 )
  1884. * origin_x -= 64;
  1885. * else if ( prev_rsb_delta - slot->lsb_delta < -31 )
  1886. * origin_x += 64;
  1887. *
  1888. * prev_rsb_delta = slot->rsb_delta;
  1889. *
  1890. * <save glyph image, or render glyph, or ...>
  1891. *
  1892. * origin_x += slot->advance.x;
  1893. * endfor
  1894. * ```
  1895. *
  1896. * If you use strong auto-hinting, you **must** apply these delta values!
  1897. * Otherwise you will experience far too large inter-glyph spacing at
  1898. * small rendering sizes in most cases. Note that it doesn't harm to use
  1899. * the above code for other hinting modes also, since the delta values
  1900. * are zero then.
  1901. */
  1902. typedef struct FT_GlyphSlotRec_
  1903. {
  1904. FT_Library library;
  1905. FT_Face face;
  1906. FT_GlyphSlot next;
  1907. FT_UInt glyph_index; /* new in 2.10; was reserved previously */
  1908. FT_Generic generic;
  1909. FT_Glyph_Metrics metrics;
  1910. FT_Fixed linearHoriAdvance;
  1911. FT_Fixed linearVertAdvance;
  1912. FT_Vector advance;
  1913. FT_Glyph_Format format;
  1914. FT_Bitmap bitmap;
  1915. FT_Int bitmap_left;
  1916. FT_Int bitmap_top;
  1917. FT_Outline outline;
  1918. FT_UInt num_subglyphs;
  1919. FT_SubGlyph subglyphs;
  1920. void* control_data;
  1921. long control_len;
  1922. FT_Pos lsb_delta;
  1923. FT_Pos rsb_delta;
  1924. void* other;
  1925. FT_Slot_Internal internal;
  1926. } FT_GlyphSlotRec;
  1927. /*************************************************************************/
  1928. /*************************************************************************/
  1929. /* */
  1930. /* F U N C T I O N S */
  1931. /* */
  1932. /*************************************************************************/
  1933. /*************************************************************************/
  1934. /**************************************************************************
  1935. *
  1936. * @function:
  1937. * FT_Init_FreeType
  1938. *
  1939. * @description:
  1940. * Initialize a new FreeType library object. The set of modules that are
  1941. * registered by this function is determined at build time.
  1942. *
  1943. * @output:
  1944. * alibrary ::
  1945. * A handle to a new library object.
  1946. *
  1947. * @return:
  1948. * FreeType error code. 0~means success.
  1949. *
  1950. * @note:
  1951. * In case you want to provide your own memory allocating routines, use
  1952. * @FT_New_Library instead, followed by a call to @FT_Add_Default_Modules
  1953. * (or a series of calls to @FT_Add_Module) and
  1954. * @FT_Set_Default_Properties.
  1955. *
  1956. * See the documentation of @FT_Library and @FT_Face for multi-threading
  1957. * issues.
  1958. *
  1959. * If you need reference-counting (cf. @FT_Reference_Library), use
  1960. * @FT_New_Library and @FT_Done_Library.
  1961. *
  1962. * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is
  1963. * set, this function reads the `FREETYPE_PROPERTIES` environment
  1964. * variable to control driver properties. See section @properties for
  1965. * more.
  1966. */
  1967. FT_EXPORT( FT_Error )
  1968. FT_Init_FreeType( FT_Library *alibrary );
  1969. /**************************************************************************
  1970. *
  1971. * @function:
  1972. * FT_Done_FreeType
  1973. *
  1974. * @description:
  1975. * Destroy a given FreeType library object and all of its children,
  1976. * including resources, drivers, faces, sizes, etc.
  1977. *
  1978. * @input:
  1979. * library ::
  1980. * A handle to the target library object.
  1981. *
  1982. * @return:
  1983. * FreeType error code. 0~means success.
  1984. */
  1985. FT_EXPORT( FT_Error )
  1986. FT_Done_FreeType( FT_Library library );
  1987. /**************************************************************************
  1988. *
  1989. * @enum:
  1990. * FT_OPEN_XXX
  1991. *
  1992. * @description:
  1993. * A list of bit field constants used within the `flags` field of the
  1994. * @FT_Open_Args structure.
  1995. *
  1996. * @values:
  1997. * FT_OPEN_MEMORY ::
  1998. * This is a memory-based stream.
  1999. *
  2000. * FT_OPEN_STREAM ::
  2001. * Copy the stream from the `stream` field.
  2002. *
  2003. * FT_OPEN_PATHNAME ::
  2004. * Create a new input stream from a C~path name.
  2005. *
  2006. * FT_OPEN_DRIVER ::
  2007. * Use the `driver` field.
  2008. *
  2009. * FT_OPEN_PARAMS ::
  2010. * Use the `num_params` and `params` fields.
  2011. *
  2012. * @note:
  2013. * The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags
  2014. * are mutually exclusive.
  2015. */
  2016. #define FT_OPEN_MEMORY 0x1
  2017. #define FT_OPEN_STREAM 0x2
  2018. #define FT_OPEN_PATHNAME 0x4
  2019. #define FT_OPEN_DRIVER 0x8
  2020. #define FT_OPEN_PARAMS 0x10
  2021. /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */
  2022. /* values instead */
  2023. #define ft_open_memory FT_OPEN_MEMORY
  2024. #define ft_open_stream FT_OPEN_STREAM
  2025. #define ft_open_pathname FT_OPEN_PATHNAME
  2026. #define ft_open_driver FT_OPEN_DRIVER
  2027. #define ft_open_params FT_OPEN_PARAMS
  2028. /**************************************************************************
  2029. *
  2030. * @struct:
  2031. * FT_Parameter
  2032. *
  2033. * @description:
  2034. * A simple structure to pass more or less generic parameters to
  2035. * @FT_Open_Face and @FT_Face_Properties.
  2036. *
  2037. * @fields:
  2038. * tag ::
  2039. * A four-byte identification tag.
  2040. *
  2041. * data ::
  2042. * A pointer to the parameter data.
  2043. *
  2044. * @note:
  2045. * The ID and function of parameters are driver-specific. See section
  2046. * @parameter_tags for more information.
  2047. */
  2048. typedef struct FT_Parameter_
  2049. {
  2050. FT_ULong tag;
  2051. FT_Pointer data;
  2052. } FT_Parameter;
  2053. /**************************************************************************
  2054. *
  2055. * @struct:
  2056. * FT_Open_Args
  2057. *
  2058. * @description:
  2059. * A structure to indicate how to open a new font file or stream. A
  2060. * pointer to such a structure can be used as a parameter for the
  2061. * functions @FT_Open_Face and @FT_Attach_Stream.
  2062. *
  2063. * @fields:
  2064. * flags ::
  2065. * A set of bit flags indicating how to use the structure.
  2066. *
  2067. * memory_base ::
  2068. * The first byte of the file in memory.
  2069. *
  2070. * memory_size ::
  2071. * The size in bytes of the file in memory.
  2072. *
  2073. * pathname ::
  2074. * A pointer to an 8-bit file pathname, which must be a C~string (i.e.,
  2075. * no null bytes except at the very end). The pointer is not owned by
  2076. * FreeType.
  2077. *
  2078. * stream ::
  2079. * A handle to a source stream object.
  2080. *
  2081. * driver ::
  2082. * This field is exclusively used by @FT_Open_Face; it simply specifies
  2083. * the font driver to use for opening the face. If set to `NULL`,
  2084. * FreeType tries to load the face with each one of the drivers in its
  2085. * list.
  2086. *
  2087. * num_params ::
  2088. * The number of extra parameters.
  2089. *
  2090. * params ::
  2091. * Extra parameters passed to the font driver when opening a new face.
  2092. *
  2093. * @note:
  2094. * The stream type is determined by the contents of `flags`:
  2095. *
  2096. * If the @FT_OPEN_MEMORY bit is set, assume that this is a memory file
  2097. * of `memory_size` bytes, located at `memory_address`. The data are not
  2098. * copied, and the client is responsible for releasing and destroying
  2099. * them _after_ the corresponding call to @FT_Done_Face.
  2100. *
  2101. * Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a custom
  2102. * input stream `stream` is used.
  2103. *
  2104. * Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this is a
  2105. * normal file and use `pathname` to open it.
  2106. *
  2107. * If none of the above bits are set or if multiple are set at the same
  2108. * time, the flags are invalid and @FT_Open_Face fails.
  2109. *
  2110. * If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to open
  2111. * the file with the driver whose handler is in `driver`.
  2112. *
  2113. * If the @FT_OPEN_PARAMS bit is set, the parameters given by
  2114. * `num_params` and `params` is used. They are ignored otherwise.
  2115. *
  2116. * Ideally, both the `pathname` and `params` fields should be tagged as
  2117. * 'const'; this is missing for API backward compatibility. In other
  2118. * words, applications should treat them as read-only.
  2119. */
  2120. typedef struct FT_Open_Args_
  2121. {
  2122. FT_UInt flags;
  2123. const FT_Byte* memory_base;
  2124. FT_Long memory_size;
  2125. FT_String* pathname;
  2126. FT_Stream stream;
  2127. FT_Module driver;
  2128. FT_Int num_params;
  2129. FT_Parameter* params;
  2130. } FT_Open_Args;
  2131. /**************************************************************************
  2132. *
  2133. * @function:
  2134. * FT_New_Face
  2135. *
  2136. * @description:
  2137. * Call @FT_Open_Face to open a font by its pathname.
  2138. *
  2139. * @inout:
  2140. * library ::
  2141. * A handle to the library resource.
  2142. *
  2143. * @input:
  2144. * pathname ::
  2145. * A path to the font file.
  2146. *
  2147. * face_index ::
  2148. * See @FT_Open_Face for a detailed description of this parameter.
  2149. *
  2150. * @output:
  2151. * aface ::
  2152. * A handle to a new face object. If `face_index` is greater than or
  2153. * equal to zero, it must be non-`NULL`.
  2154. *
  2155. * @return:
  2156. * FreeType error code. 0~means success.
  2157. *
  2158. * @note:
  2159. * The `pathname` string should be recognizable as such by a standard
  2160. * `fopen` call on your system; in particular, this means that `pathname`
  2161. * must not contain null bytes. If that is not sufficient to address all
  2162. * file name possibilities (for example, to handle wide character file
  2163. * names on Windows in UTF-16 encoding) you might use @FT_Open_Face to
  2164. * pass a memory array or a stream object instead.
  2165. *
  2166. * Use @FT_Done_Face to destroy the created @FT_Face object (along with
  2167. * its slot and sizes).
  2168. */
  2169. FT_EXPORT( FT_Error )
  2170. FT_New_Face( FT_Library library,
  2171. const char* filepathname,
  2172. FT_Long face_index,
  2173. FT_Face *aface );
  2174. /**************************************************************************
  2175. *
  2176. * @function:
  2177. * FT_New_Memory_Face
  2178. *
  2179. * @description:
  2180. * Call @FT_Open_Face to open a font that has been loaded into memory.
  2181. *
  2182. * @inout:
  2183. * library ::
  2184. * A handle to the library resource.
  2185. *
  2186. * @input:
  2187. * file_base ::
  2188. * A pointer to the beginning of the font data.
  2189. *
  2190. * file_size ::
  2191. * The size of the memory chunk used by the font data.
  2192. *
  2193. * face_index ::
  2194. * See @FT_Open_Face for a detailed description of this parameter.
  2195. *
  2196. * @output:
  2197. * aface ::
  2198. * A handle to a new face object. If `face_index` is greater than or
  2199. * equal to zero, it must be non-`NULL`.
  2200. *
  2201. * @return:
  2202. * FreeType error code. 0~means success.
  2203. *
  2204. * @note:
  2205. * You must not deallocate the memory before calling @FT_Done_Face.
  2206. */
  2207. FT_EXPORT( FT_Error )
  2208. FT_New_Memory_Face( FT_Library library,
  2209. const FT_Byte* file_base,
  2210. FT_Long file_size,
  2211. FT_Long face_index,
  2212. FT_Face *aface );
  2213. /**************************************************************************
  2214. *
  2215. * @function:
  2216. * FT_Open_Face
  2217. *
  2218. * @description:
  2219. * Create a face object from a given resource described by @FT_Open_Args.
  2220. *
  2221. * @inout:
  2222. * library ::
  2223. * A handle to the library resource.
  2224. *
  2225. * @input:
  2226. * args ::
  2227. * A pointer to an `FT_Open_Args` structure that must be filled by the
  2228. * caller.
  2229. *
  2230. * face_index ::
  2231. * This field holds two different values. Bits 0-15 are the index of
  2232. * the face in the font file (starting with value~0). Set it to~0 if
  2233. * there is only one face in the font file.
  2234. *
  2235. * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation
  2236. * fonts only, specifying the named instance index for the current face
  2237. * index (starting with value~1; value~0 makes FreeType ignore named
  2238. * instances). For non-variation fonts, bits 16-30 are ignored.
  2239. * Assuming that you want to access the third named instance in face~4,
  2240. * `face_index` should be set to 0x00030004. If you want to access
  2241. * face~4 without variation handling, simply set `face_index` to
  2242. * value~4.
  2243. *
  2244. * `FT_Open_Face` and its siblings can be used to quickly check whether
  2245. * the font format of a given font resource is supported by FreeType.
  2246. * In general, if the `face_index` argument is negative, the function's
  2247. * return value is~0 if the font format is recognized, or non-zero
  2248. * otherwise. The function allocates a more or less empty face handle
  2249. * in `*aface` (if `aface` isn't `NULL`); the only two useful fields in
  2250. * this special case are `face->num_faces` and `face->style_flags`.
  2251. * For any negative value of `face_index`, `face->num_faces` gives the
  2252. * number of faces within the font file. For the negative value
  2253. * '-(N+1)' (with 'N' a non-negative 16-bit value), bits 16-30 in
  2254. * `face->style_flags` give the number of named instances in face 'N'
  2255. * if we have a variation font (or zero otherwise). After examination,
  2256. * the returned @FT_Face structure should be deallocated with a call to
  2257. * @FT_Done_Face.
  2258. *
  2259. * @output:
  2260. * aface ::
  2261. * A handle to a new face object. If `face_index` is greater than or
  2262. * equal to zero, it must be non-`NULL`.
  2263. *
  2264. * @return:
  2265. * FreeType error code. 0~means success.
  2266. *
  2267. * @note:
  2268. * Unlike FreeType 1.x, this function automatically creates a glyph slot
  2269. * for the face object that can be accessed directly through
  2270. * `face->glyph`.
  2271. *
  2272. * Each new face object created with this function also owns a default
  2273. * @FT_Size object, accessible as `face->size`.
  2274. *
  2275. * One @FT_Library instance can have multiple face objects, this is,
  2276. * @FT_Open_Face and its siblings can be called multiple times using the
  2277. * same `library` argument.
  2278. *
  2279. * See the discussion of reference counters in the description of
  2280. * @FT_Reference_Face.
  2281. *
  2282. * If `FT_OPEN_STREAM` is set in `args->flags`, the stream in
  2283. * `args->stream` is automatically closed before this function returns
  2284. * any error (including `FT_Err_Invalid_Argument`).
  2285. *
  2286. * @example:
  2287. * To loop over all faces, use code similar to the following snippet
  2288. * (omitting the error handling).
  2289. *
  2290. * ```
  2291. * ...
  2292. * FT_Face face;
  2293. * FT_Long i, num_faces;
  2294. *
  2295. *
  2296. * error = FT_Open_Face( library, args, -1, &face );
  2297. * if ( error ) { ... }
  2298. *
  2299. * num_faces = face->num_faces;
  2300. * FT_Done_Face( face );
  2301. *
  2302. * for ( i = 0; i < num_faces; i++ )
  2303. * {
  2304. * ...
  2305. * error = FT_Open_Face( library, args, i, &face );
  2306. * ...
  2307. * FT_Done_Face( face );
  2308. * ...
  2309. * }
  2310. * ```
  2311. *
  2312. * To loop over all valid values for `face_index`, use something similar
  2313. * to the following snippet, again without error handling. The code
  2314. * accesses all faces immediately (thus only a single call of
  2315. * `FT_Open_Face` within the do-loop), with and without named instances.
  2316. *
  2317. * ```
  2318. * ...
  2319. * FT_Face face;
  2320. *
  2321. * FT_Long num_faces = 0;
  2322. * FT_Long num_instances = 0;
  2323. *
  2324. * FT_Long face_idx = 0;
  2325. * FT_Long instance_idx = 0;
  2326. *
  2327. *
  2328. * do
  2329. * {
  2330. * FT_Long id = ( instance_idx << 16 ) + face_idx;
  2331. *
  2332. *
  2333. * error = FT_Open_Face( library, args, id, &face );
  2334. * if ( error ) { ... }
  2335. *
  2336. * num_faces = face->num_faces;
  2337. * num_instances = face->style_flags >> 16;
  2338. *
  2339. * ...
  2340. *
  2341. * FT_Done_Face( face );
  2342. *
  2343. * if ( instance_idx < num_instances )
  2344. * instance_idx++;
  2345. * else
  2346. * {
  2347. * face_idx++;
  2348. * instance_idx = 0;
  2349. * }
  2350. *
  2351. * } while ( face_idx < num_faces )
  2352. * ```
  2353. */
  2354. FT_EXPORT( FT_Error )
  2355. FT_Open_Face( FT_Library library,
  2356. const FT_Open_Args* args,
  2357. FT_Long face_index,
  2358. FT_Face *aface );
  2359. /**************************************************************************
  2360. *
  2361. * @function:
  2362. * FT_Attach_File
  2363. *
  2364. * @description:
  2365. * Call @FT_Attach_Stream to attach a file.
  2366. *
  2367. * @inout:
  2368. * face ::
  2369. * The target face object.
  2370. *
  2371. * @input:
  2372. * filepathname ::
  2373. * The pathname.
  2374. *
  2375. * @return:
  2376. * FreeType error code. 0~means success.
  2377. */
  2378. FT_EXPORT( FT_Error )
  2379. FT_Attach_File( FT_Face face,
  2380. const char* filepathname );
  2381. /**************************************************************************
  2382. *
  2383. * @function:
  2384. * FT_Attach_Stream
  2385. *
  2386. * @description:
  2387. * 'Attach' data to a face object. Normally, this is used to read
  2388. * additional information for the face object. For example, you can
  2389. * attach an AFM file that comes with a Type~1 font to get the kerning
  2390. * values and other metrics.
  2391. *
  2392. * @inout:
  2393. * face ::
  2394. * The target face object.
  2395. *
  2396. * @input:
  2397. * parameters ::
  2398. * A pointer to @FT_Open_Args that must be filled by the caller.
  2399. *
  2400. * @return:
  2401. * FreeType error code. 0~means success.
  2402. *
  2403. * @note:
  2404. * The meaning of the 'attach' (i.e., what really happens when the new
  2405. * file is read) is not fixed by FreeType itself. It really depends on
  2406. * the font format (and thus the font driver).
  2407. *
  2408. * Client applications are expected to know what they are doing when
  2409. * invoking this function. Most drivers simply do not implement file or
  2410. * stream attachments.
  2411. */
  2412. FT_EXPORT( FT_Error )
  2413. FT_Attach_Stream( FT_Face face,
  2414. const FT_Open_Args* parameters );
  2415. /**************************************************************************
  2416. *
  2417. * @function:
  2418. * FT_Reference_Face
  2419. *
  2420. * @description:
  2421. * A counter gets initialized to~1 at the time an @FT_Face structure is
  2422. * created. This function increments the counter. @FT_Done_Face then
  2423. * only destroys a face if the counter is~1, otherwise it simply
  2424. * decrements the counter.
  2425. *
  2426. * This function helps in managing life-cycles of structures that
  2427. * reference @FT_Face objects.
  2428. *
  2429. * @input:
  2430. * face ::
  2431. * A handle to a target face object.
  2432. *
  2433. * @return:
  2434. * FreeType error code. 0~means success.
  2435. *
  2436. * @since:
  2437. * 2.4.2
  2438. *
  2439. */
  2440. FT_EXPORT( FT_Error )
  2441. FT_Reference_Face( FT_Face face );
  2442. /**************************************************************************
  2443. *
  2444. * @function:
  2445. * FT_Done_Face
  2446. *
  2447. * @description:
  2448. * Discard a given face object, as well as all of its child slots and
  2449. * sizes.
  2450. *
  2451. * @input:
  2452. * face ::
  2453. * A handle to a target face object.
  2454. *
  2455. * @return:
  2456. * FreeType error code. 0~means success.
  2457. *
  2458. * @note:
  2459. * See the discussion of reference counters in the description of
  2460. * @FT_Reference_Face.
  2461. */
  2462. FT_EXPORT( FT_Error )
  2463. FT_Done_Face( FT_Face face );
  2464. /**************************************************************************
  2465. *
  2466. * @function:
  2467. * FT_Select_Size
  2468. *
  2469. * @description:
  2470. * Select a bitmap strike. To be more precise, this function sets the
  2471. * scaling factors of the active @FT_Size object in a face so that
  2472. * bitmaps from this particular strike are taken by @FT_Load_Glyph and
  2473. * friends.
  2474. *
  2475. * @inout:
  2476. * face ::
  2477. * A handle to a target face object.
  2478. *
  2479. * @input:
  2480. * strike_index ::
  2481. * The index of the bitmap strike in the `available_sizes` field of
  2482. * @FT_FaceRec structure.
  2483. *
  2484. * @return:
  2485. * FreeType error code. 0~means success.
  2486. *
  2487. * @note:
  2488. * For bitmaps embedded in outline fonts it is common that only a subset
  2489. * of the available glyphs at a given ppem value is available. FreeType
  2490. * silently uses outlines if there is no bitmap for a given glyph index.
  2491. *
  2492. * For GX and OpenType variation fonts, a bitmap strike makes sense only
  2493. * if the default instance is active (this is, no glyph variation takes
  2494. * place); otherwise, FreeType simply ignores bitmap strikes. The same
  2495. * is true for all named instances that are different from the default
  2496. * instance.
  2497. *
  2498. * Don't use this function if you are using the FreeType cache API.
  2499. */
  2500. FT_EXPORT( FT_Error )
  2501. FT_Select_Size( FT_Face face,
  2502. FT_Int strike_index );
  2503. /**************************************************************************
  2504. *
  2505. * @enum:
  2506. * FT_Size_Request_Type
  2507. *
  2508. * @description:
  2509. * An enumeration type that lists the supported size request types, i.e.,
  2510. * what input size (in font units) maps to the requested output size (in
  2511. * pixels, as computed from the arguments of @FT_Size_Request).
  2512. *
  2513. * @values:
  2514. * FT_SIZE_REQUEST_TYPE_NOMINAL ::
  2515. * The nominal size. The `units_per_EM` field of @FT_FaceRec is used
  2516. * to determine both scaling values.
  2517. *
  2518. * This is the standard scaling found in most applications. In
  2519. * particular, use this size request type for TrueType fonts if they
  2520. * provide optical scaling or something similar. Note, however, that
  2521. * `units_per_EM` is a rather abstract value which bears no relation to
  2522. * the actual size of the glyphs in a font.
  2523. *
  2524. * FT_SIZE_REQUEST_TYPE_REAL_DIM ::
  2525. * The real dimension. The sum of the `ascender` and (minus of) the
  2526. * `descender` fields of @FT_FaceRec is used to determine both scaling
  2527. * values.
  2528. *
  2529. * FT_SIZE_REQUEST_TYPE_BBOX ::
  2530. * The font bounding box. The width and height of the `bbox` field of
  2531. * @FT_FaceRec are used to determine the horizontal and vertical
  2532. * scaling value, respectively.
  2533. *
  2534. * FT_SIZE_REQUEST_TYPE_CELL ::
  2535. * The `max_advance_width` field of @FT_FaceRec is used to determine
  2536. * the horizontal scaling value; the vertical scaling value is
  2537. * determined the same way as @FT_SIZE_REQUEST_TYPE_REAL_DIM does.
  2538. * Finally, both scaling values are set to the smaller one. This type
  2539. * is useful if you want to specify the font size for, say, a window of
  2540. * a given dimension and 80x24 cells.
  2541. *
  2542. * FT_SIZE_REQUEST_TYPE_SCALES ::
  2543. * Specify the scaling values directly.
  2544. *
  2545. * @note:
  2546. * The above descriptions only apply to scalable formats. For bitmap
  2547. * formats, the behaviour is up to the driver.
  2548. *
  2549. * See the note section of @FT_Size_Metrics if you wonder how size
  2550. * requesting relates to scaling values.
  2551. */
  2552. typedef enum FT_Size_Request_Type_
  2553. {
  2554. FT_SIZE_REQUEST_TYPE_NOMINAL,
  2555. FT_SIZE_REQUEST_TYPE_REAL_DIM,
  2556. FT_SIZE_REQUEST_TYPE_BBOX,
  2557. FT_SIZE_REQUEST_TYPE_CELL,
  2558. FT_SIZE_REQUEST_TYPE_SCALES,
  2559. FT_SIZE_REQUEST_TYPE_MAX
  2560. } FT_Size_Request_Type;
  2561. /**************************************************************************
  2562. *
  2563. * @struct:
  2564. * FT_Size_RequestRec
  2565. *
  2566. * @description:
  2567. * A structure to model a size request.
  2568. *
  2569. * @fields:
  2570. * type ::
  2571. * See @FT_Size_Request_Type.
  2572. *
  2573. * width ::
  2574. * The desired width, given as a 26.6 fractional point value (with 72pt
  2575. * = 1in).
  2576. *
  2577. * height ::
  2578. * The desired height, given as a 26.6 fractional point value (with
  2579. * 72pt = 1in).
  2580. *
  2581. * horiResolution ::
  2582. * The horizontal resolution (dpi, i.e., pixels per inch). If set to
  2583. * zero, `width` is treated as a 26.6 fractional **pixel** value, which
  2584. * gets internally rounded to an integer.
  2585. *
  2586. * vertResolution ::
  2587. * The vertical resolution (dpi, i.e., pixels per inch). If set to
  2588. * zero, `height` is treated as a 26.6 fractional **pixel** value,
  2589. * which gets internally rounded to an integer.
  2590. *
  2591. * @note:
  2592. * If `width` is zero, the horizontal scaling value is set equal to the
  2593. * vertical scaling value, and vice versa.
  2594. *
  2595. * If `type` is `FT_SIZE_REQUEST_TYPE_SCALES`, `width` and `height` are
  2596. * interpreted directly as 16.16 fractional scaling values, without any
  2597. * further modification, and both `horiResolution` and `vertResolution`
  2598. * are ignored.
  2599. */
  2600. typedef struct FT_Size_RequestRec_
  2601. {
  2602. FT_Size_Request_Type type;
  2603. FT_Long width;
  2604. FT_Long height;
  2605. FT_UInt horiResolution;
  2606. FT_UInt vertResolution;
  2607. } FT_Size_RequestRec;
  2608. /**************************************************************************
  2609. *
  2610. * @struct:
  2611. * FT_Size_Request
  2612. *
  2613. * @description:
  2614. * A handle to a size request structure.
  2615. */
  2616. typedef struct FT_Size_RequestRec_ *FT_Size_Request;
  2617. /**************************************************************************
  2618. *
  2619. * @function:
  2620. * FT_Request_Size
  2621. *
  2622. * @description:
  2623. * Resize the scale of the active @FT_Size object in a face.
  2624. *
  2625. * @inout:
  2626. * face ::
  2627. * A handle to a target face object.
  2628. *
  2629. * @input:
  2630. * req ::
  2631. * A pointer to a @FT_Size_RequestRec.
  2632. *
  2633. * @return:
  2634. * FreeType error code. 0~means success.
  2635. *
  2636. * @note:
  2637. * Although drivers may select the bitmap strike matching the request,
  2638. * you should not rely on this if you intend to select a particular
  2639. * bitmap strike. Use @FT_Select_Size instead in that case.
  2640. *
  2641. * The relation between the requested size and the resulting glyph size
  2642. * is dependent entirely on how the size is defined in the source face.
  2643. * The font designer chooses the final size of each glyph relative to
  2644. * this size. For more information refer to
  2645. * 'https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'.
  2646. *
  2647. * Contrary to @FT_Set_Char_Size, this function doesn't have special code
  2648. * to normalize zero-valued widths, heights, or resolutions, which are
  2649. * treated as @FT_LOAD_NO_SCALE.
  2650. *
  2651. * Don't use this function if you are using the FreeType cache API.
  2652. */
  2653. FT_EXPORT( FT_Error )
  2654. FT_Request_Size( FT_Face face,
  2655. FT_Size_Request req );
  2656. /**************************************************************************
  2657. *
  2658. * @function:
  2659. * FT_Set_Char_Size
  2660. *
  2661. * @description:
  2662. * Call @FT_Request_Size to request the nominal size (in points).
  2663. *
  2664. * @inout:
  2665. * face ::
  2666. * A handle to a target face object.
  2667. *
  2668. * @input:
  2669. * char_width ::
  2670. * The nominal width, in 26.6 fractional points.
  2671. *
  2672. * char_height ::
  2673. * The nominal height, in 26.6 fractional points.
  2674. *
  2675. * horz_resolution ::
  2676. * The horizontal resolution in dpi.
  2677. *
  2678. * vert_resolution ::
  2679. * The vertical resolution in dpi.
  2680. *
  2681. * @return:
  2682. * FreeType error code. 0~means success.
  2683. *
  2684. * @note:
  2685. * While this function allows fractional points as input values, the
  2686. * resulting ppem value for the given resolution is always rounded to the
  2687. * nearest integer.
  2688. *
  2689. * If either the character width or height is zero, it is set equal to
  2690. * the other value.
  2691. *
  2692. * If either the horizontal or vertical resolution is zero, it is set
  2693. * equal to the other value.
  2694. *
  2695. * A character width or height smaller than 1pt is set to 1pt; if both
  2696. * resolution values are zero, they are set to 72dpi.
  2697. *
  2698. * Don't use this function if you are using the FreeType cache API.
  2699. */
  2700. FT_EXPORT( FT_Error )
  2701. FT_Set_Char_Size( FT_Face face,
  2702. FT_F26Dot6 char_width,
  2703. FT_F26Dot6 char_height,
  2704. FT_UInt horz_resolution,
  2705. FT_UInt vert_resolution );
  2706. /**************************************************************************
  2707. *
  2708. * @function:
  2709. * FT_Set_Pixel_Sizes
  2710. *
  2711. * @description:
  2712. * Call @FT_Request_Size to request the nominal size (in pixels).
  2713. *
  2714. * @inout:
  2715. * face ::
  2716. * A handle to the target face object.
  2717. *
  2718. * @input:
  2719. * pixel_width ::
  2720. * The nominal width, in pixels.
  2721. *
  2722. * pixel_height ::
  2723. * The nominal height, in pixels.
  2724. *
  2725. * @return:
  2726. * FreeType error code. 0~means success.
  2727. *
  2728. * @note:
  2729. * You should not rely on the resulting glyphs matching or being
  2730. * constrained to this pixel size. Refer to @FT_Request_Size to
  2731. * understand how requested sizes relate to actual sizes.
  2732. *
  2733. * Don't use this function if you are using the FreeType cache API.
  2734. */
  2735. FT_EXPORT( FT_Error )
  2736. FT_Set_Pixel_Sizes( FT_Face face,
  2737. FT_UInt pixel_width,
  2738. FT_UInt pixel_height );
  2739. /**************************************************************************
  2740. *
  2741. * @function:
  2742. * FT_Load_Glyph
  2743. *
  2744. * @description:
  2745. * Load a glyph into the glyph slot of a face object.
  2746. *
  2747. * @inout:
  2748. * face ::
  2749. * A handle to the target face object where the glyph is loaded.
  2750. *
  2751. * @input:
  2752. * glyph_index ::
  2753. * The index of the glyph in the font file. For CID-keyed fonts
  2754. * (either in PS or in CFF format) this argument specifies the CID
  2755. * value.
  2756. *
  2757. * load_flags ::
  2758. * A flag indicating what to load for this glyph. The @FT_LOAD_XXX
  2759. * flags can be used to control the glyph loading process (e.g.,
  2760. * whether the outline should be scaled, whether to load bitmaps or
  2761. * not, whether to hint the outline, etc).
  2762. *
  2763. * @return:
  2764. * FreeType error code. 0~means success.
  2765. *
  2766. * @note:
  2767. * For proper scaling and hinting, the active @FT_Size object owned by
  2768. * the face has to be meaningfully initialized by calling
  2769. * @FT_Set_Char_Size before this function, for example. The loaded
  2770. * glyph may be transformed. See @FT_Set_Transform for the details.
  2771. *
  2772. * For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument` is returned
  2773. * for invalid CID values (this is, for CID values that don't have a
  2774. * corresponding glyph in the font). See the discussion of the
  2775. * @FT_FACE_FLAG_CID_KEYED flag for more details.
  2776. *
  2777. * If you receive `FT_Err_Glyph_Too_Big`, try getting the glyph outline
  2778. * at EM size, then scale it manually and fill it as a graphics
  2779. * operation.
  2780. */
  2781. FT_EXPORT( FT_Error )
  2782. FT_Load_Glyph( FT_Face face,
  2783. FT_UInt glyph_index,
  2784. FT_Int32 load_flags );
  2785. /**************************************************************************
  2786. *
  2787. * @function:
  2788. * FT_Load_Char
  2789. *
  2790. * @description:
  2791. * Load a glyph into the glyph slot of a face object, accessed by its
  2792. * character code.
  2793. *
  2794. * @inout:
  2795. * face ::
  2796. * A handle to a target face object where the glyph is loaded.
  2797. *
  2798. * @input:
  2799. * char_code ::
  2800. * The glyph's character code, according to the current charmap used in
  2801. * the face.
  2802. *
  2803. * load_flags ::
  2804. * A flag indicating what to load for this glyph. The @FT_LOAD_XXX
  2805. * constants can be used to control the glyph loading process (e.g.,
  2806. * whether the outline should be scaled, whether to load bitmaps or
  2807. * not, whether to hint the outline, etc).
  2808. *
  2809. * @return:
  2810. * FreeType error code. 0~means success.
  2811. *
  2812. * @note:
  2813. * This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph.
  2814. *
  2815. * Many fonts contain glyphs that can't be loaded by this function since
  2816. * its glyph indices are not listed in any of the font's charmaps.
  2817. *
  2818. * If no active cmap is set up (i.e., `face->charmap` is zero), the call
  2819. * to @FT_Get_Char_Index is omitted, and the function behaves identically
  2820. * to @FT_Load_Glyph.
  2821. */
  2822. FT_EXPORT( FT_Error )
  2823. FT_Load_Char( FT_Face face,
  2824. FT_ULong char_code,
  2825. FT_Int32 load_flags );
  2826. /**************************************************************************
  2827. *
  2828. * @enum:
  2829. * FT_LOAD_XXX
  2830. *
  2831. * @description:
  2832. * A list of bit field constants for @FT_Load_Glyph to indicate what kind
  2833. * of operations to perform during glyph loading.
  2834. *
  2835. * @values:
  2836. * FT_LOAD_DEFAULT ::
  2837. * Corresponding to~0, this value is used as the default glyph load
  2838. * operation. In this case, the following happens:
  2839. *
  2840. * 1. FreeType looks for a bitmap for the glyph corresponding to the
  2841. * face's current size. If one is found, the function returns. The
  2842. * bitmap data can be accessed from the glyph slot (see note below).
  2843. *
  2844. * 2. If no embedded bitmap is searched for or found, FreeType looks
  2845. * for a scalable outline. If one is found, it is loaded from the font
  2846. * file, scaled to device pixels, then 'hinted' to the pixel grid in
  2847. * order to optimize it. The outline data can be accessed from the
  2848. * glyph slot (see note below).
  2849. *
  2850. * Note that by default the glyph loader doesn't render outlines into
  2851. * bitmaps. The following flags are used to modify this default
  2852. * behaviour to more specific and useful cases.
  2853. *
  2854. * FT_LOAD_NO_SCALE ::
  2855. * Don't scale the loaded outline glyph but keep it in font units.
  2856. * This flag is also assumed if @FT_Size owned by the face was not
  2857. * properly initialized.
  2858. *
  2859. * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
  2860. * unsets @FT_LOAD_RENDER.
  2861. *
  2862. * If the font is 'tricky' (see @FT_FACE_FLAG_TRICKY for more), using
  2863. * `FT_LOAD_NO_SCALE` usually yields meaningless outlines because the
  2864. * subglyphs must be scaled and positioned with hinting instructions.
  2865. * This can be solved by loading the font without `FT_LOAD_NO_SCALE`
  2866. * and setting the character size to `font->units_per_EM`.
  2867. *
  2868. * FT_LOAD_NO_HINTING ::
  2869. * Disable hinting. This generally generates 'blurrier' bitmap glyphs
  2870. * when the glyphs are rendered in any of the anti-aliased modes. See
  2871. * also the note below.
  2872. *
  2873. * This flag is implied by @FT_LOAD_NO_SCALE.
  2874. *
  2875. * FT_LOAD_RENDER ::
  2876. * Call @FT_Render_Glyph after the glyph is loaded. By default, the
  2877. * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
  2878. * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
  2879. *
  2880. * This flag is unset by @FT_LOAD_NO_SCALE.
  2881. *
  2882. * FT_LOAD_NO_BITMAP ::
  2883. * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
  2884. * flag.
  2885. *
  2886. * @FT_LOAD_NO_SCALE always sets this flag.
  2887. *
  2888. * FT_LOAD_SBITS_ONLY ::
  2889. * [Since 2.12] This is the opposite of @FT_LOAD_NO_BITMAP, more or
  2890. * less: @FT_Load_Glyph returns `FT_Err_Invalid_Argument` if the face
  2891. * contains a bitmap strike for the given size (or the strike selected
  2892. * by @FT_Select_Size) but there is no glyph in the strike.
  2893. *
  2894. * Note that this load flag was part of FreeType since version 2.0.6
  2895. * but previously tagged as internal.
  2896. *
  2897. * FT_LOAD_VERTICAL_LAYOUT ::
  2898. * Load the glyph for vertical text layout. In particular, the
  2899. * `advance` value in the @FT_GlyphSlotRec structure is set to the
  2900. * `vertAdvance` value of the `metrics` field.
  2901. *
  2902. * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use this
  2903. * flag currently. Reason is that in this case vertical metrics get
  2904. * synthesized, and those values are not always consistent across
  2905. * various font formats.
  2906. *
  2907. * FT_LOAD_FORCE_AUTOHINT ::
  2908. * Prefer the auto-hinter over the font's native hinter. See also the
  2909. * note below.
  2910. *
  2911. * FT_LOAD_PEDANTIC ::
  2912. * Make the font driver perform pedantic verifications during glyph
  2913. * loading and hinting. This is mostly used to detect broken glyphs in
  2914. * fonts. By default, FreeType tries to handle broken fonts also.
  2915. *
  2916. * In particular, errors from the TrueType bytecode engine are not
  2917. * passed to the application if this flag is not set; this might result
  2918. * in partially hinted or distorted glyphs in case a glyph's bytecode
  2919. * is buggy.
  2920. *
  2921. * FT_LOAD_NO_RECURSE ::
  2922. * Don't load composite glyphs recursively. Instead, the font driver
  2923. * fills the `num_subglyph` and `subglyphs` values of the glyph slot;
  2924. * it also sets `glyph->format` to @FT_GLYPH_FORMAT_COMPOSITE. The
  2925. * description of subglyphs can then be accessed with
  2926. * @FT_Get_SubGlyph_Info.
  2927. *
  2928. * Don't use this flag for retrieving metrics information since some
  2929. * font drivers only return rudimentary data.
  2930. *
  2931. * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
  2932. *
  2933. * FT_LOAD_IGNORE_TRANSFORM ::
  2934. * Ignore the transform matrix set by @FT_Set_Transform.
  2935. *
  2936. * FT_LOAD_MONOCHROME ::
  2937. * This flag is used with @FT_LOAD_RENDER to indicate that you want to
  2938. * render an outline glyph to a 1-bit monochrome bitmap glyph, with
  2939. * 8~pixels packed into each byte of the bitmap data.
  2940. *
  2941. * Note that this has no effect on the hinting algorithm used. You
  2942. * should rather use @FT_LOAD_TARGET_MONO so that the
  2943. * monochrome-optimized hinting algorithm is used.
  2944. *
  2945. * FT_LOAD_LINEAR_DESIGN ::
  2946. * Keep `linearHoriAdvance` and `linearVertAdvance` fields of
  2947. * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for details.
  2948. *
  2949. * FT_LOAD_NO_AUTOHINT ::
  2950. * Disable the auto-hinter. See also the note below.
  2951. *
  2952. * FT_LOAD_COLOR ::
  2953. * Load colored glyphs. FreeType searches in the following order;
  2954. * there are slight differences depending on the font format.
  2955. *
  2956. * [Since 2.5] Load embedded color bitmap images (provided
  2957. * @FT_LOAD_NO_BITMAP is not set). The resulting color bitmaps, if
  2958. * available, have the @FT_PIXEL_MODE_BGRA format, with pre-multiplied
  2959. * color channels. If the flag is not set and color bitmaps are found,
  2960. * they are converted to 256-level gray bitmaps, using the
  2961. * @FT_PIXEL_MODE_GRAY format.
  2962. *
  2963. * [Since 2.12] If the glyph index maps to an entry in the face's
  2964. * 'SVG~' table, load the associated SVG document from this table and
  2965. * set the `format` field of @FT_GlyphSlotRec to @FT_GLYPH_FORMAT_SVG.
  2966. * Note that FreeType itself can't render SVG documents; however, the
  2967. * library provides hooks to seamlessly integrate an external renderer.
  2968. * See sections @ot_svg_driver and @svg_fonts for more.
  2969. *
  2970. * [Since 2.10, experimental] If the glyph index maps to an entry in
  2971. * the face's 'COLR' table with a 'CPAL' palette table (as defined in
  2972. * the OpenType specification), make @FT_Render_Glyph provide a default
  2973. * blending of the color glyph layers associated with the glyph index,
  2974. * using the same bitmap format as embedded color bitmap images. This
  2975. * is mainly for convenience and works only for glyphs in 'COLR' v0
  2976. * tables (or glyphs in 'COLR' v1 tables that exclusively use v0
  2977. * features). For full control of color layers use
  2978. * @FT_Get_Color_Glyph_Layer and FreeType's color functions like
  2979. * @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering
  2980. * so that the client application can handle blending by itself.
  2981. *
  2982. * FT_LOAD_COMPUTE_METRICS ::
  2983. * [Since 2.6.1] Compute glyph metrics from the glyph data, without the
  2984. * use of bundled metrics tables (for example, the 'hdmx' table in
  2985. * TrueType fonts). This flag is mainly used by font validating or
  2986. * font editing applications, which need to ignore, verify, or edit
  2987. * those tables.
  2988. *
  2989. * Currently, this flag is only implemented for TrueType fonts.
  2990. *
  2991. * FT_LOAD_BITMAP_METRICS_ONLY ::
  2992. * [Since 2.7.1] Request loading of the metrics and bitmap image
  2993. * information of a (possibly embedded) bitmap glyph without allocating
  2994. * or copying the bitmap image data itself. No effect if the target
  2995. * glyph is not a bitmap image.
  2996. *
  2997. * This flag unsets @FT_LOAD_RENDER.
  2998. *
  2999. * FT_LOAD_CROP_BITMAP ::
  3000. * Ignored. Deprecated.
  3001. *
  3002. * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
  3003. * Ignored. Deprecated.
  3004. *
  3005. * @note:
  3006. * By default, hinting is enabled and the font's native hinter (see
  3007. * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
  3008. * disable hinting by setting @FT_LOAD_NO_HINTING or change the
  3009. * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
  3010. * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be used
  3011. * at all.
  3012. *
  3013. * See the description of @FT_FACE_FLAG_TRICKY for a special exception
  3014. * (affecting only a handful of Asian fonts).
  3015. *
  3016. * Besides deciding which hinter to use, you can also decide which
  3017. * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
  3018. *
  3019. * Note that the auto-hinter needs a valid Unicode cmap (either a native
  3020. * one or synthesized by FreeType) for producing correct results. If a
  3021. * font provides an incorrect mapping (for example, assigning the
  3022. * character code U+005A, LATIN CAPITAL LETTER~Z, to a glyph depicting a
  3023. * mathematical integral sign), the auto-hinter might produce useless
  3024. * results.
  3025. *
  3026. */
  3027. #define FT_LOAD_DEFAULT 0x0
  3028. #define FT_LOAD_NO_SCALE ( 1L << 0 )
  3029. #define FT_LOAD_NO_HINTING ( 1L << 1 )
  3030. #define FT_LOAD_RENDER ( 1L << 2 )
  3031. #define FT_LOAD_NO_BITMAP ( 1L << 3 )
  3032. #define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
  3033. #define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
  3034. #define FT_LOAD_CROP_BITMAP ( 1L << 6 )
  3035. #define FT_LOAD_PEDANTIC ( 1L << 7 )
  3036. #define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
  3037. #define FT_LOAD_NO_RECURSE ( 1L << 10 )
  3038. #define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
  3039. #define FT_LOAD_MONOCHROME ( 1L << 12 )
  3040. #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
  3041. #define FT_LOAD_SBITS_ONLY ( 1L << 14 )
  3042. #define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
  3043. /* Bits 16-19 are used by `FT_LOAD_TARGET_` */
  3044. #define FT_LOAD_COLOR ( 1L << 20 )
  3045. #define FT_LOAD_COMPUTE_METRICS ( 1L << 21 )
  3046. #define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 )
  3047. /* */
  3048. /* used internally only by certain font drivers */
  3049. #define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
  3050. #define FT_LOAD_SVG_ONLY ( 1L << 23 )
  3051. /**************************************************************************
  3052. *
  3053. * @enum:
  3054. * FT_LOAD_TARGET_XXX
  3055. *
  3056. * @description:
  3057. * A list of values to select a specific hinting algorithm for the
  3058. * hinter. You should OR one of these values to your `load_flags` when
  3059. * calling @FT_Load_Glyph.
  3060. *
  3061. * Note that a font's native hinters may ignore the hinting algorithm you
  3062. * have specified (e.g., the TrueType bytecode interpreter). You can set
  3063. * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used.
  3064. *
  3065. * @values:
  3066. * FT_LOAD_TARGET_NORMAL ::
  3067. * The default hinting algorithm, optimized for standard gray-level
  3068. * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO instead.
  3069. *
  3070. * FT_LOAD_TARGET_LIGHT ::
  3071. * A lighter hinting algorithm for gray-level modes. Many generated
  3072. * glyphs are fuzzier but better resemble their original shape. This
  3073. * is achieved by snapping glyphs to the pixel grid only vertically
  3074. * (Y-axis), as is done by FreeType's new CFF engine or Microsoft's
  3075. * ClearType font renderer. This preserves inter-glyph spacing in
  3076. * horizontal text. The snapping is done either by the native font
  3077. * driver, if the driver itself and the font support it, or by the
  3078. * auto-hinter.
  3079. *
  3080. * Advance widths are rounded to integer values; however, using the
  3081. * `lsb_delta` and `rsb_delta` fields of @FT_GlyphSlotRec, it is
  3082. * possible to get fractional advance widths for subpixel positioning
  3083. * (which is recommended to use).
  3084. *
  3085. * If configuration option `AF_CONFIG_OPTION_TT_SIZE_METRICS` is
  3086. * active, TrueType-like metrics are used to make this mode behave
  3087. * similarly as in unpatched FreeType versions between 2.4.6 and 2.7.1
  3088. * (inclusive).
  3089. *
  3090. * FT_LOAD_TARGET_MONO ::
  3091. * Strong hinting algorithm that should only be used for monochrome
  3092. * output. The result is probably unpleasant if the glyph is rendered
  3093. * in non-monochrome modes.
  3094. *
  3095. * Note that for outline fonts only the TrueType font driver has proper
  3096. * monochrome hinting support, provided the TTFs contain hints for B/W
  3097. * rendering (which most fonts no longer provide). If these conditions
  3098. * are not met it is very likely that you get ugly results at smaller
  3099. * sizes.
  3100. *
  3101. * FT_LOAD_TARGET_LCD ::
  3102. * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally
  3103. * decimated LCD displays.
  3104. *
  3105. * FT_LOAD_TARGET_LCD_V ::
  3106. * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
  3107. * decimated LCD displays.
  3108. *
  3109. * @note:
  3110. * You should use only _one_ of the `FT_LOAD_TARGET_XXX` values in your
  3111. * `load_flags`. They can't be ORed.
  3112. *
  3113. * If @FT_LOAD_RENDER is also set, the glyph is rendered in the
  3114. * corresponding mode (i.e., the mode that matches the used algorithm
  3115. * best). An exception is `FT_LOAD_TARGET_MONO` since it implies
  3116. * @FT_LOAD_MONOCHROME.
  3117. *
  3118. * You can use a hinting algorithm that doesn't correspond to the same
  3119. * rendering mode. As an example, it is possible to use the 'light'
  3120. * hinting algorithm and have the results rendered in horizontal LCD
  3121. * pixel mode, with code like
  3122. *
  3123. * ```
  3124. * FT_Load_Glyph( face, glyph_index,
  3125. * load_flags | FT_LOAD_TARGET_LIGHT );
  3126. *
  3127. * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
  3128. * ```
  3129. *
  3130. * In general, you should stick with one rendering mode. For example,
  3131. * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO
  3132. * enforces a lot of recomputation for TrueType fonts, which is slow.
  3133. * Another reason is caching: Selecting a different mode usually causes
  3134. * changes in both the outlines and the rasterized bitmaps; it is thus
  3135. * necessary to empty the cache after a mode switch to avoid false hits.
  3136. *
  3137. */
  3138. #define FT_LOAD_TARGET_( x ) ( FT_STATIC_CAST( FT_Int32, (x) & 15 ) << 16 )
  3139. #define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
  3140. #define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
  3141. #define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
  3142. #define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
  3143. #define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
  3144. /**************************************************************************
  3145. *
  3146. * @macro:
  3147. * FT_LOAD_TARGET_MODE
  3148. *
  3149. * @description:
  3150. * Return the @FT_Render_Mode corresponding to a given
  3151. * @FT_LOAD_TARGET_XXX value.
  3152. *
  3153. */
  3154. #define FT_LOAD_TARGET_MODE( x ) \
  3155. FT_STATIC_CAST( FT_Render_Mode, ( (x) >> 16 ) & 15 )
  3156. /**************************************************************************
  3157. *
  3158. * @function:
  3159. * FT_Set_Transform
  3160. *
  3161. * @description:
  3162. * Set the transformation that is applied to glyph images when they are
  3163. * loaded into a glyph slot through @FT_Load_Glyph.
  3164. *
  3165. * @inout:
  3166. * face ::
  3167. * A handle to the source face object.
  3168. *
  3169. * @input:
  3170. * matrix ::
  3171. * A pointer to the transformation's 2x2 matrix. Use `NULL` for the
  3172. * identity matrix.
  3173. * delta ::
  3174. * A pointer to the translation vector. Use `NULL` for the null
  3175. * vector.
  3176. *
  3177. * @note:
  3178. * This function is provided as a convenience, but keep in mind that
  3179. * @FT_Matrix coefficients are only 16.16 fixed-point values, which can
  3180. * limit the accuracy of the results. Using floating-point computations
  3181. * to perform the transform directly in client code instead will always
  3182. * yield better numbers.
  3183. *
  3184. * The transformation is only applied to scalable image formats after the
  3185. * glyph has been loaded. It means that hinting is unaltered by the
  3186. * transformation and is performed on the character size given in the
  3187. * last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes.
  3188. *
  3189. * Note that this also transforms the `face.glyph.advance` field, but
  3190. * **not** the values in `face.glyph.metrics`.
  3191. */
  3192. FT_EXPORT( void )
  3193. FT_Set_Transform( FT_Face face,
  3194. FT_Matrix* matrix,
  3195. FT_Vector* delta );
  3196. /**************************************************************************
  3197. *
  3198. * @function:
  3199. * FT_Get_Transform
  3200. *
  3201. * @description:
  3202. * Return the transformation that is applied to glyph images when they
  3203. * are loaded into a glyph slot through @FT_Load_Glyph. See
  3204. * @FT_Set_Transform for more details.
  3205. *
  3206. * @input:
  3207. * face ::
  3208. * A handle to the source face object.
  3209. *
  3210. * @output:
  3211. * matrix ::
  3212. * A pointer to a transformation's 2x2 matrix. Set this to NULL if you
  3213. * are not interested in the value.
  3214. *
  3215. * delta ::
  3216. * A pointer to a translation vector. Set this to NULL if you are not
  3217. * interested in the value.
  3218. *
  3219. * @since:
  3220. * 2.11
  3221. *
  3222. */
  3223. FT_EXPORT( void )
  3224. FT_Get_Transform( FT_Face face,
  3225. FT_Matrix* matrix,
  3226. FT_Vector* delta );
  3227. /**************************************************************************
  3228. *
  3229. * @enum:
  3230. * FT_Render_Mode
  3231. *
  3232. * @description:
  3233. * Render modes supported by FreeType~2. Each mode corresponds to a
  3234. * specific type of scanline conversion performed on the outline.
  3235. *
  3236. * For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode` field
  3237. * in the @FT_GlyphSlotRec structure gives the format of the returned
  3238. * bitmap.
  3239. *
  3240. * All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity,
  3241. * indicating pixel coverage. Use linear alpha blending and gamma
  3242. * correction to correctly render non-monochrome glyph bitmaps onto a
  3243. * surface; see @FT_Render_Glyph.
  3244. *
  3245. * The @FT_RENDER_MODE_SDF is a special render mode that uses up to 256
  3246. * distance values, indicating the signed distance from the grid position
  3247. * to the nearest outline.
  3248. *
  3249. * @values:
  3250. * FT_RENDER_MODE_NORMAL ::
  3251. * Default render mode; it corresponds to 8-bit anti-aliased bitmaps.
  3252. *
  3253. * FT_RENDER_MODE_LIGHT ::
  3254. * This is equivalent to @FT_RENDER_MODE_NORMAL. It is only defined as
  3255. * a separate value because render modes are also used indirectly to
  3256. * define hinting algorithm selectors. See @FT_LOAD_TARGET_XXX for
  3257. * details.
  3258. *
  3259. * FT_RENDER_MODE_MONO ::
  3260. * This mode corresponds to 1-bit bitmaps (with 2~levels of opacity).
  3261. *
  3262. * FT_RENDER_MODE_LCD ::
  3263. * This mode corresponds to horizontal RGB and BGR subpixel displays
  3264. * like LCD screens. It produces 8-bit bitmaps that are 3~times the
  3265. * width of the original glyph outline in pixels, and which use the
  3266. * @FT_PIXEL_MODE_LCD mode.
  3267. *
  3268. * FT_RENDER_MODE_LCD_V ::
  3269. * This mode corresponds to vertical RGB and BGR subpixel displays
  3270. * (like PDA screens, rotated LCD displays, etc.). It produces 8-bit
  3271. * bitmaps that are 3~times the height of the original glyph outline in
  3272. * pixels and use the @FT_PIXEL_MODE_LCD_V mode.
  3273. *
  3274. * FT_RENDER_MODE_SDF ::
  3275. * This mode corresponds to 8-bit, single-channel signed distance field
  3276. * (SDF) bitmaps. Each pixel in the SDF grid is the value from the
  3277. * pixel's position to the nearest glyph's outline. The distances are
  3278. * calculated from the center of the pixel and are positive if they are
  3279. * filled by the outline (i.e., inside the outline) and negative
  3280. * otherwise. Check the note below on how to convert the output values
  3281. * to usable data.
  3282. *
  3283. * @note:
  3284. * The selected render mode only affects vector glyphs of a font.
  3285. * Embedded bitmaps often have a different pixel mode like
  3286. * @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform them
  3287. * into 8-bit pixmaps.
  3288. *
  3289. * For @FT_RENDER_MODE_SDF the output bitmap buffer contains normalized
  3290. * distances that are packed into unsigned 8-bit values. To get pixel
  3291. * values in floating point representation use the following pseudo-C
  3292. * code for the conversion.
  3293. *
  3294. * ```
  3295. * // Load glyph and render using FT_RENDER_MODE_SDF,
  3296. * // then use the output buffer as follows.
  3297. *
  3298. * ...
  3299. * FT_Byte buffer = glyph->bitmap->buffer;
  3300. *
  3301. *
  3302. * for pixel in buffer
  3303. * {
  3304. * // `sd` is the signed distance and `spread` is the current spread;
  3305. * // the default spread is 2 and can be changed.
  3306. *
  3307. * float sd = (float)pixel - 128.0f;
  3308. *
  3309. *
  3310. * // Convert to pixel values.
  3311. * sd = ( sd / 128.0f ) * spread;
  3312. *
  3313. * // Store `sd` in a buffer or use as required.
  3314. * }
  3315. *
  3316. * ```
  3317. *
  3318. * FreeType has two rasterizers for generating SDF, namely:
  3319. *
  3320. * 1. `sdf` for generating SDF directly from glyph's outline, and
  3321. *
  3322. * 2. `bsdf` for generating SDF from rasterized bitmaps.
  3323. *
  3324. * Depending on the glyph type (i.e., outline or bitmap), one of the two
  3325. * rasterizers is chosen at runtime and used for generating SDFs. To
  3326. * force the use of `bsdf` you should render the glyph with any of the
  3327. * FreeType's other rendering modes (e.g., `FT_RENDER_MODE_NORMAL`) and
  3328. * then re-render with `FT_RENDER_MODE_SDF`.
  3329. *
  3330. * There are some issues with stability and possible failures of the SDF
  3331. * renderers (specifically `sdf`).
  3332. *
  3333. * 1. The `sdf` rasterizer is sensitive to really small features (e.g.,
  3334. * sharp turns that are less than 1~pixel) and imperfections in the
  3335. * glyph's outline, causing artifacts in the final output.
  3336. *
  3337. * 2. The `sdf` rasterizer has limited support for handling intersecting
  3338. * contours and *cannot* handle self-intersecting contours whatsoever.
  3339. * Self-intersection happens when a single connected contour
  3340. * intersects itself at some point; having these in your font
  3341. * definitely poses a problem to the rasterizer and cause artifacts,
  3342. * too.
  3343. *
  3344. * 3. Generating SDF for really small glyphs may result in undesirable
  3345. * output; the pixel grid (which stores distance information) becomes
  3346. * too coarse.
  3347. *
  3348. * 4. Since the output buffer is normalized, precision at smaller spreads
  3349. * is greater than precision at larger spread values because the
  3350. * output range of [0..255] gets mapped to a smaller SDF range. A
  3351. * spread of~2 should be sufficient in most cases.
  3352. *
  3353. * Points (1) and (2) can be avoided by using the `bsdf` rasterizer,
  3354. * which is more stable than the `sdf` rasterizer in general.
  3355. *
  3356. */
  3357. typedef enum FT_Render_Mode_
  3358. {
  3359. FT_RENDER_MODE_NORMAL = 0,
  3360. FT_RENDER_MODE_LIGHT,
  3361. FT_RENDER_MODE_MONO,
  3362. FT_RENDER_MODE_LCD,
  3363. FT_RENDER_MODE_LCD_V,
  3364. FT_RENDER_MODE_SDF,
  3365. FT_RENDER_MODE_MAX
  3366. } FT_Render_Mode;
  3367. /* these constants are deprecated; use the corresponding */
  3368. /* `FT_Render_Mode` values instead */
  3369. #define ft_render_mode_normal FT_RENDER_MODE_NORMAL
  3370. #define ft_render_mode_mono FT_RENDER_MODE_MONO
  3371. /**************************************************************************
  3372. *
  3373. * @function:
  3374. * FT_Render_Glyph
  3375. *
  3376. * @description:
  3377. * Convert a given glyph image to a bitmap. It does so by inspecting the
  3378. * glyph image format, finding the relevant renderer, and invoking it.
  3379. *
  3380. * @inout:
  3381. * slot ::
  3382. * A handle to the glyph slot containing the image to convert.
  3383. *
  3384. * @input:
  3385. * render_mode ::
  3386. * The render mode used to render the glyph image into a bitmap. See
  3387. * @FT_Render_Mode for a list of possible values.
  3388. *
  3389. * If @FT_RENDER_MODE_NORMAL is used, a previous call of @FT_Load_Glyph
  3390. * with flag @FT_LOAD_COLOR makes `FT_Render_Glyph` provide a default
  3391. * blending of colored glyph layers associated with the current glyph
  3392. * slot (provided the font contains such layers) instead of rendering
  3393. * the glyph slot's outline. This is an experimental feature; see
  3394. * @FT_LOAD_COLOR for more information.
  3395. *
  3396. * @return:
  3397. * FreeType error code. 0~means success.
  3398. *
  3399. * @note:
  3400. * When FreeType outputs a bitmap of a glyph, it really outputs an alpha
  3401. * coverage map. If a pixel is completely covered by a filled-in
  3402. * outline, the bitmap contains 0xFF at that pixel, meaning that
  3403. * 0xFF/0xFF fraction of that pixel is covered, meaning the pixel is 100%
  3404. * black (or 0% bright). If a pixel is only 50% covered (value 0x80),
  3405. * the pixel is made 50% black (50% bright or a middle shade of grey).
  3406. * 0% covered means 0% black (100% bright or white).
  3407. *
  3408. * On high-DPI screens like on smartphones and tablets, the pixels are so
  3409. * small that their chance of being completely covered and therefore
  3410. * completely black are fairly good. On the low-DPI screens, however,
  3411. * the situation is different. The pixels are too large for most of the
  3412. * details of a glyph and shades of gray are the norm rather than the
  3413. * exception.
  3414. *
  3415. * This is relevant because all our screens have a second problem: they
  3416. * are not linear. 1~+~1 is not~2. Twice the value does not result in
  3417. * twice the brightness. When a pixel is only 50% covered, the coverage
  3418. * map says 50% black, and this translates to a pixel value of 128 when
  3419. * you use 8~bits per channel (0-255). However, this does not translate
  3420. * to 50% brightness for that pixel on our sRGB and gamma~2.2 screens.
  3421. * Due to their non-linearity, they dwell longer in the darks and only a
  3422. * pixel value of about 186 results in 50% brightness -- 128 ends up too
  3423. * dark on both bright and dark backgrounds. The net result is that dark
  3424. * text looks burnt-out, pixely and blotchy on bright background, bright
  3425. * text too frail on dark backgrounds, and colored text on colored
  3426. * background (for example, red on green) seems to have dark halos or
  3427. * 'dirt' around it. The situation is especially ugly for diagonal stems
  3428. * like in 'w' glyph shapes where the quality of FreeType's anti-aliasing
  3429. * depends on the correct display of grays. On high-DPI screens where
  3430. * smaller, fully black pixels reign supreme, this doesn't matter, but on
  3431. * our low-DPI screens with all the gray shades, it does. 0% and 100%
  3432. * brightness are the same things in linear and non-linear space, just
  3433. * all the shades in-between aren't.
  3434. *
  3435. * The blending function for placing text over a background is
  3436. *
  3437. * ```
  3438. * dst = alpha * src + (1 - alpha) * dst ,
  3439. * ```
  3440. *
  3441. * which is known as the OVER operator.
  3442. *
  3443. * To correctly composite an anti-aliased pixel of a glyph onto a
  3444. * surface,
  3445. *
  3446. * 1. take the foreground and background colors (e.g., in sRGB space)
  3447. * and apply gamma to get them in a linear space,
  3448. *
  3449. * 2. use OVER to blend the two linear colors using the glyph pixel
  3450. * as the alpha value (remember, the glyph bitmap is an alpha coverage
  3451. * bitmap), and
  3452. *
  3453. * 3. apply inverse gamma to the blended pixel and write it back to
  3454. * the image.
  3455. *
  3456. * Internal testing at Adobe found that a target inverse gamma of~1.8 for
  3457. * step~3 gives good results across a wide range of displays with an sRGB
  3458. * gamma curve or a similar one.
  3459. *
  3460. * This process can cost performance. There is an approximation that
  3461. * does not need to know about the background color; see
  3462. * https://bel.fi/alankila/lcd/ and
  3463. * https://bel.fi/alankila/lcd/alpcor.html for details.
  3464. *
  3465. * **ATTENTION**: Linear blending is even more important when dealing
  3466. * with subpixel-rendered glyphs to prevent color-fringing! A
  3467. * subpixel-rendered glyph must first be filtered with a filter that
  3468. * gives equal weight to the three color primaries and does not exceed a
  3469. * sum of 0x100, see section @lcd_rendering. Then the only difference to
  3470. * gray linear blending is that subpixel-rendered linear blending is done
  3471. * 3~times per pixel: red foreground subpixel to red background subpixel
  3472. * and so on for green and blue.
  3473. */
  3474. FT_EXPORT( FT_Error )
  3475. FT_Render_Glyph( FT_GlyphSlot slot,
  3476. FT_Render_Mode render_mode );
  3477. /**************************************************************************
  3478. *
  3479. * @enum:
  3480. * FT_Kerning_Mode
  3481. *
  3482. * @description:
  3483. * An enumeration to specify the format of kerning values returned by
  3484. * @FT_Get_Kerning.
  3485. *
  3486. * @values:
  3487. * FT_KERNING_DEFAULT ::
  3488. * Return grid-fitted kerning distances in 26.6 fractional pixels.
  3489. *
  3490. * FT_KERNING_UNFITTED ::
  3491. * Return un-grid-fitted kerning distances in 26.6 fractional pixels.
  3492. *
  3493. * FT_KERNING_UNSCALED ::
  3494. * Return the kerning vector in original font units.
  3495. *
  3496. * @note:
  3497. * `FT_KERNING_DEFAULT` returns full pixel values; it also makes FreeType
  3498. * heuristically scale down kerning distances at small ppem values so
  3499. * that they don't become too big.
  3500. *
  3501. * Both `FT_KERNING_DEFAULT` and `FT_KERNING_UNFITTED` use the current
  3502. * horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to
  3503. * convert font units to pixels.
  3504. */
  3505. typedef enum FT_Kerning_Mode_
  3506. {
  3507. FT_KERNING_DEFAULT = 0,
  3508. FT_KERNING_UNFITTED,
  3509. FT_KERNING_UNSCALED
  3510. } FT_Kerning_Mode;
  3511. /* these constants are deprecated; use the corresponding */
  3512. /* `FT_Kerning_Mode` values instead */
  3513. #define ft_kerning_default FT_KERNING_DEFAULT
  3514. #define ft_kerning_unfitted FT_KERNING_UNFITTED
  3515. #define ft_kerning_unscaled FT_KERNING_UNSCALED
  3516. /**************************************************************************
  3517. *
  3518. * @function:
  3519. * FT_Get_Kerning
  3520. *
  3521. * @description:
  3522. * Return the kerning vector between two glyphs of the same face.
  3523. *
  3524. * @input:
  3525. * face ::
  3526. * A handle to a source face object.
  3527. *
  3528. * left_glyph ::
  3529. * The index of the left glyph in the kern pair.
  3530. *
  3531. * right_glyph ::
  3532. * The index of the right glyph in the kern pair.
  3533. *
  3534. * kern_mode ::
  3535. * See @FT_Kerning_Mode for more information. Determines the scale and
  3536. * dimension of the returned kerning vector.
  3537. *
  3538. * @output:
  3539. * akerning ::
  3540. * The kerning vector. This is either in font units, fractional pixels
  3541. * (26.6 format), or pixels for scalable formats, and in pixels for
  3542. * fixed-sizes formats.
  3543. *
  3544. * @return:
  3545. * FreeType error code. 0~means success.
  3546. *
  3547. * @note:
  3548. * Only horizontal layouts (left-to-right & right-to-left) are supported
  3549. * by this method. Other layouts, or more sophisticated kernings, are
  3550. * out of the scope of this API function -- they can be implemented
  3551. * through format-specific interfaces.
  3552. *
  3553. * Kerning for OpenType fonts implemented in a 'GPOS' table is not
  3554. * supported; use @FT_HAS_KERNING to find out whether a font has data
  3555. * that can be extracted with `FT_Get_Kerning`.
  3556. */
  3557. FT_EXPORT( FT_Error )
  3558. FT_Get_Kerning( FT_Face face,
  3559. FT_UInt left_glyph,
  3560. FT_UInt right_glyph,
  3561. FT_UInt kern_mode,
  3562. FT_Vector *akerning );
  3563. /**************************************************************************
  3564. *
  3565. * @function:
  3566. * FT_Get_Track_Kerning
  3567. *
  3568. * @description:
  3569. * Return the track kerning for a given face object at a given size.
  3570. *
  3571. * @input:
  3572. * face ::
  3573. * A handle to a source face object.
  3574. *
  3575. * point_size ::
  3576. * The point size in 16.16 fractional points.
  3577. *
  3578. * degree ::
  3579. * The degree of tightness. Increasingly negative values represent
  3580. * tighter track kerning, while increasingly positive values represent
  3581. * looser track kerning. Value zero means no track kerning.
  3582. *
  3583. * @output:
  3584. * akerning ::
  3585. * The kerning in 16.16 fractional points, to be uniformly applied
  3586. * between all glyphs.
  3587. *
  3588. * @return:
  3589. * FreeType error code. 0~means success.
  3590. *
  3591. * @note:
  3592. * Currently, only the Type~1 font driver supports track kerning, using
  3593. * data from AFM files (if attached with @FT_Attach_File or
  3594. * @FT_Attach_Stream).
  3595. *
  3596. * Only very few AFM files come with track kerning data; please refer to
  3597. * Adobe's AFM specification for more details.
  3598. */
  3599. FT_EXPORT( FT_Error )
  3600. FT_Get_Track_Kerning( FT_Face face,
  3601. FT_Fixed point_size,
  3602. FT_Int degree,
  3603. FT_Fixed* akerning );
  3604. /**************************************************************************
  3605. *
  3606. * @function:
  3607. * FT_Select_Charmap
  3608. *
  3609. * @description:
  3610. * Select a given charmap by its encoding tag (as listed in
  3611. * `freetype.h`).
  3612. *
  3613. * @inout:
  3614. * face ::
  3615. * A handle to the source face object.
  3616. *
  3617. * @input:
  3618. * encoding ::
  3619. * A handle to the selected encoding.
  3620. *
  3621. * @return:
  3622. * FreeType error code. 0~means success.
  3623. *
  3624. * @note:
  3625. * This function returns an error if no charmap in the face corresponds
  3626. * to the encoding queried here.
  3627. *
  3628. * Because many fonts contain more than a single cmap for Unicode
  3629. * encoding, this function has some special code to select the one that
  3630. * covers Unicode best ('best' in the sense that a UCS-4 cmap is
  3631. * preferred to a UCS-2 cmap). It is thus preferable to @FT_Set_Charmap
  3632. * in this case.
  3633. */
  3634. FT_EXPORT( FT_Error )
  3635. FT_Select_Charmap( FT_Face face,
  3636. FT_Encoding encoding );
  3637. /**************************************************************************
  3638. *
  3639. * @function:
  3640. * FT_Set_Charmap
  3641. *
  3642. * @description:
  3643. * Select a given charmap for character code to glyph index mapping.
  3644. *
  3645. * @inout:
  3646. * face ::
  3647. * A handle to the source face object.
  3648. *
  3649. * @input:
  3650. * charmap ::
  3651. * A handle to the selected charmap.
  3652. *
  3653. * @return:
  3654. * FreeType error code. 0~means success.
  3655. *
  3656. * @note:
  3657. * This function returns an error if the charmap is not part of the face
  3658. * (i.e., if it is not listed in the `face->charmaps` table).
  3659. *
  3660. * It also fails if an OpenType type~14 charmap is selected (which
  3661. * doesn't map character codes to glyph indices at all).
  3662. */
  3663. FT_EXPORT( FT_Error )
  3664. FT_Set_Charmap( FT_Face face,
  3665. FT_CharMap charmap );
  3666. /**************************************************************************
  3667. *
  3668. * @function:
  3669. * FT_Get_Charmap_Index
  3670. *
  3671. * @description:
  3672. * Retrieve index of a given charmap.
  3673. *
  3674. * @input:
  3675. * charmap ::
  3676. * A handle to a charmap.
  3677. *
  3678. * @return:
  3679. * The index into the array of character maps within the face to which
  3680. * `charmap` belongs. If an error occurs, -1 is returned.
  3681. *
  3682. */
  3683. FT_EXPORT( FT_Int )
  3684. FT_Get_Charmap_Index( FT_CharMap charmap );
  3685. /**************************************************************************
  3686. *
  3687. * @function:
  3688. * FT_Get_Char_Index
  3689. *
  3690. * @description:
  3691. * Return the glyph index of a given character code. This function uses
  3692. * the currently selected charmap to do the mapping.
  3693. *
  3694. * @input:
  3695. * face ::
  3696. * A handle to the source face object.
  3697. *
  3698. * charcode ::
  3699. * The character code.
  3700. *
  3701. * @return:
  3702. * The glyph index. 0~means 'undefined character code'.
  3703. *
  3704. * @note:
  3705. * If you use FreeType to manipulate the contents of font files directly,
  3706. * be aware that the glyph index returned by this function doesn't always
  3707. * correspond to the internal indices used within the file. This is done
  3708. * to ensure that value~0 always corresponds to the 'missing glyph'. If
  3709. * the first glyph is not named '.notdef', then for Type~1 and Type~42
  3710. * fonts, '.notdef' will be moved into the glyph ID~0 position, and
  3711. * whatever was there will be moved to the position '.notdef' had. For
  3712. * Type~1 fonts, if there is no '.notdef' glyph at all, then one will be
  3713. * created at index~0 and whatever was there will be moved to the last
  3714. * index -- Type~42 fonts are considered invalid under this condition.
  3715. */
  3716. FT_EXPORT( FT_UInt )
  3717. FT_Get_Char_Index( FT_Face face,
  3718. FT_ULong charcode );
  3719. /**************************************************************************
  3720. *
  3721. * @function:
  3722. * FT_Get_First_Char
  3723. *
  3724. * @description:
  3725. * Return the first character code in the current charmap of a given
  3726. * face, together with its corresponding glyph index.
  3727. *
  3728. * @input:
  3729. * face ::
  3730. * A handle to the source face object.
  3731. *
  3732. * @output:
  3733. * agindex ::
  3734. * Glyph index of first character code. 0~if charmap is empty.
  3735. *
  3736. * @return:
  3737. * The charmap's first character code.
  3738. *
  3739. * @note:
  3740. * You should use this function together with @FT_Get_Next_Char to parse
  3741. * all character codes available in a given charmap. The code should
  3742. * look like this:
  3743. *
  3744. * ```
  3745. * FT_ULong charcode;
  3746. * FT_UInt gindex;
  3747. *
  3748. *
  3749. * charcode = FT_Get_First_Char( face, &gindex );
  3750. * while ( gindex != 0 )
  3751. * {
  3752. * ... do something with (charcode,gindex) pair ...
  3753. *
  3754. * charcode = FT_Get_Next_Char( face, charcode, &gindex );
  3755. * }
  3756. * ```
  3757. *
  3758. * Be aware that character codes can have values up to 0xFFFFFFFF; this
  3759. * might happen for non-Unicode or malformed cmaps. However, even with
  3760. * regular Unicode encoding, so-called 'last resort fonts' (using SFNT
  3761. * cmap format 13, see function @FT_Get_CMap_Format) normally have
  3762. * entries for all Unicode characters up to 0x1FFFFF, which can cause *a
  3763. * lot* of iterations.
  3764. *
  3765. * Note that `*agindex` is set to~0 if the charmap is empty. The result
  3766. * itself can be~0 in two cases: if the charmap is empty or if the
  3767. * value~0 is the first valid character code.
  3768. */
  3769. FT_EXPORT( FT_ULong )
  3770. FT_Get_First_Char( FT_Face face,
  3771. FT_UInt *agindex );
  3772. /**************************************************************************
  3773. *
  3774. * @function:
  3775. * FT_Get_Next_Char
  3776. *
  3777. * @description:
  3778. * Return the next character code in the current charmap of a given face
  3779. * following the value `char_code`, as well as the corresponding glyph
  3780. * index.
  3781. *
  3782. * @input:
  3783. * face ::
  3784. * A handle to the source face object.
  3785. *
  3786. * char_code ::
  3787. * The starting character code.
  3788. *
  3789. * @output:
  3790. * agindex ::
  3791. * Glyph index of next character code. 0~if charmap is empty.
  3792. *
  3793. * @return:
  3794. * The charmap's next character code.
  3795. *
  3796. * @note:
  3797. * You should use this function with @FT_Get_First_Char to walk over all
  3798. * character codes available in a given charmap. See the note for that
  3799. * function for a simple code example.
  3800. *
  3801. * Note that `*agindex` is set to~0 when there are no more codes in the
  3802. * charmap.
  3803. */
  3804. FT_EXPORT( FT_ULong )
  3805. FT_Get_Next_Char( FT_Face face,
  3806. FT_ULong char_code,
  3807. FT_UInt *agindex );
  3808. /**************************************************************************
  3809. *
  3810. * @function:
  3811. * FT_Face_Properties
  3812. *
  3813. * @description:
  3814. * Set or override certain (library or module-wide) properties on a
  3815. * face-by-face basis. Useful for finer-grained control and avoiding
  3816. * locks on shared structures (threads can modify their own faces as they
  3817. * see fit).
  3818. *
  3819. * Contrary to @FT_Property_Set, this function uses @FT_Parameter so that
  3820. * you can pass multiple properties to the target face in one call. Note
  3821. * that only a subset of the available properties can be controlled.
  3822. *
  3823. * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the
  3824. * property `no-stem-darkening` provided by the 'autofit', 'cff',
  3825. * 'type1', and 't1cid' modules; see @no-stem-darkening).
  3826. *
  3827. * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding
  3828. * to function @FT_Library_SetLcdFilterWeights).
  3829. *
  3830. * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID
  3831. * 'random' operator, corresponding to the `random-seed` property
  3832. * provided by the 'cff', 'type1', and 't1cid' modules; see
  3833. * @random-seed).
  3834. *
  3835. * Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the
  3836. * option and use the library or module default again.
  3837. *
  3838. * @input:
  3839. * face ::
  3840. * A handle to the source face object.
  3841. *
  3842. * num_properties ::
  3843. * The number of properties that follow.
  3844. *
  3845. * properties ::
  3846. * A handle to an @FT_Parameter array with `num_properties` elements.
  3847. *
  3848. * @return:
  3849. * FreeType error code. 0~means success.
  3850. *
  3851. * @example:
  3852. * Here is an example that sets three properties. You must define
  3853. * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` to make the LCD filter examples
  3854. * work.
  3855. *
  3856. * ```
  3857. * FT_Parameter property1;
  3858. * FT_Bool darken_stems = 1;
  3859. *
  3860. * FT_Parameter property2;
  3861. * FT_LcdFiveTapFilter custom_weight =
  3862. * { 0x11, 0x44, 0x56, 0x44, 0x11 };
  3863. *
  3864. * FT_Parameter property3;
  3865. * FT_Int32 random_seed = 314159265;
  3866. *
  3867. * FT_Parameter properties[3] = { property1,
  3868. * property2,
  3869. * property3 };
  3870. *
  3871. *
  3872. * property1.tag = FT_PARAM_TAG_STEM_DARKENING;
  3873. * property1.data = &darken_stems;
  3874. *
  3875. * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
  3876. * property2.data = custom_weight;
  3877. *
  3878. * property3.tag = FT_PARAM_TAG_RANDOM_SEED;
  3879. * property3.data = &random_seed;
  3880. *
  3881. * FT_Face_Properties( face, 3, properties );
  3882. * ```
  3883. *
  3884. * The next example resets a single property to its default value.
  3885. *
  3886. * ```
  3887. * FT_Parameter property;
  3888. *
  3889. *
  3890. * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
  3891. * property.data = NULL;
  3892. *
  3893. * FT_Face_Properties( face, 1, &property );
  3894. * ```
  3895. *
  3896. * @since:
  3897. * 2.8
  3898. *
  3899. */
  3900. FT_EXPORT( FT_Error )
  3901. FT_Face_Properties( FT_Face face,
  3902. FT_UInt num_properties,
  3903. FT_Parameter* properties );
  3904. /**************************************************************************
  3905. *
  3906. * @function:
  3907. * FT_Get_Name_Index
  3908. *
  3909. * @description:
  3910. * Return the glyph index of a given glyph name. This only works
  3911. * for those faces where @FT_HAS_GLYPH_NAMES returns true.
  3912. *
  3913. * @input:
  3914. * face ::
  3915. * A handle to the source face object.
  3916. *
  3917. * glyph_name ::
  3918. * The glyph name.
  3919. *
  3920. * @return:
  3921. * The glyph index. 0~means 'undefined character code'.
  3922. *
  3923. * @note:
  3924. * Acceptable glyph names might come from the [Adobe Glyph
  3925. * List](https://github.com/adobe-type-tools/agl-aglfn). See
  3926. * @FT_Get_Glyph_Name for the inverse functionality.
  3927. *
  3928. * This function has limited capabilities if the config macro
  3929. * `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` is not defined in `ftoption.h`:
  3930. * It then works only for fonts that actually embed glyph names (which
  3931. * many recent OpenType fonts do not).
  3932. */
  3933. FT_EXPORT( FT_UInt )
  3934. FT_Get_Name_Index( FT_Face face,
  3935. const FT_String* glyph_name );
  3936. /**************************************************************************
  3937. *
  3938. * @function:
  3939. * FT_Get_Glyph_Name
  3940. *
  3941. * @description:
  3942. * Retrieve the ASCII name of a given glyph in a face. This only works
  3943. * for those faces where @FT_HAS_GLYPH_NAMES returns true.
  3944. *
  3945. * @input:
  3946. * face ::
  3947. * A handle to a source face object.
  3948. *
  3949. * glyph_index ::
  3950. * The glyph index.
  3951. *
  3952. * buffer_max ::
  3953. * The maximum number of bytes available in the buffer.
  3954. *
  3955. * @output:
  3956. * buffer ::
  3957. * A pointer to a target buffer where the name is copied to.
  3958. *
  3959. * @return:
  3960. * FreeType error code. 0~means success.
  3961. *
  3962. * @note:
  3963. * An error is returned if the face doesn't provide glyph names or if the
  3964. * glyph index is invalid. In all cases of failure, the first byte of
  3965. * `buffer` is set to~0 to indicate an empty name.
  3966. *
  3967. * The glyph name is truncated to fit within the buffer if it is too
  3968. * long. The returned string is always zero-terminated.
  3969. *
  3970. * Be aware that FreeType reorders glyph indices internally so that glyph
  3971. * index~0 always corresponds to the 'missing glyph' (called '.notdef').
  3972. *
  3973. * This function has limited capabilities if the config macro
  3974. * `FT_CONFIG_OPTION_POSTSCRIPT_NAMES` is not defined in `ftoption.h`:
  3975. * It then works only for fonts that actually embed glyph names (which
  3976. * many recent OpenType fonts do not).
  3977. */
  3978. FT_EXPORT( FT_Error )
  3979. FT_Get_Glyph_Name( FT_Face face,
  3980. FT_UInt glyph_index,
  3981. FT_Pointer buffer,
  3982. FT_UInt buffer_max );
  3983. /**************************************************************************
  3984. *
  3985. * @function:
  3986. * FT_Get_Postscript_Name
  3987. *
  3988. * @description:
  3989. * Retrieve the ASCII PostScript name of a given face, if available.
  3990. * This only works with PostScript, TrueType, and OpenType fonts.
  3991. *
  3992. * @input:
  3993. * face ::
  3994. * A handle to the source face object.
  3995. *
  3996. * @return:
  3997. * A pointer to the face's PostScript name. `NULL` if unavailable.
  3998. *
  3999. * @note:
  4000. * The returned pointer is owned by the face and is destroyed with it.
  4001. *
  4002. * For variation fonts, this string changes if you select a different
  4003. * instance, and you have to call `FT_Get_PostScript_Name` again to
  4004. * retrieve it. FreeType follows Adobe TechNote #5902, 'Generating
  4005. * PostScript Names for Fonts Using OpenType Font Variations'.
  4006. *
  4007. * https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html
  4008. *
  4009. * [Since 2.9] Special PostScript names for named instances are only
  4010. * returned if the named instance is set with @FT_Set_Named_Instance (and
  4011. * the font has corresponding entries in its 'fvar' table). If
  4012. * @FT_IS_VARIATION returns true, the algorithmically derived PostScript
  4013. * name is provided, not looking up special entries for named instances.
  4014. */
  4015. FT_EXPORT( const char* )
  4016. FT_Get_Postscript_Name( FT_Face face );
  4017. /**************************************************************************
  4018. *
  4019. * @enum:
  4020. * FT_SUBGLYPH_FLAG_XXX
  4021. *
  4022. * @description:
  4023. * A list of constants describing subglyphs. Please refer to the 'glyf'
  4024. * table description in the OpenType specification for the meaning of the
  4025. * various flags (which get synthesized for non-OpenType subglyphs).
  4026. *
  4027. * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
  4028. *
  4029. * @values:
  4030. * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
  4031. * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
  4032. * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
  4033. * FT_SUBGLYPH_FLAG_SCALE ::
  4034. * FT_SUBGLYPH_FLAG_XY_SCALE ::
  4035. * FT_SUBGLYPH_FLAG_2X2 ::
  4036. * FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
  4037. *
  4038. */
  4039. #define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
  4040. #define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
  4041. #define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
  4042. #define FT_SUBGLYPH_FLAG_SCALE 8
  4043. #define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
  4044. #define FT_SUBGLYPH_FLAG_2X2 0x80
  4045. #define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
  4046. /**************************************************************************
  4047. *
  4048. * @function:
  4049. * FT_Get_SubGlyph_Info
  4050. *
  4051. * @description:
  4052. * Retrieve a description of a given subglyph. Only use it if
  4053. * `glyph->format` is @FT_GLYPH_FORMAT_COMPOSITE; an error is returned
  4054. * otherwise.
  4055. *
  4056. * @input:
  4057. * glyph ::
  4058. * The source glyph slot.
  4059. *
  4060. * sub_index ::
  4061. * The index of the subglyph. Must be less than
  4062. * `glyph->num_subglyphs`.
  4063. *
  4064. * @output:
  4065. * p_index ::
  4066. * The glyph index of the subglyph.
  4067. *
  4068. * p_flags ::
  4069. * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
  4070. *
  4071. * p_arg1 ::
  4072. * The subglyph's first argument (if any).
  4073. *
  4074. * p_arg2 ::
  4075. * The subglyph's second argument (if any).
  4076. *
  4077. * p_transform ::
  4078. * The subglyph transformation (if any).
  4079. *
  4080. * @return:
  4081. * FreeType error code. 0~means success.
  4082. *
  4083. * @note:
  4084. * The values of `*p_arg1`, `*p_arg2`, and `*p_transform` must be
  4085. * interpreted depending on the flags returned in `*p_flags`. See the
  4086. * OpenType specification for details.
  4087. *
  4088. * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description
  4089. *
  4090. */
  4091. FT_EXPORT( FT_Error )
  4092. FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
  4093. FT_UInt sub_index,
  4094. FT_Int *p_index,
  4095. FT_UInt *p_flags,
  4096. FT_Int *p_arg1,
  4097. FT_Int *p_arg2,
  4098. FT_Matrix *p_transform );
  4099. /**************************************************************************
  4100. *
  4101. * @enum:
  4102. * FT_FSTYPE_XXX
  4103. *
  4104. * @description:
  4105. * A list of bit flags used in the `fsType` field of the OS/2 table in a
  4106. * TrueType or OpenType font and the `FSType` entry in a PostScript font.
  4107. * These bit flags are returned by @FT_Get_FSType_Flags; they inform
  4108. * client applications of embedding and subsetting restrictions
  4109. * associated with a font.
  4110. *
  4111. * See
  4112. * https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf
  4113. * for more details.
  4114. *
  4115. * @values:
  4116. * FT_FSTYPE_INSTALLABLE_EMBEDDING ::
  4117. * Fonts with no fsType bit set may be embedded and permanently
  4118. * installed on the remote system by an application.
  4119. *
  4120. * FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING ::
  4121. * Fonts that have only this bit set must not be modified, embedded or
  4122. * exchanged in any manner without first obtaining permission of the
  4123. * font software copyright owner.
  4124. *
  4125. * FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING ::
  4126. * The font may be embedded and temporarily loaded on the remote
  4127. * system. Documents containing Preview & Print fonts must be opened
  4128. * 'read-only'; no edits can be applied to the document.
  4129. *
  4130. * FT_FSTYPE_EDITABLE_EMBEDDING ::
  4131. * The font may be embedded but must only be installed temporarily on
  4132. * other systems. In contrast to Preview & Print fonts, documents
  4133. * containing editable fonts may be opened for reading, editing is
  4134. * permitted, and changes may be saved.
  4135. *
  4136. * FT_FSTYPE_NO_SUBSETTING ::
  4137. * The font may not be subsetted prior to embedding.
  4138. *
  4139. * FT_FSTYPE_BITMAP_EMBEDDING_ONLY ::
  4140. * Only bitmaps contained in the font may be embedded; no outline data
  4141. * may be embedded. If there are no bitmaps available in the font,
  4142. * then the font is unembeddable.
  4143. *
  4144. * @note:
  4145. * The flags are ORed together, thus more than a single value can be
  4146. * returned.
  4147. *
  4148. * While the `fsType` flags can indicate that a font may be embedded, a
  4149. * license with the font vendor may be separately required to use the
  4150. * font in this way.
  4151. */
  4152. #define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
  4153. #define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
  4154. #define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
  4155. #define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
  4156. #define FT_FSTYPE_NO_SUBSETTING 0x0100
  4157. #define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
  4158. /**************************************************************************
  4159. *
  4160. * @function:
  4161. * FT_Get_FSType_Flags
  4162. *
  4163. * @description:
  4164. * Return the `fsType` flags for a font.
  4165. *
  4166. * @input:
  4167. * face ::
  4168. * A handle to the source face object.
  4169. *
  4170. * @return:
  4171. * The `fsType` flags, see @FT_FSTYPE_XXX.
  4172. *
  4173. * @note:
  4174. * Use this function rather than directly reading the `fs_type` field in
  4175. * the @PS_FontInfoRec structure, which is only guaranteed to return the
  4176. * correct results for Type~1 fonts.
  4177. *
  4178. * @since:
  4179. * 2.3.8
  4180. *
  4181. */
  4182. FT_EXPORT( FT_UShort )
  4183. FT_Get_FSType_Flags( FT_Face face );
  4184. /**************************************************************************
  4185. *
  4186. * @section:
  4187. * glyph_variants
  4188. *
  4189. * @title:
  4190. * Unicode Variation Sequences
  4191. *
  4192. * @abstract:
  4193. * The FreeType~2 interface to Unicode Variation Sequences (UVS), using
  4194. * the SFNT cmap format~14.
  4195. *
  4196. * @description:
  4197. * Many characters, especially for CJK scripts, have variant forms. They
  4198. * are a sort of grey area somewhere between being totally irrelevant and
  4199. * semantically distinct; for this reason, the Unicode consortium decided
  4200. * to introduce Variation Sequences (VS), consisting of a Unicode base
  4201. * character and a variation selector instead of further extending the
  4202. * already huge number of characters.
  4203. *
  4204. * Unicode maintains two different sets, namely 'Standardized Variation
  4205. * Sequences' and registered 'Ideographic Variation Sequences' (IVS),
  4206. * collected in the 'Ideographic Variation Database' (IVD).
  4207. *
  4208. * https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt
  4209. * https://unicode.org/reports/tr37/ https://unicode.org/ivd/
  4210. *
  4211. * To date (January 2017), the character with the most ideographic
  4212. * variations is U+9089, having 32 such IVS.
  4213. *
  4214. * Three Mongolian Variation Selectors have the values U+180B-U+180D; 256
  4215. * generic Variation Selectors are encoded in the ranges U+FE00-U+FE0F
  4216. * and U+E0100-U+E01EF. IVS currently use Variation Selectors from the
  4217. * range U+E0100-U+E01EF only.
  4218. *
  4219. * A VS consists of the base character value followed by a single
  4220. * Variation Selector. For example, to get the first variation of
  4221. * U+9089, you have to write the character sequence `U+9089 U+E0100`.
  4222. *
  4223. * Adobe and MS decided to support both standardized and ideographic VS
  4224. * with a new cmap subtable (format~14). It is an odd subtable because
  4225. * it is not a mapping of input code points to glyphs, but contains lists
  4226. * of all variations supported by the font.
  4227. *
  4228. * A variation may be either 'default' or 'non-default' for a given font.
  4229. * A default variation is the one you will get for that code point if you
  4230. * look it up in the standard Unicode cmap. A non-default variation is a
  4231. * different glyph.
  4232. *
  4233. */
  4234. /**************************************************************************
  4235. *
  4236. * @function:
  4237. * FT_Face_GetCharVariantIndex
  4238. *
  4239. * @description:
  4240. * Return the glyph index of a given character code as modified by the
  4241. * variation selector.
  4242. *
  4243. * @input:
  4244. * face ::
  4245. * A handle to the source face object.
  4246. *
  4247. * charcode ::
  4248. * The character code point in Unicode.
  4249. *
  4250. * variantSelector ::
  4251. * The Unicode code point of the variation selector.
  4252. *
  4253. * @return:
  4254. * The glyph index. 0~means either 'undefined character code', or
  4255. * 'undefined selector code', or 'no variation selector cmap subtable',
  4256. * or 'current CharMap is not Unicode'.
  4257. *
  4258. * @note:
  4259. * If you use FreeType to manipulate the contents of font files directly,
  4260. * be aware that the glyph index returned by this function doesn't always
  4261. * correspond to the internal indices used within the file. This is done
  4262. * to ensure that value~0 always corresponds to the 'missing glyph'.
  4263. *
  4264. * This function is only meaningful if
  4265. * a) the font has a variation selector cmap sub table, and
  4266. * b) the current charmap has a Unicode encoding.
  4267. *
  4268. * @since:
  4269. * 2.3.6
  4270. *
  4271. */
  4272. FT_EXPORT( FT_UInt )
  4273. FT_Face_GetCharVariantIndex( FT_Face face,
  4274. FT_ULong charcode,
  4275. FT_ULong variantSelector );
  4276. /**************************************************************************
  4277. *
  4278. * @function:
  4279. * FT_Face_GetCharVariantIsDefault
  4280. *
  4281. * @description:
  4282. * Check whether this variation of this Unicode character is the one to
  4283. * be found in the charmap.
  4284. *
  4285. * @input:
  4286. * face ::
  4287. * A handle to the source face object.
  4288. *
  4289. * charcode ::
  4290. * The character codepoint in Unicode.
  4291. *
  4292. * variantSelector ::
  4293. * The Unicode codepoint of the variation selector.
  4294. *
  4295. * @return:
  4296. * 1~if found in the standard (Unicode) cmap, 0~if found in the variation
  4297. * selector cmap, or -1 if it is not a variation.
  4298. *
  4299. * @note:
  4300. * This function is only meaningful if the font has a variation selector
  4301. * cmap subtable.
  4302. *
  4303. * @since:
  4304. * 2.3.6
  4305. *
  4306. */
  4307. FT_EXPORT( FT_Int )
  4308. FT_Face_GetCharVariantIsDefault( FT_Face face,
  4309. FT_ULong charcode,
  4310. FT_ULong variantSelector );
  4311. /**************************************************************************
  4312. *
  4313. * @function:
  4314. * FT_Face_GetVariantSelectors
  4315. *
  4316. * @description:
  4317. * Return a zero-terminated list of Unicode variation selectors found in
  4318. * the font.
  4319. *
  4320. * @input:
  4321. * face ::
  4322. * A handle to the source face object.
  4323. *
  4324. * @return:
  4325. * A pointer to an array of selector code points, or `NULL` if there is
  4326. * no valid variation selector cmap subtable.
  4327. *
  4328. * @note:
  4329. * The last item in the array is~0; the array is owned by the @FT_Face
  4330. * object but can be overwritten or released on the next call to a
  4331. * FreeType function.
  4332. *
  4333. * @since:
  4334. * 2.3.6
  4335. *
  4336. */
  4337. FT_EXPORT( FT_UInt32* )
  4338. FT_Face_GetVariantSelectors( FT_Face face );
  4339. /**************************************************************************
  4340. *
  4341. * @function:
  4342. * FT_Face_GetVariantsOfChar
  4343. *
  4344. * @description:
  4345. * Return a zero-terminated list of Unicode variation selectors found for
  4346. * the specified character code.
  4347. *
  4348. * @input:
  4349. * face ::
  4350. * A handle to the source face object.
  4351. *
  4352. * charcode ::
  4353. * The character codepoint in Unicode.
  4354. *
  4355. * @return:
  4356. * A pointer to an array of variation selector code points that are
  4357. * active for the given character, or `NULL` if the corresponding list is
  4358. * empty.
  4359. *
  4360. * @note:
  4361. * The last item in the array is~0; the array is owned by the @FT_Face
  4362. * object but can be overwritten or released on the next call to a
  4363. * FreeType function.
  4364. *
  4365. * @since:
  4366. * 2.3.6
  4367. *
  4368. */
  4369. FT_EXPORT( FT_UInt32* )
  4370. FT_Face_GetVariantsOfChar( FT_Face face,
  4371. FT_ULong charcode );
  4372. /**************************************************************************
  4373. *
  4374. * @function:
  4375. * FT_Face_GetCharsOfVariant
  4376. *
  4377. * @description:
  4378. * Return a zero-terminated list of Unicode character codes found for the
  4379. * specified variation selector.
  4380. *
  4381. * @input:
  4382. * face ::
  4383. * A handle to the source face object.
  4384. *
  4385. * variantSelector ::
  4386. * The variation selector code point in Unicode.
  4387. *
  4388. * @return:
  4389. * A list of all the code points that are specified by this selector
  4390. * (both default and non-default codes are returned) or `NULL` if there
  4391. * is no valid cmap or the variation selector is invalid.
  4392. *
  4393. * @note:
  4394. * The last item in the array is~0; the array is owned by the @FT_Face
  4395. * object but can be overwritten or released on the next call to a
  4396. * FreeType function.
  4397. *
  4398. * @since:
  4399. * 2.3.6
  4400. *
  4401. */
  4402. FT_EXPORT( FT_UInt32* )
  4403. FT_Face_GetCharsOfVariant( FT_Face face,
  4404. FT_ULong variantSelector );
  4405. /**************************************************************************
  4406. *
  4407. * @section:
  4408. * computations
  4409. *
  4410. * @title:
  4411. * Computations
  4412. *
  4413. * @abstract:
  4414. * Crunching fixed numbers and vectors.
  4415. *
  4416. * @description:
  4417. * This section contains various functions used to perform computations
  4418. * on 16.16 fixed-point numbers or 2D vectors. FreeType does not use
  4419. * floating-point data types.
  4420. *
  4421. * **Attention**: Most arithmetic functions take `FT_Long` as arguments.
  4422. * For historical reasons, FreeType was designed under the assumption
  4423. * that `FT_Long` is a 32-bit integer; results can thus be undefined if
  4424. * the arguments don't fit into 32 bits.
  4425. *
  4426. * @order:
  4427. * FT_MulDiv
  4428. * FT_MulFix
  4429. * FT_DivFix
  4430. * FT_RoundFix
  4431. * FT_CeilFix
  4432. * FT_FloorFix
  4433. * FT_Vector_Transform
  4434. * FT_Matrix_Multiply
  4435. * FT_Matrix_Invert
  4436. *
  4437. */
  4438. /**************************************************************************
  4439. *
  4440. * @function:
  4441. * FT_MulDiv
  4442. *
  4443. * @description:
  4444. * Compute `(a*b)/c` with maximum accuracy, using a 64-bit intermediate
  4445. * integer whenever necessary.
  4446. *
  4447. * This function isn't necessarily as fast as some processor-specific
  4448. * operations, but is at least completely portable.
  4449. *
  4450. * @input:
  4451. * a ::
  4452. * The first multiplier.
  4453. *
  4454. * b ::
  4455. * The second multiplier.
  4456. *
  4457. * c ::
  4458. * The divisor.
  4459. *
  4460. * @return:
  4461. * The result of `(a*b)/c`. This function never traps when trying to
  4462. * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on
  4463. * the signs of `a` and `b`.
  4464. */
  4465. FT_EXPORT( FT_Long )
  4466. FT_MulDiv( FT_Long a,
  4467. FT_Long b,
  4468. FT_Long c );
  4469. /**************************************************************************
  4470. *
  4471. * @function:
  4472. * FT_MulFix
  4473. *
  4474. * @description:
  4475. * Compute `(a*b)/0x10000` with maximum accuracy. Its main use is to
  4476. * multiply a given value by a 16.16 fixed-point factor.
  4477. *
  4478. * @input:
  4479. * a ::
  4480. * The first multiplier.
  4481. *
  4482. * b ::
  4483. * The second multiplier. Use a 16.16 factor here whenever possible
  4484. * (see note below).
  4485. *
  4486. * @return:
  4487. * The result of `(a*b)/0x10000`.
  4488. *
  4489. * @note:
  4490. * This function has been optimized for the case where the absolute value
  4491. * of `a` is less than 2048, and `b` is a 16.16 scaling factor. As this
  4492. * happens mainly when scaling from notional units to fractional pixels
  4493. * in FreeType, it resulted in noticeable speed improvements between
  4494. * versions 2.x and 1.x.
  4495. *
  4496. * As a conclusion, always try to place a 16.16 factor as the _second_
  4497. * argument of this function; this can make a great difference.
  4498. */
  4499. FT_EXPORT( FT_Long )
  4500. FT_MulFix( FT_Long a,
  4501. FT_Long b );
  4502. /**************************************************************************
  4503. *
  4504. * @function:
  4505. * FT_DivFix
  4506. *
  4507. * @description:
  4508. * Compute `(a*0x10000)/b` with maximum accuracy. Its main use is to
  4509. * divide a given value by a 16.16 fixed-point factor.
  4510. *
  4511. * @input:
  4512. * a ::
  4513. * The numerator.
  4514. *
  4515. * b ::
  4516. * The denominator. Use a 16.16 factor here.
  4517. *
  4518. * @return:
  4519. * The result of `(a*0x10000)/b`.
  4520. */
  4521. FT_EXPORT( FT_Long )
  4522. FT_DivFix( FT_Long a,
  4523. FT_Long b );
  4524. /**************************************************************************
  4525. *
  4526. * @function:
  4527. * FT_RoundFix
  4528. *
  4529. * @description:
  4530. * Round a 16.16 fixed number.
  4531. *
  4532. * @input:
  4533. * a ::
  4534. * The number to be rounded.
  4535. *
  4536. * @return:
  4537. * `a` rounded to the nearest 16.16 fixed integer, halfway cases away
  4538. * from zero.
  4539. *
  4540. * @note:
  4541. * The function uses wrap-around arithmetic.
  4542. */
  4543. FT_EXPORT( FT_Fixed )
  4544. FT_RoundFix( FT_Fixed a );
  4545. /**************************************************************************
  4546. *
  4547. * @function:
  4548. * FT_CeilFix
  4549. *
  4550. * @description:
  4551. * Compute the smallest following integer of a 16.16 fixed number.
  4552. *
  4553. * @input:
  4554. * a ::
  4555. * The number for which the ceiling function is to be computed.
  4556. *
  4557. * @return:
  4558. * `a` rounded towards plus infinity.
  4559. *
  4560. * @note:
  4561. * The function uses wrap-around arithmetic.
  4562. */
  4563. FT_EXPORT( FT_Fixed )
  4564. FT_CeilFix( FT_Fixed a );
  4565. /**************************************************************************
  4566. *
  4567. * @function:
  4568. * FT_FloorFix
  4569. *
  4570. * @description:
  4571. * Compute the largest previous integer of a 16.16 fixed number.
  4572. *
  4573. * @input:
  4574. * a ::
  4575. * The number for which the floor function is to be computed.
  4576. *
  4577. * @return:
  4578. * `a` rounded towards minus infinity.
  4579. */
  4580. FT_EXPORT( FT_Fixed )
  4581. FT_FloorFix( FT_Fixed a );
  4582. /**************************************************************************
  4583. *
  4584. * @function:
  4585. * FT_Vector_Transform
  4586. *
  4587. * @description:
  4588. * Transform a single vector through a 2x2 matrix.
  4589. *
  4590. * @inout:
  4591. * vector ::
  4592. * The target vector to transform.
  4593. *
  4594. * @input:
  4595. * matrix ::
  4596. * A pointer to the source 2x2 matrix.
  4597. *
  4598. * @note:
  4599. * The result is undefined if either `vector` or `matrix` is invalid.
  4600. */
  4601. FT_EXPORT( void )
  4602. FT_Vector_Transform( FT_Vector* vector,
  4603. const FT_Matrix* matrix );
  4604. /**************************************************************************
  4605. *
  4606. * @section:
  4607. * version
  4608. *
  4609. * @title:
  4610. * FreeType Version
  4611. *
  4612. * @abstract:
  4613. * Functions and macros related to FreeType versions.
  4614. *
  4615. * @description:
  4616. * Note that those functions and macros are of limited use because even a
  4617. * new release of FreeType with only documentation changes increases the
  4618. * version number.
  4619. *
  4620. * @order:
  4621. * FT_Library_Version
  4622. *
  4623. * FREETYPE_MAJOR
  4624. * FREETYPE_MINOR
  4625. * FREETYPE_PATCH
  4626. *
  4627. * FT_Face_CheckTrueTypePatents
  4628. * FT_Face_SetUnpatentedHinting
  4629. *
  4630. */
  4631. /**************************************************************************
  4632. *
  4633. * @enum:
  4634. * FREETYPE_XXX
  4635. *
  4636. * @description:
  4637. * These three macros identify the FreeType source code version. Use
  4638. * @FT_Library_Version to access them at runtime.
  4639. *
  4640. * @values:
  4641. * FREETYPE_MAJOR ::
  4642. * The major version number.
  4643. * FREETYPE_MINOR ::
  4644. * The minor version number.
  4645. * FREETYPE_PATCH ::
  4646. * The patch level.
  4647. *
  4648. * @note:
  4649. * The version number of FreeType if built as a dynamic link library with
  4650. * the 'libtool' package is _not_ controlled by these three macros.
  4651. *
  4652. */
  4653. #define FREETYPE_MAJOR 2
  4654. #define FREETYPE_MINOR 13
  4655. #define FREETYPE_PATCH 0
  4656. /**************************************************************************
  4657. *
  4658. * @function:
  4659. * FT_Library_Version
  4660. *
  4661. * @description:
  4662. * Return the version of the FreeType library being used. This is useful
  4663. * when dynamically linking to the library, since one cannot use the
  4664. * macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and @FREETYPE_PATCH.
  4665. *
  4666. * @input:
  4667. * library ::
  4668. * A source library handle.
  4669. *
  4670. * @output:
  4671. * amajor ::
  4672. * The major version number.
  4673. *
  4674. * aminor ::
  4675. * The minor version number.
  4676. *
  4677. * apatch ::
  4678. * The patch version number.
  4679. *
  4680. * @note:
  4681. * The reason why this function takes a `library` argument is because
  4682. * certain programs implement library initialization in a custom way that
  4683. * doesn't use @FT_Init_FreeType.
  4684. *
  4685. * In such cases, the library version might not be available before the
  4686. * library object has been created.
  4687. */
  4688. FT_EXPORT( void )
  4689. FT_Library_Version( FT_Library library,
  4690. FT_Int *amajor,
  4691. FT_Int *aminor,
  4692. FT_Int *apatch );
  4693. /**************************************************************************
  4694. *
  4695. * @function:
  4696. * FT_Face_CheckTrueTypePatents
  4697. *
  4698. * @description:
  4699. * Deprecated, does nothing.
  4700. *
  4701. * @input:
  4702. * face ::
  4703. * A face handle.
  4704. *
  4705. * @return:
  4706. * Always returns false.
  4707. *
  4708. * @note:
  4709. * Since May 2010, TrueType hinting is no longer patented.
  4710. *
  4711. * @since:
  4712. * 2.3.5
  4713. *
  4714. */
  4715. FT_EXPORT( FT_Bool )
  4716. FT_Face_CheckTrueTypePatents( FT_Face face );
  4717. /**************************************************************************
  4718. *
  4719. * @function:
  4720. * FT_Face_SetUnpatentedHinting
  4721. *
  4722. * @description:
  4723. * Deprecated, does nothing.
  4724. *
  4725. * @input:
  4726. * face ::
  4727. * A face handle.
  4728. *
  4729. * value ::
  4730. * New boolean setting.
  4731. *
  4732. * @return:
  4733. * Always returns false.
  4734. *
  4735. * @note:
  4736. * Since May 2010, TrueType hinting is no longer patented.
  4737. *
  4738. * @since:
  4739. * 2.3.5
  4740. *
  4741. */
  4742. FT_EXPORT( FT_Bool )
  4743. FT_Face_SetUnpatentedHinting( FT_Face face,
  4744. FT_Bool value );
  4745. /* */
  4746. FT_END_HEADER
  4747. #endif /* FREETYPE_H_ */
  4748. /* END */