DWrite.h 202 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995
  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // Abstract:
  6. // DirectX Typography Services public API definitions.
  7. //
  8. //----------------------------------------------------------------------------
  9. #ifndef DWRITE_H_INCLUDED
  10. #define DWRITE_H_INCLUDED
  11. #if _MSC_VER > 1000
  12. #pragma once
  13. #endif
  14. #ifndef DWRITE_NO_WINDOWS_H
  15. #include <specstrings.h>
  16. #include <unknwn.h>
  17. #endif // DWRITE_NO_WINDOWS_H
  18. #include <dcommon.h>
  19. #ifndef DWRITE_DECLARE_INTERFACE
  20. #define DWRITE_DECLARE_INTERFACE(iid) DECLSPEC_UUID(iid) DECLSPEC_NOVTABLE
  21. #endif
  22. #ifndef DWRITE_EXPORT
  23. #define DWRITE_EXPORT __declspec(dllimport) WINAPI
  24. #endif
  25. /// <summary>
  26. /// The type of a font represented by a single font file.
  27. /// Font formats that consist of multiple files, e.g. Type 1 .PFM and .PFB, have
  28. /// separate enum values for each of the file type.
  29. /// </summary>
  30. enum DWRITE_FONT_FILE_TYPE
  31. {
  32. /// <summary>
  33. /// Font type is not recognized by the DirectWrite font system.
  34. /// </summary>
  35. DWRITE_FONT_FILE_TYPE_UNKNOWN,
  36. /// <summary>
  37. /// OpenType font with CFF outlines.
  38. /// </summary>
  39. DWRITE_FONT_FILE_TYPE_CFF,
  40. /// <summary>
  41. /// OpenType font with TrueType outlines.
  42. /// </summary>
  43. DWRITE_FONT_FILE_TYPE_TRUETYPE,
  44. /// <summary>
  45. /// OpenType font that contains a TrueType collection.
  46. /// </summary>
  47. DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION,
  48. /// <summary>
  49. /// Type 1 PFM font.
  50. /// </summary>
  51. DWRITE_FONT_FILE_TYPE_TYPE1_PFM,
  52. /// <summary>
  53. /// Type 1 PFB font.
  54. /// </summary>
  55. DWRITE_FONT_FILE_TYPE_TYPE1_PFB,
  56. /// <summary>
  57. /// Vector .FON font.
  58. /// </summary>
  59. DWRITE_FONT_FILE_TYPE_VECTOR,
  60. /// <summary>
  61. /// Bitmap .FON font.
  62. /// </summary>
  63. DWRITE_FONT_FILE_TYPE_BITMAP
  64. };
  65. /// <summary>
  66. /// The file format of a complete font face.
  67. /// Font formats that consist of multiple files, e.g. Type 1 .PFM and .PFB, have
  68. /// a single enum entry.
  69. /// </summary>
  70. enum DWRITE_FONT_FACE_TYPE
  71. {
  72. /// <summary>
  73. /// OpenType font face with CFF outlines.
  74. /// </summary>
  75. DWRITE_FONT_FACE_TYPE_CFF,
  76. /// <summary>
  77. /// OpenType font face with TrueType outlines.
  78. /// </summary>
  79. DWRITE_FONT_FACE_TYPE_TRUETYPE,
  80. /// <summary>
  81. /// OpenType font face that is a part of a TrueType collection.
  82. /// </summary>
  83. DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION,
  84. /// <summary>
  85. /// A Type 1 font face.
  86. /// </summary>
  87. DWRITE_FONT_FACE_TYPE_TYPE1,
  88. /// <summary>
  89. /// A vector .FON format font face.
  90. /// </summary>
  91. DWRITE_FONT_FACE_TYPE_VECTOR,
  92. /// <summary>
  93. /// A bitmap .FON format font face.
  94. /// </summary>
  95. DWRITE_FONT_FACE_TYPE_BITMAP,
  96. /// <summary>
  97. /// Font face type is not recognized by the DirectWrite font system.
  98. /// </summary>
  99. DWRITE_FONT_FACE_TYPE_UNKNOWN
  100. };
  101. /// <summary>
  102. /// Specifies algorithmic style simulations to be applied to the font face.
  103. /// Bold and oblique simulations can be combined via bitwise OR operation.
  104. /// </summary>
  105. enum DWRITE_FONT_SIMULATIONS
  106. {
  107. /// <summary>
  108. /// No simulations are performed.
  109. /// </summary>
  110. DWRITE_FONT_SIMULATIONS_NONE = 0x0000,
  111. /// <summary>
  112. /// Algorithmic emboldening is performed.
  113. /// </summary>
  114. DWRITE_FONT_SIMULATIONS_BOLD = 0x0001,
  115. /// <summary>
  116. /// Algorithmic italicization is performed.
  117. /// </summary>
  118. DWRITE_FONT_SIMULATIONS_OBLIQUE = 0x0002
  119. };
  120. #ifdef DEFINE_ENUM_FLAG_OPERATORS
  121. DEFINE_ENUM_FLAG_OPERATORS(DWRITE_FONT_SIMULATIONS);
  122. #endif
  123. /// <summary>
  124. /// The font weight enumeration describes common values for degree of blackness or thickness of strokes of characters in a font.
  125. /// Font weight values less than 1 or greater than 999 are considered to be invalid, and they are rejected by font API functions.
  126. /// </summary>
  127. enum DWRITE_FONT_WEIGHT
  128. {
  129. /// <summary>
  130. /// Predefined font weight : Thin (100).
  131. /// </summary>
  132. DWRITE_FONT_WEIGHT_THIN = 100,
  133. /// <summary>
  134. /// Predefined font weight : Extra-light (200).
  135. /// </summary>
  136. DWRITE_FONT_WEIGHT_EXTRA_LIGHT = 200,
  137. /// <summary>
  138. /// Predefined font weight : Ultra-light (200).
  139. /// </summary>
  140. DWRITE_FONT_WEIGHT_ULTRA_LIGHT = 200,
  141. /// <summary>
  142. /// Predefined font weight : Light (300).
  143. /// </summary>
  144. DWRITE_FONT_WEIGHT_LIGHT = 300,
  145. /// <summary>
  146. /// Predefined font weight : Normal (400).
  147. /// </summary>
  148. DWRITE_FONT_WEIGHT_NORMAL = 400,
  149. /// <summary>
  150. /// Predefined font weight : Regular (400).
  151. /// </summary>
  152. DWRITE_FONT_WEIGHT_REGULAR = 400,
  153. /// <summary>
  154. /// Predefined font weight : Medium (500).
  155. /// </summary>
  156. DWRITE_FONT_WEIGHT_MEDIUM = 500,
  157. /// <summary>
  158. /// Predefined font weight : Demi-bold (600).
  159. /// </summary>
  160. DWRITE_FONT_WEIGHT_DEMI_BOLD = 600,
  161. /// <summary>
  162. /// Predefined font weight : Semi-bold (600).
  163. /// </summary>
  164. DWRITE_FONT_WEIGHT_SEMI_BOLD = 600,
  165. /// <summary>
  166. /// Predefined font weight : Bold (700).
  167. /// </summary>
  168. DWRITE_FONT_WEIGHT_BOLD = 700,
  169. /// <summary>
  170. /// Predefined font weight : Extra-bold (800).
  171. /// </summary>
  172. DWRITE_FONT_WEIGHT_EXTRA_BOLD = 800,
  173. /// <summary>
  174. /// Predefined font weight : Ultra-bold (800).
  175. /// </summary>
  176. DWRITE_FONT_WEIGHT_ULTRA_BOLD = 800,
  177. /// <summary>
  178. /// Predefined font weight : Black (900).
  179. /// </summary>
  180. DWRITE_FONT_WEIGHT_BLACK = 900,
  181. /// <summary>
  182. /// Predefined font weight : Heavy (900).
  183. /// </summary>
  184. DWRITE_FONT_WEIGHT_HEAVY = 900,
  185. /// <summary>
  186. /// Predefined font weight : Extra-black (950).
  187. /// </summary>
  188. DWRITE_FONT_WEIGHT_EXTRA_BLACK = 950,
  189. /// <summary>
  190. /// Predefined font weight : Ultra-black (950).
  191. /// </summary>
  192. DWRITE_FONT_WEIGHT_ULTRA_BLACK = 950
  193. };
  194. /// <summary>
  195. /// The font stretch enumeration describes relative change from the normal aspect ratio
  196. /// as specified by a font designer for the glyphs in a font.
  197. /// Values less than 1 or greater than 9 are considered to be invalid, and they are rejected by font API functions.
  198. /// </summary>
  199. enum DWRITE_FONT_STRETCH
  200. {
  201. /// <summary>
  202. /// Predefined font stretch : Not known (0).
  203. /// </summary>
  204. DWRITE_FONT_STRETCH_UNDEFINED = 0,
  205. /// <summary>
  206. /// Predefined font stretch : Ultra-condensed (1).
  207. /// </summary>
  208. DWRITE_FONT_STRETCH_ULTRA_CONDENSED = 1,
  209. /// <summary>
  210. /// Predefined font stretch : Extra-condensed (2).
  211. /// </summary>
  212. DWRITE_FONT_STRETCH_EXTRA_CONDENSED = 2,
  213. /// <summary>
  214. /// Predefined font stretch : Condensed (3).
  215. /// </summary>
  216. DWRITE_FONT_STRETCH_CONDENSED = 3,
  217. /// <summary>
  218. /// Predefined font stretch : Semi-condensed (4).
  219. /// </summary>
  220. DWRITE_FONT_STRETCH_SEMI_CONDENSED = 4,
  221. /// <summary>
  222. /// Predefined font stretch : Normal (5).
  223. /// </summary>
  224. DWRITE_FONT_STRETCH_NORMAL = 5,
  225. /// <summary>
  226. /// Predefined font stretch : Medium (5).
  227. /// </summary>
  228. DWRITE_FONT_STRETCH_MEDIUM = 5,
  229. /// <summary>
  230. /// Predefined font stretch : Semi-expanded (6).
  231. /// </summary>
  232. DWRITE_FONT_STRETCH_SEMI_EXPANDED = 6,
  233. /// <summary>
  234. /// Predefined font stretch : Expanded (7).
  235. /// </summary>
  236. DWRITE_FONT_STRETCH_EXPANDED = 7,
  237. /// <summary>
  238. /// Predefined font stretch : Extra-expanded (8).
  239. /// </summary>
  240. DWRITE_FONT_STRETCH_EXTRA_EXPANDED = 8,
  241. /// <summary>
  242. /// Predefined font stretch : Ultra-expanded (9).
  243. /// </summary>
  244. DWRITE_FONT_STRETCH_ULTRA_EXPANDED = 9
  245. };
  246. /// <summary>
  247. /// The font style enumeration describes the slope style of a font face, such as Normal, Italic or Oblique.
  248. /// Values other than the ones defined in the enumeration are considered to be invalid, and they are rejected by font API functions.
  249. /// </summary>
  250. enum DWRITE_FONT_STYLE
  251. {
  252. /// <summary>
  253. /// Font slope style : Normal.
  254. /// </summary>
  255. DWRITE_FONT_STYLE_NORMAL,
  256. /// <summary>
  257. /// Font slope style : Oblique.
  258. /// </summary>
  259. DWRITE_FONT_STYLE_OBLIQUE,
  260. /// <summary>
  261. /// Font slope style : Italic.
  262. /// </summary>
  263. DWRITE_FONT_STYLE_ITALIC
  264. };
  265. /// <summary>
  266. /// The informational string enumeration identifies a string in a font.
  267. /// </summary>
  268. enum DWRITE_INFORMATIONAL_STRING_ID
  269. {
  270. /// <summary>
  271. /// Unspecified name ID.
  272. /// </summary>
  273. DWRITE_INFORMATIONAL_STRING_NONE,
  274. /// <summary>
  275. /// Copyright notice provided by the font.
  276. /// </summary>
  277. DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE,
  278. /// <summary>
  279. /// String containing a version number.
  280. /// </summary>
  281. DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS,
  282. /// <summary>
  283. /// Trademark information provided by the font.
  284. /// </summary>
  285. DWRITE_INFORMATIONAL_STRING_TRADEMARK,
  286. /// <summary>
  287. /// Name of the font manufacturer.
  288. /// </summary>
  289. DWRITE_INFORMATIONAL_STRING_MANUFACTURER,
  290. /// <summary>
  291. /// Name of the font designer.
  292. /// </summary>
  293. DWRITE_INFORMATIONAL_STRING_DESIGNER,
  294. /// <summary>
  295. /// URL of font designer (with protocol, e.g., http://, ftp://).
  296. /// </summary>
  297. DWRITE_INFORMATIONAL_STRING_DESIGNER_URL,
  298. /// <summary>
  299. /// Description of the font. Can contain revision information, usage recommendations, history, features, etc.
  300. /// </summary>
  301. DWRITE_INFORMATIONAL_STRING_DESCRIPTION,
  302. /// <summary>
  303. /// URL of font vendor (with protocol, e.g., http://, ftp://). If a unique serial number is embedded in the URL, it can be used to register the font.
  304. /// </summary>
  305. DWRITE_INFORMATIONAL_STRING_FONT_VENDOR_URL,
  306. /// <summary>
  307. /// Description of how the font may be legally used, or different example scenarios for licensed use. This field should be written in plain language, not legalese.
  308. /// </summary>
  309. DWRITE_INFORMATIONAL_STRING_LICENSE_DESCRIPTION,
  310. /// <summary>
  311. /// URL where additional licensing information can be found.
  312. /// </summary>
  313. DWRITE_INFORMATIONAL_STRING_LICENSE_INFO_URL,
  314. /// <summary>
  315. /// GDI-compatible family name. Because GDI allows a maximum of four fonts per family, fonts in the same family may have different GDI-compatible family names
  316. /// (e.g., "Arial", "Arial Narrow", "Arial Black").
  317. /// </summary>
  318. DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES,
  319. /// <summary>
  320. /// GDI-compatible subfamily name.
  321. /// </summary>
  322. DWRITE_INFORMATIONAL_STRING_WIN32_SUBFAMILY_NAMES,
  323. /// <summary>
  324. /// Family name preferred by the designer. This enables font designers to group more than four fonts in a single family without losing compatibility with
  325. /// GDI. This name is typically only present if it differs from the GDI-compatible family name.
  326. /// </summary>
  327. DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES,
  328. /// <summary>
  329. /// Subfamily name preferred by the designer. This name is typically only present if it differs from the GDI-compatible subfamily name.
  330. /// </summary>
  331. DWRITE_INFORMATIONAL_STRING_PREFERRED_SUBFAMILY_NAMES,
  332. /// <summary>
  333. /// Sample text. This can be the font name or any other text that the designer thinks is the best example to display the font in.
  334. /// </summary>
  335. DWRITE_INFORMATIONAL_STRING_SAMPLE_TEXT
  336. };
  337. /// <summary>
  338. /// The DWRITE_FONT_METRICS structure specifies the metrics of a font face that
  339. /// are applicable to all glyphs within the font face.
  340. /// </summary>
  341. struct DWRITE_FONT_METRICS
  342. {
  343. /// <summary>
  344. /// The number of font design units per em unit.
  345. /// Font files use their own coordinate system of font design units.
  346. /// A font design unit is the smallest measurable unit in the em square,
  347. /// an imaginary square that is used to size and align glyphs.
  348. /// The concept of em square is used as a reference scale factor when defining font size and device transformation semantics.
  349. /// The size of one em square is also commonly used to compute the paragraph identation value.
  350. /// </summary>
  351. UINT16 designUnitsPerEm;
  352. /// <summary>
  353. /// Ascent value of the font face in font design units.
  354. /// Ascent is the distance from the top of font character alignment box to English baseline.
  355. /// </summary>
  356. UINT16 ascent;
  357. /// <summary>
  358. /// Descent value of the font face in font design units.
  359. /// Descent is the distance from the bottom of font character alignment box to English baseline.
  360. /// </summary>
  361. UINT16 descent;
  362. /// <summary>
  363. /// Line gap in font design units.
  364. /// Recommended additional white space to add between lines to improve legibility. The recommended line spacing
  365. /// (baseline-to-baseline distance) is thus the sum of ascent, descent, and lineGap. The line gap is usually
  366. /// positive or zero but can be negative, in which case the recommended line spacing is less than the height
  367. /// of the character alignment box.
  368. /// </summary>
  369. INT16 lineGap;
  370. /// <summary>
  371. /// Cap height value of the font face in font design units.
  372. /// Cap height is the distance from English baseline to the top of a typical English capital.
  373. /// Capital "H" is often used as a reference character for the purpose of calculating the cap height value.
  374. /// </summary>
  375. UINT16 capHeight;
  376. /// <summary>
  377. /// x-height value of the font face in font design units.
  378. /// x-height is the distance from English baseline to the top of lowercase letter "x", or a similar lowercase character.
  379. /// </summary>
  380. UINT16 xHeight;
  381. /// <summary>
  382. /// The underline position value of the font face in font design units.
  383. /// Underline position is the position of underline relative to the English baseline.
  384. /// The value is usually made negative in order to place the underline below the baseline.
  385. /// </summary>
  386. INT16 underlinePosition;
  387. /// <summary>
  388. /// The suggested underline thickness value of the font face in font design units.
  389. /// </summary>
  390. UINT16 underlineThickness;
  391. /// <summary>
  392. /// The strikethrough position value of the font face in font design units.
  393. /// Strikethrough position is the position of strikethrough relative to the English baseline.
  394. /// The value is usually made positive in order to place the strikethrough above the baseline.
  395. /// </summary>
  396. INT16 strikethroughPosition;
  397. /// <summary>
  398. /// The suggested strikethrough thickness value of the font face in font design units.
  399. /// </summary>
  400. UINT16 strikethroughThickness;
  401. };
  402. /// <summary>
  403. /// The DWRITE_GLYPH_METRICS structure specifies the metrics of an individual glyph.
  404. /// The units depend on how the metrics are obtained.
  405. /// </summary>
  406. struct DWRITE_GLYPH_METRICS
  407. {
  408. /// <summary>
  409. /// Specifies the X offset from the glyph origin to the left edge of the black box.
  410. /// The glyph origin is the current horizontal writing position.
  411. /// A negative value means the black box extends to the left of the origin (often true for lowercase italic 'f').
  412. /// </summary>
  413. INT32 leftSideBearing;
  414. /// <summary>
  415. /// Specifies the X offset from the origin of the current glyph to the origin of the next glyph when writing horizontally.
  416. /// </summary>
  417. UINT32 advanceWidth;
  418. /// <summary>
  419. /// Specifies the X offset from the right edge of the black box to the origin of the next glyph when writing horizontally.
  420. /// The value is negative when the right edge of the black box overhangs the layout box.
  421. /// </summary>
  422. INT32 rightSideBearing;
  423. /// <summary>
  424. /// Specifies the vertical offset from the vertical origin to the top of the black box.
  425. /// Thus, a positive value adds whitespace whereas a negative value means the glyph overhangs the top of the layout box.
  426. /// </summary>
  427. INT32 topSideBearing;
  428. /// <summary>
  429. /// Specifies the Y offset from the vertical origin of the current glyph to the vertical origin of the next glyph when writing vertically.
  430. /// (Note that the term "origin" by itself denotes the horizontal origin. The vertical origin is different.
  431. /// Its Y coordinate is specified by verticalOriginY value,
  432. /// and its X coordinate is half the advanceWidth to the right of the horizontal origin).
  433. /// </summary>
  434. UINT32 advanceHeight;
  435. /// <summary>
  436. /// Specifies the vertical distance from the black box's bottom edge to the advance height.
  437. /// Positive when the bottom edge of the black box is within the layout box.
  438. /// Negative when the bottom edge of black box overhangs the layout box.
  439. /// </summary>
  440. INT32 bottomSideBearing;
  441. /// <summary>
  442. /// Specifies the Y coordinate of a glyph's vertical origin, in the font's design coordinate system.
  443. /// The y coordinate of a glyph's vertical origin is the sum of the glyph's top side bearing
  444. /// and the top (i.e. yMax) of the glyph's bounding box.
  445. /// </summary>
  446. INT32 verticalOriginY;
  447. };
  448. /// <summary>
  449. /// Optional adjustment to a glyph's position. An glyph offset changes the position of a glyph without affecting
  450. /// the pen position. Offsets are in logical, pre-transform units.
  451. /// </summary>
  452. struct DWRITE_GLYPH_OFFSET
  453. {
  454. /// <summary>
  455. /// Offset in the advance direction of the run. A positive advance offset moves the glyph to the right
  456. /// (in pre-transform coordinates) if the run is left-to-right or to the left if the run is right-to-left.
  457. /// </summary>
  458. FLOAT advanceOffset;
  459. /// <summary>
  460. /// Offset in the ascent direction, i.e., the direction ascenders point. A positive ascender offset moves
  461. /// the glyph up (in pre-transform coordinates).
  462. /// </summary>
  463. FLOAT ascenderOffset;
  464. };
  465. /// <summary>
  466. /// Specifies the type of DirectWrite factory object.
  467. /// DirectWrite factory contains internal state such as font loader registration and cached font data.
  468. /// In most cases it is recommended to use the shared factory object, because it allows multiple components
  469. /// that use DirectWrite to share internal DirectWrite state and reduce memory usage.
  470. /// However, there are cases when it is desirable to reduce the impact of a component,
  471. /// such as a plug-in from an untrusted source, on the rest of the process by sandboxing and isolating it
  472. /// from the rest of the process components. In such cases, it is recommended to use an isolated factory for the sandboxed
  473. /// component.
  474. /// </summary>
  475. enum DWRITE_FACTORY_TYPE
  476. {
  477. /// <summary>
  478. /// Shared factory allow for re-use of cached font data across multiple in process components.
  479. /// Such factories also take advantage of cross process font caching components for better performance.
  480. /// </summary>
  481. DWRITE_FACTORY_TYPE_SHARED,
  482. /// <summary>
  483. /// Objects created from the isolated factory do not interact with internal DirectWrite state from other components.
  484. /// </summary>
  485. DWRITE_FACTORY_TYPE_ISOLATED
  486. };
  487. // Creates an OpenType tag as a 32bit integer such that
  488. // the first character in the tag is the lowest byte,
  489. // (least significant on little endian architectures)
  490. // which can be used to compare with tags in the font file.
  491. // This macro is compatible with DWRITE_FONT_FEATURE_TAG.
  492. //
  493. // Example: DWRITE_MAKE_OPENTYPE_TAG('c','c','m','p')
  494. // Dword: 0x706D6363
  495. //
  496. #define DWRITE_MAKE_OPENTYPE_TAG(a,b,c,d) ( \
  497. (static_cast<UINT32>(static_cast<UINT8>(d)) << 24) | \
  498. (static_cast<UINT32>(static_cast<UINT8>(c)) << 16) | \
  499. (static_cast<UINT32>(static_cast<UINT8>(b)) << 8) | \
  500. static_cast<UINT32>(static_cast<UINT8>(a)))
  501. interface IDWriteFontFileStream;
  502. /// <summary>
  503. /// Font file loader interface handles loading font file resources of a particular type from a key.
  504. /// The font file loader interface is recommended to be implemented by a singleton object.
  505. /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite factory
  506. /// inside their constructors and must not unregister themselves in their destructors, because
  507. /// registration and unregistraton operations increment and decrement the object reference count respectively.
  508. /// Instead, registration and unregistration of font file loaders with DirectWrite factory should be performed
  509. /// outside of the font file loader implementation as a separate step.
  510. /// </summary>
  511. interface DWRITE_DECLARE_INTERFACE("727cad4e-d6af-4c9e-8a08-d695b11caa49") IDWriteFontFileLoader : public IUnknown
  512. {
  513. /// <summary>
  514. /// Creates a font file stream object that encapsulates an open file resource.
  515. /// The resource is closed when the last reference to fontFileStream is released.
  516. /// </summary>
  517. /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the font file resource
  518. /// within the scope of the font loader being used.</param>
  519. /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  520. /// <param name="fontFileStream">Pointer to the newly created font file stream.</param>
  521. /// <returns>
  522. /// Standard HRESULT error code.
  523. /// </returns>
  524. STDMETHOD(CreateStreamFromKey)(
  525. __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  526. UINT32 fontFileReferenceKeySize,
  527. __out IDWriteFontFileStream** fontFileStream
  528. ) PURE;
  529. };
  530. /// <summary>
  531. /// A built-in implementation of IDWriteFontFileLoader interface that operates on local font files
  532. /// and exposes local font file information from the font file reference key.
  533. /// Font file references created using CreateFontFileReference use this font file loader.
  534. /// </summary>
  535. interface DWRITE_DECLARE_INTERFACE("b2d9f3ec-c9fe-4a11-a2ec-d86208f7c0a2") IDWriteLocalFontFileLoader : public IDWriteFontFileLoader
  536. {
  537. /// <summary>
  538. /// Obtains the length of the absolute file path from the font file reference key.
  539. /// </summary>
  540. /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file
  541. /// within the scope of the font loader being used.</param>
  542. /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  543. /// <param name="filePathLength">Length of the file path string not including the terminated NULL character.</param>
  544. /// <returns>
  545. /// Standard HRESULT error code.
  546. /// </returns>
  547. STDMETHOD(GetFilePathLengthFromKey)(
  548. __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  549. UINT32 fontFileReferenceKeySize,
  550. __out UINT32* filePathLength
  551. ) PURE;
  552. /// <summary>
  553. /// Obtains the absolute font file path from the font file reference key.
  554. /// </summary>
  555. /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file
  556. /// within the scope of the font loader being used.</param>
  557. /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  558. /// <param name="filePath">Character array that receives the local file path.</param>
  559. /// <param name="filePathSize">Size of the filePath array in character count including the terminated NULL character.</param>
  560. /// <returns>
  561. /// Standard HRESULT error code.
  562. /// </returns>
  563. STDMETHOD(GetFilePathFromKey)(
  564. __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  565. UINT32 fontFileReferenceKeySize,
  566. __out_ecount_z(filePathSize) WCHAR* filePath,
  567. UINT32 filePathSize
  568. ) PURE;
  569. /// <summary>
  570. /// Obtains the last write time of the file from the font file reference key.
  571. /// </summary>
  572. /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the local font file
  573. /// within the scope of the font loader being used.</param>
  574. /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  575. /// <param name="lastWriteTime">Last modified time of the font file.</param>
  576. /// <returns>
  577. /// Standard HRESULT error code.
  578. /// </returns>
  579. STDMETHOD(GetLastWriteTimeFromKey)(
  580. __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  581. UINT32 fontFileReferenceKeySize,
  582. __out FILETIME* lastWriteTime
  583. ) PURE;
  584. };
  585. /// <summary>
  586. /// The interface for loading font file data.
  587. /// </summary>
  588. interface DWRITE_DECLARE_INTERFACE("6d4865fe-0ab8-4d91-8f62-5dd6be34a3e0") IDWriteFontFileStream : public IUnknown
  589. {
  590. /// <summary>
  591. /// Reads a fragment from a file.
  592. /// </summary>
  593. /// <param name="fragmentStart">Receives the pointer to the start of the font file fragment.</param>
  594. /// <param name="fileOffset">Offset of the fragment from the beginning of the font file.</param>
  595. /// <param name="fragmentSize">Size of the fragment in bytes.</param>
  596. /// <param name="fragmentContext">The client defined context to be passed to the ReleaseFileFragment.</param>
  597. /// <returns>
  598. /// Standard HRESULT error code.
  599. /// </returns>
  600. /// <remarks>
  601. /// IMPORTANT: ReadFileFragment() implementations must check whether the requested file fragment
  602. /// is within the file bounds. Otherwise, an error should be returned from ReadFileFragment.
  603. /// </remarks>
  604. STDMETHOD(ReadFileFragment)(
  605. __deref_out_bcount(fragmentSize) void const** fragmentStart,
  606. UINT64 fileOffset,
  607. UINT64 fragmentSize,
  608. __out void** fragmentContext
  609. ) PURE;
  610. /// <summary>
  611. /// Releases a fragment from a file.
  612. /// </summary>
  613. /// <param name="fragmentContext">The client defined context of a font fragment returned from ReadFileFragment.</param>
  614. STDMETHOD_(void, ReleaseFileFragment)(
  615. void* fragmentContext
  616. ) PURE;
  617. /// <summary>
  618. /// Obtains the total size of a file.
  619. /// </summary>
  620. /// <param name="fileSize">Receives the total size of the file.</param>
  621. /// <returns>
  622. /// Standard HRESULT error code.
  623. /// </returns>
  624. /// <remarks>
  625. /// Implementing GetFileSize() for asynchronously loaded font files may require
  626. /// downloading the complete file contents, therefore this method should only be used for operations that
  627. /// either require complete font file to be loaded (e.g., copying a font file) or need to make
  628. /// decisions based on the value of the file size (e.g., validation against a persisted file size).
  629. /// </remarks>
  630. STDMETHOD(GetFileSize)(
  631. __out UINT64* fileSize
  632. ) PURE;
  633. /// <summary>
  634. /// Obtains the last modified time of the file. The last modified time is used by DirectWrite font selection algorithms
  635. /// to determine whether one font resource is more up to date than another one.
  636. /// </summary>
  637. /// <param name="lastWriteTime">Receives the last modifed time of the file in the format that represents
  638. /// the number of 100-nanosecond intervals since January 1, 1601 (UTC).</param>
  639. /// <returns>
  640. /// Standard HRESULT error code. For resources that don't have a concept of the last modified time, the implementation of
  641. /// GetLastWriteTime should return E_NOTIMPL.
  642. /// </returns>
  643. STDMETHOD(GetLastWriteTime)(
  644. __out UINT64* lastWriteTime
  645. ) PURE;
  646. };
  647. /// <summary>
  648. /// The interface that represents a reference to a font file.
  649. /// </summary>
  650. interface DWRITE_DECLARE_INTERFACE("739d886a-cef5-47dc-8769-1a8b41bebbb0") IDWriteFontFile : public IUnknown
  651. {
  652. /// <summary>
  653. /// This method obtains the pointer to the reference key of a font file. The pointer is only valid until the object that refers to it is released.
  654. /// </summary>
  655. /// <param name="fontFileReferenceKey">Pointer to the font file reference key.
  656. /// IMPORTANT: The pointer value is valid until the font file reference object it is obtained from is released.</param>
  657. /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  658. /// <returns>
  659. /// Standard HRESULT error code.
  660. /// </returns>
  661. STDMETHOD(GetReferenceKey)(
  662. __deref_out_bcount(*fontFileReferenceKeySize) void const** fontFileReferenceKey,
  663. __out UINT32* fontFileReferenceKeySize
  664. ) PURE;
  665. /// <summary>
  666. /// Obtains the file loader associated with a font file object.
  667. /// </summary>
  668. /// <param name="fontFileLoader">The font file loader associated with the font file object.</param>
  669. /// <returns>
  670. /// Standard HRESULT error code.
  671. /// </returns>
  672. STDMETHOD(GetLoader)(
  673. __out IDWriteFontFileLoader** fontFileLoader
  674. ) PURE;
  675. /// <summary>
  676. /// Analyzes a file and returns whether it represents a font, and whether the font type is supported by the font system.
  677. /// </summary>
  678. /// <param name="isSupportedFontType">TRUE if the font type is supported by the font system, FALSE otherwise.</param>
  679. /// <param name="fontFileType">The type of the font file. Note that even if isSupportedFontType is FALSE,
  680. /// the fontFileType value may be different from DWRITE_FONT_FILE_TYPE_UNKNOWN.</param>
  681. /// <param name="fontFaceType">The type of the font face that can be constructed from the font file.
  682. /// Note that even if isSupportedFontType is FALSE, the fontFaceType value may be different from
  683. /// DWRITE_FONT_FACE_TYPE_UNKNOWN.</param>
  684. /// <param name="numberOfFaces">Number of font faces contained in the font file.</param>
  685. /// <returns>
  686. /// Standard HRESULT error code if there was a processing error during analysis.
  687. /// </returns>
  688. /// <remarks>
  689. /// IMPORTANT: certain font file types are recognized, but not supported by the font system.
  690. /// For example, the font system will recognize a file as a Type 1 font file,
  691. /// but will not be able to construct a font face object from it. In such situations, Analyze will set
  692. /// isSupportedFontType output parameter to FALSE.
  693. /// </remarks>
  694. STDMETHOD(Analyze)(
  695. __out BOOL* isSupportedFontType,
  696. __out DWRITE_FONT_FILE_TYPE* fontFileType,
  697. __out_opt DWRITE_FONT_FACE_TYPE* fontFaceType,
  698. __out UINT32* numberOfFaces
  699. ) PURE;
  700. };
  701. /// <summary>
  702. /// Represents the internal structure of a device pixel (i.e., the physical arrangement of red,
  703. /// green, and blue color components) that is assumed for purposes of rendering text.
  704. /// </summary>
  705. #ifndef DWRITE_PIXEL_GEOMETRY_DEFINED
  706. enum DWRITE_PIXEL_GEOMETRY
  707. {
  708. /// <summary>
  709. /// The red, green, and blue color components of each pixel are assumed to occupy the same point.
  710. /// </summary>
  711. DWRITE_PIXEL_GEOMETRY_FLAT,
  712. /// <summary>
  713. /// Each pixel comprises three vertical stripes, with red on the left, green in the center, and
  714. /// blue on the right. This is the most common pixel geometry for LCD monitors.
  715. /// </summary>
  716. DWRITE_PIXEL_GEOMETRY_RGB,
  717. /// <summary>
  718. /// Each pixel comprises three vertical stripes, with blue on the left, green in the center, and
  719. /// red on the right.
  720. /// </summary>
  721. DWRITE_PIXEL_GEOMETRY_BGR
  722. };
  723. #define DWRITE_PIXEL_GEOMETRY_DEFINED
  724. #endif
  725. /// <summary>
  726. /// Represents a method of rendering glyphs.
  727. /// </summary>
  728. enum DWRITE_RENDERING_MODE
  729. {
  730. /// <summary>
  731. /// Specifies that the rendering mode is determined automatically based on the font and size.
  732. /// </summary>
  733. DWRITE_RENDERING_MODE_DEFAULT,
  734. /// <summary>
  735. /// Specifies that no anti-aliasing is performed. Each pixel is either set to the foreground
  736. /// color of the text or retains the color of the background.
  737. /// </summary>
  738. DWRITE_RENDERING_MODE_ALIASED,
  739. /// <summary>
  740. /// Specifies ClearType rendering with the same metrics as aliased text. Glyphs can only
  741. /// be positioned on whole-pixel boundaries.
  742. /// </summary>
  743. DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC,
  744. /// <summary>
  745. /// Specifies ClearType rendering with the same metrics as text rendering using GDI using a font
  746. /// created with CLEARTYPE_NATURAL_QUALITY. Glyph metrics are closer to their ideal values than
  747. /// with aliased text, but glyphs are still positioned on whole-pixel boundaries.
  748. /// </summary>
  749. DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL,
  750. /// <summary>
  751. /// Specifies ClearType rendering with anti-aliasing in the horizontal dimension only. This is
  752. /// typically used with small to medium font sizes (up to 16 ppem).
  753. /// </summary>
  754. DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL,
  755. /// <summary>
  756. /// Specifies ClearType rendering with anti-aliasing in both horizontal and vertical dimensions.
  757. /// This is typically used at larger sizes to makes curves and diagonal lines look smoother, at
  758. /// the expense of some softness.
  759. /// </summary>
  760. DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC,
  761. /// <summary>
  762. /// Specifies that rendering should bypass the rasterizer and use the outlines directly. This is
  763. /// typically used at very large sizes.
  764. /// </summary>
  765. DWRITE_RENDERING_MODE_OUTLINE
  766. };
  767. /// <summary>
  768. /// The DWRITE_MATRIX structure specifies the graphics transform to be applied
  769. /// to rendered glyphs.
  770. /// </summary>
  771. struct DWRITE_MATRIX
  772. {
  773. /// <summary>
  774. /// Horizontal scaling / cosine of rotation
  775. /// </summary>
  776. FLOAT m11;
  777. /// <summary>
  778. /// Vertical shear / sine of rotation
  779. /// </summary>
  780. FLOAT m12;
  781. /// <summary>
  782. /// Horizontal shear / negative sine of rotation
  783. /// </summary>
  784. FLOAT m21;
  785. /// <summary>
  786. /// Vertical scaling / cosine of rotation
  787. /// </summary>
  788. FLOAT m22;
  789. /// <summary>
  790. /// Horizontal shift (always orthogonal regardless of rotation)
  791. /// </summary>
  792. FLOAT dx;
  793. /// <summary>
  794. /// Vertical shift (always orthogonal regardless of rotation)
  795. /// </summary>
  796. FLOAT dy;
  797. };
  798. /// <summary>
  799. /// The interface that represents text rendering settings for glyph rasterization and filtering.
  800. /// </summary>
  801. interface DWRITE_DECLARE_INTERFACE("2f0da53a-2add-47cd-82ee-d9ec34688e75") IDWriteRenderingParams : public IUnknown
  802. {
  803. /// <summary>
  804. /// Gets the gamma value used for gamma correction. Valid values must be
  805. /// greater than zero and cannot exceed 256.
  806. /// </summary>
  807. STDMETHOD_(FLOAT, GetGamma)() PURE;
  808. /// <summary>
  809. /// Gets the amount of contrast enhancement. Valid values are greater than
  810. /// or equal to zero.
  811. /// </summary>
  812. STDMETHOD_(FLOAT, GetEnhancedContrast)() PURE;
  813. /// <summary>
  814. /// Gets the ClearType level. Valid values range from 0.0f (no ClearType)
  815. /// to 1.0f (full ClearType).
  816. /// </summary>
  817. STDMETHOD_(FLOAT, GetClearTypeLevel)() PURE;
  818. /// <summary>
  819. /// Gets the pixel geometry.
  820. /// </summary>
  821. STDMETHOD_(DWRITE_PIXEL_GEOMETRY, GetPixelGeometry)() PURE;
  822. /// <summary>
  823. /// Gets the rendering mode.
  824. /// </summary>
  825. STDMETHOD_(DWRITE_RENDERING_MODE, GetRenderingMode)() PURE;
  826. };
  827. // Forward declarations of D2D types
  828. interface ID2D1SimplifiedGeometrySink;
  829. typedef ID2D1SimplifiedGeometrySink IDWriteGeometrySink;
  830. /// <summary>
  831. /// The interface that represents an absolute reference to a font face.
  832. /// It contains font face type, appropriate file references and face identification data.
  833. /// Various font data such as metrics, names and glyph outlines is obtained from IDWriteFontFace.
  834. /// </summary>
  835. interface DWRITE_DECLARE_INTERFACE("5f49804d-7024-4d43-bfa9-d25984f53849") IDWriteFontFace : public IUnknown
  836. {
  837. /// <summary>
  838. /// Obtains the file format type of a font face.
  839. /// </summary>
  840. STDMETHOD_(DWRITE_FONT_FACE_TYPE, GetType)() PURE;
  841. /// <summary>
  842. /// Obtains the font files representing a font face.
  843. /// </summary>
  844. /// <param name="numberOfFiles">The number of files representing the font face.</param>
  845. /// <param name="fontFiles">User provided array that stores pointers to font files representing the font face.
  846. /// This parameter can be NULL if the user is only interested in the number of files representing the font face.
  847. /// This API increments reference count of the font file pointers returned according to COM conventions, and the client
  848. /// should release them when finished.</param>
  849. /// <returns>
  850. /// Standard HRESULT error code.
  851. /// </returns>
  852. STDMETHOD(GetFiles)(
  853. __inout UINT32* numberOfFiles,
  854. __out_ecount_opt(*numberOfFiles) IDWriteFontFile** fontFiles
  855. ) PURE;
  856. /// <summary>
  857. /// Obtains the zero-based index of the font face in its font file or files. If the font files contain a single face,
  858. /// the return value is zero.
  859. /// </summary>
  860. STDMETHOD_(UINT32, GetIndex)() PURE;
  861. /// <summary>
  862. /// Obtains the algorithmic style simulation flags of a font face.
  863. /// </summary>
  864. STDMETHOD_(DWRITE_FONT_SIMULATIONS, GetSimulations)() PURE;
  865. /// <summary>
  866. /// Determines whether the font is a symbol font.
  867. /// </summary>
  868. STDMETHOD_(BOOL, IsSymbolFont)() PURE;
  869. /// <summary>
  870. /// Obtains design units and common metrics for the font face.
  871. /// These metrics are applicable to all the glyphs within a fontface and are used by applications for layout calculations.
  872. /// </summary>
  873. /// <param name="fontFaceMetrics">Points to a DWRITE_FONT_METRICS structure to fill in.
  874. /// The metrics returned by this function are in font design units.</param>
  875. STDMETHOD_(void, GetMetrics)(
  876. __out DWRITE_FONT_METRICS* fontFaceMetrics
  877. ) PURE;
  878. /// <summary>
  879. /// Obtains the number of glyphs in the font face.
  880. /// </summary>
  881. STDMETHOD_(UINT16, GetGlyphCount)() PURE;
  882. /// <summary>
  883. /// Obtains ideal glyph metrics in font design units. Design glyphs metrics are used for glyph positioning.
  884. /// </summary>
  885. /// <param name="glyphIndices">An array of glyph indices to compute the metrics for.</param>
  886. /// <param name="glyphCount">The number of elements in the glyphIndices array.</param>
  887. /// <param name="glyphMetrics">Array of DWRITE_GLYPH_METRICS structures filled by this function.
  888. /// The metrics returned by this function are in font design units.</param>
  889. /// <param name="isSideways">Indicates whether the font is being used in a sideways run.
  890. /// This can affect the glyph metrics if the font has oblique simulation
  891. /// because sideways oblique simulation differs from non-sideways oblique simulation.</param>
  892. /// <returns>
  893. /// Standard HRESULT error code. If any of the input glyph indices are outside of the valid glyph index range
  894. /// for the current font face, E_INVALIDARG will be returned.
  895. /// </returns>
  896. STDMETHOD(GetDesignGlyphMetrics)(
  897. __in_ecount(glyphCount) UINT16 const* glyphIndices,
  898. UINT32 glyphCount,
  899. __out_ecount(glyphCount) DWRITE_GLYPH_METRICS* glyphMetrics,
  900. BOOL isSideways = FALSE
  901. ) PURE;
  902. /// <summary>
  903. /// Returns the nominal mapping of UCS4 Unicode code points to glyph indices as defined by the font 'CMAP' table.
  904. /// Note that this mapping is primarily provided for line layout engines built on top of the physical font API.
  905. /// Because of OpenType glyph substitution and line layout character substitution, the nominal conversion does not always correspond
  906. /// to how a Unicode string will map to glyph indices when rendering using a particular font face.
  907. /// Also, note that Unicode Variant Selectors provide for alternate mappings for character to glyph.
  908. /// This call will always return the default variant.
  909. /// </summary>
  910. /// <param name="codePoints">An array of USC4 code points to obtain nominal glyph indices from.</param>
  911. /// <param name="codePointCount">The number of elements in the codePoints array.</param>
  912. /// <param name="glyphIndices">Array of nominal glyph indices filled by this function.</param>
  913. /// <returns>
  914. /// Standard HRESULT error code.
  915. /// </returns>
  916. STDMETHOD(GetGlyphIndices)(
  917. __in_ecount(codePointCount) UINT32 const* codePoints,
  918. UINT32 codePointCount,
  919. __out_ecount(codePointCount) UINT16* glyphIndices
  920. ) PURE;
  921. /// <summary>
  922. /// Finds the specified OpenType font table if it exists and returns a pointer to it.
  923. /// The function accesses the underling font data via the IDWriteFontStream interface
  924. /// implemented by the font file loader.
  925. /// </summary>
  926. /// <param name="openTypeTableTag">Four character tag of table to find.
  927. /// Use the DWRITE_MAKE_OPENTYPE_TAG() macro to create it.
  928. /// Unlike GDI, it does not support the special TTCF and null tags to access the whole font.</param>
  929. /// <param name="tableData">
  930. /// Pointer to base of table in memory.
  931. /// The pointer is only valid so long as the FontFace used to get the font table still exists
  932. /// (not any other FontFace, even if it actually refers to the same physical font).
  933. /// </param>
  934. /// <param name="tableSize">Byte size of table.</param>
  935. /// <param name="tableContext">
  936. /// Opaque context which must be freed by calling ReleaseFontTable.
  937. /// The context actually comes from the lower level IDWriteFontFileStream,
  938. /// which may be implemented by the application or DWrite itself.
  939. /// It is possible for a NULL tableContext to be returned, especially if
  940. /// the implementation directly memory maps the whole file.
  941. /// Nevertheless, always release it later, and do not use it as a test for function success.
  942. /// The same table can be queried multiple times,
  943. /// but each returned context can be different, so release each separately.
  944. /// </param>
  945. /// <param name="exists">True if table exists.</param>
  946. /// <returns>
  947. /// Standard HRESULT error code.
  948. /// If a table can not be found, the function will not return an error, but the size will be 0, table NULL, and exists = FALSE.
  949. /// The context does not need to be freed if the table was not found.
  950. /// </returns>
  951. /// <remarks>
  952. /// The context for the same tag may be different for each call,
  953. /// so each one must be held and released separately.
  954. /// </remarks>
  955. STDMETHOD(TryGetFontTable)(
  956. __in UINT32 openTypeTableTag,
  957. __deref_out_bcount(*tableSize) const void** tableData,
  958. __out UINT32* tableSize,
  959. __out void** tableContext,
  960. __out BOOL* exists
  961. ) PURE;
  962. /// <summary>
  963. /// Releases the table obtained earlier from TryGetFontTable.
  964. /// </summary>
  965. /// <param name="tableContext">Opaque context from TryGetFontTable.</param>
  966. /// <returns>
  967. /// Standard HRESULT error code.
  968. /// </returns>
  969. STDMETHOD_(void, ReleaseFontTable)(
  970. __in void* tableContext
  971. ) PURE;
  972. /// <summary>
  973. /// Computes the outline of a run of glyphs by calling back to the outline sink interface.
  974. /// </summary>
  975. /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  976. /// <param name="glyphIndices">Array of glyph indices.</param>
  977. /// <param name="glyphAdvances">Optional array of glyph advances in DIPs.</param>
  978. /// <param name="glyphOffsets">Optional array of glyph offsets.</param>
  979. /// <param name="glyphCount">Number of glyphs.</param>
  980. /// <param name="isSideways">If true, specifies that glyphs are rotated 90 degrees to the left and vertical metrics are used.
  981. /// A client can render a vertical run by specifying isSideways = true and rotating the resulting geometry 90 degrees to the
  982. /// right using a transform. The isSideways and isRightToLeft parameters cannot both be true.</param>
  983. /// <param name="isRightToLeft">If true, specifies that the advance direction is right to left. By default, the advance direction
  984. /// is left to right.</param>
  985. /// <param name="geometrySink">Interface the function calls back to draw each element of the geometry.</param>
  986. /// <returns>
  987. /// Standard HRESULT error code.
  988. /// </returns>
  989. STDMETHOD(GetGlyphRunOutline)(
  990. FLOAT emSize,
  991. __in_ecount(glyphCount) UINT16 const* glyphIndices,
  992. __in_ecount_opt(glyphCount) FLOAT const* glyphAdvances,
  993. __in_ecount_opt(glyphCount) DWRITE_GLYPH_OFFSET const* glyphOffsets,
  994. UINT32 glyphCount,
  995. BOOL isSideways,
  996. BOOL isRightToLeft,
  997. IDWriteGeometrySink* geometrySink
  998. ) PURE;
  999. /// <summary>
  1000. /// Determines the recommended rendering mode for the font given the specified size and rendering parameters.
  1001. /// </summary>
  1002. /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  1003. /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this
  1004. /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param>
  1005. /// <param name="measuringMode">Specifies measuring method that will be used for glyphs in the font.
  1006. /// Renderer implementations may choose different rendering modes for given measuring methods, but
  1007. /// best results are seen when the corresponding modes match:
  1008. /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL
  1009. /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC
  1010. /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL
  1011. /// </param>
  1012. /// <param name="renderingParams">Rendering parameters object. This parameter is necessary in case the rendering parameters
  1013. /// object overrides the rendering mode.</param>
  1014. /// <param name="renderingMode">Receives the recommended rendering mode to use.</param>
  1015. /// <returns>
  1016. /// Standard HRESULT error code.
  1017. /// </returns>
  1018. STDMETHOD(GetRecommendedRenderingMode)(
  1019. FLOAT emSize,
  1020. FLOAT pixelsPerDip,
  1021. DWRITE_MEASURING_MODE measuringMode,
  1022. IDWriteRenderingParams* renderingParams,
  1023. __out DWRITE_RENDERING_MODE* renderingMode
  1024. ) PURE;
  1025. /// <summary>
  1026. /// Obtains design units and common metrics for the font face.
  1027. /// These metrics are applicable to all the glyphs within a fontface and are used by applications for layout calculations.
  1028. /// </summary>
  1029. /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  1030. /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this
  1031. /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param>
  1032. /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  1033. /// scaling specified by the font size and pixelsPerDip.</param>
  1034. /// <param name="fontFaceMetrics">Points to a DWRITE_FONT_METRICS structure to fill in.
  1035. /// The metrics returned by this function are in font design units.</param>
  1036. STDMETHOD(GetGdiCompatibleMetrics)(
  1037. FLOAT emSize,
  1038. FLOAT pixelsPerDip,
  1039. __in_opt DWRITE_MATRIX const* transform,
  1040. __out DWRITE_FONT_METRICS* fontFaceMetrics
  1041. ) PURE;
  1042. /// <summary>
  1043. /// Obtains glyph metrics in font design units with the return values compatible with what GDI would produce.
  1044. /// Glyphs metrics are used for positioning of individual glyphs.
  1045. /// </summary>
  1046. /// <param name="emSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  1047. /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this
  1048. /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param>
  1049. /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  1050. /// scaling specified by the font size and pixelsPerDip.</param>
  1051. /// <param name="useGdiNatural">
  1052. /// When set to FALSE, the metrics are the same as the metrics of GDI aliased text.
  1053. /// When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font
  1054. /// created with CLEARTYPE_NATURAL_QUALITY.
  1055. /// </param>
  1056. /// <param name="glyphIndices">An array of glyph indices to compute the metrics for.</param>
  1057. /// <param name="glyphCount">The number of elements in the glyphIndices array.</param>
  1058. /// <param name="glyphMetrics">Array of DWRITE_GLYPH_METRICS structures filled by this function.
  1059. /// The metrics returned by this function are in font design units.</param>
  1060. /// <param name="isSideways">Indicates whether the font is being used in a sideways run.
  1061. /// This can affect the glyph metrics if the font has oblique simulation
  1062. /// because sideways oblique simulation differs from non-sideways oblique simulation.</param>
  1063. /// <returns>
  1064. /// Standard HRESULT error code. If any of the input glyph indices are outside of the valid glyph index range
  1065. /// for the current font face, E_INVALIDARG will be returned.
  1066. /// </returns>
  1067. STDMETHOD(GetGdiCompatibleGlyphMetrics)(
  1068. FLOAT emSize,
  1069. FLOAT pixelsPerDip,
  1070. __in_opt DWRITE_MATRIX const* transform,
  1071. BOOL useGdiNatural,
  1072. __in_ecount(glyphCount) UINT16 const* glyphIndices,
  1073. UINT32 glyphCount,
  1074. __out_ecount(glyphCount) DWRITE_GLYPH_METRICS* glyphMetrics,
  1075. BOOL isSideways = FALSE
  1076. ) PURE;
  1077. };
  1078. interface IDWriteFactory;
  1079. interface IDWriteFontFileEnumerator;
  1080. /// <summary>
  1081. /// The font collection loader interface is used to construct a collection of fonts given a particular type of key.
  1082. /// The font collection loader interface is recommended to be implemented by a singleton object.
  1083. /// IMPORTANT: font collection loader implementations must not register themselves with a DirectWrite factory
  1084. /// inside their constructors and must not unregister themselves in their destructors, because
  1085. /// registration and unregistraton operations increment and decrement the object reference count respectively.
  1086. /// Instead, registration and unregistration of font file loaders with DirectWrite factory should be performed
  1087. /// outside of the font file loader implementation as a separate step.
  1088. /// </summary>
  1089. interface DWRITE_DECLARE_INTERFACE("cca920e4-52f0-492b-bfa8-29c72ee0a468") IDWriteFontCollectionLoader : public IUnknown
  1090. {
  1091. /// <summary>
  1092. /// Creates a font file enumerator object that encapsulates a collection of font files.
  1093. /// The font system calls back to this interface to create a font collection.
  1094. /// </summary>
  1095. /// <param name="factory">Factory associated with the loader.</param>
  1096. /// <param name="collectionKey">Font collection key that uniquely identifies the collection of font files within
  1097. /// the scope of the font collection loader being used.</param>
  1098. /// <param name="collectionKeySize">Size of the font collection key in bytes.</param>
  1099. /// <param name="fontFileEnumerator">Pointer to the newly created font file enumerator.</param>
  1100. /// <returns>
  1101. /// Standard HRESULT error code.
  1102. /// </returns>
  1103. STDMETHOD(CreateEnumeratorFromKey)(
  1104. IDWriteFactory* factory,
  1105. __in_bcount(collectionKeySize) void const* collectionKey,
  1106. UINT32 collectionKeySize,
  1107. __out IDWriteFontFileEnumerator** fontFileEnumerator
  1108. ) PURE;
  1109. };
  1110. /// <summary>
  1111. /// The font file enumerator interface encapsulates a collection of font files. The font system uses this interface
  1112. /// to enumerate font files when building a font collection.
  1113. /// </summary>
  1114. interface DWRITE_DECLARE_INTERFACE("72755049-5ff7-435d-8348-4be97cfa6c7c") IDWriteFontFileEnumerator : public IUnknown
  1115. {
  1116. /// <summary>
  1117. /// Advances to the next font file in the collection. When it is first created, the enumerator is positioned
  1118. /// before the first element of the collection and the first call to MoveNext advances to the first file.
  1119. /// </summary>
  1120. /// <param name="hasCurrentFile">Receives the value TRUE if the enumerator advances to a file, or FALSE if
  1121. /// the enumerator advanced past the last file in the collection.</param>
  1122. /// <returns>
  1123. /// Standard HRESULT error code.
  1124. /// </returns>
  1125. STDMETHOD(MoveNext)(
  1126. __out BOOL* hasCurrentFile
  1127. ) PURE;
  1128. /// <summary>
  1129. /// Gets a reference to the current font file.
  1130. /// </summary>
  1131. /// <param name="fontFile">Pointer to the newly created font file object.</param>
  1132. /// <returns>
  1133. /// Standard HRESULT error code.
  1134. /// </returns>
  1135. STDMETHOD(GetCurrentFontFile)(
  1136. __out IDWriteFontFile** fontFile
  1137. ) PURE;
  1138. };
  1139. /// <summary>
  1140. /// Represents a collection of strings indexed by locale name.
  1141. /// </summary>
  1142. interface DWRITE_DECLARE_INTERFACE("08256209-099a-4b34-b86d-c22b110e7771") IDWriteLocalizedStrings : public IUnknown
  1143. {
  1144. /// <summary>
  1145. /// Gets the number of language/string pairs.
  1146. /// </summary>
  1147. STDMETHOD_(UINT32, GetCount)() PURE;
  1148. /// <summary>
  1149. /// Gets the index of the item with the specified locale name.
  1150. /// </summary>
  1151. /// <param name="localeName">Locale name to look for.</param>
  1152. /// <param name="index">Receives the zero-based index of the locale name/string pair.</param>
  1153. /// <param name="exists">Receives TRUE if the locale name exists or FALSE if not.</param>
  1154. /// <returns>
  1155. /// Standard HRESULT error code. If the specified locale name does not exist, the return value is S_OK,
  1156. /// but *index is UINT_MAX and *exists is FALSE.
  1157. /// </returns>
  1158. STDMETHOD(FindLocaleName)(
  1159. __in_z WCHAR const* localeName,
  1160. __out UINT32* index,
  1161. __out BOOL* exists
  1162. ) PURE;
  1163. /// <summary>
  1164. /// Gets the length in characters (not including the null terminator) of the locale name with the specified index.
  1165. /// </summary>
  1166. /// <param name="index">Zero-based index of the locale name.</param>
  1167. /// <param name="length">Receives the length in characters, not including the null terminator.</param>
  1168. /// <returns>
  1169. /// Standard HRESULT error code.
  1170. /// </returns>
  1171. STDMETHOD(GetLocaleNameLength)(
  1172. UINT32 index,
  1173. __out UINT32* length
  1174. ) PURE;
  1175. /// <summary>
  1176. /// Copies the locale name with the specified index to the specified array.
  1177. /// </summary>
  1178. /// <param name="index">Zero-based index of the locale name.</param>
  1179. /// <param name="localeName">Character array that receives the locale name.</param>
  1180. /// <param name="size">Size of the array in characters. The size must include space for the terminating
  1181. /// null character.</param>
  1182. /// <returns>
  1183. /// Standard HRESULT error code.
  1184. /// </returns>
  1185. STDMETHOD(GetLocaleName)(
  1186. UINT32 index,
  1187. __out_ecount_z(size) WCHAR* localeName,
  1188. UINT32 size
  1189. ) PURE;
  1190. /// <summary>
  1191. /// Gets the length in characters (not including the null terminator) of the string with the specified index.
  1192. /// </summary>
  1193. /// <param name="index">Zero-based index of the string.</param>
  1194. /// <param name="length">Receives the length in characters, not including the null terminator.</param>
  1195. /// <returns>
  1196. /// Standard HRESULT error code.
  1197. /// </returns>
  1198. STDMETHOD(GetStringLength)(
  1199. UINT32 index,
  1200. __out UINT32* length
  1201. ) PURE;
  1202. /// <summary>
  1203. /// Copies the string with the specified index to the specified array.
  1204. /// </summary>
  1205. /// <param name="index">Zero-based index of the string.</param>
  1206. /// <param name="stringBuffer">Character array that receives the string.</param>
  1207. /// <param name="size">Size of the array in characters. The size must include space for the terminating
  1208. /// null character.</param>
  1209. /// <returns>
  1210. /// Standard HRESULT error code.
  1211. /// </returns>
  1212. STDMETHOD(GetString)(
  1213. UINT32 index,
  1214. __out_ecount_z(size) WCHAR* stringBuffer,
  1215. UINT32 size
  1216. ) PURE;
  1217. };
  1218. interface IDWriteFontFamily;
  1219. interface IDWriteFont;
  1220. /// <summary>
  1221. /// The IDWriteFontCollection encapsulates a collection of fonts.
  1222. /// </summary>
  1223. interface DWRITE_DECLARE_INTERFACE("a84cee02-3eea-4eee-a827-87c1a02a0fcc") IDWriteFontCollection : public IUnknown
  1224. {
  1225. /// <summary>
  1226. /// Gets the number of font families in the collection.
  1227. /// </summary>
  1228. STDMETHOD_(UINT32, GetFontFamilyCount)() PURE;
  1229. /// <summary>
  1230. /// Creates a font family object given a zero-based font family index.
  1231. /// </summary>
  1232. /// <param name="index">Zero-based index of the font family.</param>
  1233. /// <param name="fontFamily">Receives a pointer the newly created font family object.</param>
  1234. /// <returns>
  1235. /// Standard HRESULT error code.
  1236. /// </returns>
  1237. STDMETHOD(GetFontFamily)(
  1238. UINT32 index,
  1239. __out IDWriteFontFamily** fontFamily
  1240. ) PURE;
  1241. /// <summary>
  1242. /// Finds the font family with the specified family name.
  1243. /// </summary>
  1244. /// <param name="familyName">Name of the font family. The name is not case-sensitive but must otherwise exactly match a family name in the collection.</param>
  1245. /// <param name="index">Receives the zero-based index of the matching font family if the family name was found or UINT_MAX otherwise.</param>
  1246. /// <param name="exists">Receives TRUE if the family name exists or FALSE otherwise.</param>
  1247. /// <returns>
  1248. /// Standard HRESULT error code. If the specified family name does not exist, the return value is S_OK, but *index is UINT_MAX and *exists is FALSE.
  1249. /// </returns>
  1250. STDMETHOD(FindFamilyName)(
  1251. __in_z WCHAR const* familyName,
  1252. __out UINT32* index,
  1253. __out BOOL* exists
  1254. ) PURE;
  1255. /// <summary>
  1256. /// Gets the font object that corresponds to the same physical font as the specified font face object. The specified physical font must belong
  1257. /// to the font collection.
  1258. /// </summary>
  1259. /// <param name="fontFace">Font face object that specifies the physical font.</param>
  1260. /// <param name="font">Receives a pointer to the newly created font object if successful or NULL otherwise.</param>
  1261. /// <returns>
  1262. /// Standard HRESULT error code. If the specified physical font is not part of the font collection the return value is DWRITE_E_NOFONT.
  1263. /// </returns>
  1264. STDMETHOD(GetFontFromFontFace)(
  1265. IDWriteFontFace* fontFace,
  1266. __out IDWriteFont** font
  1267. ) PURE;
  1268. };
  1269. /// <summary>
  1270. /// The IDWriteFontList interface represents a list of fonts.
  1271. /// </summary>
  1272. interface DWRITE_DECLARE_INTERFACE("1a0d8438-1d97-4ec1-aef9-a2fb86ed6acb") IDWriteFontList : public IUnknown
  1273. {
  1274. /// <summary>
  1275. /// Gets the font collection that contains the fonts.
  1276. /// </summary>
  1277. /// <param name="fontCollection">Receives a pointer to the font collection object.</param>
  1278. /// <returns>
  1279. /// Standard HRESULT error code.
  1280. /// </returns>
  1281. STDMETHOD(GetFontCollection)(
  1282. __out IDWriteFontCollection** fontCollection
  1283. ) PURE;
  1284. /// <summary>
  1285. /// Gets the number of fonts in the font list.
  1286. /// </summary>
  1287. STDMETHOD_(UINT32, GetFontCount)() PURE;
  1288. /// <summary>
  1289. /// Gets a font given its zero-based index.
  1290. /// </summary>
  1291. /// <param name="index">Zero-based index of the font in the font list.</param>
  1292. /// <param name="font">Receives a pointer to the newly created font object.</param>
  1293. /// <returns>
  1294. /// Standard HRESULT error code.
  1295. /// </returns>
  1296. STDMETHOD(GetFont)(
  1297. UINT32 index,
  1298. __out IDWriteFont** font
  1299. ) PURE;
  1300. };
  1301. /// <summary>
  1302. /// The IDWriteFontFamily interface represents a set of fonts that share the same design but are differentiated
  1303. /// by weight, stretch, and style.
  1304. /// </summary>
  1305. interface DWRITE_DECLARE_INTERFACE("da20d8ef-812a-4c43-9802-62ec4abd7add") IDWriteFontFamily : public IDWriteFontList
  1306. {
  1307. /// <summary>
  1308. /// Creates an localized strings object that contains the family names for the font family, indexed by locale name.
  1309. /// </summary>
  1310. /// <param name="names">Receives a pointer to the newly created localized strings object.</param>
  1311. /// <returns>
  1312. /// Standard HRESULT error code.
  1313. /// </returns>
  1314. STDMETHOD(GetFamilyNames)(
  1315. __out IDWriteLocalizedStrings** names
  1316. ) PURE;
  1317. /// <summary>
  1318. /// Gets the font that best matches the specified properties.
  1319. /// </summary>
  1320. /// <param name="weight">Requested font weight.</param>
  1321. /// <param name="stretch">Requested font stretch.</param>
  1322. /// <param name="style">Requested font style.</param>
  1323. /// <param name="matchingFont">Receives a pointer to the newly created font object.</param>
  1324. /// <returns>
  1325. /// Standard HRESULT error code.
  1326. /// </returns>
  1327. STDMETHOD(GetFirstMatchingFont)(
  1328. DWRITE_FONT_WEIGHT weight,
  1329. DWRITE_FONT_STRETCH stretch,
  1330. DWRITE_FONT_STYLE style,
  1331. __out IDWriteFont** matchingFont
  1332. ) PURE;
  1333. /// <summary>
  1334. /// Gets a list of fonts in the font family ranked in order of how well they match the specified properties.
  1335. /// </summary>
  1336. /// <param name="weight">Requested font weight.</param>
  1337. /// <param name="stretch">Requested font stretch.</param>
  1338. /// <param name="style">Requested font style.</param>
  1339. /// <param name="matchingFonts">Receives a pointer to the newly created font list object.</param>
  1340. /// <returns>
  1341. /// Standard HRESULT error code.
  1342. /// </returns>
  1343. STDMETHOD(GetMatchingFonts)(
  1344. DWRITE_FONT_WEIGHT weight,
  1345. DWRITE_FONT_STRETCH stretch,
  1346. DWRITE_FONT_STYLE style,
  1347. __out IDWriteFontList** matchingFonts
  1348. ) PURE;
  1349. };
  1350. /// <summary>
  1351. /// The IDWriteFont interface represents a physical font in a font collection.
  1352. /// </summary>
  1353. interface DWRITE_DECLARE_INTERFACE("acd16696-8c14-4f5d-877e-fe3fc1d32737") IDWriteFont : public IUnknown
  1354. {
  1355. /// <summary>
  1356. /// Gets the font family to which the specified font belongs.
  1357. /// </summary>
  1358. /// <param name="fontFamily">Receives a pointer to the font family object.</param>
  1359. /// <returns>
  1360. /// Standard HRESULT error code.
  1361. /// </returns>
  1362. STDMETHOD(GetFontFamily)(
  1363. __out IDWriteFontFamily** fontFamily
  1364. ) PURE;
  1365. /// <summary>
  1366. /// Gets the weight of the specified font.
  1367. /// </summary>
  1368. STDMETHOD_(DWRITE_FONT_WEIGHT, GetWeight)() PURE;
  1369. /// <summary>
  1370. /// Gets the stretch (aka. width) of the specified font.
  1371. /// </summary>
  1372. STDMETHOD_(DWRITE_FONT_STRETCH, GetStretch)() PURE;
  1373. /// <summary>
  1374. /// Gets the style (aka. slope) of the specified font.
  1375. /// </summary>
  1376. STDMETHOD_(DWRITE_FONT_STYLE, GetStyle)() PURE;
  1377. /// <summary>
  1378. /// Returns TRUE if the font is a symbol font or FALSE if not.
  1379. /// </summary>
  1380. STDMETHOD_(BOOL, IsSymbolFont)() PURE;
  1381. /// <summary>
  1382. /// Gets a localized strings collection containing the face names for the font (e.g., Regular or Bold), indexed by locale name.
  1383. /// </summary>
  1384. /// <param name="names">Receives a pointer to the newly created localized strings object.</param>
  1385. /// <returns>
  1386. /// Standard HRESULT error code.
  1387. /// </returns>
  1388. STDMETHOD(GetFaceNames)(
  1389. __out IDWriteLocalizedStrings** names
  1390. ) PURE;
  1391. /// <summary>
  1392. /// Gets a localized strings collection containing the specified informational strings, indexed by locale name.
  1393. /// </summary>
  1394. /// <param name="informationalStringID">Identifies the string to get.</param>
  1395. /// <param name="informationalStrings">Receives a pointer to the newly created localized strings object.</param>
  1396. /// <param name="exists">Receives the value TRUE if the font contains the specified string ID or FALSE if not.</param>
  1397. /// <returns>
  1398. /// Standard HRESULT error code. If the font does not contain the specified string, the return value is S_OK but
  1399. /// informationalStrings receives a NULL pointer and exists receives the value FALSE.
  1400. /// </returns>
  1401. STDMETHOD(GetInformationalStrings)(
  1402. DWRITE_INFORMATIONAL_STRING_ID informationalStringID,
  1403. __out IDWriteLocalizedStrings** informationalStrings,
  1404. __out BOOL* exists
  1405. ) PURE;
  1406. /// <summary>
  1407. /// Gets a value that indicates what simulation are applied to the specified font.
  1408. /// </summary>
  1409. STDMETHOD_(DWRITE_FONT_SIMULATIONS, GetSimulations)() PURE;
  1410. /// <summary>
  1411. /// Gets the metrics for the font.
  1412. /// </summary>
  1413. /// <param name="fontMetrics">Receives the font metrics.</param>
  1414. STDMETHOD_(void, GetMetrics)(
  1415. __out DWRITE_FONT_METRICS* fontMetrics
  1416. ) PURE;
  1417. /// <summary>
  1418. /// Determines whether the font supports the specified character.
  1419. /// </summary>
  1420. /// <param name="unicodeValue">Unicode (UCS-4) character value.</param>
  1421. /// <param name="exists">Receives the value TRUE if the font supports the specified character or FALSE if not.</param>
  1422. /// <returns>
  1423. /// Standard HRESULT error code.
  1424. /// </returns>
  1425. STDMETHOD(HasCharacter)(
  1426. UINT32 unicodeValue,
  1427. __out BOOL* exists
  1428. ) PURE;
  1429. /// <summary>
  1430. /// Creates a font face object for the font.
  1431. /// </summary>
  1432. /// <param name="fontFace">Receives a pointer to the newly created font face object.</param>
  1433. /// <returns>
  1434. /// Standard HRESULT error code.
  1435. /// </returns>
  1436. STDMETHOD(CreateFontFace)(
  1437. __out IDWriteFontFace** fontFace
  1438. ) PURE;
  1439. };
  1440. /// <summary>
  1441. /// Direction for how reading progresses.
  1442. /// </summary>
  1443. enum DWRITE_READING_DIRECTION
  1444. {
  1445. /// <summary>
  1446. /// Reading progresses from left to right.
  1447. /// </summary>
  1448. DWRITE_READING_DIRECTION_LEFT_TO_RIGHT,
  1449. /// <summary>
  1450. /// Reading progresses from right to left.
  1451. /// </summary>
  1452. DWRITE_READING_DIRECTION_RIGHT_TO_LEFT
  1453. };
  1454. /// <summary>
  1455. /// Direction for how lines of text are placed relative to one another.
  1456. /// </summary>
  1457. enum DWRITE_FLOW_DIRECTION
  1458. {
  1459. /// <summary>
  1460. /// Text lines are placed from top to bottom.
  1461. /// </summary>
  1462. DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM
  1463. };
  1464. /// <summary>
  1465. /// Alignment of paragraph text along the reading direction axis relative to
  1466. /// the leading and trailing edge of the layout box.
  1467. /// </summary>
  1468. enum DWRITE_TEXT_ALIGNMENT
  1469. {
  1470. /// <summary>
  1471. /// The leading edge of the paragraph text is aligned to the layout box's leading edge.
  1472. /// </summary>
  1473. DWRITE_TEXT_ALIGNMENT_LEADING,
  1474. /// <summary>
  1475. /// The trailing edge of the paragraph text is aligned to the layout box's trailing edge.
  1476. /// </summary>
  1477. DWRITE_TEXT_ALIGNMENT_TRAILING,
  1478. /// <summary>
  1479. /// The center of the paragraph text is aligned to the center of the layout box.
  1480. /// </summary>
  1481. DWRITE_TEXT_ALIGNMENT_CENTER
  1482. };
  1483. /// <summary>
  1484. /// Alignment of paragraph text along the flow direction axis relative to the
  1485. /// flow's beginning and ending edge of the layout box.
  1486. /// </summary>
  1487. enum DWRITE_PARAGRAPH_ALIGNMENT
  1488. {
  1489. /// <summary>
  1490. /// The first line of paragraph is aligned to the flow's beginning edge of the layout box.
  1491. /// </summary>
  1492. DWRITE_PARAGRAPH_ALIGNMENT_NEAR,
  1493. /// <summary>
  1494. /// The last line of paragraph is aligned to the flow's ending edge of the layout box.
  1495. /// </summary>
  1496. DWRITE_PARAGRAPH_ALIGNMENT_FAR,
  1497. /// <summary>
  1498. /// The center of the paragraph is aligned to the center of the flow of the layout box.
  1499. /// </summary>
  1500. DWRITE_PARAGRAPH_ALIGNMENT_CENTER
  1501. };
  1502. /// <summary>
  1503. /// Word wrapping in multiline paragraph.
  1504. /// </summary>
  1505. enum DWRITE_WORD_WRAPPING
  1506. {
  1507. /// <summary>
  1508. /// Words are broken across lines to avoid text overflowing the layout box.
  1509. /// </summary>
  1510. DWRITE_WORD_WRAPPING_WRAP,
  1511. /// <summary>
  1512. /// Words are kept within the same line even when it overflows the layout box.
  1513. /// This option is often used with scrolling to reveal overflow text.
  1514. /// </summary>
  1515. DWRITE_WORD_WRAPPING_NO_WRAP
  1516. };
  1517. /// <summary>
  1518. /// The method used for line spacing in layout.
  1519. /// </summary>
  1520. enum DWRITE_LINE_SPACING_METHOD
  1521. {
  1522. /// <summary>
  1523. /// Line spacing depends solely on the content, growing to accomodate the size of fonts and inline objects.
  1524. /// </summary>
  1525. DWRITE_LINE_SPACING_METHOD_DEFAULT,
  1526. /// <summary>
  1527. /// Lines are explicitly set to uniform spacing, regardless of contained font sizes.
  1528. /// This can be useful to avoid the uneven appearance that can occur from font fallback.
  1529. /// </summary>
  1530. DWRITE_LINE_SPACING_METHOD_UNIFORM
  1531. };
  1532. /// <summary>
  1533. /// Text granularity used to trim text overflowing the layout box.
  1534. /// </summary>
  1535. enum DWRITE_TRIMMING_GRANULARITY
  1536. {
  1537. /// <summary>
  1538. /// No trimming occurs. Text flows beyond the layout width.
  1539. /// </summary>
  1540. DWRITE_TRIMMING_GRANULARITY_NONE,
  1541. /// <summary>
  1542. /// Trimming occurs at character cluster boundary.
  1543. /// </summary>
  1544. DWRITE_TRIMMING_GRANULARITY_CHARACTER,
  1545. /// <summary>
  1546. /// Trimming occurs at word boundary.
  1547. /// </summary>
  1548. DWRITE_TRIMMING_GRANULARITY_WORD
  1549. };
  1550. /// <summary>
  1551. /// Typographic feature of text supplied by the font.
  1552. /// </summary>
  1553. enum DWRITE_FONT_FEATURE_TAG
  1554. {
  1555. DWRITE_FONT_FEATURE_TAG_ALTERNATIVE_FRACTIONS = 0x63726661, // 'afrc'
  1556. DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS_FROM_CAPITALS = 0x63703263, // 'c2pc'
  1557. DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS_FROM_CAPITALS = 0x63733263, // 'c2sc'
  1558. DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_ALTERNATES = 0x746c6163, // 'calt'
  1559. DWRITE_FONT_FEATURE_TAG_CASE_SENSITIVE_FORMS = 0x65736163, // 'case'
  1560. DWRITE_FONT_FEATURE_TAG_GLYPH_COMPOSITION_DECOMPOSITION = 0x706d6363, // 'ccmp'
  1561. DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_LIGATURES = 0x67696c63, // 'clig'
  1562. DWRITE_FONT_FEATURE_TAG_CAPITAL_SPACING = 0x70737063, // 'cpsp'
  1563. DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_SWASH = 0x68777363, // 'cswh'
  1564. DWRITE_FONT_FEATURE_TAG_CURSIVE_POSITIONING = 0x73727563, // 'curs'
  1565. DWRITE_FONT_FEATURE_TAG_DEFAULT = 0x746c6664, // 'dflt'
  1566. DWRITE_FONT_FEATURE_TAG_DISCRETIONARY_LIGATURES = 0x67696c64, // 'dlig'
  1567. DWRITE_FONT_FEATURE_TAG_EXPERT_FORMS = 0x74707865, // 'expt'
  1568. DWRITE_FONT_FEATURE_TAG_FRACTIONS = 0x63617266, // 'frac'
  1569. DWRITE_FONT_FEATURE_TAG_FULL_WIDTH = 0x64697766, // 'fwid'
  1570. DWRITE_FONT_FEATURE_TAG_HALF_FORMS = 0x666c6168, // 'half'
  1571. DWRITE_FONT_FEATURE_TAG_HALANT_FORMS = 0x6e6c6168, // 'haln'
  1572. DWRITE_FONT_FEATURE_TAG_ALTERNATE_HALF_WIDTH = 0x746c6168, // 'halt'
  1573. DWRITE_FONT_FEATURE_TAG_HISTORICAL_FORMS = 0x74736968, // 'hist'
  1574. DWRITE_FONT_FEATURE_TAG_HORIZONTAL_KANA_ALTERNATES = 0x616e6b68, // 'hkna'
  1575. DWRITE_FONT_FEATURE_TAG_HISTORICAL_LIGATURES = 0x67696c68, // 'hlig'
  1576. DWRITE_FONT_FEATURE_TAG_HALF_WIDTH = 0x64697768, // 'hwid'
  1577. DWRITE_FONT_FEATURE_TAG_HOJO_KANJI_FORMS = 0x6f6a6f68, // 'hojo'
  1578. DWRITE_FONT_FEATURE_TAG_JIS04_FORMS = 0x3430706a, // 'jp04'
  1579. DWRITE_FONT_FEATURE_TAG_JIS78_FORMS = 0x3837706a, // 'jp78'
  1580. DWRITE_FONT_FEATURE_TAG_JIS83_FORMS = 0x3338706a, // 'jp83'
  1581. DWRITE_FONT_FEATURE_TAG_JIS90_FORMS = 0x3039706a, // 'jp90'
  1582. DWRITE_FONT_FEATURE_TAG_KERNING = 0x6e72656b, // 'kern'
  1583. DWRITE_FONT_FEATURE_TAG_STANDARD_LIGATURES = 0x6167696c, // 'liga'
  1584. DWRITE_FONT_FEATURE_TAG_LINING_FIGURES = 0x6d756e6c, // 'lnum'
  1585. DWRITE_FONT_FEATURE_TAG_LOCALIZED_FORMS = 0x6c636f6c, // 'locl'
  1586. DWRITE_FONT_FEATURE_TAG_MARK_POSITIONING = 0x6b72616d, // 'mark'
  1587. DWRITE_FONT_FEATURE_TAG_MATHEMATICAL_GREEK = 0x6b72676d, // 'mgrk'
  1588. DWRITE_FONT_FEATURE_TAG_MARK_TO_MARK_POSITIONING = 0x6b6d6b6d, // 'mkmk'
  1589. DWRITE_FONT_FEATURE_TAG_ALTERNATE_ANNOTATION_FORMS = 0x746c616e, // 'nalt'
  1590. DWRITE_FONT_FEATURE_TAG_NLC_KANJI_FORMS = 0x6b636c6e, // 'nlck'
  1591. DWRITE_FONT_FEATURE_TAG_OLD_STYLE_FIGURES = 0x6d756e6f, // 'onum'
  1592. DWRITE_FONT_FEATURE_TAG_ORDINALS = 0x6e64726f, // 'ordn'
  1593. DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_ALTERNATE_WIDTH = 0x746c6170, // 'palt'
  1594. DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS = 0x70616370, // 'pcap'
  1595. DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_FIGURES = 0x6d756e70, // 'pnum'
  1596. DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_WIDTHS = 0x64697770, // 'pwid'
  1597. DWRITE_FONT_FEATURE_TAG_QUARTER_WIDTHS = 0x64697771, // 'qwid'
  1598. DWRITE_FONT_FEATURE_TAG_REQUIRED_LIGATURES = 0x67696c72, // 'rlig'
  1599. DWRITE_FONT_FEATURE_TAG_RUBY_NOTATION_FORMS = 0x79627572, // 'ruby'
  1600. DWRITE_FONT_FEATURE_TAG_STYLISTIC_ALTERNATES = 0x746c6173, // 'salt'
  1601. DWRITE_FONT_FEATURE_TAG_SCIENTIFIC_INFERIORS = 0x666e6973, // 'sinf'
  1602. DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS = 0x70636d73, // 'smcp'
  1603. DWRITE_FONT_FEATURE_TAG_SIMPLIFIED_FORMS = 0x6c706d73, // 'smpl'
  1604. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_1 = 0x31307373, // 'ss01'
  1605. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_2 = 0x32307373, // 'ss02'
  1606. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_3 = 0x33307373, // 'ss03'
  1607. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_4 = 0x34307373, // 'ss04'
  1608. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_5 = 0x35307373, // 'ss05'
  1609. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6 = 0x36307373, // 'ss06'
  1610. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7 = 0x37307373, // 'ss07'
  1611. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_8 = 0x38307373, // 'ss08'
  1612. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_9 = 0x39307373, // 'ss09'
  1613. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_10 = 0x30317373, // 'ss10'
  1614. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_11 = 0x31317373, // 'ss11'
  1615. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_12 = 0x32317373, // 'ss12'
  1616. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_13 = 0x33317373, // 'ss13'
  1617. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_14 = 0x34317373, // 'ss14'
  1618. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_15 = 0x35317373, // 'ss15'
  1619. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_16 = 0x36317373, // 'ss16'
  1620. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_17 = 0x37317373, // 'ss17'
  1621. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_18 = 0x38317373, // 'ss18'
  1622. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_19 = 0x39317373, // 'ss19'
  1623. DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_20 = 0x30327373, // 'ss20'
  1624. DWRITE_FONT_FEATURE_TAG_SUBSCRIPT = 0x73627573, // 'subs'
  1625. DWRITE_FONT_FEATURE_TAG_SUPERSCRIPT = 0x73707573, // 'sups'
  1626. DWRITE_FONT_FEATURE_TAG_SWASH = 0x68737773, // 'swsh'
  1627. DWRITE_FONT_FEATURE_TAG_TITLING = 0x6c746974, // 'titl'
  1628. DWRITE_FONT_FEATURE_TAG_TRADITIONAL_NAME_FORMS = 0x6d616e74, // 'tnam'
  1629. DWRITE_FONT_FEATURE_TAG_TABULAR_FIGURES = 0x6d756e74, // 'tnum'
  1630. DWRITE_FONT_FEATURE_TAG_TRADITIONAL_FORMS = 0x64617274, // 'trad'
  1631. DWRITE_FONT_FEATURE_TAG_THIRD_WIDTHS = 0x64697774, // 'twid'
  1632. DWRITE_FONT_FEATURE_TAG_UNICASE = 0x63696e75, // 'unic'
  1633. DWRITE_FONT_FEATURE_TAG_SLASHED_ZERO = 0x6f72657a, // 'zero'
  1634. };
  1635. /// <summary>
  1636. /// The DWRITE_TEXT_RANGE structure specifies a range of text positions where format is applied.
  1637. /// </summary>
  1638. struct DWRITE_TEXT_RANGE
  1639. {
  1640. /// <summary>
  1641. /// The start text position of the range.
  1642. /// </summary>
  1643. UINT32 startPosition;
  1644. /// <summary>
  1645. /// The number of text positions in the range.
  1646. /// </summary>
  1647. UINT32 length;
  1648. };
  1649. /// <summary>
  1650. /// The DWRITE_FONT_FEATURE structure specifies properties used to identify and execute typographic feature in the font.
  1651. /// </summary>
  1652. struct DWRITE_FONT_FEATURE
  1653. {
  1654. /// <summary>
  1655. /// The feature OpenType name identifier.
  1656. /// </summary>
  1657. DWRITE_FONT_FEATURE_TAG nameTag;
  1658. /// <summary>
  1659. /// Execution parameter of the feature.
  1660. /// </summary>
  1661. /// <remarks>
  1662. /// The parameter should be non-zero to enable the feature. Once enabled, a feature can't be disabled again within
  1663. /// the same range. Features requiring a selector use this value to indicate the selector index.
  1664. /// </remarks>
  1665. UINT32 parameter;
  1666. };
  1667. /// <summary>
  1668. /// Defines a set of typographic features to be applied during shaping.
  1669. /// Notice the character range which this feature list spans is specified
  1670. /// as a separate parameter to GetGlyphs.
  1671. /// </summary>
  1672. struct DWRITE_TYPOGRAPHIC_FEATURES
  1673. {
  1674. /// <summary>
  1675. /// Array of font features.
  1676. /// </summary>
  1677. __field_ecount(featureCount) DWRITE_FONT_FEATURE* features;
  1678. /// <summary>
  1679. /// The number of features.
  1680. /// </summary>
  1681. UINT32 featureCount;
  1682. };
  1683. /// <summary>
  1684. /// The DWRITE_TRIMMING structure specifies the trimming option for text overflowing the layout box.
  1685. /// </summary>
  1686. struct DWRITE_TRIMMING
  1687. {
  1688. /// <summary>
  1689. /// Text granularity of which trimming applies.
  1690. /// </summary>
  1691. DWRITE_TRIMMING_GRANULARITY granularity;
  1692. /// <summary>
  1693. /// Character code used as the delimiter signaling the beginning of the portion of text to be preserved,
  1694. /// most useful for path ellipsis, where the delimeter would be a slash.
  1695. /// </summary>
  1696. UINT32 delimiter;
  1697. /// <summary>
  1698. /// How many occurences of the delimiter to step back.
  1699. /// </summary>
  1700. UINT32 delimiterCount;
  1701. };
  1702. interface IDWriteTypography;
  1703. interface IDWriteInlineObject;
  1704. /// <summary>
  1705. /// The format of text used for text layout purpose.
  1706. /// </summary>
  1707. /// <remarks>
  1708. /// This object may not be thread-safe and it may carry the state of text format change.
  1709. /// </remarks>
  1710. interface DWRITE_DECLARE_INTERFACE("9c906818-31d7-4fd3-a151-7c5e225db55a") IDWriteTextFormat : public IUnknown
  1711. {
  1712. /// <summary>
  1713. /// Set alignment option of text relative to layout box's leading and trailing edge.
  1714. /// </summary>
  1715. /// <param name="textAlignment">Text alignment option</param>
  1716. /// <returns>
  1717. /// Standard HRESULT error code.
  1718. /// </returns>
  1719. STDMETHOD(SetTextAlignment)(
  1720. DWRITE_TEXT_ALIGNMENT textAlignment
  1721. ) PURE;
  1722. /// <summary>
  1723. /// Set alignment option of paragraph relative to layout box's top and bottom edge.
  1724. /// </summary>
  1725. /// <param name="paragraphAlignment">Paragraph alignment option</param>
  1726. /// <returns>
  1727. /// Standard HRESULT error code.
  1728. /// </returns>
  1729. STDMETHOD(SetParagraphAlignment)(
  1730. DWRITE_PARAGRAPH_ALIGNMENT paragraphAlignment
  1731. ) PURE;
  1732. /// <summary>
  1733. /// Set word wrapping option.
  1734. /// </summary>
  1735. /// <param name="wordWrapping">Word wrapping option</param>
  1736. /// <returns>
  1737. /// Standard HRESULT error code.
  1738. /// </returns>
  1739. STDMETHOD(SetWordWrapping)(
  1740. DWRITE_WORD_WRAPPING wordWrapping
  1741. ) PURE;
  1742. /// <summary>
  1743. /// Set paragraph reading direction.
  1744. /// </summary>
  1745. /// <param name="readingDirection">Text reading direction</param>
  1746. /// <returns>
  1747. /// Standard HRESULT error code.
  1748. /// </returns>
  1749. STDMETHOD(SetReadingDirection)(
  1750. DWRITE_READING_DIRECTION readingDirection
  1751. ) PURE;
  1752. /// <summary>
  1753. /// Set paragraph flow direction.
  1754. /// </summary>
  1755. /// <param name="flowDirection">Paragraph flow direction</param>
  1756. /// <returns>
  1757. /// Standard HRESULT error code.
  1758. /// </returns>
  1759. STDMETHOD(SetFlowDirection)(
  1760. DWRITE_FLOW_DIRECTION flowDirection
  1761. ) PURE;
  1762. /// <summary>
  1763. /// Set incremental tab stop position.
  1764. /// </summary>
  1765. /// <param name="incrementalTabStop">The incremental tab stop value</param>
  1766. /// <returns>
  1767. /// Standard HRESULT error code.
  1768. /// </returns>
  1769. STDMETHOD(SetIncrementalTabStop)(
  1770. FLOAT incrementalTabStop
  1771. ) PURE;
  1772. /// <summary>
  1773. /// Set trimming options for any trailing text exceeding the layout width
  1774. /// or for any far text exceeding the layout height.
  1775. /// </summary>
  1776. /// <param name="trimmingOptions">Text trimming options.</param>
  1777. /// <param name="trimmingSign">Application-defined omission sign. This parameter may be NULL if no trimming sign is desired.</param>
  1778. /// <remarks>
  1779. /// Any inline object can be used for the trimming sign, but CreateEllipsisTrimmingSign
  1780. /// provides a typical ellipsis symbol. Trimming is also useful vertically for hiding
  1781. /// partial lines.
  1782. /// </remarks>
  1783. /// <returns>
  1784. /// Standard HRESULT error code.
  1785. /// </returns>
  1786. STDMETHOD(SetTrimming)(
  1787. __in DWRITE_TRIMMING const* trimmingOptions,
  1788. IDWriteInlineObject* trimmingSign
  1789. ) PURE;
  1790. /// <summary>
  1791. /// Set line spacing.
  1792. /// </summary>
  1793. /// <param name="lineSpacingMethod">How to determine line height.</param>
  1794. /// <param name="lineSpacing">The line height, or rather distance between one baseline to another.</param>
  1795. /// <param name="baseline">Distance from top of line to baseline. A reasonable ratio to lineSpacing is 80%.</param>
  1796. /// <remarks>
  1797. /// For the default method, spacing depends solely on the content.
  1798. /// For uniform spacing, the given line height will override the content.
  1799. /// </remarks>
  1800. /// <returns>
  1801. /// Standard HRESULT error code.
  1802. /// </returns>
  1803. STDMETHOD(SetLineSpacing)(
  1804. DWRITE_LINE_SPACING_METHOD lineSpacingMethod,
  1805. FLOAT lineSpacing,
  1806. FLOAT baseline
  1807. ) PURE;
  1808. /// <summary>
  1809. /// Get alignment option of text relative to layout box's leading and trailing edge.
  1810. /// </summary>
  1811. STDMETHOD_(DWRITE_TEXT_ALIGNMENT, GetTextAlignment)() PURE;
  1812. /// <summary>
  1813. /// Get alignment option of paragraph relative to layout box's top and bottom edge.
  1814. /// </summary>
  1815. STDMETHOD_(DWRITE_PARAGRAPH_ALIGNMENT, GetParagraphAlignment)() PURE;
  1816. /// <summary>
  1817. /// Get word wrapping option.
  1818. /// </summary>
  1819. STDMETHOD_(DWRITE_WORD_WRAPPING, GetWordWrapping)() PURE;
  1820. /// <summary>
  1821. /// Get paragraph reading direction.
  1822. /// </summary>
  1823. STDMETHOD_(DWRITE_READING_DIRECTION, GetReadingDirection)() PURE;
  1824. /// <summary>
  1825. /// Get paragraph flow direction.
  1826. /// </summary>
  1827. STDMETHOD_(DWRITE_FLOW_DIRECTION, GetFlowDirection)() PURE;
  1828. /// <summary>
  1829. /// Get incremental tab stop position.
  1830. /// </summary>
  1831. STDMETHOD_(FLOAT, GetIncrementalTabStop)() PURE;
  1832. /// <summary>
  1833. /// Get trimming options for text overflowing the layout width.
  1834. /// </summary>
  1835. /// <param name="trimmingOptions">Text trimming options.</param>
  1836. /// <param name="trimmingSign">Trimming omission sign. This parameter may be NULL.</param>
  1837. /// <returns>
  1838. /// Standard HRESULT error code.
  1839. /// </returns>
  1840. STDMETHOD(GetTrimming)(
  1841. __out DWRITE_TRIMMING* trimmingOptions,
  1842. __out IDWriteInlineObject** trimmingSign
  1843. ) PURE;
  1844. /// <summary>
  1845. /// Get line spacing.
  1846. /// </summary>
  1847. /// <param name="lineSpacingMethod">How line height is determined.</param>
  1848. /// <param name="lineSpacing">The line height, or rather distance between one baseline to another.</param>
  1849. /// <param name="baseline">Distance from top of line to baseline.</param>
  1850. /// <returns>
  1851. /// Standard HRESULT error code.
  1852. /// </returns>
  1853. STDMETHOD(GetLineSpacing)(
  1854. __out DWRITE_LINE_SPACING_METHOD* lineSpacingMethod,
  1855. __out FLOAT* lineSpacing,
  1856. __out FLOAT* baseline
  1857. ) PURE;
  1858. /// <summary>
  1859. /// Get the font collection.
  1860. /// </summary>
  1861. /// <param name="fontCollection">The current font collection.</param>
  1862. /// <returns>
  1863. /// Standard HRESULT error code.
  1864. /// </returns>
  1865. STDMETHOD(GetFontCollection)(
  1866. __out IDWriteFontCollection** fontCollection
  1867. ) PURE;
  1868. /// <summary>
  1869. /// Get the length of the font family name, in characters, not including the terminating NULL character.
  1870. /// </summary>
  1871. STDMETHOD_(UINT32, GetFontFamilyNameLength)() PURE;
  1872. /// <summary>
  1873. /// Get a copy of the font family name.
  1874. /// </summary>
  1875. /// <param name="fontFamilyName">Character array that receives the current font family name</param>
  1876. /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param>
  1877. /// <returns>
  1878. /// Standard HRESULT error code.
  1879. /// </returns>
  1880. STDMETHOD(GetFontFamilyName)(
  1881. __out_ecount_z(nameSize) WCHAR* fontFamilyName,
  1882. UINT32 nameSize
  1883. ) PURE;
  1884. /// <summary>
  1885. /// Get the font weight.
  1886. /// </summary>
  1887. STDMETHOD_(DWRITE_FONT_WEIGHT, GetFontWeight)() PURE;
  1888. /// <summary>
  1889. /// Get the font style.
  1890. /// </summary>
  1891. STDMETHOD_(DWRITE_FONT_STYLE, GetFontStyle)() PURE;
  1892. /// <summary>
  1893. /// Get the font stretch.
  1894. /// </summary>
  1895. STDMETHOD_(DWRITE_FONT_STRETCH, GetFontStretch)() PURE;
  1896. /// <summary>
  1897. /// Get the font em height.
  1898. /// </summary>
  1899. STDMETHOD_(FLOAT, GetFontSize)() PURE;
  1900. /// <summary>
  1901. /// Get the length of the locale name, in characters, not including the terminating NULL character.
  1902. /// </summary>
  1903. STDMETHOD_(UINT32, GetLocaleNameLength)() PURE;
  1904. /// <summary>
  1905. /// Get a copy of the locale name.
  1906. /// </summary>
  1907. /// <param name="localeName">Character array that receives the current locale name</param>
  1908. /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param>
  1909. /// <returns>
  1910. /// Standard HRESULT error code.
  1911. /// </returns>
  1912. STDMETHOD(GetLocaleName)(
  1913. __out_ecount_z(nameSize) WCHAR* localeName,
  1914. UINT32 nameSize
  1915. ) PURE;
  1916. };
  1917. /// <summary>
  1918. /// Font typography setting.
  1919. /// </summary>
  1920. interface DWRITE_DECLARE_INTERFACE("55f1112b-1dc2-4b3c-9541-f46894ed85b6") IDWriteTypography : public IUnknown
  1921. {
  1922. /// <summary>
  1923. /// Add font feature.
  1924. /// </summary>
  1925. /// <param name="fontFeature">The font feature to add.</param>
  1926. /// <returns>
  1927. /// Standard HRESULT error code.
  1928. /// </returns>
  1929. STDMETHOD(AddFontFeature)(
  1930. DWRITE_FONT_FEATURE fontFeature
  1931. ) PURE;
  1932. /// <summary>
  1933. /// Get the number of font features.
  1934. /// </summary>
  1935. STDMETHOD_(UINT32, GetFontFeatureCount)() PURE;
  1936. /// <summary>
  1937. /// Get the font feature at the specified index.
  1938. /// </summary>
  1939. /// <param name="fontFeatureIndex">The zero-based index of the font feature to get.</param>
  1940. /// <param name="fontFeature">The font feature.</param>
  1941. /// <returns>
  1942. /// Standard HRESULT error code.
  1943. /// </returns>
  1944. STDMETHOD(GetFontFeature)(
  1945. UINT32 fontFeatureIndex,
  1946. __out DWRITE_FONT_FEATURE* fontFeature
  1947. ) PURE;
  1948. };
  1949. enum DWRITE_SCRIPT_SHAPES
  1950. {
  1951. /// <summary>
  1952. /// No additional shaping requirement. Text is shaped with the writing system default behavior.
  1953. /// </summary>
  1954. DWRITE_SCRIPT_SHAPES_DEFAULT = 0,
  1955. /// <summary>
  1956. /// Text should leave no visual on display i.e. control or format control characters.
  1957. /// </summary>
  1958. DWRITE_SCRIPT_SHAPES_NO_VISUAL = 1
  1959. };
  1960. #ifdef DEFINE_ENUM_FLAG_OPERATORS
  1961. DEFINE_ENUM_FLAG_OPERATORS(DWRITE_SCRIPT_SHAPES);
  1962. #endif
  1963. /// <summary>
  1964. /// Association of text and its writing system script as well as some display attributes.
  1965. /// </summary>
  1966. struct DWRITE_SCRIPT_ANALYSIS
  1967. {
  1968. /// <summary>
  1969. /// Zero-based index representation of writing system script.
  1970. /// </summary>
  1971. UINT16 script;
  1972. /// <summary>
  1973. /// Additional shaping requirement of text.
  1974. /// </summary>
  1975. DWRITE_SCRIPT_SHAPES shapes;
  1976. };
  1977. /// <summary>
  1978. /// Condition at the edges of inline object or text used to determine
  1979. /// line-breaking behavior.
  1980. /// </summary>
  1981. enum DWRITE_BREAK_CONDITION
  1982. {
  1983. /// <summary>
  1984. /// Whether a break is allowed is determined by the condition of the
  1985. /// neighboring text span or inline object.
  1986. /// </summary>
  1987. DWRITE_BREAK_CONDITION_NEUTRAL,
  1988. /// <summary>
  1989. /// A break is allowed, unless overruled by the condition of the
  1990. /// neighboring text span or inline object, either prohibited by a
  1991. /// May Not or forced by a Must.
  1992. /// </summary>
  1993. DWRITE_BREAK_CONDITION_CAN_BREAK,
  1994. /// <summary>
  1995. /// There should be no break, unless overruled by a Must condition from
  1996. /// the neighboring text span or inline object.
  1997. /// </summary>
  1998. DWRITE_BREAK_CONDITION_MAY_NOT_BREAK,
  1999. /// <summary>
  2000. /// The break must happen, regardless of the condition of the adjacent
  2001. /// text span or inline object.
  2002. /// </summary>
  2003. DWRITE_BREAK_CONDITION_MUST_BREAK
  2004. };
  2005. /// <summary>
  2006. /// Line breakpoint characteristics of a character.
  2007. /// </summary>
  2008. struct DWRITE_LINE_BREAKPOINT
  2009. {
  2010. /// <summary>
  2011. /// Breaking condition before the character.
  2012. /// </summary>
  2013. UINT8 breakConditionBefore : 2;
  2014. /// <summary>
  2015. /// Breaking condition after the character.
  2016. /// </summary>
  2017. UINT8 breakConditionAfter : 2;
  2018. /// <summary>
  2019. /// The character is some form of whitespace, which may be meaningful
  2020. /// for justification.
  2021. /// </summary>
  2022. UINT8 isWhitespace : 1;
  2023. /// <summary>
  2024. /// The character is a soft hyphen, often used to indicate hyphenation
  2025. /// points inside words.
  2026. /// </summary>
  2027. UINT8 isSoftHyphen : 1;
  2028. UINT8 padding : 2;
  2029. };
  2030. /// <summary>
  2031. /// How to apply number substitution on digits and related punctuation.
  2032. /// </summary>
  2033. enum DWRITE_NUMBER_SUBSTITUTION_METHOD
  2034. {
  2035. /// <summary>
  2036. /// Specifies that the substitution method should be determined based
  2037. /// on LOCALE_IDIGITSUBSTITUTION value of the specified text culture.
  2038. /// </summary>
  2039. DWRITE_NUMBER_SUBSTITUTION_METHOD_FROM_CULTURE,
  2040. /// <summary>
  2041. /// If the culture is Arabic or Farsi, specifies that the number shape
  2042. /// depend on the context. Either traditional or nominal number shape
  2043. /// are used depending on the nearest preceding strong character or (if
  2044. /// there is none) the reading direction of the paragraph.
  2045. /// </summary>
  2046. DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL,
  2047. /// <summary>
  2048. /// Specifies that code points 0x30-0x39 are always rendered as nominal numeral
  2049. /// shapes (ones of the European number), i.e., no substitution is performed.
  2050. /// </summary>
  2051. DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE,
  2052. /// <summary>
  2053. /// Specifies that number are rendered using the national number shape
  2054. /// as specified by the LOCALE_SNATIVEDIGITS value of the specified text culture.
  2055. /// </summary>
  2056. DWRITE_NUMBER_SUBSTITUTION_METHOD_NATIONAL,
  2057. /// <summary>
  2058. /// Specifies that number are rendered using the traditional shape
  2059. /// for the specified culture. For most cultures, this is the same as
  2060. /// NativeNational. However, NativeNational results in Latin number
  2061. /// for some Arabic cultures, whereas this value results in Arabic
  2062. /// number for all Arabic cultures.
  2063. /// </summary>
  2064. DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL
  2065. };
  2066. /// <summary>
  2067. /// Holds the appropriate digits and numeric punctuation for a given locale.
  2068. /// </summary>
  2069. interface DECLSPEC_UUID("14885CC9-BAB0-4f90-B6ED-5C366A2CD03D") DECLSPEC_NOVTABLE IDWriteNumberSubstitution : public IUnknown
  2070. {
  2071. };
  2072. /// <summary>
  2073. /// Shaping output properties per input character.
  2074. /// </summary>
  2075. struct DWRITE_SHAPING_TEXT_PROPERTIES
  2076. {
  2077. /// <summary>
  2078. /// This character can be shaped independently from the others
  2079. /// (usually set for the space character).
  2080. /// </summary>
  2081. UINT16 isShapedAlone : 1;
  2082. /// <summary>
  2083. /// Reserved for use by shaping engine.
  2084. /// </summary>
  2085. UINT16 reserved : 15;
  2086. };
  2087. /// <summary>
  2088. /// Shaping output properties per output glyph.
  2089. /// </summary>
  2090. struct DWRITE_SHAPING_GLYPH_PROPERTIES
  2091. {
  2092. /// <summary>
  2093. /// Justification class, whether to use spacing, kashidas, or
  2094. /// another method. This exists for backwards compatibility
  2095. /// with Uniscribe's SCRIPT_JUSTIFY enum.
  2096. /// </summary>
  2097. UINT16 justification : 4;
  2098. /// <summary>
  2099. /// Indicates glyph is the first of a cluster.
  2100. /// </summary>
  2101. UINT16 isClusterStart : 1;
  2102. /// <summary>
  2103. /// Glyph is a diacritic.
  2104. /// </summary>
  2105. UINT16 isDiacritic : 1;
  2106. /// <summary>
  2107. /// Glyph has no width, blank, ZWJ, ZWNJ etc.
  2108. /// </summary>
  2109. UINT16 isZeroWidthSpace : 1;
  2110. /// <summary>
  2111. /// Reserved for use by shaping engine.
  2112. /// </summary>
  2113. UINT16 reserved : 9;
  2114. };
  2115. /// <summary>
  2116. /// The interface implemented by the text analyzer's client to provide text to
  2117. /// the analyzer. It allows the separation between the logical view of text as
  2118. /// a continuous stream of characters identifiable by unique text positions,
  2119. /// and the actual memory layout of potentially discrete blocks of text in the
  2120. /// client's backing store.
  2121. ///
  2122. /// If any of these callbacks returns an error, the analysis functions will
  2123. /// stop prematurely and return a callback error. Rather than return E_NOTIMPL,
  2124. /// an application should stub the method and return a constant/null and S_OK.
  2125. /// </summary>
  2126. interface DECLSPEC_UUID("688e1a58-5094-47c8-adc8-fbcea60ae92b") DECLSPEC_NOVTABLE IDWriteTextAnalysisSource : public IUnknown
  2127. {
  2128. /// <summary>
  2129. /// Get a block of text starting at the specified text position.
  2130. /// Returning NULL indicates the end of text - the position is after
  2131. /// the last character. This function is called iteratively for
  2132. /// each consecutive block, tying together several fragmented blocks
  2133. /// in the backing store into a virtual contiguous string.
  2134. /// </summary>
  2135. /// <param name="textPosition">First position of the piece to obtain. All
  2136. /// positions are in UTF16 code-units, not whole characters, which
  2137. /// matters when supplementary characters are used.</param>
  2138. /// <param name="textString">Address that receives a pointer to the text block
  2139. /// at the specified position.</param>
  2140. /// <param name="textLength">Number of UTF16 units of the retrieved chunk.
  2141. /// The returned length is not the length of the block, but the length
  2142. /// remaining in the block, from the given position until its end.
  2143. /// So querying for a position that is 75 positions into a 100
  2144. /// postition block would return 25.</param>
  2145. /// <returns>Pointer to the first character at the given text position.
  2146. /// NULL indicates no chunk available at the specified position, either
  2147. /// because textPosition >= the entire text content length or because the
  2148. /// queried position is not mapped into the app's backing store.</returns>
  2149. /// <remarks>
  2150. /// Although apps can implement sparse textual content that only maps part of
  2151. /// the backing store, the app must map any text that is in the range passed
  2152. /// to any analysis functions.
  2153. /// </remarks>
  2154. STDMETHOD(GetTextAtPosition)(
  2155. UINT32 textPosition,
  2156. __out WCHAR const** textString,
  2157. __out UINT32* textLength
  2158. ) PURE;
  2159. /// <summary>
  2160. /// Get a block of text immediately preceding the specified position.
  2161. /// </summary>
  2162. /// <param name="textPosition">Position immediately after the last position of the chunk to obtain.</param>
  2163. /// <param name="textString">Address that receives a pointer to the text block
  2164. /// at the specified position.</param>
  2165. /// <param name="textLength">Number of UTF16 units of the retrieved block.
  2166. /// The length returned is from the given position to the front of
  2167. /// the block.</param>
  2168. /// <returns>Pointer to the first character at (textPosition - textLength).
  2169. /// NULL indicates no chunk available at the specified position, either
  2170. /// because textPosition == 0,the textPosition > the entire text content
  2171. /// length, or the queried position is not mapped into the app's backing
  2172. /// store.</returns>
  2173. /// <remarks>
  2174. /// Although apps can implement sparse textual content that only maps part of
  2175. /// the backing store, the app must map any text that is in the range passed
  2176. /// to any analysis functions.
  2177. /// </remarks>
  2178. STDMETHOD(GetTextBeforePosition)(
  2179. UINT32 textPosition,
  2180. __out WCHAR const** textString,
  2181. __out UINT32* textLength
  2182. ) PURE;
  2183. /// <summary>
  2184. /// Get paragraph reading direction.
  2185. /// </summary>
  2186. STDMETHOD_(DWRITE_READING_DIRECTION, GetParagraphReadingDirection)() PURE;
  2187. /// <summary>
  2188. /// Get locale name on the range affected by it.
  2189. /// </summary>
  2190. /// <param name="textPosition">Position to get the locale name of.</param>
  2191. /// <param name="textLength">Receives the length from the given position up to the
  2192. /// next differing locale.</param>
  2193. /// <param name="localeName">Address that receives a pointer to the locale
  2194. /// at the specified position.</param>
  2195. /// <remarks>
  2196. /// The localeName pointer must remain valid until the next call or until
  2197. /// the analysis returns.
  2198. /// </remarks>
  2199. STDMETHOD(GetLocaleName)(
  2200. UINT32 textPosition,
  2201. __out UINT32* textLength,
  2202. __out_z WCHAR const** localeName
  2203. ) PURE;
  2204. /// <summary>
  2205. /// Get number substitution on the range affected by it.
  2206. /// </summary>
  2207. /// <param name="textPosition">Position to get the number substitution of.</param>
  2208. /// <param name="textLength">Receives the length from the given position up to the
  2209. /// next differing number substitution.</param>
  2210. /// <param name="numberSubstitution">Address that receives a pointer to the number substitution
  2211. /// at the specified position.</param>
  2212. /// <remarks>
  2213. /// Any implementation should return the number substitution with an
  2214. /// incremented ref count, and the analysis will release when finished
  2215. /// with it (either before the next call or before it returns). However,
  2216. /// the sink callback may hold onto it after that.
  2217. /// </remarks>
  2218. STDMETHOD(GetNumberSubstitution)(
  2219. UINT32 textPosition,
  2220. __out UINT32* textLength,
  2221. __out IDWriteNumberSubstitution** numberSubstitution
  2222. ) PURE;
  2223. };
  2224. /// <summary>
  2225. /// The interface implemented by the text analyzer's client to receive the
  2226. /// output of a given text analysis. The Text analyzer disregards any current
  2227. /// state of the analysis sink, therefore a Set method call on a range
  2228. /// overwrites the previously set analysis result of the same range.
  2229. /// </summary>
  2230. interface DECLSPEC_UUID("5810cd44-0ca0-4701-b3fa-bec5182ae4f6") DECLSPEC_NOVTABLE IDWriteTextAnalysisSink : public IUnknown
  2231. {
  2232. /// <summary>
  2233. /// Report script analysis for the text range.
  2234. /// </summary>
  2235. /// <param name="textPosition">Starting position to report from.</param>
  2236. /// <param name="textLength">Number of UTF16 units of the reported range.</param>
  2237. /// <param name="scriptAnalysis">Script analysis of characters in range.</param>
  2238. /// <returns>
  2239. /// A successful code or error code to abort analysis.
  2240. /// </returns>
  2241. STDMETHOD(SetScriptAnalysis)(
  2242. UINT32 textPosition,
  2243. UINT32 textLength,
  2244. __in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis
  2245. ) PURE;
  2246. /// <summary>
  2247. /// Repport line-break opportunities for each character, starting from
  2248. /// the specified position.
  2249. /// </summary>
  2250. /// <param name="textPosition">Starting position to report from.</param>
  2251. /// <param name="textLength">Number of UTF16 units of the reported range.</param>
  2252. /// <param name="lineBreakpoints">Breaking conditions for each character.</param>
  2253. /// <returns>
  2254. /// A successful code or error code to abort analysis.
  2255. /// </returns>
  2256. STDMETHOD(SetLineBreakpoints)(
  2257. UINT32 textPosition,
  2258. UINT32 textLength,
  2259. __in_ecount(textLength) DWRITE_LINE_BREAKPOINT const* lineBreakpoints
  2260. ) PURE;
  2261. /// <summary>
  2262. /// Set bidirectional level on the range, called once per each
  2263. /// level run change (either explicit or resolved implicit).
  2264. /// </summary>
  2265. /// <param name="textPosition">Starting position to report from.</param>
  2266. /// <param name="textLength">Number of UTF16 units of the reported range.</param>
  2267. /// <param name="explicitLevel">Explicit level from embedded control codes
  2268. /// RLE/RLO/LRE/LRO/PDF, determined before any additional rules.</param>
  2269. /// <param name="resolvedLevel">Final implicit level considering the
  2270. /// explicit level and characters' natural directionality, after all
  2271. /// Bidi rules have been applied.</param>
  2272. /// <returns>
  2273. /// A successful code or error code to abort analysis.
  2274. /// </returns>
  2275. STDMETHOD(SetBidiLevel)(
  2276. UINT32 textPosition,
  2277. UINT32 textLength,
  2278. UINT8 explicitLevel,
  2279. UINT8 resolvedLevel
  2280. ) PURE;
  2281. /// <summary>
  2282. /// Set number substitution on the range.
  2283. /// </summary>
  2284. /// <param name="textPosition">Starting position to report from.</param>
  2285. /// <param name="textLength">Number of UTF16 units of the reported range.</param>
  2286. /// <param name="numberSubstitution">The number substitution applicable to
  2287. /// the returned range of text. The sink callback may hold onto it by
  2288. /// incrementing its ref count.</param>
  2289. /// <returns>
  2290. /// A successful code or error code to abort analysis.
  2291. /// </returns>
  2292. /// <remark>
  2293. /// Unlike script and bidi analysis, where every character passed to the
  2294. /// analyzer has a result, this will only be called for those ranges where
  2295. /// substitution is applicable. For any other range, you will simply not
  2296. /// be called.
  2297. /// </remark>
  2298. STDMETHOD(SetNumberSubstitution)(
  2299. UINT32 textPosition,
  2300. UINT32 textLength,
  2301. __notnull IDWriteNumberSubstitution* numberSubstitution
  2302. ) PURE;
  2303. };
  2304. /// <summary>
  2305. /// Analyzes various text properties for complex script processing.
  2306. /// </summary>
  2307. interface DWRITE_DECLARE_INTERFACE("b7e6163e-7f46-43b4-84b3-e4e6249c365d") IDWriteTextAnalyzer : public IUnknown
  2308. {
  2309. /// <summary>
  2310. /// Analyzes a text range for script boundaries, reading text attributes
  2311. /// from the source and reporting the Unicode script ID to the sink
  2312. /// callback SetScript.
  2313. /// </summary>
  2314. /// <param name="analysisSource">Source object to analyze.</param>
  2315. /// <param name="textPosition">Starting position within the source object.</param>
  2316. /// <param name="textLength">Length to analyze.</param>
  2317. /// <param name="analysisSink">Callback object.</param>
  2318. /// <returns>
  2319. /// Standard HRESULT error code.
  2320. /// </returns>
  2321. STDMETHOD(AnalyzeScript)(
  2322. IDWriteTextAnalysisSource* analysisSource,
  2323. UINT32 textPosition,
  2324. UINT32 textLength,
  2325. IDWriteTextAnalysisSink* analysisSink
  2326. ) PURE;
  2327. /// <summary>
  2328. /// Analyzes a text range for script directionality, reading attributes
  2329. /// from the source and reporting levels to the sink callback SetBidiLevel.
  2330. /// </summary>
  2331. /// <param name="analysisSource">Source object to analyze.</param>
  2332. /// <param name="textPosition">Starting position within the source object.</param>
  2333. /// <param name="textLength">Length to analyze.</param>
  2334. /// <param name="analysisSink">Callback object.</param>
  2335. /// <returns>
  2336. /// Standard HRESULT error code.
  2337. /// </returns>
  2338. /// <remarks>
  2339. /// While the function can handle multiple paragraphs, the text range
  2340. /// should not arbitrarily split the middle of paragraphs. Otherwise the
  2341. /// returned levels may be wrong, since the Bidi algorithm is meant to
  2342. /// apply to the paragraph as a whole.
  2343. /// </remarks>
  2344. /// <remarks>
  2345. /// Embedded control codes (LRE/LRO/RLE/RLO/PDF) are taken into account.
  2346. /// </remarks>
  2347. STDMETHOD(AnalyzeBidi)(
  2348. IDWriteTextAnalysisSource* analysisSource,
  2349. UINT32 textPosition,
  2350. UINT32 textLength,
  2351. IDWriteTextAnalysisSink* analysisSink
  2352. ) PURE;
  2353. /// <summary>
  2354. /// Analyzes a text range for spans where number substitution is applicable,
  2355. /// reading attributes from the source and reporting substitutable ranges
  2356. /// to the sink callback SetNumberSubstitution.
  2357. /// </summary>
  2358. /// <param name="analysisSource">Source object to analyze.</param>
  2359. /// <param name="textPosition">Starting position within the source object.</param>
  2360. /// <param name="textLength">Length to analyze.</param>
  2361. /// <param name="analysisSink">Callback object.</param>
  2362. /// <returns>
  2363. /// Standard HRESULT error code.
  2364. /// </returns>
  2365. /// <remarks>
  2366. /// While the function can handle multiple ranges of differing number
  2367. /// substitutions, the text ranges should not arbitrarily split the
  2368. /// middle of numbers. Otherwise it will treat the numbers separately
  2369. /// and will not translate any intervening punctuation.
  2370. /// </remarks>
  2371. /// <remarks>
  2372. /// Embedded control codes (LRE/LRO/RLE/RLO/PDF) are taken into account.
  2373. /// </remarks>
  2374. STDMETHOD(AnalyzeNumberSubstitution)(
  2375. IDWriteTextAnalysisSource* analysisSource,
  2376. UINT32 textPosition,
  2377. UINT32 textLength,
  2378. IDWriteTextAnalysisSink* analysisSink
  2379. ) PURE;
  2380. /// <summary>
  2381. /// Analyzes a text range for potential breakpoint opportunities, reading
  2382. /// attributes from the source and reporting breakpoint opportunities to
  2383. /// the sink callback SetLineBreakpoints.
  2384. /// </summary>
  2385. /// <param name="analysisSource">Source object to analyze.</param>
  2386. /// <param name="textPosition">Starting position within the source object.</param>
  2387. /// <param name="textLength">Length to analyze.</param>
  2388. /// <param name="analysisSink">Callback object.</param>
  2389. /// <returns>
  2390. /// Standard HRESULT error code.
  2391. /// </returns>
  2392. /// <remarks>
  2393. /// While the function can handle multiple paragraphs, the text range
  2394. /// should not arbitrarily split the middle of paragraphs, unless the
  2395. /// given text span is considered a whole unit. Otherwise the
  2396. /// returned properties for the first and last characters will
  2397. /// inappropriately allow breaks.
  2398. /// </remarks>
  2399. /// <remarks>
  2400. /// Special cases include the first, last, and surrogate characters. Any
  2401. /// text span is treated as if adjacent to inline objects on either side.
  2402. /// So the rules with contingent-break opportunities are used, where the
  2403. /// edge between text and inline objects is always treated as a potential
  2404. /// break opportunity, dependent on any overriding rules of the adjacent
  2405. /// objects to prohibit or force the break (see Unicode TR #14).
  2406. /// Surrogate pairs never break between.
  2407. /// </remarks>
  2408. STDMETHOD(AnalyzeLineBreakpoints)(
  2409. IDWriteTextAnalysisSource* analysisSource,
  2410. UINT32 textPosition,
  2411. UINT32 textLength,
  2412. IDWriteTextAnalysisSink* analysisSink
  2413. ) PURE;
  2414. /// <summary>
  2415. /// Parses the input text string and maps it to the set of glyphs and associated glyph data
  2416. /// according to the font and the writing system's rendering rules.
  2417. /// </summary>
  2418. /// <param name="textString">The string to convert to glyphs.</param>
  2419. /// <param name="textLength">The length of textString.</param>
  2420. /// <param name="fontFace">The font face to get glyphs from.</param>
  2421. /// <param name="isSideways">Set to true if the text is intended to be
  2422. /// drawn vertically.</param>
  2423. /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param>
  2424. /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param>
  2425. /// <param name="localeName">The locale to use when selecting glyphs.
  2426. /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs.
  2427. /// If this is NULL then the default mapping based on the script is used.</param>
  2428. /// <param name="numberSubstitution">Optional number substitution which
  2429. /// selects the appropriate glyphs for digits and related numeric characters,
  2430. /// depending on the results obtained from AnalyzeNumberSubstitution. Passing
  2431. /// null indicates that no substitution is needed and that the digits should
  2432. /// receive nominal glyphs.</param>
  2433. /// <param name="features">An array of pointers to the sets of typographic
  2434. /// features to use in each feature range.</param>
  2435. /// <param name="featureRangeLengths">The length of each feature range, in characters.
  2436. /// The sum of all lengths should be equal to textLength.</param>
  2437. /// <param name="featureRanges">The number of feature ranges.</param>
  2438. /// <param name="maxGlyphCount">The maximum number of glyphs that can be
  2439. /// returned.</param>
  2440. /// <param name="clusterMap">The mapping from character ranges to glyph
  2441. /// ranges.</param>
  2442. /// <param name="textProps">Per-character output properties.</param>
  2443. /// <param name="glyphIndices">Output glyph indices.</param>
  2444. /// <param name="glyphProps">Per-glyph output properties.</param>
  2445. /// <param name="actualGlyphCount">The actual number of glyphs returned if
  2446. /// the call succeeds.</param>
  2447. /// <returns>
  2448. /// Standard HRESULT error code.
  2449. /// </returns>
  2450. /// <remarks>
  2451. /// Note that the mapping from characters to glyphs is, in general, many-
  2452. /// to-many. The recommended estimate for the per-glyph output buffers is
  2453. /// (3 * textLength / 2 + 16). This is not guaranteed to be sufficient.
  2454. ///
  2455. /// The value of the actualGlyphCount parameter is only valid if the call
  2456. /// succeeds. In the event that maxGlyphCount is not big enough
  2457. /// E_NOT_SUFFICIENT_BUFFER, which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
  2458. /// will be returned. The application should allocate a larger buffer and try again.
  2459. /// </remarks>
  2460. STDMETHOD(GetGlyphs)(
  2461. __in_ecount(textLength) WCHAR const* textString,
  2462. UINT32 textLength,
  2463. IDWriteFontFace* fontFace,
  2464. BOOL isSideways,
  2465. BOOL isRightToLeft,
  2466. __in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis,
  2467. __in_z_opt WCHAR const* localeName,
  2468. __maybenull IDWriteNumberSubstitution* numberSubstitution,
  2469. __in_ecount_opt(featureRanges) DWRITE_TYPOGRAPHIC_FEATURES const** features,
  2470. __in_ecount_opt(featureRanges) UINT32 const* featureRangeLengths,
  2471. UINT32 featureRanges,
  2472. UINT32 maxGlyphCount,
  2473. __out_ecount(textLength) UINT16* clusterMap,
  2474. __out_ecount(textLength) DWRITE_SHAPING_TEXT_PROPERTIES* textProps,
  2475. __out_ecount(maxGlyphCount) UINT16* glyphIndices,
  2476. __out_ecount(maxGlyphCount) DWRITE_SHAPING_GLYPH_PROPERTIES* glyphProps,
  2477. __out UINT32* actualGlyphCount
  2478. ) PURE;
  2479. /// <summary>
  2480. /// Place glyphs output from the GetGlyphs method according to the font
  2481. /// and the writing system's rendering rules.
  2482. /// </summary>
  2483. /// <param name="textString">The original string the glyphs came from.</param>
  2484. /// <param name="clusterMap">The mapping from character ranges to glyph
  2485. /// ranges. Returned by GetGlyphs.</param>
  2486. /// <param name="textProps">Per-character properties. Returned by
  2487. /// GetGlyphs.</param>
  2488. /// <param name="textLength">The length of textString.</param>
  2489. /// <param name="glyphIndices">Glyph indices. See GetGlyphs</param>
  2490. /// <param name="glyphProps">Per-glyph properties. See GetGlyphs</param>
  2491. /// <param name="glyphCount">The number of glyphs.</param>
  2492. /// <param name="fontFace">The font face the glyphs came from.</param>
  2493. /// <param name="fontEmSize">Logical font size in DIP's.</param>
  2494. /// <param name="isSideways">Set to true if the text is intended to be
  2495. /// drawn vertically.</param>
  2496. /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param>
  2497. /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param>
  2498. /// <param name="localeName">The locale to use when selecting glyphs.
  2499. /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs.
  2500. /// If this is NULL then the default mapping based on the script is used.</param>
  2501. /// <param name="features">An array of pointers to the sets of typographic
  2502. /// features to use in each feature range.</param>
  2503. /// <param name="featureRangeLengths">The length of each feature range, in characters.
  2504. /// The sum of all lengths should be equal to textLength.</param>
  2505. /// <param name="featureRanges">The number of feature ranges.</param>
  2506. /// <param name="glyphAdvances">The advance width of each glyph.</param>
  2507. /// <param name="glyphOffsets">The offset of the origin of each glyph.</param>
  2508. /// <returns>
  2509. /// Standard HRESULT error code.
  2510. /// </returns>
  2511. STDMETHOD(GetGlyphPlacements)(
  2512. __in_ecount(textLength) WCHAR const* textString,
  2513. __in_ecount(textLength) UINT16 const* clusterMap,
  2514. __in_ecount(textLength) DWRITE_SHAPING_TEXT_PROPERTIES* textProps,
  2515. UINT32 textLength,
  2516. __in_ecount(glyphCount) UINT16 const* glyphIndices,
  2517. __in_ecount(glyphCount) DWRITE_SHAPING_GLYPH_PROPERTIES const* glyphProps,
  2518. UINT32 glyphCount,
  2519. IDWriteFontFace * fontFace,
  2520. FLOAT fontEmSize,
  2521. BOOL isSideways,
  2522. BOOL isRightToLeft,
  2523. __in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis,
  2524. __in_z_opt WCHAR const* localeName,
  2525. __in_ecount_opt(featureRanges) DWRITE_TYPOGRAPHIC_FEATURES const** features,
  2526. __in_ecount_opt(featureRanges) UINT32 const* featureRangeLengths,
  2527. UINT32 featureRanges,
  2528. __out_ecount(glyphCount) FLOAT* glyphAdvances,
  2529. __out_ecount(glyphCount) DWRITE_GLYPH_OFFSET* glyphOffsets
  2530. ) PURE;
  2531. /// <summary>
  2532. /// Place glyphs output from the GetGlyphs method according to the font
  2533. /// and the writing system's rendering rules.
  2534. /// </summary>
  2535. /// <param name="textString">The original string the glyphs came from.</param>
  2536. /// <param name="clusterMap">The mapping from character ranges to glyph
  2537. /// ranges. Returned by GetGlyphs.</param>
  2538. /// <param name="textProps">Per-character properties. Returned by
  2539. /// GetGlyphs.</param>
  2540. /// <param name="textLength">The length of textString.</param>
  2541. /// <param name="glyphIndices">Glyph indices. See GetGlyphs</param>
  2542. /// <param name="glyphProps">Per-glyph properties. See GetGlyphs</param>
  2543. /// <param name="glyphCount">The number of glyphs.</param>
  2544. /// <param name="fontFace">The font face the glyphs came from.</param>
  2545. /// <param name="fontEmSize">Logical font size in DIP's.</param>
  2546. /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if the DPI of the rendering surface is 96 this
  2547. /// value is 1.0f. If the DPI is 120, this value is 120.0f/96.</param>
  2548. /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  2549. /// scaling specified by the font size and pixelsPerDip.</param>
  2550. /// <param name="useGdiNatural">
  2551. /// When set to FALSE, the metrics are the same as the metrics of GDI aliased text.
  2552. /// When set to TRUE, the metrics are the same as the metrics of text measured by GDI using a font
  2553. /// created with CLEARTYPE_NATURAL_QUALITY.
  2554. /// </param>
  2555. /// <param name="isSideways">Set to true if the text is intended to be
  2556. /// drawn vertically.</param>
  2557. /// <param name="isRightToLeft">Set to TRUE for right-to-left text.</param>
  2558. /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param>
  2559. /// <param name="localeName">The locale to use when selecting glyphs.
  2560. /// e.g. the same character may map to different glyphs for ja-jp vs zh-chs.
  2561. /// If this is NULL then the default mapping based on the script is used.</param>
  2562. /// <param name="features">An array of pointers to the sets of typographic
  2563. /// features to use in each feature range.</param>
  2564. /// <param name="featureRangeLengths">The length of each feature range, in characters.
  2565. /// The sum of all lengths should be equal to textLength.</param>
  2566. /// <param name="featureRanges">The number of feature ranges.</param>
  2567. /// <param name="glyphAdvances">The advance width of each glyph.</param>
  2568. /// <param name="glyphOffsets">The offset of the origin of each glyph.</param>
  2569. /// <returns>
  2570. /// Standard HRESULT error code.
  2571. /// </returns>
  2572. STDMETHOD(GetGdiCompatibleGlyphPlacements)(
  2573. __in_ecount(textLength) WCHAR const* textString,
  2574. __in_ecount(textLength) UINT16 const* clusterMap,
  2575. __in_ecount(textLength) DWRITE_SHAPING_TEXT_PROPERTIES* textProps,
  2576. UINT32 textLength,
  2577. __in_ecount(glyphCount) UINT16 const* glyphIndices,
  2578. __in_ecount(glyphCount) DWRITE_SHAPING_GLYPH_PROPERTIES const* glyphProps,
  2579. UINT32 glyphCount,
  2580. IDWriteFontFace * fontFace,
  2581. FLOAT fontEmSize,
  2582. FLOAT pixelsPerDip,
  2583. __in_opt DWRITE_MATRIX const* transform,
  2584. BOOL useGdiNatural,
  2585. BOOL isSideways,
  2586. BOOL isRightToLeft,
  2587. __in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis,
  2588. __in_z_opt WCHAR const* localeName,
  2589. __in_ecount_opt(featureRanges) DWRITE_TYPOGRAPHIC_FEATURES const** features,
  2590. __in_ecount_opt(featureRanges) UINT32 const* featureRangeLengths,
  2591. UINT32 featureRanges,
  2592. __out_ecount(glyphCount) FLOAT* glyphAdvances,
  2593. __out_ecount(glyphCount) DWRITE_GLYPH_OFFSET* glyphOffsets
  2594. ) PURE;
  2595. };
  2596. /// <summary>
  2597. /// The DWRITE_GLYPH_RUN structure contains the information needed by renderers
  2598. /// to draw glyph runs. All coordinates are in device independent pixels (DIPs).
  2599. /// </summary>
  2600. struct DWRITE_GLYPH_RUN
  2601. {
  2602. /// <summary>
  2603. /// The physical font face to draw with.
  2604. /// </summary>
  2605. __notnull IDWriteFontFace* fontFace;
  2606. /// <summary>
  2607. /// Logical size of the font in DIPs, not points (equals 1/96 inch).
  2608. /// </summary>
  2609. FLOAT fontEmSize;
  2610. /// <summary>
  2611. /// The number of glyphs.
  2612. /// </summary>
  2613. UINT32 glyphCount;
  2614. /// <summary>
  2615. /// The indices to render.
  2616. /// </summary>
  2617. __field_ecount(glyphCount) UINT16 const* glyphIndices;
  2618. /// <summary>
  2619. /// Glyph advance widths.
  2620. /// </summary>
  2621. __field_ecount_opt(glyphCount) FLOAT const* glyphAdvances;
  2622. /// <summary>
  2623. /// Glyph offsets.
  2624. /// </summary>
  2625. __field_ecount_opt(glyphCount) DWRITE_GLYPH_OFFSET const* glyphOffsets;
  2626. /// <summary>
  2627. /// If true, specifies that glyphs are rotated 90 degrees to the left and
  2628. /// vertical metrics are used. Vertical writing is achieved by specifying
  2629. /// isSideways = true and rotating the entire run 90 degrees to the right
  2630. /// via a rotate transform.
  2631. /// </summary>
  2632. BOOL isSideways;
  2633. /// <summary>
  2634. /// The implicit resolved bidi level of the run. Odd levels indicate
  2635. /// right-to-left languages like Hebrew and Arabic, while even levels
  2636. /// indicate left-to-right languages like English and Japanese (when
  2637. /// written horizontally). For right-to-left languages, the text origin
  2638. /// is on the right, and text should be drawn to the left.
  2639. /// </summary>
  2640. UINT32 bidiLevel;
  2641. };
  2642. /// <summary>
  2643. /// The DWRITE_GLYPH_RUN_DESCRIPTION structure contains additional properties
  2644. /// related to those in DWRITE_GLYPH_RUN.
  2645. /// </summary>
  2646. struct DWRITE_GLYPH_RUN_DESCRIPTION
  2647. {
  2648. /// <summary>
  2649. /// The locale name associated with this run.
  2650. /// </summary>
  2651. __nullterminated WCHAR const* localeName;
  2652. /// <summary>
  2653. /// The text associated with the glyphs.
  2654. /// </summary>
  2655. __field_ecount(stringLength) WCHAR const* string;
  2656. /// <summary>
  2657. /// The number of characters (UTF16 code-units).
  2658. /// Note that this may be different than the number of glyphs.
  2659. /// </summary>
  2660. UINT32 stringLength;
  2661. /// <summary>
  2662. /// An array of indices to the glyph indices array, of the first glyphs of
  2663. /// all the glyph clusters of the glyphs to render.
  2664. /// </summary>
  2665. __field_ecount(stringLength) UINT16 const* clusterMap;
  2666. /// <summary>
  2667. /// Corresponding text position in the original string
  2668. /// this glyph run came from.
  2669. /// </summary>
  2670. UINT32 textPosition;
  2671. };
  2672. /// <summary>
  2673. /// The DWRITE_UNDERLINE structure contains about the size and placement of
  2674. /// underlines. All coordinates are in device independent pixels (DIPs).
  2675. /// </summary>
  2676. struct DWRITE_UNDERLINE
  2677. {
  2678. /// <summary>
  2679. /// Width of the underline, measured parallel to the baseline.
  2680. /// </summary>
  2681. FLOAT width;
  2682. /// <summary>
  2683. /// Thickness of the underline, measured perpendicular to the
  2684. /// baseline.
  2685. /// </summary>
  2686. FLOAT thickness;
  2687. /// <summary>
  2688. /// Offset of the underline from the baseline.
  2689. /// A positive offset represents a position below the baseline and
  2690. /// a negative offset is above.
  2691. /// </summary>
  2692. FLOAT offset;
  2693. /// <summary>
  2694. /// Height of the tallest run where the underline applies.
  2695. /// </summary>
  2696. FLOAT runHeight;
  2697. /// <summary>
  2698. /// Reading direction of the text associated with the underline. This
  2699. /// value is used to interpret whether the width value runs horizontally
  2700. /// or vertically.
  2701. /// </summary>
  2702. DWRITE_READING_DIRECTION readingDirection;
  2703. /// <summary>
  2704. /// Flow direction of the text associated with the underline. This value
  2705. /// is used to interpret whether the thickness value advances top to
  2706. /// bottom, left to right, or right to left.
  2707. /// </summary>
  2708. DWRITE_FLOW_DIRECTION flowDirection;
  2709. /// <summary>
  2710. /// Locale of the text the underline is being drawn under. Can be
  2711. /// pertinent where the locale affects how the underline is drawn.
  2712. /// For example, in vertical text, the underline belongs on the
  2713. /// left for Chinese but on the right for Japanese.
  2714. /// This choice is completely left up to higher levels.
  2715. /// </summary>
  2716. __nullterminated WCHAR const* localeName;
  2717. /// <summary>
  2718. /// The measuring mode can be useful to the renderer to determine how
  2719. /// underlines are rendered, e.g. rounding the thickness to a whole pixel
  2720. /// in GDI-compatible modes.
  2721. /// </summary>
  2722. DWRITE_MEASURING_MODE measuringMode;
  2723. };
  2724. /// <summary>
  2725. /// The DWRITE_STRIKETHROUGH structure contains about the size and placement of
  2726. /// strickthroughs. All coordinates are in device independent pixels (DIPs).
  2727. /// </summary>
  2728. struct DWRITE_STRIKETHROUGH
  2729. {
  2730. /// <summary>
  2731. /// Width of the strikethrough, measured parallel to the baseline.
  2732. /// </summary>
  2733. FLOAT width;
  2734. /// <summary>
  2735. /// Thickness of the strikethrough, measured perpendicular to the
  2736. /// baseline.
  2737. /// </summary>
  2738. FLOAT thickness;
  2739. /// <summary>
  2740. /// Offset of the stikethrough from the baseline.
  2741. /// A positive offset represents a position below the baseline and
  2742. /// a negative offset is above.
  2743. /// </summary>
  2744. FLOAT offset;
  2745. /// <summary>
  2746. /// Reading direction of the text associated with the strikethrough. This
  2747. /// value is used to interpret whether the width value runs horizontally
  2748. /// or vertically.
  2749. /// </summary>
  2750. DWRITE_READING_DIRECTION readingDirection;
  2751. /// <summary>
  2752. /// Flow direction of the text associated with the strikethrough. This
  2753. /// value is used to interpret whether the thickness value advances top to
  2754. /// bottom, left to right, or right to left.
  2755. /// </summary>
  2756. DWRITE_FLOW_DIRECTION flowDirection;
  2757. /// <summary>
  2758. /// Locale of the range. Can be pertinent where the locale affects the style.
  2759. /// </summary>
  2760. __nullterminated WCHAR const* localeName;
  2761. /// <summary>
  2762. /// The measuring mode can be useful to the renderer to determine how
  2763. /// underlines are rendered, e.g. rounding the thickness to a whole pixel
  2764. /// in GDI-compatible modes.
  2765. /// </summary>
  2766. DWRITE_MEASURING_MODE measuringMode;
  2767. };
  2768. /// <summary>
  2769. /// The DWRITE_LINE_METRICS structure contains information about a formatted
  2770. /// line of text.
  2771. /// </summary>
  2772. struct DWRITE_LINE_METRICS
  2773. {
  2774. /// <summary>
  2775. /// The number of total text positions in the line.
  2776. /// This includes any trailing whitespace and newline characters.
  2777. /// </summary>
  2778. UINT32 length;
  2779. /// <summary>
  2780. /// The number of whitespace positions at the end of the line. Newline
  2781. /// sequences are considered whitespace.
  2782. /// </summary>
  2783. UINT32 trailingWhitespaceLength;
  2784. /// <summary>
  2785. /// The number of characters in the newline sequence at the end of the line.
  2786. /// If the count is zero, then the line was either wrapped or it is the
  2787. /// end of the text.
  2788. /// </summary>
  2789. UINT32 newlineLength;
  2790. /// <summary>
  2791. /// Height of the line as measured from top to bottom.
  2792. /// </summary>
  2793. FLOAT height;
  2794. /// <summary>
  2795. /// Distance from the top of the line to its baseline.
  2796. /// </summary>
  2797. FLOAT baseline;
  2798. /// <summary>
  2799. /// The line is trimmed.
  2800. /// </summary>
  2801. BOOL isTrimmed;
  2802. };
  2803. /// <summary>
  2804. /// The DWRITE_CLUSTER_METRICS structure contains information about a glyph cluster.
  2805. /// </summary>
  2806. struct DWRITE_CLUSTER_METRICS
  2807. {
  2808. /// <summary>
  2809. /// The total advance width of all glyphs in the cluster.
  2810. /// </summary>
  2811. FLOAT width;
  2812. /// <summary>
  2813. /// The number of text positions in the cluster.
  2814. /// </summary>
  2815. UINT16 length;
  2816. /// <summary>
  2817. /// Indicate whether line can be broken right after the cluster.
  2818. /// </summary>
  2819. UINT16 canWrapLineAfter : 1;
  2820. /// <summary>
  2821. /// Indicate whether the cluster corresponds to whitespace character.
  2822. /// </summary>
  2823. UINT16 isWhitespace : 1;
  2824. /// <summary>
  2825. /// Indicate whether the cluster corresponds to a newline character.
  2826. /// </summary>
  2827. UINT16 isNewline : 1;
  2828. /// <summary>
  2829. /// Indicate whether the cluster corresponds to soft hyphen character.
  2830. /// </summary>
  2831. UINT16 isSoftHyphen : 1;
  2832. /// <summary>
  2833. /// Indicate whether the cluster is read from right to left.
  2834. /// </summary>
  2835. UINT16 isRightToLeft : 1;
  2836. UINT16 padding : 11;
  2837. };
  2838. /// <summary>
  2839. /// Overall metrics associated with text after layout.
  2840. /// All coordinates are in device independent pixels (DIPs).
  2841. /// </summary>
  2842. struct DWRITE_TEXT_METRICS
  2843. {
  2844. /// <summary>
  2845. /// Left-most point of formatted text relative to layout box
  2846. /// (excluding any glyph overhang).
  2847. /// </summary>
  2848. FLOAT left;
  2849. /// <summary>
  2850. /// Top-most point of formatted text relative to layout box
  2851. /// (excluding any glyph overhang).
  2852. /// </summary>
  2853. FLOAT top;
  2854. /// <summary>
  2855. /// The width of the formatted text ignoring trailing whitespace
  2856. /// at the end of each line.
  2857. /// </summary>
  2858. FLOAT width;
  2859. /// <summary>
  2860. /// The width of the formatted text taking into account the
  2861. /// trailing whitespace at the end of each line.
  2862. /// </summary>
  2863. FLOAT widthIncludingTrailingWhitespace;
  2864. /// <summary>
  2865. /// The height of the formatted text. The height of an empty string
  2866. /// is determined by the size of the default font's line height.
  2867. /// </summary>
  2868. FLOAT height;
  2869. /// <summary>
  2870. /// Initial width given to the layout. Depending on whether the text
  2871. /// was wrapped or not, it can be either larger or smaller than the
  2872. /// text content width.
  2873. /// </summary>
  2874. FLOAT layoutWidth;
  2875. /// <summary>
  2876. /// Initial height given to the layout. Depending on the length of the
  2877. /// text, it may be larger or smaller than the text content height.
  2878. /// </summary>
  2879. FLOAT layoutHeight;
  2880. /// <summary>
  2881. /// The maximum reordering count of any line of text, used
  2882. /// to calculate the most number of hit-testing boxes needed.
  2883. /// If the layout has no bidirectional text or no text at all,
  2884. /// the minimum level is 1.
  2885. /// </summary>
  2886. UINT32 maxBidiReorderingDepth;
  2887. /// <summary>
  2888. /// Total number of lines.
  2889. /// </summary>
  2890. UINT32 lineCount;
  2891. };
  2892. /// <summary>
  2893. /// Properties describing the geometric measurement of an
  2894. /// application-defined inline object.
  2895. /// </summary>
  2896. struct DWRITE_INLINE_OBJECT_METRICS
  2897. {
  2898. /// <summary>
  2899. /// Width of the inline object.
  2900. /// </summary>
  2901. FLOAT width;
  2902. /// <summary>
  2903. /// Height of the inline object as measured from top to bottom.
  2904. /// </summary>
  2905. FLOAT height;
  2906. /// <summary>
  2907. /// Distance from the top of the object to the baseline where it is lined up with the adjacent text.
  2908. /// If the baseline is at the bottom, baseline simply equals height.
  2909. /// </summary>
  2910. FLOAT baseline;
  2911. /// <summary>
  2912. /// Flag indicating whether the object is to be placed upright or alongside the text baseline
  2913. /// for vertical text.
  2914. /// </summary>
  2915. BOOL supportsSideways;
  2916. };
  2917. /// <summary>
  2918. /// The DWRITE_OVERHANG_METRICS structure holds how much any visible pixels
  2919. /// (in DIPs) overshoot each side of the layout or inline objects.
  2920. /// </summary>
  2921. /// <remarks>
  2922. /// Positive overhangs indicate that the visible area extends outside the layout
  2923. /// box or inline object, while negative values mean there is whitespace inside.
  2924. /// The returned values are unaffected by rendering transforms or pixel snapping.
  2925. /// Additionally, they may not exactly match final target's pixel bounds after
  2926. /// applying grid fitting and hinting.
  2927. /// </remarks>
  2928. struct DWRITE_OVERHANG_METRICS
  2929. {
  2930. /// <summary>
  2931. /// The distance from the left-most visible DIP to its left alignment edge.
  2932. /// </summary>
  2933. FLOAT left;
  2934. /// <summary>
  2935. /// The distance from the top-most visible DIP to its top alignment edge.
  2936. /// </summary>
  2937. FLOAT top;
  2938. /// <summary>
  2939. /// The distance from the right-most visible DIP to its right alignment edge.
  2940. /// </summary>
  2941. FLOAT right;
  2942. /// <summary>
  2943. /// The distance from the bottom-most visible DIP to its bottom alignment edge.
  2944. /// </summary>
  2945. FLOAT bottom;
  2946. };
  2947. /// <summary>
  2948. /// Geometry enclosing of text positions.
  2949. /// </summary>
  2950. struct DWRITE_HIT_TEST_METRICS
  2951. {
  2952. /// <summary>
  2953. /// First text position within the geometry.
  2954. /// </summary>
  2955. UINT32 textPosition;
  2956. /// <summary>
  2957. /// Number of text positions within the geometry.
  2958. /// </summary>
  2959. UINT32 length;
  2960. /// <summary>
  2961. /// Left position of the top-left coordinate of the geometry.
  2962. /// </summary>
  2963. FLOAT left;
  2964. /// <summary>
  2965. /// Top position of the top-left coordinate of the geometry.
  2966. /// </summary>
  2967. FLOAT top;
  2968. /// <summary>
  2969. /// Geometry's width.
  2970. /// </summary>
  2971. FLOAT width;
  2972. /// <summary>
  2973. /// Geometry's height.
  2974. /// </summary>
  2975. FLOAT height;
  2976. /// <summary>
  2977. /// Bidi level of text positions enclosed within the geometry.
  2978. /// </summary>
  2979. UINT32 bidiLevel;
  2980. /// <summary>
  2981. /// Geometry encloses text?
  2982. /// </summary>
  2983. BOOL isText;
  2984. /// <summary>
  2985. /// Range is trimmed.
  2986. /// </summary>
  2987. BOOL isTrimmed;
  2988. };
  2989. interface IDWriteTextRenderer;
  2990. /// <summary>
  2991. /// The IDWriteInlineObject interface wraps an application defined inline graphic,
  2992. /// allowing DWrite to query metrics as if it was a glyph inline with the text.
  2993. /// </summary>
  2994. interface DWRITE_DECLARE_INTERFACE("8339FDE3-106F-47ab-8373-1C6295EB10B3") IDWriteInlineObject : public IUnknown
  2995. {
  2996. /// <summary>
  2997. /// The application implemented rendering callback (IDWriteTextRenderer::DrawInlineObject)
  2998. /// can use this to draw the inline object without needing to cast or query the object
  2999. /// type. The text layout does not call this method directly.
  3000. /// </summary>
  3001. /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3002. /// <param name="renderer">The renderer passed to IDWriteTextLayout::Draw as the object's containing parent.</param>
  3003. /// <param name="originX">X-coordinate at the top-left corner of the inline object.</param>
  3004. /// <param name="originY">Y-coordinate at the top-left corner of the inline object.</param>
  3005. /// <param name="isSideways">The object should be drawn on its side.</param>
  3006. /// <param name="isRightToLeft">The object is in an right-to-left context and should be drawn flipped.</param>
  3007. /// <param name="clientDrawingEffect">The drawing effect set in IDWriteTextLayout::SetDrawingEffect.</param>
  3008. /// <returns>
  3009. /// Standard HRESULT error code.
  3010. /// </returns>
  3011. STDMETHOD(Draw)(
  3012. __maybenull void* clientDrawingContext,
  3013. IDWriteTextRenderer* renderer,
  3014. FLOAT originX,
  3015. FLOAT originY,
  3016. BOOL isSideways,
  3017. BOOL isRightToLeft,
  3018. __maybenull IUnknown* clientDrawingEffect
  3019. ) PURE;
  3020. /// <summary>
  3021. /// TextLayout calls this callback function to get the measurement of the inline object.
  3022. /// </summary>
  3023. /// <param name="metrics">Returned metrics</param>
  3024. /// <returns>
  3025. /// Standard HRESULT error code.
  3026. /// </returns>
  3027. STDMETHOD(GetMetrics)(
  3028. __out DWRITE_INLINE_OBJECT_METRICS* metrics
  3029. ) PURE;
  3030. /// <summary>
  3031. /// TextLayout calls this callback function to get the visible extents (in DIPs) of the inline object.
  3032. /// In the case of a simple bitmap, with no padding and no overhang, all the overhangs will
  3033. /// simply be zeroes.
  3034. /// </summary>
  3035. /// <param name="overhangs">Overshoot of visible extents (in DIPs) outside the object.</param>
  3036. /// <returns>
  3037. /// Standard HRESULT error code.
  3038. /// </returns>
  3039. /// <remarks>
  3040. /// The overhangs should be returned relative to the reported size of the object
  3041. /// (DWRITE_INLINE_OBJECT_METRICS::width/height), and should not be baseline
  3042. /// adjusted. If you have an image that is actually 100x100 DIPs, but you want it
  3043. /// slightly inset (perhaps it has a glow) by 20 DIPs on each side, you would
  3044. /// return a width/height of 60x60 and four overhangs of 20 DIPs.
  3045. /// </remarks>
  3046. STDMETHOD(GetOverhangMetrics)(
  3047. __out DWRITE_OVERHANG_METRICS* overhangs
  3048. ) PURE;
  3049. /// <summary>
  3050. /// Layout uses this to determine the line breaking behavior of the inline object
  3051. /// amidst the text.
  3052. /// </summary>
  3053. /// <param name="breakConditionBefore">Line-breaking condition between the object and the content immediately preceding it.</param>
  3054. /// <param name="breakConditionAfter" >Line-breaking condition between the object and the content immediately following it.</param>
  3055. /// <returns>
  3056. /// Standard HRESULT error code.
  3057. /// </returns>
  3058. STDMETHOD(GetBreakConditions)(
  3059. __out DWRITE_BREAK_CONDITION* breakConditionBefore,
  3060. __out DWRITE_BREAK_CONDITION* breakConditionAfter
  3061. ) PURE;
  3062. };
  3063. /// <summary>
  3064. /// The IDWritePixelSnapping interface defines the pixel snapping properties of a text renderer.
  3065. /// </summary>
  3066. interface DWRITE_DECLARE_INTERFACE("eaf3a2da-ecf4-4d24-b644-b34f6842024b") IDWritePixelSnapping : public IUnknown
  3067. {
  3068. /// <summary>
  3069. /// Determines whether pixel snapping is disabled. The recommended default is FALSE,
  3070. /// unless doing animation that requires subpixel vertical placement.
  3071. /// </summary>
  3072. /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3073. /// <param name="isDisabled">Receives TRUE if pixel snapping is disabled or FALSE if it not.</param>
  3074. /// <returns>
  3075. /// Standard HRESULT error code.
  3076. /// </returns>
  3077. STDMETHOD(IsPixelSnappingDisabled)(
  3078. __maybenull void* clientDrawingContext,
  3079. __out BOOL* isDisabled
  3080. ) PURE;
  3081. /// <summary>
  3082. /// Gets the current transform that maps abstract coordinates to DIPs,
  3083. /// which may disable pixel snapping upon any rotation or shear.
  3084. /// </summary>
  3085. /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3086. /// <param name="transform">Receives the transform.</param>
  3087. /// <returns>
  3088. /// Standard HRESULT error code.
  3089. /// </returns>
  3090. STDMETHOD(GetCurrentTransform)(
  3091. __maybenull void* clientDrawingContext,
  3092. __out DWRITE_MATRIX* transform
  3093. ) PURE;
  3094. /// <summary>
  3095. /// Gets the number of physical pixels per DIP. A DIP (device-independent pixel) is 1/96 inch,
  3096. /// so the pixelsPerDip value is the number of logical pixels per inch divided by 96 (yielding
  3097. /// a value of 1 for 96 DPI and 1.25 for 120).
  3098. /// </summary>
  3099. /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3100. /// <param name="pixelsPerDip">Receives the number of physical pixels per DIP.</param>
  3101. /// <returns>
  3102. /// Standard HRESULT error code.
  3103. /// </returns>
  3104. STDMETHOD(GetPixelsPerDip)(
  3105. __maybenull void* clientDrawingContext,
  3106. __out FLOAT* pixelsPerDip
  3107. ) PURE;
  3108. };
  3109. /// <summary>
  3110. /// The IDWriteTextLayout interface represents a set of application-defined
  3111. /// callbacks that perform rendering of text, inline objects, and decorations
  3112. /// such as underlines.
  3113. /// </summary>
  3114. interface DWRITE_DECLARE_INTERFACE("ef8a8135-5cc6-45fe-8825-c5a0724eb819") IDWriteTextRenderer : public IDWritePixelSnapping
  3115. {
  3116. /// <summary>
  3117. /// IDWriteTextLayout::Draw calls this function to instruct the client to
  3118. /// render a run of glyphs.
  3119. /// </summary>
  3120. /// <param name="clientDrawingContext">The context passed to
  3121. /// IDWriteTextLayout::Draw.</param>
  3122. /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
  3123. /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
  3124. /// <param name="measuringMode">Specifies measuring method for glyphs in the run.
  3125. /// Renderer implementations may choose different rendering modes for given measuring methods,
  3126. /// but best results are seen when the rendering mode matches the corresponding measuring mode:
  3127. /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL
  3128. /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC
  3129. /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL
  3130. /// </param>
  3131. /// <param name="glyphRun">The glyph run to draw.</param>
  3132. /// <param name="glyphRunDescription">Properties of the characters
  3133. /// associated with this run.</param>
  3134. /// <param name="clientDrawingEffect">The drawing effect set in
  3135. /// IDWriteTextLayout::SetDrawingEffect.</param>
  3136. /// <returns>
  3137. /// Standard HRESULT error code.
  3138. /// </returns>
  3139. STDMETHOD(DrawGlyphRun)(
  3140. __maybenull void* clientDrawingContext,
  3141. FLOAT baselineOriginX,
  3142. FLOAT baselineOriginY,
  3143. DWRITE_MEASURING_MODE measuringMode,
  3144. __in DWRITE_GLYPH_RUN const* glyphRun,
  3145. __in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
  3146. __maybenull IUnknown* clientDrawingEffect
  3147. ) PURE;
  3148. /// <summary>
  3149. /// IDWriteTextLayout::Draw calls this function to instruct the client to draw
  3150. /// an underline.
  3151. /// </summary>
  3152. /// <param name="clientDrawingContext">The context passed to
  3153. /// IDWriteTextLayout::Draw.</param>
  3154. /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
  3155. /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
  3156. /// <param name="underline">Underline logical information.</param>
  3157. /// <param name="clientDrawingEffect">The drawing effect set in
  3158. /// IDWriteTextLayout::SetDrawingEffect.</param>
  3159. /// <returns>
  3160. /// Standard HRESULT error code.
  3161. /// </returns>
  3162. /// <remarks>
  3163. /// A single underline can be broken into multiple calls, depending on
  3164. /// how the formatting changes attributes. If font sizes/styles change
  3165. /// within an underline, the thickness and offset will be averaged
  3166. /// weighted according to characters.
  3167. /// To get the correct top coordinate of the underline rect, add underline::offset
  3168. /// to the baseline's Y. Otherwise the underline will be immediately under the text.
  3169. /// The x coordinate will always be passed as the left side, regardless
  3170. /// of text directionality. This simplifies drawing and reduces the
  3171. /// problem of round-off that could potentially cause gaps or a double
  3172. /// stamped alpha blend. To avoid alpha overlap, round the end points
  3173. /// to the nearest device pixel.
  3174. /// </remarks>
  3175. STDMETHOD(DrawUnderline)(
  3176. __maybenull void* clientDrawingContext,
  3177. FLOAT baselineOriginX,
  3178. FLOAT baselineOriginY,
  3179. __in DWRITE_UNDERLINE const* underline,
  3180. __maybenull IUnknown* clientDrawingEffect
  3181. ) PURE;
  3182. /// <summary>
  3183. /// IDWriteTextLayout::Draw calls this function to instruct the client to draw
  3184. /// a strikethrough.
  3185. /// </summary>
  3186. /// <param name="clientDrawingContext">The context passed to
  3187. /// IDWriteTextLayout::Draw.</param>
  3188. /// <param name="baselineOriginX">X-coordinate of the baseline.</param>
  3189. /// <param name="baselineOriginY">Y-coordinate of the baseline.</param>
  3190. /// <param name="strikethrough">Strikethrough logical information.</param>
  3191. /// <param name="clientDrawingEffect">The drawing effect set in
  3192. /// IDWriteTextLayout::SetDrawingEffect.</param>
  3193. /// <returns>
  3194. /// Standard HRESULT error code.
  3195. /// </returns>
  3196. /// <remarks>
  3197. /// A single strikethrough can be broken into multiple calls, depending on
  3198. /// how the formatting changes attributes. Strikethrough is not averaged
  3199. /// across font sizes/styles changes.
  3200. /// To get the correct top coordinate of the strikethrough rect,
  3201. /// add strikethrough::offset to the baseline's Y.
  3202. /// Like underlines, the x coordinate will always be passed as the left side,
  3203. /// regardless of text directionality.
  3204. /// </remarks>
  3205. STDMETHOD(DrawStrikethrough)(
  3206. __maybenull void* clientDrawingContext,
  3207. FLOAT baselineOriginX,
  3208. FLOAT baselineOriginY,
  3209. __in DWRITE_STRIKETHROUGH const* strikethrough,
  3210. __maybenull IUnknown* clientDrawingEffect
  3211. ) PURE;
  3212. /// <summary>
  3213. /// IDWriteTextLayout::Draw calls this application callback when it needs to
  3214. /// draw an inline object.
  3215. /// </summary>
  3216. /// <param name="clientDrawingContext">The context passed to IDWriteTextLayout::Draw.</param>
  3217. /// <param name="originX">X-coordinate at the top-left corner of the inline object.</param>
  3218. /// <param name="originY">Y-coordinate at the top-left corner of the inline object.</param>
  3219. /// <param name="inlineObject">The object set using IDWriteTextLayout::SetInlineObject.</param>
  3220. /// <param name="isSideways">The object should be drawn on its side.</param>
  3221. /// <param name="isRightToLeft">The object is in an right-to-left context and should be drawn flipped.</param>
  3222. /// <param name="clientDrawingEffect">The drawing effect set in
  3223. /// IDWriteTextLayout::SetDrawingEffect.</param>
  3224. /// <returns>
  3225. /// Standard HRESULT error code.
  3226. /// </returns>
  3227. /// <remarks>
  3228. /// The right-to-left flag is a hint for those cases where it would look
  3229. /// strange for the image to be shown normally (like an arrow pointing to
  3230. /// right to indicate a submenu).
  3231. /// </remarks>
  3232. STDMETHOD(DrawInlineObject)(
  3233. __maybenull void* clientDrawingContext,
  3234. FLOAT originX,
  3235. FLOAT originY,
  3236. IDWriteInlineObject* inlineObject,
  3237. BOOL isSideways,
  3238. BOOL isRightToLeft,
  3239. __maybenull IUnknown* clientDrawingEffect
  3240. ) PURE;
  3241. };
  3242. /// <summary>
  3243. /// The IDWriteTextLayout interface represents a block of text after it has
  3244. /// been fully analyzed and formatted.
  3245. ///
  3246. /// All coordinates are in device independent pixels (DIPs).
  3247. /// </summary>
  3248. interface DWRITE_DECLARE_INTERFACE("53737037-6d14-410b-9bfe-0b182bb70961") IDWriteTextLayout : public IDWriteTextFormat
  3249. {
  3250. /// <summary>
  3251. /// Set layout maximum width
  3252. /// </summary>
  3253. /// <param name="maxWidth">Layout maximum width</param>
  3254. /// <returns>
  3255. /// Standard HRESULT error code.
  3256. /// </returns>
  3257. STDMETHOD(SetMaxWidth)(
  3258. FLOAT maxWidth
  3259. ) PURE;
  3260. /// <summary>
  3261. /// Set layout maximum height
  3262. /// </summary>
  3263. /// <param name="maxHeight">Layout maximum height</param>
  3264. /// <returns>
  3265. /// Standard HRESULT error code.
  3266. /// </returns>
  3267. STDMETHOD(SetMaxHeight)(
  3268. FLOAT maxHeight
  3269. ) PURE;
  3270. /// <summary>
  3271. /// Set the font collection.
  3272. /// </summary>
  3273. /// <param name="fontCollection">The font collection to set</param>
  3274. /// <param name="textRange">Text range to which this change applies.</param>
  3275. /// <returns>
  3276. /// Standard HRESULT error code.
  3277. /// </returns>
  3278. STDMETHOD(SetFontCollection)(
  3279. IDWriteFontCollection* fontCollection,
  3280. DWRITE_TEXT_RANGE textRange
  3281. ) PURE;
  3282. /// <summary>
  3283. /// Set null-terminated font family name.
  3284. /// </summary>
  3285. /// <param name="fontFamilyName">Font family name</param>
  3286. /// <param name="textRange">Text range to which this change applies.</param>
  3287. /// <returns>
  3288. /// Standard HRESULT error code.
  3289. /// </returns>
  3290. STDMETHOD(SetFontFamilyName)(
  3291. __in_z WCHAR const* fontFamilyName,
  3292. DWRITE_TEXT_RANGE textRange
  3293. ) PURE;
  3294. /// <summary>
  3295. /// Set font weight.
  3296. /// </summary>
  3297. /// <param name="fontWeight">Font weight</param>
  3298. /// <param name="textRange">Text range to which this change applies.</param>
  3299. /// <returns>
  3300. /// Standard HRESULT error code.
  3301. /// </returns>
  3302. STDMETHOD(SetFontWeight)(
  3303. DWRITE_FONT_WEIGHT fontWeight,
  3304. DWRITE_TEXT_RANGE textRange
  3305. ) PURE;
  3306. /// <summary>
  3307. /// Set font style.
  3308. /// </summary>
  3309. /// <param name="fontStyle">Font style</param>
  3310. /// <param name="textRange">Text range to which this change applies.</param>
  3311. /// <returns>
  3312. /// Standard HRESULT error code.
  3313. /// </returns>
  3314. STDMETHOD(SetFontStyle)(
  3315. DWRITE_FONT_STYLE fontStyle,
  3316. DWRITE_TEXT_RANGE textRange
  3317. ) PURE;
  3318. /// <summary>
  3319. /// Set font stretch.
  3320. /// </summary>
  3321. /// <param name="fontStretch">font stretch</param>
  3322. /// <param name="textRange">Text range to which this change applies.</param>
  3323. /// <returns>
  3324. /// Standard HRESULT error code.
  3325. /// </returns>
  3326. STDMETHOD(SetFontStretch)(
  3327. DWRITE_FONT_STRETCH fontStretch,
  3328. DWRITE_TEXT_RANGE textRange
  3329. ) PURE;
  3330. /// <summary>
  3331. /// Set font em height.
  3332. /// </summary>
  3333. /// <param name="fontSize">Font em height</param>
  3334. /// <param name="textRange">Text range to which this change applies.</param>
  3335. /// <returns>
  3336. /// Standard HRESULT error code.
  3337. /// </returns>
  3338. STDMETHOD(SetFontSize)(
  3339. FLOAT fontSize,
  3340. DWRITE_TEXT_RANGE textRange
  3341. ) PURE;
  3342. /// <summary>
  3343. /// Set underline.
  3344. /// </summary>
  3345. /// <param name="hasUnderline">The Boolean flag indicates whether underline takes place</param>
  3346. /// <param name="textRange">Text range to which this change applies.</param>
  3347. /// <returns>
  3348. /// Standard HRESULT error code.
  3349. /// </returns>
  3350. STDMETHOD(SetUnderline)(
  3351. BOOL hasUnderline,
  3352. DWRITE_TEXT_RANGE textRange
  3353. ) PURE;
  3354. /// <summary>
  3355. /// Set strikethrough.
  3356. /// </summary>
  3357. /// <param name="hasStrikethrough">The Boolean flag indicates whether strikethrough takes place</param>
  3358. /// <param name="textRange">Text range to which this change applies.</param>
  3359. /// <returns>
  3360. /// Standard HRESULT error code.
  3361. /// </returns>
  3362. STDMETHOD(SetStrikethrough)(
  3363. BOOL hasStrikethrough,
  3364. DWRITE_TEXT_RANGE textRange
  3365. ) PURE;
  3366. /// <summary>
  3367. /// Set application-defined drawing effect.
  3368. /// </summary>
  3369. /// <param name="drawingEffect">Pointer to an application-defined drawing effect.</param>
  3370. /// <param name="textRange">Text range to which this change applies.</param>
  3371. /// <returns>
  3372. /// Standard HRESULT error code.
  3373. /// </returns>
  3374. /// <remarks>
  3375. /// This drawing effect is associated with the specified range and will be passed back
  3376. /// to the application via the callback when the range is drawn at drawing time.
  3377. /// </remarks>
  3378. STDMETHOD(SetDrawingEffect)(
  3379. IUnknown* drawingEffect,
  3380. DWRITE_TEXT_RANGE textRange
  3381. ) PURE;
  3382. /// <summary>
  3383. /// Set inline object.
  3384. /// </summary>
  3385. /// <param name="inlineObject">Pointer to an application-implemented inline object.</param>
  3386. /// <param name="textRange">Text range to which this change applies.</param>
  3387. /// <returns>
  3388. /// Standard HRESULT error code.
  3389. /// </returns>
  3390. /// <remarks>
  3391. /// This inline object applies to the specified range and will be passed back
  3392. /// to the application via the DrawInlineObject callback when the range is drawn.
  3393. /// Any text in that range will be suppressed.
  3394. /// </remarks>
  3395. STDMETHOD(SetInlineObject)(
  3396. IDWriteInlineObject* inlineObject,
  3397. DWRITE_TEXT_RANGE textRange
  3398. ) PURE;
  3399. /// <summary>
  3400. /// Set font typography features.
  3401. /// </summary>
  3402. /// <param name="typography">Pointer to font typography setting.</param>
  3403. /// <param name="textRange">Text range to which this change applies.</param>
  3404. /// <returns>
  3405. /// Standard HRESULT error code.
  3406. /// </returns>
  3407. STDMETHOD(SetTypography)(
  3408. IDWriteTypography* typography,
  3409. DWRITE_TEXT_RANGE textRange
  3410. ) PURE;
  3411. /// <summary>
  3412. /// Set locale name.
  3413. /// </summary>
  3414. /// <param name="localeName">Locale name</param>
  3415. /// <param name="textRange">Text range to which this change applies.</param>
  3416. /// <returns>
  3417. /// Standard HRESULT error code.
  3418. /// </returns>
  3419. STDMETHOD(SetLocaleName)(
  3420. __in_z WCHAR const* localeName,
  3421. DWRITE_TEXT_RANGE textRange
  3422. ) PURE;
  3423. /// <summary>
  3424. /// Get layout maximum width
  3425. /// </summary>
  3426. STDMETHOD_(FLOAT, GetMaxWidth)() PURE;
  3427. /// <summary>
  3428. /// Get layout maximum height
  3429. /// </summary>
  3430. STDMETHOD_(FLOAT, GetMaxHeight)() PURE;
  3431. /// <summary>
  3432. /// Get the font collection where the current position is at.
  3433. /// </summary>
  3434. /// <param name="currentPosition">The current text position.</param>
  3435. /// <param name="fontCollection">The current font collection</param>
  3436. /// <param name="textRange">Text range to which this change applies.</param>
  3437. /// <returns>
  3438. /// Standard HRESULT error code.
  3439. /// </returns>
  3440. STDMETHOD(GetFontCollection)(
  3441. UINT32 currentPosition,
  3442. __out IDWriteFontCollection** fontCollection,
  3443. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3444. ) PURE;
  3445. /// <summary>
  3446. /// Get the length of the font family name where the current position is at.
  3447. /// </summary>
  3448. /// <param name="currentPosition">The current text position.</param>
  3449. /// <param name="nameLength">Size of the character array in character count not including the terminated NULL character.</param>
  3450. /// <param name="textRange">The position range of the current format.</param>
  3451. /// <returns>
  3452. /// Standard HRESULT error code.
  3453. /// </returns>
  3454. STDMETHOD(GetFontFamilyNameLength)(
  3455. UINT32 currentPosition,
  3456. __out UINT32* nameLength,
  3457. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3458. ) PURE;
  3459. /// <summary>
  3460. /// Copy the font family name where the current position is at.
  3461. /// </summary>
  3462. /// <param name="currentPosition">The current text position.</param>
  3463. /// <param name="fontFamilyName">Character array that receives the current font family name</param>
  3464. /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param>
  3465. /// <param name="textRange">The position range of the current format.</param>
  3466. /// <returns>
  3467. /// Standard HRESULT error code.
  3468. /// </returns>
  3469. STDMETHOD(GetFontFamilyName)(
  3470. UINT32 currentPosition,
  3471. __out_ecount_z(nameSize) WCHAR* fontFamilyName,
  3472. UINT32 nameSize,
  3473. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3474. ) PURE;
  3475. /// <summary>
  3476. /// Get the font weight where the current position is at.
  3477. /// </summary>
  3478. /// <param name="currentPosition">The current text position.</param>
  3479. /// <param name="fontWeight">The current font weight</param>
  3480. /// <param name="textRange">The position range of the current format.</param>
  3481. /// <returns>
  3482. /// Standard HRESULT error code.
  3483. /// </returns>
  3484. STDMETHOD(GetFontWeight)(
  3485. UINT32 currentPosition,
  3486. __out DWRITE_FONT_WEIGHT* fontWeight,
  3487. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3488. ) PURE;
  3489. /// <summary>
  3490. /// Get the font style where the current position is at.
  3491. /// </summary>
  3492. /// <param name="currentPosition">The current text position.</param>
  3493. /// <param name="fontStyle">The current font style</param>
  3494. /// <param name="textRange">The position range of the current format.</param>
  3495. /// <returns>
  3496. /// Standard HRESULT error code.
  3497. /// </returns>
  3498. STDMETHOD(GetFontStyle)(
  3499. UINT32 currentPosition,
  3500. __out DWRITE_FONT_STYLE* fontStyle,
  3501. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3502. ) PURE;
  3503. /// <summary>
  3504. /// Get the font stretch where the current position is at.
  3505. /// </summary>
  3506. /// <param name="currentPosition">The current text position.</param>
  3507. /// <param name="fontStretch">The current font stretch</param>
  3508. /// <param name="textRange">The position range of the current format.</param>
  3509. /// <returns>
  3510. /// Standard HRESULT error code.
  3511. /// </returns>
  3512. STDMETHOD(GetFontStretch)(
  3513. UINT32 currentPosition,
  3514. __out DWRITE_FONT_STRETCH* fontStretch,
  3515. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3516. ) PURE;
  3517. /// <summary>
  3518. /// Get the font em height where the current position is at.
  3519. /// </summary>
  3520. /// <param name="currentPosition">The current text position.</param>
  3521. /// <param name="fontSize">The current font em height</param>
  3522. /// <param name="textRange">The position range of the current format.</param>
  3523. /// <returns>
  3524. /// Standard HRESULT error code.
  3525. /// </returns>
  3526. STDMETHOD(GetFontSize)(
  3527. UINT32 currentPosition,
  3528. __out FLOAT* fontSize,
  3529. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3530. ) PURE;
  3531. /// <summary>
  3532. /// Get the underline presence where the current position is at.
  3533. /// </summary>
  3534. /// <param name="currentPosition">The current text position.</param>
  3535. /// <param name="hasUnderline">The Boolean flag indicates whether text is underlined.</param>
  3536. /// <param name="textRange">The position range of the current format.</param>
  3537. /// <returns>
  3538. /// Standard HRESULT error code.
  3539. /// </returns>
  3540. STDMETHOD(GetUnderline)(
  3541. UINT32 currentPosition,
  3542. __out BOOL* hasUnderline,
  3543. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3544. ) PURE;
  3545. /// <summary>
  3546. /// Get the strikethrough presence where the current position is at.
  3547. /// </summary>
  3548. /// <param name="currentPosition">The current text position.</param>
  3549. /// <param name="hasStrikethrough">The Boolean flag indicates whether text has strikethrough.</param>
  3550. /// <param name="textRange">The position range of the current format.</param>
  3551. /// <returns>
  3552. /// Standard HRESULT error code.
  3553. /// </returns>
  3554. STDMETHOD(GetStrikethrough)(
  3555. UINT32 currentPosition,
  3556. __out BOOL* hasStrikethrough,
  3557. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3558. ) PURE;
  3559. /// <summary>
  3560. /// Get the application-defined drawing effect where the current position is at.
  3561. /// </summary>
  3562. /// <param name="currentPosition">The current text position.</param>
  3563. /// <param name="drawingEffect">The current application-defined drawing effect.</param>
  3564. /// <param name="textRange">The position range of the current format.</param>
  3565. /// <returns>
  3566. /// Standard HRESULT error code.
  3567. /// </returns>
  3568. STDMETHOD(GetDrawingEffect)(
  3569. UINT32 currentPosition,
  3570. __out IUnknown** drawingEffect,
  3571. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3572. ) PURE;
  3573. /// <summary>
  3574. /// Get the inline object at the given position.
  3575. /// </summary>
  3576. /// <param name="currentPosition">The given text position.</param>
  3577. /// <param name="inlineObject">The inline object.</param>
  3578. /// <param name="textRange">The position range of the current format.</param>
  3579. /// <returns>
  3580. /// Standard HRESULT error code.
  3581. /// </returns>
  3582. STDMETHOD(GetInlineObject)(
  3583. UINT32 currentPosition,
  3584. __out IDWriteInlineObject** inlineObject,
  3585. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3586. ) PURE;
  3587. /// <summary>
  3588. /// Get the typography setting where the current position is at.
  3589. /// </summary>
  3590. /// <param name="currentPosition">The current text position.</param>
  3591. /// <param name="typography">The current typography setting.</param>
  3592. /// <param name="textRange">The position range of the current format.</param>
  3593. /// <returns>
  3594. /// Standard HRESULT error code.
  3595. /// </returns>
  3596. STDMETHOD(GetTypography)(
  3597. UINT32 currentPosition,
  3598. __out IDWriteTypography** typography,
  3599. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3600. ) PURE;
  3601. /// <summary>
  3602. /// Get the length of the locale name where the current position is at.
  3603. /// </summary>
  3604. /// <param name="currentPosition">The current text position.</param>
  3605. /// <param name="nameLength">Size of the character array in character count not including the terminated NULL character.</param>
  3606. /// <param name="textRange">The position range of the current format.</param>
  3607. /// <returns>
  3608. /// Standard HRESULT error code.
  3609. /// </returns>
  3610. STDMETHOD(GetLocaleNameLength)(
  3611. UINT32 currentPosition,
  3612. __out UINT32* nameLength,
  3613. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3614. ) PURE;
  3615. /// <summary>
  3616. /// Get the locale name where the current position is at.
  3617. /// </summary>
  3618. /// <param name="currentPosition">The current text position.</param>
  3619. /// <param name="localeName">Character array that receives the current locale name</param>
  3620. /// <param name="nameSize">Size of the character array in character count including the terminated NULL character.</param>
  3621. /// <param name="textRange">The position range of the current format.</param>
  3622. /// <returns>
  3623. /// Standard HRESULT error code.
  3624. /// </returns>
  3625. STDMETHOD(GetLocaleName)(
  3626. UINT32 currentPosition,
  3627. __out_ecount_z(nameSize) WCHAR* localeName,
  3628. UINT32 nameSize,
  3629. __out_opt DWRITE_TEXT_RANGE* textRange = NULL
  3630. ) PURE;
  3631. /// <summary>
  3632. /// Initiate drawing of the text.
  3633. /// </summary>
  3634. /// <param name="clientDrawingContext">An application defined value
  3635. /// included in rendering callbacks.</param>
  3636. /// <param name="renderer">The set of application-defined callbacks that do
  3637. /// the actual rendering.</param>
  3638. /// <param name="originX">X-coordinate of the layout's left side.</param>
  3639. /// <param name="originY">Y-coordinate of the layout's top side.</param>
  3640. /// <returns>
  3641. /// Standard HRESULT error code.
  3642. /// </returns>
  3643. STDMETHOD(Draw)(
  3644. __maybenull void* clientDrawingContext,
  3645. IDWriteTextRenderer* renderer,
  3646. FLOAT originX,
  3647. FLOAT originY
  3648. ) PURE;
  3649. /// <summary>
  3650. /// GetLineMetrics returns properties of each line.
  3651. /// </summary>
  3652. /// <param name="lineMetrics">The array to fill with line information.</param>
  3653. /// <param name="maxLineCount">The maximum size of the lineMetrics array.</param>
  3654. /// <param name="actualLineCount">The actual size of the lineMetrics
  3655. /// array that is needed.</param>
  3656. /// <returns>
  3657. /// Standard HRESULT error code.
  3658. /// </returns>
  3659. /// <remarks>
  3660. /// If maxLineCount is not large enough E_NOT_SUFFICIENT_BUFFER,
  3661. /// which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
  3662. /// is returned and *actualLineCount is set to the number of lines
  3663. /// needed.
  3664. /// </remarks>
  3665. STDMETHOD(GetLineMetrics)(
  3666. __out_ecount_opt(maxLineCount) DWRITE_LINE_METRICS* lineMetrics,
  3667. UINT32 maxLineCount,
  3668. __out UINT32* actualLineCount
  3669. ) PURE;
  3670. /// <summary>
  3671. /// GetMetrics retrieves overall metrics for the formatted string.
  3672. /// </summary>
  3673. /// <param name="textMetrics">The returned metrics.</param>
  3674. /// <returns>
  3675. /// Standard HRESULT error code.
  3676. /// </returns>
  3677. /// <remarks>
  3678. /// Drawing effects like underline and strikethrough do not contribute
  3679. /// to the text size, which is essentially the sum of advance widths and
  3680. /// line heights. Additionally, visible swashes and other graphic
  3681. /// adornments may extend outside the returned width and height.
  3682. /// </remarks>
  3683. STDMETHOD(GetMetrics)(
  3684. __out DWRITE_TEXT_METRICS* textMetrics
  3685. ) PURE;
  3686. /// <summary>
  3687. /// GetOverhangMetrics returns the overhangs (in DIPs) of the layout and all
  3688. /// objects contained in it, including text glyphs and inline objects.
  3689. /// </summary>
  3690. /// <param name="overhangs">Overshoots of visible extents (in DIPs) outside the layout.</param>
  3691. /// <returns>
  3692. /// Standard HRESULT error code.
  3693. /// </returns>
  3694. /// <remarks>
  3695. /// Any underline and strikethrough do not contribute to the black box
  3696. /// determination, since these are actually drawn by the renderer, which
  3697. /// is allowed to draw them in any variety of styles.
  3698. /// </remarks>
  3699. STDMETHOD(GetOverhangMetrics)(
  3700. __out DWRITE_OVERHANG_METRICS* overhangs
  3701. ) PURE;
  3702. /// <summary>
  3703. /// Retrieve logical properties and measurement of each cluster.
  3704. /// </summary>
  3705. /// <param name="clusterMetrics">The array to fill with cluster information.</param>
  3706. /// <param name="maxClusterCount">The maximum size of the clusterMetrics array.</param>
  3707. /// <param name="actualClusterCount">The actual size of the clusterMetrics array that is needed.</param>
  3708. /// <returns>
  3709. /// Standard HRESULT error code.
  3710. /// </returns>
  3711. /// <remarks>
  3712. /// If maxClusterCount is not large enough E_NOT_SUFFICIENT_BUFFER,
  3713. /// which is equivalent to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),
  3714. /// is returned and *actualClusterCount is set to the number of clusters
  3715. /// needed.
  3716. /// </remarks>
  3717. STDMETHOD(GetClusterMetrics)(
  3718. __out_ecount_opt(maxClusterCount) DWRITE_CLUSTER_METRICS* clusterMetrics,
  3719. UINT32 maxClusterCount,
  3720. __out UINT32* actualClusterCount
  3721. ) PURE;
  3722. /// <summary>
  3723. /// Determines the minimum possible width the layout can be set to without
  3724. /// emergency breaking between the characters of whole words.
  3725. /// </summary>
  3726. /// <param name="minWidth">Minimum width.</param>
  3727. /// <returns>
  3728. /// Standard HRESULT error code.
  3729. /// </returns>
  3730. STDMETHOD(DetermineMinWidth)(
  3731. __out FLOAT* minWidth
  3732. ) PURE;
  3733. /// <summary>
  3734. /// Given a coordinate (in DIPs) relative to the top-left of the layout box,
  3735. /// this returns the corresponding hit-test metrics of the text string where
  3736. /// the hit-test has occurred. This is useful for mapping mouse clicks to caret
  3737. /// positions. When the given coordinate is outside the text string, the function
  3738. /// sets the output value *isInside to false but returns the nearest character
  3739. /// position.
  3740. /// </summary>
  3741. /// <param name="pointX">X coordinate to hit-test, relative to the top-left location of the layout box.</param>
  3742. /// <param name="pointY">Y coordinate to hit-test, relative to the top-left location of the layout box.</param>
  3743. /// <param name="isTrailingHit">Output flag indicating whether the hit-test location is at the leading or the trailing
  3744. /// side of the character. When the output *isInside value is set to false, this value is set according to the output
  3745. /// *position value to represent the edge closest to the hit-test location. </param>
  3746. /// <param name="isInside">Output flag indicating whether the hit-test location is inside the text string.
  3747. /// When false, the position nearest the text's edge is returned.</param>
  3748. /// <param name="hitTestMetrics">Output geometry fully enclosing the hit-test location. When the output *isInside value
  3749. /// is set to false, this structure represents the geometry enclosing the edge closest to the hit-test location.</param>
  3750. /// <returns>
  3751. /// Standard HRESULT error code.
  3752. /// </returns>
  3753. STDMETHOD(HitTestPoint)(
  3754. FLOAT pointX,
  3755. FLOAT pointY,
  3756. __out BOOL* isTrailingHit,
  3757. __out BOOL* isInside,
  3758. __out DWRITE_HIT_TEST_METRICS* hitTestMetrics
  3759. ) PURE;
  3760. /// <summary>
  3761. /// Given a text position and whether the caret is on the leading or trailing
  3762. /// edge of that position, this returns the corresponding coordinate (in DIPs)
  3763. /// relative to the top-left of the layout box. This is most useful for drawing
  3764. /// the caret's current position, but it could also be used to anchor an IME to the
  3765. /// typed text or attach a floating menu near the point of interest. It may also be
  3766. /// used to programmatically obtain the geometry of a particular text position
  3767. /// for UI automation.
  3768. /// </summary>
  3769. /// <param name="textPosition">Text position to get the coordinate of.</param>
  3770. /// <param name="isTrailingHit">Flag indicating whether the location is of the leading or the trailing side of the specified text position. </param>
  3771. /// <param name="pointX">Output caret X, relative to the top-left of the layout box.</param>
  3772. /// <param name="pointY">Output caret Y, relative to the top-left of the layout box.</param>
  3773. /// <param name="hitTestMetrics">Output geometry fully enclosing the specified text position.</param>
  3774. /// <returns>
  3775. /// Standard HRESULT error code.
  3776. /// </returns>
  3777. /// <remarks>
  3778. /// When drawing a caret at the returned X,Y, it should should be centered on X
  3779. /// and drawn from the Y coordinate down. The height will be the size of the
  3780. /// hit-tested text (which can vary in size within a line).
  3781. /// Reading direction also affects which side of the character the caret is drawn.
  3782. /// However, the returned X coordinate will be correct for either case.
  3783. /// You can get a text length back that is larger than a single character.
  3784. /// This happens for complex scripts when multiple characters form a single cluster,
  3785. /// when diacritics join their base character, or when you test a surrogate pair.
  3786. /// </remarks>
  3787. STDMETHOD(HitTestTextPosition)(
  3788. UINT32 textPosition,
  3789. BOOL isTrailingHit,
  3790. __out FLOAT* pointX,
  3791. __out FLOAT* pointY,
  3792. __out DWRITE_HIT_TEST_METRICS* hitTestMetrics
  3793. ) PURE;
  3794. /// <summary>
  3795. /// The application calls this function to get a set of hit-test metrics
  3796. /// corresponding to a range of text positions. The main usage for this
  3797. /// is to draw highlighted selection of the text string.
  3798. ///
  3799. /// The function returns E_NOT_SUFFICIENT_BUFFER, which is equivalent to
  3800. /// HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), when the buffer size of
  3801. /// hitTestMetrics is too small to hold all the regions calculated by the
  3802. /// function. In such situation, the function sets the output value
  3803. /// *actualHitTestMetricsCount to the number of geometries calculated.
  3804. /// The application is responsible to allocate a new buffer of greater
  3805. /// size and call the function again.
  3806. ///
  3807. /// A good value to use as an initial value for maxHitTestMetricsCount may
  3808. /// be calculated from the following equation:
  3809. /// maxHitTestMetricsCount = lineCount * maxBidiReorderingDepth
  3810. ///
  3811. /// where lineCount is obtained from the value of the output argument
  3812. /// *actualLineCount from the function IDWriteTextLayout::GetLineMetrics,
  3813. /// and the maxBidiReorderingDepth value from the DWRITE_TEXT_METRICS
  3814. /// structure of the output argument *textMetrics from the function
  3815. /// IDWriteFactory::CreateTextLayout.
  3816. /// </summary>
  3817. /// <param name="textPosition">First text position of the specified range.</param>
  3818. /// <param name="textLength">Number of positions of the specified range.</param>
  3819. /// <param name="originX">Offset of the X origin (left of the layout box) which is added to each of the hit-test metrics returned.</param>
  3820. /// <param name="originY">Offset of the Y origin (top of the layout box) which is added to each of the hit-test metrics returned.</param>
  3821. /// <param name="hitTestMetrics">Pointer to a buffer of the output geometry fully enclosing the specified position range.</param>
  3822. /// <param name="maxHitTestMetricsCount">Maximum number of distinct metrics it could hold in its buffer memory.</param>
  3823. /// <param name="actualHitTestMetricsCount">Actual number of metrics returned or needed.</param>
  3824. /// <returns>
  3825. /// Standard HRESULT error code.
  3826. /// </returns>
  3827. /// <remarks>
  3828. /// There are no gaps in the returned metrics. While there could be visual gaps,
  3829. /// depending on bidi ordering, each range is contiguous and reports all the text,
  3830. /// including any hidden characters and trimmed text.
  3831. /// The height of each returned range will be the same within each line, regardless
  3832. /// of how the font sizes vary.
  3833. /// </remarks>
  3834. STDMETHOD(HitTestTextRange)(
  3835. UINT32 textPosition,
  3836. UINT32 textLength,
  3837. FLOAT originX,
  3838. FLOAT originY,
  3839. __out_ecount_opt(maxHitTestMetricsCount) DWRITE_HIT_TEST_METRICS* hitTestMetrics,
  3840. UINT32 maxHitTestMetricsCount,
  3841. __out UINT32* actualHitTestMetricsCount
  3842. ) PURE;
  3843. };
  3844. /// <summary>
  3845. /// Encapsulates a 32-bit device independent bitmap and device context, which can be used for rendering glyphs.
  3846. /// </summary>
  3847. interface DWRITE_DECLARE_INTERFACE("5e5a32a3-8dff-4773-9ff6-0696eab77267") IDWriteBitmapRenderTarget : public IUnknown
  3848. {
  3849. /// <summary>
  3850. /// Draws a run of glyphs to the bitmap.
  3851. /// </summary>
  3852. /// <param name="baselineOriginX">Horizontal position of the baseline origin, in DIPs, relative to the upper-left corner of the DIB.</param>
  3853. /// <param name="baselineOriginY">Vertical position of the baseline origin, in DIPs, relative to the upper-left corner of the DIB.</param>
  3854. /// <param name="measuringMode">Specifies measuring method for glyphs in the run.
  3855. /// Renderer implementations may choose different rendering modes for different measuring methods, for example
  3856. /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL,
  3857. /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC, and
  3858. /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL.
  3859. /// </param>
  3860. /// <param name="glyphRun">Structure containing the properties of the glyph run.</param>
  3861. /// <param name="renderingParams">Object that controls rendering behavior.</param>
  3862. /// <param name="textColor">Specifies the foreground color of the text.</param>
  3863. /// <param name="blackBoxRect">Optional rectangle that receives the bounding box (in pixels not DIPs) of all the pixels affected by
  3864. /// drawing the glyph run. The black box rectangle may extend beyond the dimensions of the bitmap.</param>
  3865. /// <returns>
  3866. /// Standard HRESULT error code.
  3867. /// </returns>
  3868. STDMETHOD(DrawGlyphRun)(
  3869. FLOAT baselineOriginX,
  3870. FLOAT baselineOriginY,
  3871. DWRITE_MEASURING_MODE measuringMode,
  3872. __in DWRITE_GLYPH_RUN const* glyphRun,
  3873. IDWriteRenderingParams* renderingParams,
  3874. COLORREF textColor,
  3875. __out_opt RECT* blackBoxRect = NULL
  3876. ) PURE;
  3877. /// <summary>
  3878. /// Gets a handle to the memory device context.
  3879. /// </summary>
  3880. /// <returns>
  3881. /// Returns the device context handle.
  3882. /// </returns>
  3883. /// <remarks>
  3884. /// An application can use the device context to draw using GDI functions. An application can obtain the bitmap handle
  3885. /// (HBITMAP) by calling GetCurrentObject. An application that wants information about the underlying bitmap, including
  3886. /// a pointer to the pixel data, can call GetObject to fill in a DIBSECTION structure. The bitmap is always a 32-bit
  3887. /// top-down DIB.
  3888. /// </remarks>
  3889. STDMETHOD_(HDC, GetMemoryDC)() PURE;
  3890. /// <summary>
  3891. /// Gets the number of bitmap pixels per DIP. A DIP (device-independent pixel) is 1/96 inch so this value is the number
  3892. /// if pixels per inch divided by 96.
  3893. /// </summary>
  3894. /// <returns>
  3895. /// Returns the number of bitmap pixels per DIP.
  3896. /// </returns>
  3897. STDMETHOD_(FLOAT, GetPixelsPerDip)() PURE;
  3898. /// <summary>
  3899. /// Sets the number of bitmap pixels per DIP. A DIP (device-independent pixel) is 1/96 inch so this value is the number
  3900. /// if pixels per inch divided by 96.
  3901. /// </summary>
  3902. /// <param name="pixelsPerDip">Specifies the number of pixels per DIP.</param>
  3903. /// <returns>
  3904. /// Standard HRESULT error code.
  3905. /// </returns>
  3906. STDMETHOD(SetPixelsPerDip)(
  3907. FLOAT pixelsPerDip
  3908. ) PURE;
  3909. /// <summary>
  3910. /// Gets the transform that maps abstract coordinate to DIPs. By default this is the identity
  3911. /// transform. Note that this is unrelated to the world transform of the underlying device
  3912. /// context.
  3913. /// </summary>
  3914. /// <param name="transform">Receives the transform.</param>
  3915. /// <returns>
  3916. /// Standard HRESULT error code.
  3917. /// </returns>
  3918. STDMETHOD(GetCurrentTransform)(
  3919. __out DWRITE_MATRIX* transform
  3920. ) PURE;
  3921. /// <summary>
  3922. /// Sets the transform that maps abstract coordinate to DIPs. This does not affect the world
  3923. /// transform of the underlying device context.
  3924. /// </summary>
  3925. /// <param name="transform">Specifies the new transform. This parameter can be NULL, in which
  3926. /// case the identity transform is implied.</param>
  3927. /// <returns>
  3928. /// Standard HRESULT error code.
  3929. /// </returns>
  3930. STDMETHOD(SetCurrentTransform)(
  3931. __in_opt DWRITE_MATRIX const* transform
  3932. ) PURE;
  3933. /// <summary>
  3934. /// Gets the dimensions of the bitmap.
  3935. /// </summary>
  3936. /// <param name="size">Receives the size of the bitmap in pixels.</param>
  3937. /// <returns>
  3938. /// Standard HRESULT error code.
  3939. /// </returns>
  3940. STDMETHOD(GetSize)(
  3941. __out SIZE* size
  3942. ) PURE;
  3943. /// <summary>
  3944. /// Resizes the bitmap.
  3945. /// </summary>
  3946. /// <param name="width">New bitmap width, in pixels.</param>
  3947. /// <param name="height">New bitmap height, in pixels.</param>
  3948. /// <returns>
  3949. /// Standard HRESULT error code.
  3950. /// </returns>
  3951. STDMETHOD(Resize)(
  3952. UINT32 width,
  3953. UINT32 height
  3954. ) PURE;
  3955. };
  3956. /// <summary>
  3957. /// The GDI interop interface provides interoperability with GDI.
  3958. /// </summary>
  3959. interface DWRITE_DECLARE_INTERFACE("1edd9491-9853-4299-898f-6432983b6f3a") IDWriteGdiInterop : public IUnknown
  3960. {
  3961. /// <summary>
  3962. /// Creates a font object that matches the properties specified by the LOGFONT structure.
  3963. /// </summary>
  3964. /// <param name="logFont">Structure containing a GDI-compatible font description.</param>
  3965. /// <param name="font">Receives a newly created font object if successful, or NULL in case of error.</param>
  3966. /// <returns>
  3967. /// Standard HRESULT error code.
  3968. /// </returns>
  3969. STDMETHOD(CreateFontFromLOGFONT)(
  3970. __in LOGFONTW const* logFont,
  3971. __out IDWriteFont** font
  3972. ) PURE;
  3973. /// <summary>
  3974. /// Initializes a LOGFONT structure based on the GDI-compatible properties of the specified font.
  3975. /// </summary>
  3976. /// <param name="font">Specifies a font in the system font collection.</param>
  3977. /// <param name="logFont">Structure that receives a GDI-compatible font description.</param>
  3978. /// <param name="isSystemFont">Contains TRUE if the specified font object is part of the system font collection
  3979. /// or FALSE otherwise.</param>
  3980. /// <returns>
  3981. /// Standard HRESULT error code.
  3982. /// </returns>
  3983. STDMETHOD(ConvertFontToLOGFONT)(
  3984. IDWriteFont* font,
  3985. __out LOGFONTW* logFont,
  3986. __out BOOL* isSystemFont
  3987. ) PURE;
  3988. /// <summary>
  3989. /// Initializes a LOGFONT structure based on the GDI-compatible properties of the specified font.
  3990. /// </summary>
  3991. /// <param name="font">Specifies a font face.</param>
  3992. /// <param name="logFont">Structure that receives a GDI-compatible font description.</param>
  3993. /// <returns>
  3994. /// Standard HRESULT error code.
  3995. /// </returns>
  3996. STDMETHOD(ConvertFontFaceToLOGFONT)(
  3997. IDWriteFontFace* font,
  3998. __out LOGFONTW* logFont
  3999. ) PURE;
  4000. /// <summary>
  4001. /// Creates a font face object that corresponds to the currently selected HFONT.
  4002. /// </summary>
  4003. /// <param name="hdc">Handle to a device context into which a font has been selected. It is assumed that the client
  4004. /// has already performed font mapping and that the font selected into the DC is the actual font that would be used
  4005. /// for rendering glyphs.</param>
  4006. /// <param name="fontFace">Contains the newly created font face object, or NULL in case of failure.</param>
  4007. /// <returns>
  4008. /// Standard HRESULT error code.
  4009. /// </returns>
  4010. STDMETHOD(CreateFontFaceFromHdc)(
  4011. HDC hdc,
  4012. __out IDWriteFontFace** fontFace
  4013. ) PURE;
  4014. /// <summary>
  4015. /// Creates an object that encapsulates a bitmap and memory DC which can be used for rendering glyphs.
  4016. /// </summary>
  4017. /// <param name="hdc">Optional device context used to create a compatible memory DC.</param>
  4018. /// <param name="width">Width of the bitmap.</param>
  4019. /// <param name="height">Height of the bitmap.</param>
  4020. /// <param name="renderTarget">Receives a pointer to the newly created render target.</param>
  4021. STDMETHOD(CreateBitmapRenderTarget)(
  4022. __in_opt HDC hdc,
  4023. UINT32 width,
  4024. UINT32 height,
  4025. __out IDWriteBitmapRenderTarget** renderTarget
  4026. ) PURE;
  4027. };
  4028. /// <summary>
  4029. /// The DWRITE_TEXTURE_TYPE enumeration identifies a type of alpha texture. An alpha texture is a bitmap of alpha values, each
  4030. /// representing the darkness (i.e., opacity) of a pixel or subpixel.
  4031. /// </summary>
  4032. enum DWRITE_TEXTURE_TYPE
  4033. {
  4034. /// <summary>
  4035. /// Specifies an alpha texture for aliased text rendering (i.e., bi-level, where each pixel is either fully opaque or fully transparent),
  4036. /// with one byte per pixel.
  4037. /// </summary>
  4038. DWRITE_TEXTURE_ALIASED_1x1,
  4039. /// <summary>
  4040. /// Specifies an alpha texture for ClearType text rendering, with three bytes per pixel in the horizontal dimension and
  4041. /// one byte per pixel in the vertical dimension.
  4042. /// </summary>
  4043. DWRITE_TEXTURE_CLEARTYPE_3x1
  4044. };
  4045. /// <summary>
  4046. /// Maximum alpha value in a texture returned by IDWriteGlyphRunAnalysis::CreateAlphaTexture.
  4047. /// </summary>
  4048. #define DWRITE_ALPHA_MAX 255
  4049. /// <summary>
  4050. /// Interface that encapsulates information used to render a glyph run.
  4051. /// </summary>
  4052. interface DWRITE_DECLARE_INTERFACE("7d97dbf7-e085-42d4-81e3-6a883bded118") IDWriteGlyphRunAnalysis : public IUnknown
  4053. {
  4054. /// <summary>
  4055. /// Gets the bounding rectangle of the physical pixels affected by the glyph run.
  4056. /// </summary>
  4057. /// <param name="textureType">Specifies the type of texture requested. If a bi-level texture is requested, the
  4058. /// bounding rectangle includes only bi-level glyphs. Otherwise, the bounding rectangle includes only anti-aliased
  4059. /// glyphs.</param>
  4060. /// <param name="textureBounds">Receives the bounding rectangle, or an empty rectangle if there are no glyphs
  4061. /// if the specified type.</param>
  4062. /// <returns>
  4063. /// Standard HRESULT error code.
  4064. /// </returns>
  4065. STDMETHOD(GetAlphaTextureBounds)(
  4066. DWRITE_TEXTURE_TYPE textureType,
  4067. __out RECT* textureBounds
  4068. ) PURE;
  4069. /// <summary>
  4070. /// Creates an alpha texture of the specified type.
  4071. /// </summary>
  4072. /// <param name="textureType">Specifies the type of texture requested. If a bi-level texture is requested, the
  4073. /// texture contains only bi-level glyphs. Otherwise, the texture contains only anti-aliased glyphs.</param>
  4074. /// <param name="textureBounds">Specifies the bounding rectangle of the texture, which can be different than
  4075. /// the bounding rectangle returned by GetAlphaTextureBounds.</param>
  4076. /// <param name="alphaValues">Receives the array of alpha values.</param>
  4077. /// <param name="bufferSize">Size of the alphaValues array. The minimum size depends on the dimensions of the
  4078. /// rectangle and the type of texture requested.</param>
  4079. /// <returns>
  4080. /// Standard HRESULT error code.
  4081. /// </returns>
  4082. STDMETHOD(CreateAlphaTexture)(
  4083. DWRITE_TEXTURE_TYPE textureType,
  4084. __in RECT const* textureBounds,
  4085. __out_bcount(bufferSize) BYTE* alphaValues,
  4086. UINT32 bufferSize
  4087. ) PURE;
  4088. /// <summary>
  4089. /// Gets properties required for ClearType blending.
  4090. /// </summary>
  4091. /// <param name="renderingParams">Rendering parameters object. In most cases, the values returned in the output
  4092. /// parameters are based on the properties of this object. The exception is if a GDI-compatible rendering mode
  4093. /// is specified.</param>
  4094. /// <param name="blendGamma">Receives the gamma value to use for gamma correction.</param>
  4095. /// <param name="blendEnhancedContrast">Receives the enhanced contrast value.</param>
  4096. /// <param name="blendClearTypeLevel">Receives the ClearType level.</param>
  4097. STDMETHOD(GetAlphaBlendParams)(
  4098. IDWriteRenderingParams* renderingParams,
  4099. __out FLOAT* blendGamma,
  4100. __out FLOAT* blendEnhancedContrast,
  4101. __out FLOAT* blendClearTypeLevel
  4102. ) PURE;
  4103. };
  4104. /// <summary>
  4105. /// The root factory interface for all DWrite objects.
  4106. /// </summary>
  4107. interface DWRITE_DECLARE_INTERFACE("b859ee5a-d838-4b5b-a2e8-1adc7d93db48") IDWriteFactory : public IUnknown
  4108. {
  4109. /// <summary>
  4110. /// Gets a font collection representing the set of installed fonts.
  4111. /// </summary>
  4112. /// <param name="fontCollection">Receives a pointer to the system font collection object, or NULL in case of failure.</param>
  4113. /// <param name="checkForUpdates">If this parameter is nonzero, the function performs an immediate check for changes to the set of
  4114. /// installed fonts. If this parameter is FALSE, the function will still detect changes if the font cache service is running, but
  4115. /// there may be some latency. For example, an application might specify TRUE if it has itself just installed a font and wants to
  4116. /// be sure the font collection contains that font.</param>
  4117. /// <returns>
  4118. /// Standard HRESULT error code.
  4119. /// </returns>
  4120. STDMETHOD(GetSystemFontCollection)(
  4121. __out IDWriteFontCollection** fontCollection,
  4122. BOOL checkForUpdates = FALSE
  4123. ) PURE;
  4124. /// <summary>
  4125. /// Creates a font collection using a custom font collection loader.
  4126. /// </summary>
  4127. /// <param name="collectionLoader">Application-defined font collection loader, which must have been previously
  4128. /// registered using RegisterFontCollectionLoader.</param>
  4129. /// <param name="collectionKey">Key used by the loader to identify a collection of font files.</param>
  4130. /// <param name="collectionKeySize">Size in bytes of the collection key.</param>
  4131. /// <param name="fontCollection">Receives a pointer to the system font collection object, or NULL in case of failure.</param>
  4132. /// <returns>
  4133. /// Standard HRESULT error code.
  4134. /// </returns>
  4135. STDMETHOD(CreateCustomFontCollection)(
  4136. IDWriteFontCollectionLoader* collectionLoader,
  4137. __in_bcount(collectionKeySize) void const* collectionKey,
  4138. UINT32 collectionKeySize,
  4139. __out IDWriteFontCollection** fontCollection
  4140. ) PURE;
  4141. /// <summary>
  4142. /// Registers a custom font collection loader with the factory object.
  4143. /// </summary>
  4144. /// <param name="fontCollectionLoader">Application-defined font collection loader.</param>
  4145. /// <returns>
  4146. /// Standard HRESULT error code.
  4147. /// </returns>
  4148. STDMETHOD(RegisterFontCollectionLoader)(
  4149. IDWriteFontCollectionLoader* fontCollectionLoader
  4150. ) PURE;
  4151. /// <summary>
  4152. /// Unregisters a custom font collection loader that was previously registered using RegisterFontCollectionLoader.
  4153. /// </summary>
  4154. /// <param name="fontCollectionLoader">Application-defined font collection loader.</param>
  4155. /// <returns>
  4156. /// Standard HRESULT error code.
  4157. /// </returns>
  4158. STDMETHOD(UnregisterFontCollectionLoader)(
  4159. IDWriteFontCollectionLoader* fontCollectionLoader
  4160. ) PURE;
  4161. /// <summary>
  4162. /// CreateFontFileReference creates a font file reference object from a local font file.
  4163. /// </summary>
  4164. /// <param name="filePath">Absolute file path. Subsequent operations on the constructed object may fail
  4165. /// if the user provided filePath doesn't correspond to a valid file on the disk.</param>
  4166. /// <param name="lastWriteTime">Last modified time of the input file path. If the parameter is omitted,
  4167. /// the function will access the font file to obtain its last write time, so the clients are encouraged to specify this value
  4168. /// to avoid extra disk access. Subsequent operations on the constructed object may fail
  4169. /// if the user provided lastWriteTime doesn't match the file on the disk.</param>
  4170. /// <param name="fontFile">Contains newly created font file reference object, or NULL in case of failure.</param>
  4171. /// <returns>
  4172. /// Standard HRESULT error code.
  4173. /// </returns>
  4174. STDMETHOD(CreateFontFileReference)(
  4175. __in_z WCHAR const* filePath,
  4176. __in_opt FILETIME const* lastWriteTime,
  4177. __out IDWriteFontFile** fontFile
  4178. ) PURE;
  4179. /// <summary>
  4180. /// CreateCustomFontFileReference creates a reference to an application specific font file resource.
  4181. /// This function enables an application or a document to use a font without having to install it on the system.
  4182. /// The fontFileReferenceKey has to be unique only in the scope of the fontFileLoader used in this call.
  4183. /// </summary>
  4184. /// <param name="fontFileReferenceKey">Font file reference key that uniquely identifies the font file resource
  4185. /// during the lifetime of fontFileLoader.</param>
  4186. /// <param name="fontFileReferenceKeySize">Size of font file reference key in bytes.</param>
  4187. /// <param name="fontFileLoader">Font file loader that will be used by the font system to load data from the file identified by
  4188. /// fontFileReferenceKey.</param>
  4189. /// <param name="fontFile">Contains the newly created font file object, or NULL in case of failure.</param>
  4190. /// <returns>
  4191. /// Standard HRESULT error code.
  4192. /// </returns>
  4193. /// <remarks>
  4194. /// This function is provided for cases when an application or a document needs to use a font
  4195. /// without having to install it on the system. fontFileReferenceKey has to be unique only in the scope
  4196. /// of the fontFileLoader used in this call.
  4197. /// </remarks>
  4198. STDMETHOD(CreateCustomFontFileReference)(
  4199. __in_bcount(fontFileReferenceKeySize) void const* fontFileReferenceKey,
  4200. UINT32 fontFileReferenceKeySize,
  4201. IDWriteFontFileLoader* fontFileLoader,
  4202. __out IDWriteFontFile** fontFile
  4203. ) PURE;
  4204. /// <summary>
  4205. /// Creates a font face object.
  4206. /// </summary>
  4207. /// <param name="fontFaceType">The file format of the font face.</param>
  4208. /// <param name="numberOfFiles">The number of font files require to represent the font face.</param>
  4209. /// <param name="fontFiles">Font files representing the font face. Since IDWriteFontFace maintains its own references
  4210. /// to the input font file objects, it's OK to release them after this call.</param>
  4211. /// <param name="faceIndex">The zero based index of a font face in cases when the font files contain a collection of font faces.
  4212. /// If the font files contain a single face, this value should be zero.</param>
  4213. /// <param name="fontFaceSimulationFlags">Font face simulation flags for algorithmic emboldening and italicization.</param>
  4214. /// <param name="fontFace">Contains the newly created font face object, or NULL in case of failure.</param>
  4215. /// <returns>
  4216. /// Standard HRESULT error code.
  4217. /// </returns>
  4218. STDMETHOD(CreateFontFace)(
  4219. DWRITE_FONT_FACE_TYPE fontFaceType,
  4220. UINT32 numberOfFiles,
  4221. __in_ecount(numberOfFiles) IDWriteFontFile* const* fontFiles,
  4222. UINT32 faceIndex,
  4223. DWRITE_FONT_SIMULATIONS fontFaceSimulationFlags,
  4224. __out IDWriteFontFace** fontFace
  4225. ) PURE;
  4226. /// <summary>
  4227. /// Creates a rendering parameters object with default settings for the primary monitor.
  4228. /// </summary>
  4229. /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param>
  4230. /// <returns>
  4231. /// Standard HRESULT error code.
  4232. /// </returns>
  4233. STDMETHOD(CreateRenderingParams)(
  4234. __out IDWriteRenderingParams** renderingParams
  4235. ) PURE;
  4236. /// <summary>
  4237. /// Creates a rendering parameters object with default settings for the specified monitor.
  4238. /// </summary>
  4239. /// <param name="monitor">The monitor to read the default values from.</param>
  4240. /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param>
  4241. /// <returns>
  4242. /// Standard HRESULT error code.
  4243. /// </returns>
  4244. STDMETHOD(CreateMonitorRenderingParams)(
  4245. HMONITOR monitor,
  4246. __out IDWriteRenderingParams** renderingParams
  4247. ) PURE;
  4248. /// <summary>
  4249. /// Creates a rendering parameters object with the specified properties.
  4250. /// </summary>
  4251. /// <param name="gamma">The gamma value used for gamma correction, which must be greater than zero and cannot exceed 256.</param>
  4252. /// <param name="enhancedContrast">The amount of contrast enhancement, zero or greater.</param>
  4253. /// <param name="clearTypeLevel">The degree of ClearType level, from 0.0f (no ClearType) to 1.0f (full ClearType).</param>
  4254. /// <param name="pixelGeometry">The geometry of a device pixel.</param>
  4255. /// <param name="renderingMode">Method of rendering glyphs. In most cases, this should be DWRITE_RENDERING_MODE_DEFAULT to automatically use an appropriate mode.</param>
  4256. /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param>
  4257. /// <returns>
  4258. /// Standard HRESULT error code.
  4259. /// </returns>
  4260. STDMETHOD(CreateCustomRenderingParams)(
  4261. FLOAT gamma,
  4262. FLOAT enhancedContrast,
  4263. FLOAT clearTypeLevel,
  4264. DWRITE_PIXEL_GEOMETRY pixelGeometry,
  4265. DWRITE_RENDERING_MODE renderingMode,
  4266. __out IDWriteRenderingParams** renderingParams
  4267. ) PURE;
  4268. /// <summary>
  4269. /// Registers a font file loader with DirectWrite.
  4270. /// </summary>
  4271. /// <param name="fontFileLoader">Pointer to the implementation of the IDWriteFontFileLoader for a particular file resource type.</param>
  4272. /// <returns>
  4273. /// Standard HRESULT error code.
  4274. /// </returns>
  4275. /// <remarks>
  4276. /// This function registers a font file loader with DirectWrite.
  4277. /// Font file loader interface handles loading font file resources of a particular type from a key.
  4278. /// The font file loader interface is recommended to be implemented by a singleton object.
  4279. /// A given instance can only be registered once.
  4280. /// Succeeding attempts will return an error that it has already been registered.
  4281. /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite
  4282. /// inside their constructors and must not unregister themselves in their destructors, because
  4283. /// registration and unregistraton operations increment and decrement the object reference count respectively.
  4284. /// Instead, registration and unregistration of font file loaders with DirectWrite should be performed
  4285. /// outside of the font file loader implementation as a separate step.
  4286. /// </remarks>
  4287. STDMETHOD(RegisterFontFileLoader)(
  4288. IDWriteFontFileLoader* fontFileLoader
  4289. ) PURE;
  4290. /// <summary>
  4291. /// Unregisters a font file loader that was previously registered with the DirectWrite font system using RegisterFontFileLoader.
  4292. /// </summary>
  4293. /// <param name="fontFileLoader">Pointer to the file loader that was previously registered with the DirectWrite font system using RegisterFontFileLoader.</param>
  4294. /// <returns>
  4295. /// This function will succeed if the user loader is requested to be removed.
  4296. /// It will fail if the pointer to the file loader identifies a standard DirectWrite loader,
  4297. /// or a loader that is never registered or has already been unregistered.
  4298. /// </returns>
  4299. /// <remarks>
  4300. /// This function unregisters font file loader callbacks with the DirectWrite font system.
  4301. /// The font file loader interface is recommended to be implemented by a singleton object.
  4302. /// IMPORTANT: font file loader implementations must not register themselves with DirectWrite
  4303. /// inside their constructors and must not unregister themselves in their destructors, because
  4304. /// registration and unregistraton operations increment and decrement the object reference count respectively.
  4305. /// Instead, registration and unregistration of font file loaders with DirectWrite should be performed
  4306. /// outside of the font file loader implementation as a separate step.
  4307. /// </remarks>
  4308. STDMETHOD(UnregisterFontFileLoader)(
  4309. IDWriteFontFileLoader* fontFileLoader
  4310. ) PURE;
  4311. /// <summary>
  4312. /// Create a text format object used for text layout.
  4313. /// </summary>
  4314. /// <param name="fontFamilyName">Name of the font family</param>
  4315. /// <param name="fontCollection">Font collection. NULL indicates the system font collection.</param>
  4316. /// <param name="fontWeight">Font weight</param>
  4317. /// <param name="fontStyle">Font style</param>
  4318. /// <param name="fontStretch">Font stretch</param>
  4319. /// <param name="fontSize">Logical size of the font in DIP units. A DIP ("device-independent pixel") equals 1/96 inch.</param>
  4320. /// <param name="localeName">Locale name</param>
  4321. /// <param name="textFormat">Contains newly created text format object, or NULL in case of failure.</param>
  4322. /// <returns>
  4323. /// Standard HRESULT error code.
  4324. /// </returns>
  4325. STDMETHOD(CreateTextFormat)(
  4326. __in_z WCHAR const* fontFamilyName,
  4327. __maybenull IDWriteFontCollection* fontCollection,
  4328. DWRITE_FONT_WEIGHT fontWeight,
  4329. DWRITE_FONT_STYLE fontStyle,
  4330. DWRITE_FONT_STRETCH fontStretch,
  4331. FLOAT fontSize,
  4332. __in_z WCHAR const* localeName,
  4333. __out IDWriteTextFormat** textFormat
  4334. ) PURE;
  4335. /// <summary>
  4336. /// Create a typography object used in conjunction with text format for text layout.
  4337. /// </summary>
  4338. /// <param name="typography">Contains newly created typography object, or NULL in case of failure.</param>
  4339. /// <returns>
  4340. /// Standard HRESULT error code.
  4341. /// </returns>
  4342. STDMETHOD(CreateTypography)(
  4343. __out IDWriteTypography** typography
  4344. ) PURE;
  4345. /// <summary>
  4346. /// Create an object used for interoperability with GDI.
  4347. /// </summary>
  4348. /// <param name="gdiInterop">Receives the GDI interop object if successful, or NULL in case of failure.</param>
  4349. /// <returns>
  4350. /// Standard HRESULT error code.
  4351. /// </returns>
  4352. STDMETHOD(GetGdiInterop)(
  4353. __out IDWriteGdiInterop** gdiInterop
  4354. ) PURE;
  4355. /// <summary>
  4356. /// CreateTextLayout takes a string, format, and associated constraints
  4357. /// and produces and object representing the fully analyzed
  4358. /// and formatted result.
  4359. /// </summary>
  4360. /// <param name="string">The string to layout.</param>
  4361. /// <param name="stringLength">The length of the string.</param>
  4362. /// <param name="textFormat">The format to apply to the string.</param>
  4363. /// <param name="maxWidth">Width of the layout box.</param>
  4364. /// <param name="maxHeight">Height of the layout box.</param>
  4365. /// <param name="textLayout">The resultant object.</param>
  4366. /// <returns>
  4367. /// Standard HRESULT error code.
  4368. /// </returns>
  4369. STDMETHOD(CreateTextLayout)(
  4370. __in_ecount(stringLength) WCHAR const* string,
  4371. UINT32 stringLength,
  4372. IDWriteTextFormat* textFormat,
  4373. FLOAT maxWidth,
  4374. FLOAT maxHeight,
  4375. __out IDWriteTextLayout** textLayout
  4376. ) PURE;
  4377. /// <summary>
  4378. /// CreateGdiCompatibleTextLayout takes a string, format, and associated constraints
  4379. /// and produces and object representing the result formatted for a particular display resolution
  4380. /// and measuring method. The resulting text layout should only be used for the intended resolution,
  4381. /// and for cases where text scalability is desired, CreateTextLayout should be used instead.
  4382. /// </summary>
  4383. /// <param name="string">The string to layout.</param>
  4384. /// <param name="stringLength">The length of the string.</param>
  4385. /// <param name="textFormat">The format to apply to the string.</param>
  4386. /// <param name="layoutWidth">Width of the layout box.</param>
  4387. /// <param name="layoutHeight">Height of the layout box.</param>
  4388. /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if rendering onto a 96 DPI device then pixelsPerDip
  4389. /// is 1. If rendering onto a 120 DPI device then pixelsPerDip is 120/96.</param>
  4390. /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  4391. /// scaling specified the font size and pixelsPerDip.</param>
  4392. /// <param name="useGdiNatural">
  4393. /// When set to FALSE, instructs the text layout to use the same metrics as GDI aliased text.
  4394. /// When set to TRUE, instructs the text layout to use the same metrics as text measured by GDI using a font
  4395. /// created with CLEARTYPE_NATURAL_QUALITY.
  4396. /// </param>
  4397. /// <param name="textLayout">The resultant object.</param>
  4398. /// <returns>
  4399. /// Standard HRESULT error code.
  4400. /// </returns>
  4401. STDMETHOD(CreateGdiCompatibleTextLayout)(
  4402. __in_ecount(stringLength) WCHAR const* string,
  4403. UINT32 stringLength,
  4404. IDWriteTextFormat* textFormat,
  4405. FLOAT layoutWidth,
  4406. FLOAT layoutHeight,
  4407. FLOAT pixelsPerDip,
  4408. __in_opt DWRITE_MATRIX const* transform,
  4409. BOOL useGdiNatural,
  4410. __out IDWriteTextLayout** textLayout
  4411. ) PURE;
  4412. /// <summary>
  4413. /// The application may call this function to create an inline object for trimming, using an ellipsis as the omission sign.
  4414. /// The ellipsis will be created using the current settings of the format, including base font, style, and any effects.
  4415. /// Alternate omission signs can be created by the application by implementing IDWriteInlineObject.
  4416. /// </summary>
  4417. /// <param name="textFormat">Text format used as a template for the omission sign.</param>
  4418. /// <param name="trimmingSign">Created omission sign.</param>
  4419. /// <returns>
  4420. /// Standard HRESULT error code.
  4421. /// </returns>
  4422. STDMETHOD(CreateEllipsisTrimmingSign)(
  4423. IDWriteTextFormat* textFormat,
  4424. __out IDWriteInlineObject** trimmingSign
  4425. ) PURE;
  4426. /// <summary>
  4427. /// Return an interface to perform text analysis with.
  4428. /// </summary>
  4429. /// <param name="textAnalyzer">The resultant object.</param>
  4430. /// <returns>
  4431. /// Standard HRESULT error code.
  4432. /// </returns>
  4433. STDMETHOD(CreateTextAnalyzer)(
  4434. __out IDWriteTextAnalyzer** textAnalyzer
  4435. ) PURE;
  4436. /// <summary>
  4437. /// Creates a number substitution object using a locale name,
  4438. /// substitution method, and whether to ignore user overrides (uses NLS
  4439. /// defaults for the given culture instead).
  4440. /// </summary>
  4441. /// <param name="substitutionMethod">Method of number substitution to use.</param>
  4442. /// <param name="localeName">Which locale to obtain the digits from.</param>
  4443. /// <param name="ignoreUserOverride">Ignore the user's settings and use the locale defaults</param>
  4444. /// <param name="numberSubstitution">Receives a pointer to the newly created object.</param>
  4445. STDMETHOD(CreateNumberSubstitution)(
  4446. __in DWRITE_NUMBER_SUBSTITUTION_METHOD substitutionMethod,
  4447. __in_z WCHAR const* localeName,
  4448. __in BOOL ignoreUserOverride,
  4449. __out IDWriteNumberSubstitution** numberSubstitution
  4450. ) PURE;
  4451. /// <summary>
  4452. /// Creates a glyph run analysis object, which encapsulates information
  4453. /// used to render a glyph run.
  4454. /// </summary>
  4455. /// <param name="glyphRun">Structure specifying the properties of the glyph run.</param>
  4456. /// <param name="pixelsPerDip">Number of physical pixels per DIP. For example, if rendering onto a 96 DPI bitmap then pixelsPerDip
  4457. /// is 1. If rendering onto a 120 DPI bitmap then pixelsPerDip is 120/96.</param>
  4458. /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the
  4459. /// scaling specified the emSize and pixelsPerDip.</param>
  4460. /// <param name="renderingMode">Specifies the rendering mode, which must be one of the raster rendering modes (i.e., not default
  4461. /// and not outline).</param>
  4462. /// <param name="measuringMode">Specifies the method to measure glyphs.</param>
  4463. /// <param name="baselineOriginX">Horizontal position of the baseline origin, in DIPs.</param>
  4464. /// <param name="baselineOriginY">Vertical position of the baseline origin, in DIPs.</param>
  4465. /// <param name="glyphRunAnalysis">Receives a pointer to the newly created object.</param>
  4466. /// <returns>
  4467. /// Standard HRESULT error code.
  4468. /// </returns>
  4469. STDMETHOD(CreateGlyphRunAnalysis)(
  4470. __in DWRITE_GLYPH_RUN const* glyphRun,
  4471. FLOAT pixelsPerDip,
  4472. __in_opt DWRITE_MATRIX const* transform,
  4473. DWRITE_RENDERING_MODE renderingMode,
  4474. DWRITE_MEASURING_MODE measuringMode,
  4475. FLOAT baselineOriginX,
  4476. FLOAT baselineOriginY,
  4477. __out IDWriteGlyphRunAnalysis** glyphRunAnalysis
  4478. ) PURE;
  4479. }; // interface IDWriteFactory
  4480. /// <summary>
  4481. /// Creates a DirectWrite factory object that is used for subsequent creation of individual DirectWrite objects.
  4482. /// </summary>
  4483. /// <param name="factoryType">Identifies whether the factory object will be shared or isolated.</param>
  4484. /// <param name="iid">Identifies the DirectWrite factory interface, such as __uuidof(IDWriteFactory).</param>
  4485. /// <param name="factory">Receives the DirectWrite factory object.</param>
  4486. /// <returns>
  4487. /// Standard HRESULT error code.
  4488. /// </returns>
  4489. /// <remarks>
  4490. /// Obtains DirectWrite factory object that is used for subsequent creation of individual DirectWrite classes.
  4491. /// DirectWrite factory contains internal state such as font loader registration and cached font data.
  4492. /// In most cases it is recommended to use the shared factory object, because it allows multiple components
  4493. /// that use DirectWrite to share internal DirectWrite state and reduce memory usage.
  4494. /// However, there are cases when it is desirable to reduce the impact of a component,
  4495. /// such as a plug-in from an untrusted source, on the rest of the process by sandboxing and isolating it
  4496. /// from the rest of the process components. In such cases, it is recommended to use an isolated factory for the sandboxed
  4497. /// component.
  4498. /// </remarks>
  4499. EXTERN_C HRESULT DWRITE_EXPORT DWriteCreateFactory(
  4500. __in DWRITE_FACTORY_TYPE factoryType,
  4501. __in REFIID iid,
  4502. __out IUnknown **factory
  4503. );
  4504. // Macros used to define DirectWrite error codes.
  4505. #define FACILITY_DWRITE 0x898
  4506. #define DWRITE_ERR_BASE 0x5000
  4507. #define MAKE_DWRITE_HR(severity, code) MAKE_HRESULT(severity, FACILITY_DWRITE, (DWRITE_ERR_BASE + code))
  4508. #define MAKE_DWRITE_HR_ERR(code) MAKE_DWRITE_HR(SEVERITY_ERROR, code)
  4509. /// <summary>
  4510. /// Indicates an error in an input file such as a font file.
  4511. /// </summary>
  4512. #define DWRITE_E_FILEFORMAT MAKE_DWRITE_HR_ERR(0x000)
  4513. /// <summary>
  4514. /// Indicates an error originating in DirectWrite code, which is not expected to occur but is safe to recover from.
  4515. /// </summary>
  4516. #define DWRITE_E_UNEXPECTED MAKE_DWRITE_HR_ERR(0x001)
  4517. /// <summary>
  4518. /// Indicates the specified font does not exist.
  4519. /// </summary>
  4520. #define DWRITE_E_NOFONT MAKE_DWRITE_HR_ERR(0x002)
  4521. /// <summary>
  4522. /// A font file could not be opened because the file, directory, network location, drive, or other storage
  4523. /// location does not exist or is unavailable.
  4524. /// </summary>
  4525. #define DWRITE_E_FILENOTFOUND MAKE_DWRITE_HR_ERR(0x003)
  4526. /// <summary>
  4527. /// A font file exists but could not be opened due to access denied, sharing violation, or similar error.
  4528. /// </summary>
  4529. #define DWRITE_E_FILEACCESS MAKE_DWRITE_HR_ERR(0x004)
  4530. /// <summary>
  4531. /// A font collection is obsolete due to changes in the system.
  4532. /// </summary>
  4533. #define DWRITE_E_FONTCOLLECTIONOBSOLETE MAKE_DWRITE_HR_ERR(0x005)
  4534. /// <summary>
  4535. /// The given interface is already registered.
  4536. /// </summary>
  4537. #define DWRITE_E_ALREADYREGISTERED MAKE_DWRITE_HR_ERR(0x006)
  4538. #endif /* DWRITE_H_INCLUDED */