]> git.cworth.org Git - apitrace/blob - specs/dwrite.py
Merge remote-tracking branch 'github/master' into d2d
[apitrace] / specs / dwrite.py
1 ##########################################################################
2 #
3 # Copyright 2011 Jose Fonseca
4 # All Rights Reserved.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24 ##########################################################################/
25
26
27 from winapi import *
28 from dcommon import *
29
30
31 ID2D1SimplifiedGeometrySink = Interface("ID2D1SimplifiedGeometrySink", IUnknown)
32 IDWriteGeometrySink = Alias("IDWriteGeometrySink", ID2D1SimplifiedGeometrySink)
33
34 IDWriteFontFileLoader = Interface("IDWriteFontFileLoader", IUnknown)
35 IDWriteLocalFontFileLoader = Interface("IDWriteLocalFontFileLoader", IDWriteFontFileLoader)
36 IDWriteFontFileStream = Interface("IDWriteFontFileStream", IUnknown)
37 IDWriteFontFile = Interface("IDWriteFontFile", IUnknown)
38 IDWriteRenderingParams = Interface("IDWriteRenderingParams", IUnknown)
39 IDWriteFontFace = Interface("IDWriteFontFace", IUnknown)
40 IDWriteFontCollectionLoader = Interface("IDWriteFontCollectionLoader", IUnknown)
41 IDWriteFontFileEnumerator = Interface("IDWriteFontFileEnumerator", IUnknown)
42 IDWriteLocalizedStrings = Interface("IDWriteLocalizedStrings", IUnknown)
43 IDWriteFontCollection = Interface("IDWriteFontCollection", IUnknown)
44 IDWriteFontList = Interface("IDWriteFontList", IUnknown)
45 IDWriteFontFamily = Interface("IDWriteFontFamily", IDWriteFontList)
46 IDWriteFont = Interface("IDWriteFont", IUnknown)
47 IDWriteTextFormat = Interface("IDWriteTextFormat", IUnknown)
48 IDWriteTypography = Interface("IDWriteTypography", IUnknown)
49 IDWriteNumberSubstitution = Interface("IDWriteNumberSubstitution", IUnknown)
50 IDWriteTextAnalysisSource = Interface("IDWriteTextAnalysisSource", IUnknown)
51 IDWriteTextAnalysisSink = Interface("IDWriteTextAnalysisSink", IUnknown)
52 IDWriteTextAnalyzer = Interface("IDWriteTextAnalyzer", IUnknown)
53 IDWriteInlineObject = Interface("IDWriteInlineObject", IUnknown)
54 IDWritePixelSnapping = Interface("IDWritePixelSnapping", IUnknown)
55 IDWriteTextRenderer = Interface("IDWriteTextRenderer", IDWritePixelSnapping)
56 IDWriteTextLayout = Interface("IDWriteTextLayout", IDWriteTextFormat)
57 IDWriteBitmapRenderTarget = Interface("IDWriteBitmapRenderTarget", IUnknown)
58 IDWriteGdiInterop = Interface("IDWriteGdiInterop", IUnknown)
59 IDWriteGlyphRunAnalysis = Interface("IDWriteGlyphRunAnalysis", IUnknown)
60 IDWriteFactory = Interface("IDWriteFactory", IUnknown)
61
62
63 def EnumFlag(expr, values):
64     return Flags(Alias(expr, DWORD), values)
65
66
67 DWRITE_FONT_FILE_TYPE = Enum("DWRITE_FONT_FILE_TYPE", [
68     "DWRITE_FONT_FILE_TYPE_UNKNOWN",
69     "DWRITE_FONT_FILE_TYPE_CFF",
70     "DWRITE_FONT_FILE_TYPE_TRUETYPE",
71     "DWRITE_FONT_FILE_TYPE_TRUETYPE_COLLECTION",
72     "DWRITE_FONT_FILE_TYPE_TYPE1_PFM",
73     "DWRITE_FONT_FILE_TYPE_TYPE1_PFB",
74     "DWRITE_FONT_FILE_TYPE_VECTOR",
75     "DWRITE_FONT_FILE_TYPE_BITMAP",
76 ])
77
78 DWRITE_FONT_FACE_TYPE = Enum("DWRITE_FONT_FACE_TYPE", [
79     "DWRITE_FONT_FACE_TYPE_CFF",
80     "DWRITE_FONT_FACE_TYPE_TRUETYPE",
81     "DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION",
82     "DWRITE_FONT_FACE_TYPE_TYPE1",
83     "DWRITE_FONT_FACE_TYPE_VECTOR",
84     "DWRITE_FONT_FACE_TYPE_BITMAP",
85     "DWRITE_FONT_FACE_TYPE_UNKNOWN",
86 ])
87
88 DWRITE_FONT_SIMULATIONS = EnumFlag("DWRITE_FONT_SIMULATIONS", [
89     "DWRITE_FONT_SIMULATIONS_NONE",
90     "DWRITE_FONT_SIMULATIONS_BOLD",
91     "DWRITE_FONT_SIMULATIONS_OBLIQUE",
92 ])
93
94 DWRITE_FONT_WEIGHT = Enum("DWRITE_FONT_WEIGHT", [
95     "DWRITE_FONT_WEIGHT_THIN",
96     "DWRITE_FONT_WEIGHT_EXTRA_LIGHT",
97     #"DWRITE_FONT_WEIGHT_ULTRA_LIGHT",
98     "DWRITE_FONT_WEIGHT_LIGHT",
99     "DWRITE_FONT_WEIGHT_NORMAL",
100     #"DWRITE_FONT_WEIGHT_REGULAR",
101     "DWRITE_FONT_WEIGHT_MEDIUM",
102     "DWRITE_FONT_WEIGHT_DEMI_BOLD",
103     #"DWRITE_FONT_WEIGHT_SEMI_BOLD",
104     "DWRITE_FONT_WEIGHT_BOLD",
105     "DWRITE_FONT_WEIGHT_EXTRA_BOLD",
106     #"DWRITE_FONT_WEIGHT_ULTRA_BOLD",
107     "DWRITE_FONT_WEIGHT_BLACK",
108     #"DWRITE_FONT_WEIGHT_HEAVY",
109     "DWRITE_FONT_WEIGHT_EXTRA_BLACK",
110     #"DWRITE_FONT_WEIGHT_ULTRA_BLACK",
111 ])
112
113 DWRITE_FONT_STRETCH = Enum("DWRITE_FONT_STRETCH", [
114     "DWRITE_FONT_STRETCH_UNDEFINED",
115     "DWRITE_FONT_STRETCH_ULTRA_CONDENSED",
116     "DWRITE_FONT_STRETCH_EXTRA_CONDENSED",
117     "DWRITE_FONT_STRETCH_CONDENSED",
118     "DWRITE_FONT_STRETCH_SEMI_CONDENSED",
119     "DWRITE_FONT_STRETCH_NORMAL",
120     #"DWRITE_FONT_STRETCH_MEDIUM",
121     "DWRITE_FONT_STRETCH_SEMI_EXPANDED",
122     "DWRITE_FONT_STRETCH_EXPANDED",
123     "DWRITE_FONT_STRETCH_EXTRA_EXPANDED",
124     "DWRITE_FONT_STRETCH_ULTRA_EXPANDED",
125 ])
126
127 DWRITE_FONT_STYLE = Enum("DWRITE_FONT_STYLE", [
128     "DWRITE_FONT_STYLE_NORMAL",
129     "DWRITE_FONT_STYLE_OBLIQUE",
130     "DWRITE_FONT_STYLE_ITALIC",
131 ])
132
133 DWRITE_INFORMATIONAL_STRING_ID = Enum("DWRITE_INFORMATIONAL_STRING_ID", [
134     "DWRITE_INFORMATIONAL_STRING_NONE",
135     "DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE",
136     "DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS",
137     "DWRITE_INFORMATIONAL_STRING_TRADEMARK",
138     "DWRITE_INFORMATIONAL_STRING_MANUFACTURER",
139     "DWRITE_INFORMATIONAL_STRING_DESIGNER",
140     "DWRITE_INFORMATIONAL_STRING_DESIGNER_URL",
141     "DWRITE_INFORMATIONAL_STRING_DESCRIPTION",
142     "DWRITE_INFORMATIONAL_STRING_FONT_VENDOR_URL",
143     "DWRITE_INFORMATIONAL_STRING_LICENSE_DESCRIPTION",
144     "DWRITE_INFORMATIONAL_STRING_LICENSE_INFO_URL",
145     "DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES",
146     "DWRITE_INFORMATIONAL_STRING_WIN32_SUBFAMILY_NAMES",
147     "DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES",
148     "DWRITE_INFORMATIONAL_STRING_PREFERRED_SUBFAMILY_NAMES",
149     "DWRITE_INFORMATIONAL_STRING_SAMPLE_TEXT",
150 ])
151
152 DWRITE_FONT_METRICS = Struct("DWRITE_FONT_METRICS", [
153     (UINT16, "designUnitsPerEm"),
154     (UINT16, "ascent"),
155     (UINT16, "descent"),
156     (INT16, "lineGap"),
157     (UINT16, "capHeight"),
158     (UINT16, "xHeight"),
159     (INT16, "underlinePosition"),
160     (UINT16, "underlineThickness"),
161     (INT16, "strikethroughPosition"),
162     (UINT16, "strikethroughThickness"),
163 ])
164
165 DWRITE_GLYPH_METRICS = Struct("DWRITE_GLYPH_METRICS", [
166     (INT32, "leftSideBearing"),
167     (UINT32, "advanceWidth"),
168     (INT32, "rightSideBearing"),
169     (INT32, "topSideBearing"),
170     (UINT32, "advanceHeight"),
171     (INT32, "bottomSideBearing"),
172     (INT32, "verticalOriginY"),
173 ])
174
175 DWRITE_GLYPH_OFFSET = Struct("DWRITE_GLYPH_OFFSET", [
176     (FLOAT, "advanceOffset"),
177     (FLOAT, "ascenderOffset"),
178 ])
179
180 DWRITE_FACTORY_TYPE = Enum("DWRITE_FACTORY_TYPE", [
181     "DWRITE_FACTORY_TYPE_SHARED",
182     "DWRITE_FACTORY_TYPE_ISOLATED",
183 ])
184
185 IDWriteFontFileLoader.methods += [
186     Method(HRESULT, "CreateStreamFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(ObjPointer(IDWriteFontFileStream)), "fontFileStream")]),
187 ]
188
189 IDWriteLocalFontFileLoader.methods += [
190     Method(HRESULT, "GetFilePathLengthFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(UINT32), "filePathLength")]),
191     Method(HRESULT, "GetFilePathFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(WCHAR), "filePath"), (UINT32, "filePathSize")]),
192     Method(HRESULT, "GetLastWriteTimeFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(FILETIME), "lastWriteTime")]),
193 ]
194
195 IDWriteFontFileStream.methods += [
196     Method(HRESULT, "ReadFileFragment", [Out(Pointer(OpaquePointer(Const(Void))), "fragmentStart"), (UINT64, "fileOffset"), (UINT64, "fragmentSize"), Out(Pointer(OpaquePointer(Void)), "fragmentContext")]),
197     Method(Void, "ReleaseFileFragment", [(OpaquePointer(Void), "fragmentContext")]),
198     Method(HRESULT, "GetFileSize", [Out(Pointer(UINT64), "fileSize")]),
199     Method(HRESULT, "GetLastWriteTime", [Out(Pointer(UINT64), "lastWriteTime")]),
200 ]
201
202 IDWriteFontFile.methods += [
203     Method(HRESULT, "GetReferenceKey", [Out(Pointer(OpaquePointer(Const(Void))), "fontFileReferenceKey"), Out(Pointer(UINT32), "fontFileReferenceKeySize")]),
204     Method(HRESULT, "GetLoader", [Out(Pointer(ObjPointer(IDWriteFontFileLoader)), "fontFileLoader")]),
205     Method(HRESULT, "Analyze", [Out(Pointer(BOOL), "isSupportedFontType"), Out(Pointer(DWRITE_FONT_FILE_TYPE), "fontFileType"), Out(Pointer(DWRITE_FONT_FACE_TYPE), "fontFaceType"), Out(Pointer(UINT32), "numberOfFaces")]),
206 ]
207
208 DWRITE_PIXEL_GEOMETRY = Enum("DWRITE_PIXEL_GEOMETRY", [
209     "DWRITE_PIXEL_GEOMETRY_FLAT",
210     "DWRITE_PIXEL_GEOMETRY_RGB",
211     "DWRITE_PIXEL_GEOMETRY_BGR",
212 ])
213
214 DWRITE_RENDERING_MODE = Enum("DWRITE_RENDERING_MODE", [
215     "DWRITE_RENDERING_MODE_DEFAULT",
216     "DWRITE_RENDERING_MODE_ALIASED",
217     "DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC",
218     "DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL",
219     "DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL",
220     "DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC",
221     "DWRITE_RENDERING_MODE_OUTLINE",
222 ])
223
224 DWRITE_MATRIX = Struct("DWRITE_MATRIX", [
225     (FLOAT, "m11"),
226     (FLOAT, "m12"),
227     (FLOAT, "m21"),
228     (FLOAT, "m22"),
229     (FLOAT, "dx"),
230     (FLOAT, "dy"),
231 ])
232
233 IDWriteRenderingParams.methods += [
234     Method(FLOAT, "GetGamma", []),
235     Method(FLOAT, "GetEnhancedContrast", []),
236     Method(FLOAT, "GetClearTypeLevel", []),
237     Method(DWRITE_PIXEL_GEOMETRY, "GetPixelGeometry", []),
238     Method(DWRITE_RENDERING_MODE, "GetRenderingMode", []),
239 ]
240
241 IDWriteFontFace.methods += [
242     Method(DWRITE_FONT_FACE_TYPE, "GetType", []),
243     Method(HRESULT, "GetFiles", [(OpaquePointer(UINT32), "numberOfFiles"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFiles")]),
244     Method(UINT32, "GetIndex", []),
245     Method(DWRITE_FONT_SIMULATIONS, "GetSimulations", []),
246     Method(BOOL, "IsSymbolFont", []),
247     Method(Void, "GetMetrics", [Out(Pointer(DWRITE_FONT_METRICS), "fontFaceMetrics")]),
248     Method(UINT16, "GetGlyphCount", []),
249     Method(HRESULT, "GetDesignGlyphMetrics", [(Pointer(Const(UINT16)), "glyphIndices"), (UINT32, "glyphCount"), Out(Pointer(DWRITE_GLYPH_METRICS), "glyphMetrics"), (BOOL, "isSideways")]),
250     Method(HRESULT, "GetGlyphIndices", [(Pointer(Const(UINT32)), "codePoints"), (UINT32, "codePointCount"), Out(Pointer(UINT16), "glyphIndices")]),
251     Method(HRESULT, "TryGetFontTable", [(UINT32, "openTypeTableTag"), Out(Pointer(OpaquePointer(Const(Void))), "tableData"), Out(Pointer(UINT32), "tableSize"), Out(Pointer(OpaquePointer(Void)), "tableContext"), Out(Pointer(BOOL), "exists")]),
252     Method(Void, "ReleaseFontTable", [(OpaquePointer(Void), "tableContext")]),
253     Method(HRESULT, "GetGlyphRunOutline", [(FLOAT, "emSize"), (Pointer(Const(UINT16)), "glyphIndices"), (Pointer(Const(FLOAT)), "glyphAdvances"), (Pointer(Const(DWRITE_GLYPH_OFFSET)), "glyphOffsets"), (UINT32, "glyphCount"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (ObjPointer(IDWriteGeometrySink), "geometrySink")]),
254     Method(HRESULT, "GetRecommendedRenderingMode", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (DWRITE_MEASURING_MODE, "measuringMode"), (ObjPointer(IDWriteRenderingParams), "renderingParams"), Out(Pointer(DWRITE_RENDERING_MODE), "renderingMode")]),
255     Method(HRESULT, "GetGdiCompatibleMetrics", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), Out(Pointer(DWRITE_FONT_METRICS), "fontFaceMetrics")]),
256     Method(HRESULT, "GetGdiCompatibleGlyphMetrics", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (BOOL, "useGdiNatural"), (Array(Const(UINT16), "glyphCount"), "glyphIndices"), (UINT32, "glyphCount"), Out(Array(DWRITE_GLYPH_METRICS, "glyphCount"), "glyphMetrics"), (BOOL, "isSideways")]),
257 ]
258
259 IDWriteFontCollectionLoader.methods += [
260     Method(HRESULT, "CreateEnumeratorFromKey", [(ObjPointer(IDWriteFactory), "factory"), (OpaquePointer(Const(Void)), "collectionKey"), (UINT32, "collectionKeySize"), Out(Pointer(ObjPointer(IDWriteFontFileEnumerator)), "fontFileEnumerator")]),
261 ]
262
263 IDWriteFontFileEnumerator.methods += [
264     Method(HRESULT, "MoveNext", [Out(Pointer(BOOL), "hasCurrentFile")]),
265     Method(HRESULT, "GetCurrentFontFile", [Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
266 ]
267
268 IDWriteLocalizedStrings.methods += [
269     Method(UINT32, "GetCount", []),
270     Method(HRESULT, "FindLocaleName", [(Pointer(Const(WCHAR)), "localeName"), Out(Pointer(UINT32), "index"), Out(Pointer(BOOL), "exists")]),
271     Method(HRESULT, "GetLocaleNameLength", [(UINT32, "index"), Out(Pointer(UINT32), "length")]),
272     Method(HRESULT, "GetLocaleName", [(UINT32, "index"), Out(Pointer(WCHAR), "localeName"), (UINT32, "size")]),
273     Method(HRESULT, "GetStringLength", [(UINT32, "index"), Out(Pointer(UINT32), "length")]),
274     Method(HRESULT, "GetString", [(UINT32, "index"), Out(Pointer(WCHAR), "stringBuffer"), (UINT32, "size")]),
275 ]
276
277 IDWriteFontCollection.methods += [
278     Method(UINT32, "GetFontFamilyCount", []),
279     Method(HRESULT, "GetFontFamily", [(UINT32, "index"), Out(Pointer(ObjPointer(IDWriteFontFamily)), "fontFamily")]),
280     Method(HRESULT, "FindFamilyName", [(Pointer(Const(WCHAR)), "familyName"), Out(Pointer(UINT32), "index"), Out(Pointer(BOOL), "exists")]),
281     Method(HRESULT, "GetFontFromFontFace", [(ObjPointer(IDWriteFontFace), "fontFace"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
282 ]
283
284 IDWriteFontList.methods += [
285     Method(HRESULT, "GetFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
286     Method(UINT32, "GetFontCount", []),
287     Method(HRESULT, "GetFont", [(UINT32, "index"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
288 ]
289
290 IDWriteFontFamily.methods += [
291     Method(HRESULT, "GetFamilyNames", [Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "names")]),
292     Method(HRESULT, "GetFirstMatchingFont", [(DWRITE_FONT_WEIGHT, "weight"), (DWRITE_FONT_STRETCH, "stretch"), (DWRITE_FONT_STYLE, "style"), Out(Pointer(ObjPointer(IDWriteFont)), "matchingFont")]),
293     Method(HRESULT, "GetMatchingFonts", [(DWRITE_FONT_WEIGHT, "weight"), (DWRITE_FONT_STRETCH, "stretch"), (DWRITE_FONT_STYLE, "style"), Out(Pointer(ObjPointer(IDWriteFontList)), "matchingFonts")]),
294 ]
295
296 IDWriteFont.methods += [
297     Method(HRESULT, "GetFontFamily", [Out(Pointer(ObjPointer(IDWriteFontFamily)), "fontFamily")]),
298     Method(DWRITE_FONT_WEIGHT, "GetWeight", []),
299     Method(DWRITE_FONT_STRETCH, "GetStretch", []),
300     Method(DWRITE_FONT_STYLE, "GetStyle", []),
301     Method(BOOL, "IsSymbolFont", []),
302     Method(HRESULT, "GetFaceNames", [Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "names")]),
303     Method(HRESULT, "GetInformationalStrings", [(DWRITE_INFORMATIONAL_STRING_ID, "informationalStringID"), Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "informationalStrings"), Out(Pointer(BOOL), "exists")]),
304     Method(DWRITE_FONT_SIMULATIONS, "GetSimulations", []),
305     Method(Void, "GetMetrics", [Out(Pointer(DWRITE_FONT_METRICS), "fontMetrics")]),
306     Method(HRESULT, "HasCharacter", [(UINT32, "unicodeValue"), Out(Pointer(BOOL), "exists")]),
307     Method(HRESULT, "CreateFontFace", [Out(Pointer(ObjPointer(IDWriteFontFace)), "fontFace")]),
308 ]
309
310 DWRITE_READING_DIRECTION = Enum("DWRITE_READING_DIRECTION", [
311     "DWRITE_READING_DIRECTION_LEFT_TO_RIGHT",
312     "DWRITE_READING_DIRECTION_RIGHT_TO_LEFT",
313 ])
314
315 DWRITE_FLOW_DIRECTION = Enum("DWRITE_FLOW_DIRECTION", [
316     "DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM",
317 ])
318
319 DWRITE_TEXT_ALIGNMENT = Enum("DWRITE_TEXT_ALIGNMENT", [
320     "DWRITE_TEXT_ALIGNMENT_LEADING",
321     "DWRITE_TEXT_ALIGNMENT_TRAILING",
322     "DWRITE_TEXT_ALIGNMENT_CENTER",
323 ])
324
325 DWRITE_PARAGRAPH_ALIGNMENT = Enum("DWRITE_PARAGRAPH_ALIGNMENT", [
326     "DWRITE_PARAGRAPH_ALIGNMENT_NEAR",
327     "DWRITE_PARAGRAPH_ALIGNMENT_FAR",
328     "DWRITE_PARAGRAPH_ALIGNMENT_CENTER",
329 ])
330
331 DWRITE_WORD_WRAPPING = Enum("DWRITE_WORD_WRAPPING", [
332     "DWRITE_WORD_WRAPPING_WRAP",
333     "DWRITE_WORD_WRAPPING_NO_WRAP",
334 ])
335
336 DWRITE_LINE_SPACING_METHOD = Enum("DWRITE_LINE_SPACING_METHOD", [
337     "DWRITE_LINE_SPACING_METHOD_DEFAULT",
338     "DWRITE_LINE_SPACING_METHOD_UNIFORM",
339 ])
340
341 DWRITE_TRIMMING_GRANULARITY = Enum("DWRITE_TRIMMING_GRANULARITY", [
342     "DWRITE_TRIMMING_GRANULARITY_NONE",
343     "DWRITE_TRIMMING_GRANULARITY_CHARACTER",
344     "DWRITE_TRIMMING_GRANULARITY_WORD",
345 ])
346
347 DWRITE_FONT_FEATURE_TAG = Enum("DWRITE_FONT_FEATURE_TAG", [
348     "DWRITE_FONT_FEATURE_TAG_ALTERNATIVE_FRACTIONS",
349     "DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS_FROM_CAPITALS",
350     "DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS_FROM_CAPITALS",
351     "DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_ALTERNATES",
352     "DWRITE_FONT_FEATURE_TAG_CASE_SENSITIVE_FORMS",
353     "DWRITE_FONT_FEATURE_TAG_GLYPH_COMPOSITION_DECOMPOSITION",
354     "DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_LIGATURES",
355     "DWRITE_FONT_FEATURE_TAG_CAPITAL_SPACING",
356     "DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_SWASH",
357     "DWRITE_FONT_FEATURE_TAG_CURSIVE_POSITIONING",
358     "DWRITE_FONT_FEATURE_TAG_DEFAULT",
359     "DWRITE_FONT_FEATURE_TAG_DISCRETIONARY_LIGATURES",
360     "DWRITE_FONT_FEATURE_TAG_EXPERT_FORMS",
361     "DWRITE_FONT_FEATURE_TAG_FRACTIONS",
362     "DWRITE_FONT_FEATURE_TAG_FULL_WIDTH",
363     "DWRITE_FONT_FEATURE_TAG_HALF_FORMS",
364     "DWRITE_FONT_FEATURE_TAG_HALANT_FORMS",
365     "DWRITE_FONT_FEATURE_TAG_ALTERNATE_HALF_WIDTH",
366     "DWRITE_FONT_FEATURE_TAG_HISTORICAL_FORMS",
367     "DWRITE_FONT_FEATURE_TAG_HORIZONTAL_KANA_ALTERNATES",
368     "DWRITE_FONT_FEATURE_TAG_HISTORICAL_LIGATURES",
369     "DWRITE_FONT_FEATURE_TAG_HALF_WIDTH",
370     "DWRITE_FONT_FEATURE_TAG_HOJO_KANJI_FORMS",
371     "DWRITE_FONT_FEATURE_TAG_JIS04_FORMS",
372     "DWRITE_FONT_FEATURE_TAG_JIS78_FORMS",
373     "DWRITE_FONT_FEATURE_TAG_JIS83_FORMS",
374     "DWRITE_FONT_FEATURE_TAG_JIS90_FORMS",
375     "DWRITE_FONT_FEATURE_TAG_KERNING",
376     "DWRITE_FONT_FEATURE_TAG_STANDARD_LIGATURES",
377     "DWRITE_FONT_FEATURE_TAG_LINING_FIGURES",
378     "DWRITE_FONT_FEATURE_TAG_LOCALIZED_FORMS",
379     "DWRITE_FONT_FEATURE_TAG_MARK_POSITIONING",
380     "DWRITE_FONT_FEATURE_TAG_MATHEMATICAL_GREEK",
381     "DWRITE_FONT_FEATURE_TAG_MARK_TO_MARK_POSITIONING",
382     "DWRITE_FONT_FEATURE_TAG_ALTERNATE_ANNOTATION_FORMS",
383     "DWRITE_FONT_FEATURE_TAG_NLC_KANJI_FORMS",
384     "DWRITE_FONT_FEATURE_TAG_OLD_STYLE_FIGURES",
385     "DWRITE_FONT_FEATURE_TAG_ORDINALS",
386     "DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_ALTERNATE_WIDTH",
387     "DWRITE_FONT_FEATURE_TAG_PETITE_CAPITALS",
388     "DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_FIGURES",
389     "DWRITE_FONT_FEATURE_TAG_PROPORTIONAL_WIDTHS",
390     "DWRITE_FONT_FEATURE_TAG_QUARTER_WIDTHS",
391     "DWRITE_FONT_FEATURE_TAG_REQUIRED_LIGATURES",
392     "DWRITE_FONT_FEATURE_TAG_RUBY_NOTATION_FORMS",
393     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_ALTERNATES",
394     "DWRITE_FONT_FEATURE_TAG_SCIENTIFIC_INFERIORS",
395     "DWRITE_FONT_FEATURE_TAG_SMALL_CAPITALS",
396     "DWRITE_FONT_FEATURE_TAG_SIMPLIFIED_FORMS",
397     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_1",
398     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_2",
399     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_3",
400     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_4",
401     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_5",
402     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_6",
403     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_7",
404     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_8",
405     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_9",
406     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_10",
407     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_11",
408     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_12",
409     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_13",
410     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_14",
411     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_15",
412     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_16",
413     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_17",
414     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_18",
415     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_19",
416     "DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET_20",
417     "DWRITE_FONT_FEATURE_TAG_SUBSCRIPT",
418     "DWRITE_FONT_FEATURE_TAG_SUPERSCRIPT",
419     "DWRITE_FONT_FEATURE_TAG_SWASH",
420     "DWRITE_FONT_FEATURE_TAG_TITLING",
421     "DWRITE_FONT_FEATURE_TAG_TRADITIONAL_NAME_FORMS",
422     "DWRITE_FONT_FEATURE_TAG_TABULAR_FIGURES",
423     "DWRITE_FONT_FEATURE_TAG_TRADITIONAL_FORMS",
424     "DWRITE_FONT_FEATURE_TAG_THIRD_WIDTHS",
425     "DWRITE_FONT_FEATURE_TAG_UNICASE",
426     "DWRITE_FONT_FEATURE_TAG_SLASHED_ZERO",
427 ])
428
429 DWRITE_TEXT_RANGE = Struct("DWRITE_TEXT_RANGE", [
430     (UINT32, "startPosition"),
431     (UINT32, "length"),
432 ])
433
434 DWRITE_FONT_FEATURE = Struct("DWRITE_FONT_FEATURE", [
435     (DWRITE_FONT_FEATURE_TAG, "nameTag"),
436     (UINT32, "parameter"),
437 ])
438
439 DWRITE_TYPOGRAPHIC_FEATURES = Struct("DWRITE_TYPOGRAPHIC_FEATURES", [
440     (OpaquePointer(DWRITE_FONT_FEATURE), "features"),
441     (UINT32, "featureCount"),
442 ])
443
444 DWRITE_TRIMMING = Struct("DWRITE_TRIMMING", [
445     (DWRITE_TRIMMING_GRANULARITY, "granularity"),
446     (UINT32, "delimiter"),
447     (UINT32, "delimiterCount"),
448 ])
449
450 IDWriteTextFormat.methods += [
451     Method(HRESULT, "SetTextAlignment", [(DWRITE_TEXT_ALIGNMENT, "textAlignment")]),
452     Method(HRESULT, "SetParagraphAlignment", [(DWRITE_PARAGRAPH_ALIGNMENT, "paragraphAlignment")]),
453     Method(HRESULT, "SetWordWrapping", [(DWRITE_WORD_WRAPPING, "wordWrapping")]),
454     Method(HRESULT, "SetReadingDirection", [(DWRITE_READING_DIRECTION, "readingDirection")]),
455     Method(HRESULT, "SetFlowDirection", [(DWRITE_FLOW_DIRECTION, "flowDirection")]),
456     Method(HRESULT, "SetIncrementalTabStop", [(FLOAT, "incrementalTabStop")]),
457     Method(HRESULT, "SetTrimming", [(Pointer(Const(DWRITE_TRIMMING)), "trimmingOptions"), (ObjPointer(IDWriteInlineObject), "trimmingSign")]),
458     Method(HRESULT, "SetLineSpacing", [(DWRITE_LINE_SPACING_METHOD, "lineSpacingMethod"), (FLOAT, "lineSpacing"), (FLOAT, "baseline")]),
459     Method(DWRITE_TEXT_ALIGNMENT, "GetTextAlignment", []),
460     Method(DWRITE_PARAGRAPH_ALIGNMENT, "GetParagraphAlignment", []),
461     Method(DWRITE_WORD_WRAPPING, "GetWordWrapping", []),
462     Method(DWRITE_READING_DIRECTION, "GetReadingDirection", []),
463     Method(DWRITE_FLOW_DIRECTION, "GetFlowDirection", []),
464     Method(FLOAT, "GetIncrementalTabStop", []),
465     Method(HRESULT, "GetTrimming", [Out(Pointer(DWRITE_TRIMMING), "trimmingOptions"), Out(Pointer(ObjPointer(IDWriteInlineObject)), "trimmingSign")]),
466     Method(HRESULT, "GetLineSpacing", [Out(Pointer(DWRITE_LINE_SPACING_METHOD), "lineSpacingMethod"), Out(Pointer(FLOAT), "lineSpacing"), Out(Pointer(FLOAT), "baseline")]),
467     Method(HRESULT, "GetFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
468     Method(UINT32, "GetFontFamilyNameLength", []),
469     Method(HRESULT, "GetFontFamilyName", [Out(Pointer(WCHAR), "fontFamilyName"), (UINT32, "nameSize")]),
470     Method(DWRITE_FONT_WEIGHT, "GetFontWeight", []),
471     Method(DWRITE_FONT_STYLE, "GetFontStyle", []),
472     Method(DWRITE_FONT_STRETCH, "GetFontStretch", []),
473     Method(FLOAT, "GetFontSize", []),
474     Method(UINT32, "GetLocaleNameLength", []),
475     Method(HRESULT, "GetLocaleName", [Out(Pointer(WCHAR), "localeName"), (UINT32, "nameSize")]),
476 ]
477
478 IDWriteTypography.methods += [
479     Method(HRESULT, "AddFontFeature", [(DWRITE_FONT_FEATURE, "fontFeature")]),
480     Method(UINT32, "GetFontFeatureCount", []),
481     Method(HRESULT, "GetFontFeature", [(UINT32, "fontFeatureIndex"), Out(Pointer(DWRITE_FONT_FEATURE), "fontFeature")]),
482 ]
483
484 DWRITE_SCRIPT_SHAPES = EnumFlag("DWRITE_SCRIPT_SHAPES", [
485     "DWRITE_SCRIPT_SHAPES_DEFAULT",
486     "DWRITE_SCRIPT_SHAPES_NO_VISUAL",
487 ])
488
489 DWRITE_SCRIPT_ANALYSIS = Struct("DWRITE_SCRIPT_ANALYSIS", [
490     (UINT16, "script"),
491     (DWRITE_SCRIPT_SHAPES, "shapes"),
492 ])
493
494 DWRITE_BREAK_CONDITION = Enum("DWRITE_BREAK_CONDITION", [
495     "DWRITE_BREAK_CONDITION_NEUTRAL",
496     "DWRITE_BREAK_CONDITION_CAN_BREAK",
497     "DWRITE_BREAK_CONDITION_MAY_NOT_BREAK",
498     "DWRITE_BREAK_CONDITION_MUST_BREAK",
499 ])
500
501 DWRITE_LINE_BREAKPOINT = Struct("DWRITE_LINE_BREAKPOINT", [
502     (UINT8, "breakConditionBefore"),
503     (UINT8, "breakConditionAfter"),
504     (UINT8, "isWhitespace"),
505     (UINT8, "isSoftHyphen"),
506     (UINT8, "padding"),
507 ])
508
509 DWRITE_NUMBER_SUBSTITUTION_METHOD = Enum("DWRITE_NUMBER_SUBSTITUTION_METHOD", [
510     "DWRITE_NUMBER_SUBSTITUTION_METHOD_FROM_CULTURE",
511     "DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL",
512     "DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE",
513     "DWRITE_NUMBER_SUBSTITUTION_METHOD_NATIONAL",
514     "DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL",
515 ])
516
517 IDWriteNumberSubstitution.methods += [
518 ]
519
520 DWRITE_SHAPING_TEXT_PROPERTIES = Struct("DWRITE_SHAPING_TEXT_PROPERTIES", [
521     (UINT16, "isShapedAlone"),
522     (UINT16, "reserved"),
523 ])
524
525 DWRITE_SHAPING_GLYPH_PROPERTIES = Struct("DWRITE_SHAPING_GLYPH_PROPERTIES", [
526     (UINT16, "justification"),
527     (UINT16, "isClusterStart"),
528     (UINT16, "isDiacritic"),
529     (UINT16, "isZeroWidthSpace"),
530     (UINT16, "reserved"),
531 ])
532
533 IDWriteTextAnalysisSource.methods += [
534     Method(HRESULT, "GetTextAtPosition", [(UINT32, "textPosition"), Out(Pointer(Pointer(Const(WCHAR))), "textString"), Out(Pointer(UINT32), "textLength")]),
535     Method(HRESULT, "GetTextBeforePosition", [(UINT32, "textPosition"), Out(Pointer(Pointer(Const(WCHAR))), "textString"), Out(Pointer(UINT32), "textLength")]),
536     Method(DWRITE_READING_DIRECTION, "GetParagraphReadingDirection", []),
537     Method(HRESULT, "GetLocaleName", [(UINT32, "textPosition"), Out(Pointer(UINT32), "textLength"), Out(Pointer(Pointer(Const(WCHAR))), "localeName")]),
538     Method(HRESULT, "GetNumberSubstitution", [(UINT32, "textPosition"), Out(Pointer(UINT32), "textLength"), Out(Pointer(ObjPointer(IDWriteNumberSubstitution)), "numberSubstitution")]),
539 ]
540
541 IDWriteTextAnalysisSink.methods += [
542     Method(HRESULT, "SetScriptAnalysis", [(UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis")]),
543     Method(HRESULT, "SetLineBreakpoints", [(UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(Const(DWRITE_LINE_BREAKPOINT)), "lineBreakpoints")]),
544     Method(HRESULT, "SetBidiLevel", [(UINT32, "textPosition"), (UINT32, "textLength"), (UINT8, "explicitLevel"), (UINT8, "resolvedLevel")]),
545     Method(HRESULT, "SetNumberSubstitution", [(UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteNumberSubstitution), "numberSubstitution")]),
546 ]
547
548 IDWriteTextAnalyzer.methods += [
549     Method(HRESULT, "AnalyzeScript", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
550     Method(HRESULT, "AnalyzeBidi", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
551     Method(HRESULT, "AnalyzeNumberSubstitution", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
552     Method(HRESULT, "AnalyzeLineBreakpoints", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
553     Method(HRESULT, "GetGlyphs", [(Pointer(Const(WCHAR)), "textString"), (UINT32, "textLength"), (ObjPointer(IDWriteFontFace), "fontFace"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (Pointer(Const(WCHAR)), "localeName"), (ObjPointer(IDWriteNumberSubstitution), "numberSubstitution"), (OpaquePointer(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES))), "features"), (Pointer(Const(UINT32)), "featureRangeLengths"), (UINT32, "featureRanges"), (UINT32, "maxGlyphCount"), Out(Pointer(UINT16), "clusterMap"), Out(Pointer(DWRITE_SHAPING_TEXT_PROPERTIES), "textProps"), Out(Pointer(UINT16), "glyphIndices"), Out(Pointer(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphProps"), Out(Pointer(UINT32), "actualGlyphCount")]),
554     Method(HRESULT, "GetGlyphPlacements", [(Array(Const(WCHAR), "textLength"), "textString"), (Array(Const(UINT16), "textLength"), "clusterMap"), (Array(DWRITE_SHAPING_TEXT_PROPERTIES, "textLength"), "textProps"), (UINT32, "textLength"), (Array(Const(UINT16), "glyphCount"), "glyphIndices"), (Array(Const(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphCount"), "glyphProps"), (UINT32, "glyphCount"), (ObjPointer(IDWriteFontFace), "fontFace"), (FLOAT, "fontEmSize"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (LPCWSTR, "localeName"), (Array(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES)), "featureRanges"), "features"), (Array(Const(UINT32), "featureRanges"), "featureRangeLengths"), (UINT32, "featureRanges"), Out(Array(FLOAT, "glyphCount"), "glyphAdvances"), Out(Array(DWRITE_GLYPH_OFFSET, "glyphCount"), "glyphOffsets")]), 
555     Method(HRESULT, "GetGdiCompatibleGlyphPlacements", [(Array(Const(WCHAR), "textLength"), "textString"), (Array(Const(UINT16), "textLength"), "clusterMap"), (Array(DWRITE_SHAPING_TEXT_PROPERTIES, "textLength"), "textProps"), (UINT32, "textLength"), (Array(Const(UINT16), "glyphCount"), "glyphIndices"), (Array(Const(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphCount"), "glyphProps"), (UINT32, "glyphCount"), (ObjPointer(IDWriteFontFace), "fontFace"), (FLOAT, "fontEmSize"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (BOOL, "useGdiNatural"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (LPCWSTR, "localeName"), (Array(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES)), "featureRanges"), "features"), (Array(Const(UINT32), "featureRanges"), "featureRangeLengths"), (UINT32, "featureRanges"), Out(Array(FLOAT, "glyphCount"), "glyphAdvances"), Out(Array(DWRITE_GLYPH_OFFSET, "glyphCount"), "glyphOffsets")]),
556 ]
557
558 DWRITE_GLYPH_RUN = Struct("DWRITE_GLYPH_RUN", [
559     (ObjPointer(IDWriteFontFace), "fontFace"),
560     (FLOAT, "fontEmSize"),
561     (UINT32, "glyphCount"),
562     (Pointer(Const(UINT16)), "glyphIndices"),
563     (Pointer(Const(FLOAT)), "glyphAdvances"),
564     (Pointer(Const(DWRITE_GLYPH_OFFSET)), "glyphOffsets"),
565     (BOOL, "isSideways"),
566     (UINT32, "bidiLevel"),
567 ])
568
569 DWRITE_GLYPH_RUN_DESCRIPTION = Struct("DWRITE_GLYPH_RUN_DESCRIPTION", [
570     (Pointer(Const(WCHAR)), "localeName"),
571     (Pointer(Const(WCHAR)), "string"),
572     (UINT32, "stringLength"),
573     (Pointer(Const(UINT16)), "clusterMap"),
574     (UINT32, "textPosition"),
575 ])
576
577 DWRITE_UNDERLINE = Struct("DWRITE_UNDERLINE", [
578     (FLOAT, "width"),
579     (FLOAT, "thickness"),
580     (FLOAT, "offset"),
581     (FLOAT, "runHeight"),
582     (DWRITE_READING_DIRECTION, "readingDirection"),
583     (DWRITE_FLOW_DIRECTION, "flowDirection"),
584     (Pointer(Const(WCHAR)), "localeName"),
585     (DWRITE_MEASURING_MODE, "measuringMode"),
586 ])
587
588 DWRITE_STRIKETHROUGH = Struct("DWRITE_STRIKETHROUGH", [
589     (FLOAT, "width"),
590     (FLOAT, "thickness"),
591     (FLOAT, "offset"),
592     (DWRITE_READING_DIRECTION, "readingDirection"),
593     (DWRITE_FLOW_DIRECTION, "flowDirection"),
594     (Pointer(Const(WCHAR)), "localeName"),
595     (DWRITE_MEASURING_MODE, "measuringMode"),
596 ])
597
598 DWRITE_LINE_METRICS = Struct("DWRITE_LINE_METRICS", [
599     (UINT32, "length"),
600     (UINT32, "trailingWhitespaceLength"),
601     (UINT32, "newlineLength"),
602     (FLOAT, "height"),
603     (FLOAT, "baseline"),
604     (BOOL, "isTrimmed"),
605 ])
606
607 DWRITE_CLUSTER_METRICS = Struct("DWRITE_CLUSTER_METRICS", [
608     (FLOAT, "width"),
609     (UINT16, "length"),
610     (UINT16, "canWrapLineAfter"),
611     (UINT16, "isWhitespace"),
612     (UINT16, "isNewline"),
613     (UINT16, "isSoftHyphen"),
614     (UINT16, "isRightToLeft"),
615     (UINT16, "padding"),
616 ])
617
618 DWRITE_TEXT_METRICS = Struct("DWRITE_TEXT_METRICS", [
619     (FLOAT, "left"),
620     (FLOAT, "top"),
621     (FLOAT, "width"),
622     (FLOAT, "widthIncludingTrailingWhitespace"),
623     (FLOAT, "height"),
624     (FLOAT, "layoutWidth"),
625     (FLOAT, "layoutHeight"),
626     (UINT32, "maxBidiReorderingDepth"),
627     (UINT32, "lineCount"),
628 ])
629
630 DWRITE_INLINE_OBJECT_METRICS = Struct("DWRITE_INLINE_OBJECT_METRICS", [
631     (FLOAT, "width"),
632     (FLOAT, "height"),
633     (FLOAT, "baseline"),
634     (BOOL, "supportsSideways"),
635 ])
636
637 DWRITE_OVERHANG_METRICS = Struct("DWRITE_OVERHANG_METRICS", [
638     (FLOAT, "left"),
639     (FLOAT, "top"),
640     (FLOAT, "right"),
641     (FLOAT, "bottom"),
642 ])
643
644 DWRITE_HIT_TEST_METRICS = Struct("DWRITE_HIT_TEST_METRICS", [
645     (UINT32, "textPosition"),
646     (UINT32, "length"),
647     (FLOAT, "left"),
648     (FLOAT, "top"),
649     (FLOAT, "width"),
650     (FLOAT, "height"),
651     (UINT32, "bidiLevel"),
652     (BOOL, "isText"),
653     (BOOL, "isTrimmed"),
654 ])
655
656 IDWriteInlineObject.methods += [
657     Method(HRESULT, "Draw", [(OpaquePointer(Void), "clientDrawingContext"), (ObjPointer(IDWriteTextRenderer), "renderer"), (FLOAT, "originX"), (FLOAT, "originY"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
658     Method(HRESULT, "GetMetrics", [Out(Pointer(DWRITE_INLINE_OBJECT_METRICS), "metrics")]),
659     Method(HRESULT, "GetOverhangMetrics", [Out(Pointer(DWRITE_OVERHANG_METRICS), "overhangs")]),
660     Method(HRESULT, "GetBreakConditions", [Out(Pointer(DWRITE_BREAK_CONDITION), "breakConditionBefore"), Out(Pointer(DWRITE_BREAK_CONDITION), "breakConditionAfter")]),
661 ]
662
663 IDWritePixelSnapping.methods += [
664     Method(HRESULT, "IsPixelSnappingDisabled", [(OpaquePointer(Void), "clientDrawingContext"), Out(Pointer(BOOL), "isDisabled")]),
665     Method(HRESULT, "GetCurrentTransform", [(OpaquePointer(Void), "clientDrawingContext"), Out(Pointer(DWRITE_MATRIX), "transform")]),
666     Method(HRESULT, "GetPixelsPerDip", [(OpaquePointer(Void), "clientDrawingContext"), Out(Pointer(FLOAT), "pixelsPerDip")]),
667 ]
668
669 IDWriteTextRenderer.methods += [
670     Method(HRESULT, "DrawGlyphRun", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (DWRITE_MEASURING_MODE, "measuringMode"), (Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (Pointer(Const(DWRITE_GLYPH_RUN_DESCRIPTION)), "glyphRunDescription"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
671     Method(HRESULT, "DrawUnderline", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (Pointer(Const(DWRITE_UNDERLINE)), "underline"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
672     Method(HRESULT, "DrawStrikethrough", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (Pointer(Const(DWRITE_STRIKETHROUGH)), "strikethrough"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
673     Method(HRESULT, "DrawInlineObject", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "originX"), (FLOAT, "originY"), (ObjPointer(IDWriteInlineObject), "inlineObject"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
674 ]
675
676 IDWriteTextLayout.methods += [
677     Method(HRESULT, "SetMaxWidth", [(FLOAT, "maxWidth")]),
678     Method(HRESULT, "SetMaxHeight", [(FLOAT, "maxHeight")]),
679     Method(HRESULT, "SetFontCollection", [(ObjPointer(IDWriteFontCollection), "fontCollection"), (DWRITE_TEXT_RANGE, "textRange")]),
680     Method(HRESULT, "SetFontFamilyName", [(Pointer(Const(WCHAR)), "fontFamilyName"), (DWRITE_TEXT_RANGE, "textRange")]),
681     Method(HRESULT, "SetFontWeight", [(DWRITE_FONT_WEIGHT, "fontWeight"), (DWRITE_TEXT_RANGE, "textRange")]),
682     Method(HRESULT, "SetFontStyle", [(DWRITE_FONT_STYLE, "fontStyle"), (DWRITE_TEXT_RANGE, "textRange")]),
683     Method(HRESULT, "SetFontStretch", [(DWRITE_FONT_STRETCH, "fontStretch"), (DWRITE_TEXT_RANGE, "textRange")]),
684     Method(HRESULT, "SetFontSize", [(FLOAT, "fontSize"), (DWRITE_TEXT_RANGE, "textRange")]),
685     Method(HRESULT, "SetUnderline", [(BOOL, "hasUnderline"), (DWRITE_TEXT_RANGE, "textRange")]),
686     Method(HRESULT, "SetStrikethrough", [(BOOL, "hasStrikethrough"), (DWRITE_TEXT_RANGE, "textRange")]),
687     Method(HRESULT, "SetDrawingEffect", [(ObjPointer(IUnknown), "drawingEffect"), (DWRITE_TEXT_RANGE, "textRange")]),
688     Method(HRESULT, "SetInlineObject", [(ObjPointer(IDWriteInlineObject), "inlineObject"), (DWRITE_TEXT_RANGE, "textRange")]),
689     Method(HRESULT, "SetTypography", [(ObjPointer(IDWriteTypography), "typography"), (DWRITE_TEXT_RANGE, "textRange")]),
690     Method(HRESULT, "SetLocaleName", [(Pointer(Const(WCHAR)), "localeName"), (DWRITE_TEXT_RANGE, "textRange")]),
691     Method(FLOAT, "GetMaxWidth", []),
692     Method(FLOAT, "GetMaxHeight", []),
693     Method(HRESULT, "GetFontCollection", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
694     Method(HRESULT, "GetFontFamilyNameLength", [(UINT32, "currentPosition"), Out(Pointer(UINT32), "nameLength"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
695     Method(HRESULT, "GetFontFamilyName", [(UINT32, "currentPosition"), Out(Pointer(WCHAR), "fontFamilyName"), (UINT32, "nameSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
696     Method(HRESULT, "GetFontWeight", [(UINT32, "currentPosition"), Out(Pointer(DWRITE_FONT_WEIGHT), "fontWeight"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
697     Method(HRESULT, "GetFontStyle", [(UINT32, "currentPosition"), Out(Pointer(DWRITE_FONT_STYLE), "fontStyle"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
698     Method(HRESULT, "GetFontStretch", [(UINT32, "currentPosition"), Out(Pointer(DWRITE_FONT_STRETCH), "fontStretch"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
699     Method(HRESULT, "GetFontSize", [(UINT32, "currentPosition"), Out(Pointer(FLOAT), "fontSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
700     Method(HRESULT, "GetUnderline", [(UINT32, "currentPosition"), Out(Pointer(BOOL), "hasUnderline"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
701     Method(HRESULT, "GetStrikethrough", [(UINT32, "currentPosition"), Out(Pointer(BOOL), "hasStrikethrough"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
702     Method(HRESULT, "GetDrawingEffect", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IUnknown)), "drawingEffect"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
703     Method(HRESULT, "GetInlineObject", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteInlineObject)), "inlineObject"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
704     Method(HRESULT, "GetTypography", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteTypography)), "typography"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
705     Method(HRESULT, "GetLocaleNameLength", [(UINT32, "currentPosition"), Out(Pointer(UINT32), "nameLength"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
706     Method(HRESULT, "GetLocaleName", [(UINT32, "currentPosition"), Out(Pointer(WCHAR), "localeName"), (UINT32, "nameSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
707     Method(HRESULT, "Draw", [(OpaquePointer(Void), "clientDrawingContext"), (ObjPointer(IDWriteTextRenderer), "renderer"), (FLOAT, "originX"), (FLOAT, "originY")]),
708     Method(HRESULT, "GetLineMetrics", [Out(Pointer(DWRITE_LINE_METRICS), "lineMetrics"), (UINT32, "maxLineCount"), Out(Pointer(UINT32), "actualLineCount")]),
709     Method(HRESULT, "GetMetrics", [Out(Pointer(DWRITE_TEXT_METRICS), "textMetrics")]),
710     Method(HRESULT, "GetOverhangMetrics", [Out(Pointer(DWRITE_OVERHANG_METRICS), "overhangs")]),
711     Method(HRESULT, "GetClusterMetrics", [Out(Pointer(DWRITE_CLUSTER_METRICS), "clusterMetrics"), (UINT32, "maxClusterCount"), Out(Pointer(UINT32), "actualClusterCount")]),
712     Method(HRESULT, "DetermineMinWidth", [Out(Pointer(FLOAT), "minWidth")]),
713     Method(HRESULT, "HitTestPoint", [(FLOAT, "pointX"), (FLOAT, "pointY"), Out(Pointer(BOOL), "isTrailingHit"), Out(Pointer(BOOL), "isInside"), Out(Pointer(DWRITE_HIT_TEST_METRICS), "hitTestMetrics")]),
714     Method(HRESULT, "HitTestTextPosition", [(UINT32, "textPosition"), (BOOL, "isTrailingHit"), Out(Pointer(FLOAT), "pointX"), Out(Pointer(FLOAT), "pointY"), Out(Pointer(DWRITE_HIT_TEST_METRICS), "hitTestMetrics")]),
715     Method(HRESULT, "HitTestTextRange", [(UINT32, "textPosition"), (UINT32, "textLength"), (FLOAT, "originX"), (FLOAT, "originY"), Out(Pointer(DWRITE_HIT_TEST_METRICS), "hitTestMetrics"), (UINT32, "maxHitTestMetricsCount"), Out(Pointer(UINT32), "actualHitTestMetricsCount")]),
716 ]
717
718 IDWriteBitmapRenderTarget.methods += [
719     Method(HRESULT, "DrawGlyphRun", [(FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (DWRITE_MEASURING_MODE, "measuringMode"), (Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (ObjPointer(IDWriteRenderingParams), "renderingParams"), (COLORREF, "textColor"), Out(Pointer(RECT), "blackBoxRect")]),
720     Method(HDC, "GetMemoryDC", []),
721     Method(FLOAT, "GetPixelsPerDip", []),
722     Method(HRESULT, "SetPixelsPerDip", [(FLOAT, "pixelsPerDip")]),
723     Method(HRESULT, "GetCurrentTransform", [Out(Pointer(DWRITE_MATRIX), "transform")]),
724     Method(HRESULT, "SetCurrentTransform", [(Pointer(Const(DWRITE_MATRIX)), "transform")]),
725     Method(HRESULT, "GetSize", [Out(Pointer(SIZE), "size")]),
726     Method(HRESULT, "Resize", [(UINT32, "width"), (UINT32, "height")]),
727 ]
728
729 IDWriteGdiInterop.methods += [
730     Method(HRESULT, "CreateFontFromLOGFONT", [(Pointer(Const(LOGFONTW)), "logFont"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
731     Method(HRESULT, "ConvertFontToLOGFONT", [(ObjPointer(IDWriteFont), "font"), Out(Pointer(LOGFONTW), "logFont"), Out(Pointer(BOOL), "isSystemFont")]),
732     Method(HRESULT, "ConvertFontFaceToLOGFONT", [(ObjPointer(IDWriteFontFace), "font"), Out(Pointer(LOGFONTW), "logFont")]),
733     Method(HRESULT, "CreateFontFaceFromHdc", [(HDC, "hdc"), Out(Pointer(ObjPointer(IDWriteFontFace)), "fontFace")]),
734     Method(HRESULT, "CreateBitmapRenderTarget", [(HDC, "hdc"), (UINT32, "width"), (UINT32, "height"), Out(Pointer(ObjPointer(IDWriteBitmapRenderTarget)), "renderTarget")]),
735 ]
736
737 DWRITE_TEXTURE_TYPE = Enum("DWRITE_TEXTURE_TYPE", [
738     "DWRITE_TEXTURE_ALIASED_1x1",
739     "DWRITE_TEXTURE_CLEARTYPE_3x1",
740 ])
741
742 IDWriteGlyphRunAnalysis.methods += [
743     Method(HRESULT, "GetAlphaTextureBounds", [(DWRITE_TEXTURE_TYPE, "textureType"), Out(Pointer(RECT), "textureBounds")]),
744     Method(HRESULT, "CreateAlphaTexture", [(DWRITE_TEXTURE_TYPE, "textureType"), (Pointer(Const(RECT)), "textureBounds"), Out(Pointer(BYTE), "alphaValues"), (UINT32, "bufferSize")]),
745     Method(HRESULT, "GetAlphaBlendParams", [(ObjPointer(IDWriteRenderingParams), "renderingParams"), Out(Pointer(FLOAT), "blendGamma"), Out(Pointer(FLOAT), "blendEnhancedContrast"), Out(Pointer(FLOAT), "blendClearTypeLevel")]),
746 ]
747
748 IDWriteFactory.methods += [
749     Method(HRESULT, "GetSystemFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection"), (BOOL, "checkForUpdates")]),
750     Method(HRESULT, "CreateCustomFontCollection", [(ObjPointer(IDWriteFontCollectionLoader), "collectionLoader"), (OpaquePointer(Const(Void)), "collectionKey"), (UINT32, "collectionKeySize"), Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
751     Method(HRESULT, "RegisterFontCollectionLoader", [(ObjPointer(IDWriteFontCollectionLoader), "fontCollectionLoader")]),
752     Method(HRESULT, "UnregisterFontCollectionLoader", [(ObjPointer(IDWriteFontCollectionLoader), "fontCollectionLoader")]),
753     Method(HRESULT, "CreateFontFileReference", [(Pointer(Const(WCHAR)), "filePath"), (Pointer(Const(FILETIME)), "lastWriteTime"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
754     Method(HRESULT, "CreateCustomFontFileReference", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), (ObjPointer(IDWriteFontFileLoader), "fontFileLoader"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
755     Method(HRESULT, "CreateFontFace", [(DWRITE_FONT_FACE_TYPE, "fontFaceType"), (UINT32, "numberOfFiles"), (Array(Const(ObjPointer(IDWriteFontFile)), "numberOfFiles"), "fontFiles"), (UINT32, "faceIndex"), (DWRITE_FONT_SIMULATIONS, "fontFaceSimulationFlags"), Out(Pointer(ObjPointer(IDWriteFontFace)), "fontFace")]),
756     Method(HRESULT, "CreateRenderingParams", [Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
757     Method(HRESULT, "CreateMonitorRenderingParams", [(HMONITOR, "monitor"), Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
758     Method(HRESULT, "CreateCustomRenderingParams", [(FLOAT, "gamma"), (FLOAT, "enhancedContrast"), (FLOAT, "clearTypeLevel"), (DWRITE_PIXEL_GEOMETRY, "pixelGeometry"), (DWRITE_RENDERING_MODE, "renderingMode"), Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
759     Method(HRESULT, "RegisterFontFileLoader", [(ObjPointer(IDWriteFontFileLoader), "fontFileLoader")]),
760     Method(HRESULT, "UnregisterFontFileLoader", [(ObjPointer(IDWriteFontFileLoader), "fontFileLoader")]),
761     Method(HRESULT, "CreateTextFormat", [(Pointer(Const(WCHAR)), "fontFamilyName"), (ObjPointer(IDWriteFontCollection), "fontCollection"), (DWRITE_FONT_WEIGHT, "fontWeight"), (DWRITE_FONT_STYLE, "fontStyle"), (DWRITE_FONT_STRETCH, "fontStretch"), (FLOAT, "fontSize"), (Pointer(Const(WCHAR)), "localeName"), Out(Pointer(ObjPointer(IDWriteTextFormat)), "textFormat")]),
762     Method(HRESULT, "CreateTypography", [Out(Pointer(ObjPointer(IDWriteTypography)), "typography")]),
763     Method(HRESULT, "GetGdiInterop", [Out(Pointer(ObjPointer(IDWriteGdiInterop)), "gdiInterop")]),
764     Method(HRESULT, "CreateTextLayout", [(Pointer(Const(WCHAR)), "string"), (UINT32, "stringLength"), (ObjPointer(IDWriteTextFormat), "textFormat"), (FLOAT, "maxWidth"), (FLOAT, "maxHeight"), Out(Pointer(ObjPointer(IDWriteTextLayout)), "textLayout")]),
765     Method(HRESULT, "CreateGdiCompatibleTextLayout", [(Pointer(Const(WCHAR)), "string"), (UINT32, "stringLength"), (ObjPointer(IDWriteTextFormat), "textFormat"), (FLOAT, "layoutWidth"), (FLOAT, "layoutHeight"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (BOOL, "useGdiNatural"), Out(Pointer(ObjPointer(IDWriteTextLayout)), "textLayout")]),
766     Method(HRESULT, "CreateEllipsisTrimmingSign", [(ObjPointer(IDWriteTextFormat), "textFormat"), Out(Pointer(ObjPointer(IDWriteInlineObject)), "trimmingSign")]),
767     Method(HRESULT, "CreateTextAnalyzer", [Out(Pointer(ObjPointer(IDWriteTextAnalyzer)), "textAnalyzer")]),
768     Method(HRESULT, "CreateNumberSubstitution", [(DWRITE_NUMBER_SUBSTITUTION_METHOD, "substitutionMethod"), (Pointer(Const(WCHAR)), "localeName"), (BOOL, "ignoreUserOverride"), Out(Pointer(ObjPointer(IDWriteNumberSubstitution)), "numberSubstitution")]),
769     Method(HRESULT, "CreateGlyphRunAnalysis", [(Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (DWRITE_RENDERING_MODE, "renderingMode"), (DWRITE_MEASURING_MODE, "measuringMode"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), Out(Pointer(ObjPointer(IDWriteGlyphRunAnalysis)), "glyphRunAnalysis")]),
770 ]
771
772 dwrite = API("dwrite")
773 dwrite.addInterface(IDWriteFactory)
774 dwrite.addFunctions([
775     StdFunction(HRESULT, "DWriteCreateFactory", [(DWRITE_FACTORY_TYPE, "factoryType"), (REFIID, "iid"), Out(Pointer(ObjPointer(IUnknown)), "factory")]),
776 ])