]> git.cworth.org Git - apitrace/blob - specs/dwrite.py
d3dstate: Fix MSVC build.
[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     StdMethod(HRESULT, "CreateStreamFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(ObjPointer(IDWriteFontFileStream)), "fontFileStream")]),
187 ]
188
189 IDWriteLocalFontFileLoader.methods += [
190     StdMethod(HRESULT, "GetFilePathLengthFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(UINT32), "filePathLength")]),
191     StdMethod(HRESULT, "GetFilePathFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(WCHAR), "filePath"), (UINT32, "filePathSize")]),
192     StdMethod(HRESULT, "GetLastWriteTimeFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(FILETIME), "lastWriteTime")]),
193 ]
194
195 IDWriteFontFileStream.methods += [
196     StdMethod(HRESULT, "ReadFileFragment", [Out(Pointer(OpaquePointer(Const(Void))), "fragmentStart"), (UINT64, "fileOffset"), (UINT64, "fragmentSize"), Out(Pointer(OpaquePointer(Void)), "fragmentContext")]),
197     StdMethod(Void, "ReleaseFileFragment", [(OpaquePointer(Void), "fragmentContext")]),
198     StdMethod(HRESULT, "GetFileSize", [Out(Pointer(UINT64), "fileSize")]),
199     StdMethod(HRESULT, "GetLastWriteTime", [Out(Pointer(UINT64), "lastWriteTime")]),
200 ]
201
202 IDWriteFontFile.methods += [
203     StdMethod(HRESULT, "GetReferenceKey", [Out(Pointer(OpaquePointer(Const(Void))), "fontFileReferenceKey"), Out(Pointer(UINT32), "fontFileReferenceKeySize")]),
204     StdMethod(HRESULT, "GetLoader", [Out(Pointer(ObjPointer(IDWriteFontFileLoader)), "fontFileLoader")]),
205     StdMethod(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     StdMethod(FLOAT, "GetGamma", []),
235     StdMethod(FLOAT, "GetEnhancedContrast", []),
236     StdMethod(FLOAT, "GetClearTypeLevel", []),
237     StdMethod(DWRITE_PIXEL_GEOMETRY, "GetPixelGeometry", []),
238     StdMethod(DWRITE_RENDERING_MODE, "GetRenderingMode", []),
239 ]
240
241 IDWriteFontFace.methods += [
242     StdMethod(DWRITE_FONT_FACE_TYPE, "GetType", []),
243     StdMethod(HRESULT, "GetFiles", [(OpaquePointer(UINT32), "numberOfFiles"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFiles")]),
244     StdMethod(UINT32, "GetIndex", []),
245     StdMethod(DWRITE_FONT_SIMULATIONS, "GetSimulations", []),
246     StdMethod(BOOL, "IsSymbolFont", []),
247     StdMethod(Void, "GetMetrics", [Out(Pointer(DWRITE_FONT_METRICS), "fontFaceMetrics")]),
248     StdMethod(UINT16, "GetGlyphCount", []),
249     StdMethod(HRESULT, "GetDesignGlyphMetrics", [(Pointer(Const(UINT16)), "glyphIndices"), (UINT32, "glyphCount"), Out(Pointer(DWRITE_GLYPH_METRICS), "glyphMetrics"), (BOOL, "isSideways")]),
250     StdMethod(HRESULT, "GetGlyphIndices", [(Pointer(Const(UINT32)), "codePoints"), (UINT32, "codePointCount"), Out(Pointer(UINT16), "glyphIndices")]),
251     StdMethod(HRESULT, "TryGetFontTable", [(UINT32, "openTypeTableTag"), Out(Pointer(OpaquePointer(Const(Void))), "tableData"), Out(Pointer(UINT32), "tableSize"), Out(Pointer(OpaquePointer(Void)), "tableContext"), Out(Pointer(BOOL), "exists")]),
252     StdMethod(Void, "ReleaseFontTable", [(OpaquePointer(Void), "tableContext")]),
253     StdMethod(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     StdMethod(HRESULT, "GetRecommendedRenderingMode", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (DWRITE_MEASURING_MODE, "measuringMode"), (ObjPointer(IDWriteRenderingParams), "renderingParams"), Out(Pointer(DWRITE_RENDERING_MODE), "renderingMode")]),
255     StdMethod(HRESULT, "GetGdiCompatibleMetrics", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), Out(Pointer(DWRITE_FONT_METRICS), "fontFaceMetrics")]),
256     StdMethod(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     StdMethod(HRESULT, "CreateEnumeratorFromKey", [(ObjPointer(IDWriteFactory), "factory"), (OpaquePointer(Const(Void)), "collectionKey"), (UINT32, "collectionKeySize"), Out(Pointer(ObjPointer(IDWriteFontFileEnumerator)), "fontFileEnumerator")]),
261 ]
262
263 IDWriteFontFileEnumerator.methods += [
264     StdMethod(HRESULT, "MoveNext", [Out(Pointer(BOOL), "hasCurrentFile")]),
265     StdMethod(HRESULT, "GetCurrentFontFile", [Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
266 ]
267
268 IDWriteLocalizedStrings.methods += [
269     StdMethod(UINT32, "GetCount", []),
270     StdMethod(HRESULT, "FindLocaleName", [(Pointer(Const(WCHAR)), "localeName"), Out(Pointer(UINT32), "index"), Out(Pointer(BOOL), "exists")]),
271     StdMethod(HRESULT, "GetLocaleNameLength", [(UINT32, "index"), Out(Pointer(UINT32), "length")]),
272     StdMethod(HRESULT, "GetLocaleName", [(UINT32, "index"), Out(Pointer(WCHAR), "localeName"), (UINT32, "size")]),
273     StdMethod(HRESULT, "GetStringLength", [(UINT32, "index"), Out(Pointer(UINT32), "length")]),
274     StdMethod(HRESULT, "GetString", [(UINT32, "index"), Out(Pointer(WCHAR), "stringBuffer"), (UINT32, "size")]),
275 ]
276
277 IDWriteFontCollection.methods += [
278     StdMethod(UINT32, "GetFontFamilyCount", []),
279     StdMethod(HRESULT, "GetFontFamily", [(UINT32, "index"), Out(Pointer(ObjPointer(IDWriteFontFamily)), "fontFamily")]),
280     StdMethod(HRESULT, "FindFamilyName", [(Pointer(Const(WCHAR)), "familyName"), Out(Pointer(UINT32), "index"), Out(Pointer(BOOL), "exists")]),
281     StdMethod(HRESULT, "GetFontFromFontFace", [(ObjPointer(IDWriteFontFace), "fontFace"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
282 ]
283
284 IDWriteFontList.methods += [
285     StdMethod(HRESULT, "GetFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
286     StdMethod(UINT32, "GetFontCount", []),
287     StdMethod(HRESULT, "GetFont", [(UINT32, "index"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
288 ]
289
290 IDWriteFontFamily.methods += [
291     StdMethod(HRESULT, "GetFamilyNames", [Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "names")]),
292     StdMethod(HRESULT, "GetFirstMatchingFont", [(DWRITE_FONT_WEIGHT, "weight"), (DWRITE_FONT_STRETCH, "stretch"), (DWRITE_FONT_STYLE, "style"), Out(Pointer(ObjPointer(IDWriteFont)), "matchingFont")]),
293     StdMethod(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     StdMethod(HRESULT, "GetFontFamily", [Out(Pointer(ObjPointer(IDWriteFontFamily)), "fontFamily")]),
298     StdMethod(DWRITE_FONT_WEIGHT, "GetWeight", []),
299     StdMethod(DWRITE_FONT_STRETCH, "GetStretch", []),
300     StdMethod(DWRITE_FONT_STYLE, "GetStyle", []),
301     StdMethod(BOOL, "IsSymbolFont", []),
302     StdMethod(HRESULT, "GetFaceNames", [Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "names")]),
303     StdMethod(HRESULT, "GetInformationalStrings", [(DWRITE_INFORMATIONAL_STRING_ID, "informationalStringID"), Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "informationalStrings"), Out(Pointer(BOOL), "exists")]),
304     StdMethod(DWRITE_FONT_SIMULATIONS, "GetSimulations", []),
305     StdMethod(Void, "GetMetrics", [Out(Pointer(DWRITE_FONT_METRICS), "fontMetrics")]),
306     StdMethod(HRESULT, "HasCharacter", [(UINT32, "unicodeValue"), Out(Pointer(BOOL), "exists")]),
307     StdMethod(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     StdMethod(HRESULT, "SetTextAlignment", [(DWRITE_TEXT_ALIGNMENT, "textAlignment")]),
452     StdMethod(HRESULT, "SetParagraphAlignment", [(DWRITE_PARAGRAPH_ALIGNMENT, "paragraphAlignment")]),
453     StdMethod(HRESULT, "SetWordWrapping", [(DWRITE_WORD_WRAPPING, "wordWrapping")]),
454     StdMethod(HRESULT, "SetReadingDirection", [(DWRITE_READING_DIRECTION, "readingDirection")]),
455     StdMethod(HRESULT, "SetFlowDirection", [(DWRITE_FLOW_DIRECTION, "flowDirection")]),
456     StdMethod(HRESULT, "SetIncrementalTabStop", [(FLOAT, "incrementalTabStop")]),
457     StdMethod(HRESULT, "SetTrimming", [(Pointer(Const(DWRITE_TRIMMING)), "trimmingOptions"), (OpaquePointer(IDWriteInlineObject), "trimmingSign")]),
458     StdMethod(HRESULT, "SetLineSpacing", [(DWRITE_LINE_SPACING_METHOD, "lineSpacingMethod"), (FLOAT, "lineSpacing"), (FLOAT, "baseline")]),
459     StdMethod(DWRITE_TEXT_ALIGNMENT, "GetTextAlignment", []),
460     StdMethod(DWRITE_PARAGRAPH_ALIGNMENT, "GetParagraphAlignment", []),
461     StdMethod(DWRITE_WORD_WRAPPING, "GetWordWrapping", []),
462     StdMethod(DWRITE_READING_DIRECTION, "GetReadingDirection", []),
463     StdMethod(DWRITE_FLOW_DIRECTION, "GetFlowDirection", []),
464     StdMethod(FLOAT, "GetIncrementalTabStop", []),
465     StdMethod(HRESULT, "GetTrimming", [Out(Pointer(DWRITE_TRIMMING), "trimmingOptions"), Out(Pointer(OpaquePointer(IDWriteInlineObject)), "trimmingSign")]),
466     StdMethod(HRESULT, "GetLineSpacing", [Out(Pointer(DWRITE_LINE_SPACING_METHOD), "lineSpacingMethod"), Out(Pointer(FLOAT), "lineSpacing"), Out(Pointer(FLOAT), "baseline")]),
467     StdMethod(HRESULT, "GetFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
468     StdMethod(UINT32, "GetFontFamilyNameLength", []),
469     StdMethod(HRESULT, "GetFontFamilyName", [Out(Pointer(WCHAR), "fontFamilyName"), (UINT32, "nameSize")]),
470     StdMethod(DWRITE_FONT_WEIGHT, "GetFontWeight", []),
471     StdMethod(DWRITE_FONT_STYLE, "GetFontStyle", []),
472     StdMethod(DWRITE_FONT_STRETCH, "GetFontStretch", []),
473     StdMethod(FLOAT, "GetFontSize", []),
474     StdMethod(UINT32, "GetLocaleNameLength", []),
475     StdMethod(HRESULT, "GetLocaleName", [Out(Pointer(WCHAR), "localeName"), (UINT32, "nameSize")]),
476 ]
477
478 IDWriteTypography.methods += [
479     StdMethod(HRESULT, "AddFontFeature", [(DWRITE_FONT_FEATURE, "fontFeature")]),
480     StdMethod(UINT32, "GetFontFeatureCount", []),
481     StdMethod(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     StdMethod(HRESULT, "GetTextAtPosition", [(UINT32, "textPosition"), Out(Pointer(Pointer(Const(WCHAR))), "textString"), Out(Pointer(UINT32), "textLength")]),
535     StdMethod(HRESULT, "GetTextBeforePosition", [(UINT32, "textPosition"), Out(Pointer(Pointer(Const(WCHAR))), "textString"), Out(Pointer(UINT32), "textLength")]),
536     StdMethod(DWRITE_READING_DIRECTION, "GetParagraphReadingDirection", []),
537     StdMethod(HRESULT, "GetLocaleName", [(UINT32, "textPosition"), Out(Pointer(UINT32), "textLength"), Out(Pointer(Pointer(Const(WCHAR))), "localeName")]),
538     StdMethod(HRESULT, "GetNumberSubstitution", [(UINT32, "textPosition"), Out(Pointer(UINT32), "textLength"), Out(Pointer(ObjPointer(IDWriteNumberSubstitution)), "numberSubstitution")]),
539 ]
540
541 IDWriteTextAnalysisSink.methods += [
542     StdMethod(HRESULT, "SetScriptAnalysis", [(UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis")]),
543     StdMethod(HRESULT, "SetLineBreakpoints", [(UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(Const(DWRITE_LINE_BREAKPOINT)), "lineBreakpoints")]),
544     StdMethod(HRESULT, "SetBidiLevel", [(UINT32, "textPosition"), (UINT32, "textLength"), (UINT8, "explicitLevel"), (UINT8, "resolvedLevel")]),
545     StdMethod(HRESULT, "SetNumberSubstitution", [(UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteNumberSubstitution), "numberSubstitution")]),
546 ]
547
548 IDWriteTextAnalyzer.methods += [
549     StdMethod(HRESULT, "AnalyzeScript", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
550     StdMethod(HRESULT, "AnalyzeBidi", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
551     StdMethod(HRESULT, "AnalyzeNumberSubstitution", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
552     StdMethod(HRESULT, "AnalyzeLineBreakpoints", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
553     StdMethod(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     StdMethod(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     StdMethod(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     StdMethod(HRESULT, "Draw", [(OpaquePointer(Void), "clientDrawingContext"), (OpaquePointer(IDWriteTextRenderer), "renderer"), (FLOAT, "originX"), (FLOAT, "originY"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
658     StdMethod(HRESULT, "GetMetrics", [Out(Pointer(DWRITE_INLINE_OBJECT_METRICS), "metrics")]),
659     StdMethod(HRESULT, "GetOverhangMetrics", [Out(Pointer(DWRITE_OVERHANG_METRICS), "overhangs")]),
660     StdMethod(HRESULT, "GetBreakConditions", [Out(Pointer(DWRITE_BREAK_CONDITION), "breakConditionBefore"), Out(Pointer(DWRITE_BREAK_CONDITION), "breakConditionAfter")]),
661 ]
662
663 IDWritePixelSnapping.methods += [
664     StdMethod(HRESULT, "IsPixelSnappingDisabled", [(OpaquePointer(Void), "clientDrawingContext"), Out(Pointer(BOOL), "isDisabled")]),
665     StdMethod(HRESULT, "GetCurrentTransform", [(OpaquePointer(Void), "clientDrawingContext"), Out(Pointer(DWRITE_MATRIX), "transform")]),
666     StdMethod(HRESULT, "GetPixelsPerDip", [(OpaquePointer(Void), "clientDrawingContext"), Out(Pointer(FLOAT), "pixelsPerDip")]),
667 ]
668
669 IDWriteTextRenderer.methods += [
670     StdMethod(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     StdMethod(HRESULT, "DrawUnderline", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (Pointer(Const(DWRITE_UNDERLINE)), "underline"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
672     StdMethod(HRESULT, "DrawStrikethrough", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (Pointer(Const(DWRITE_STRIKETHROUGH)), "strikethrough"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
673     StdMethod(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     StdMethod(HRESULT, "SetMaxWidth", [(FLOAT, "maxWidth")]),
678     StdMethod(HRESULT, "SetMaxHeight", [(FLOAT, "maxHeight")]),
679     StdMethod(HRESULT, "SetFontCollection", [(ObjPointer(IDWriteFontCollection), "fontCollection"), (DWRITE_TEXT_RANGE, "textRange")]),
680     StdMethod(HRESULT, "SetFontFamilyName", [(Pointer(Const(WCHAR)), "fontFamilyName"), (DWRITE_TEXT_RANGE, "textRange")]),
681     StdMethod(HRESULT, "SetFontWeight", [(DWRITE_FONT_WEIGHT, "fontWeight"), (DWRITE_TEXT_RANGE, "textRange")]),
682     StdMethod(HRESULT, "SetFontStyle", [(DWRITE_FONT_STYLE, "fontStyle"), (DWRITE_TEXT_RANGE, "textRange")]),
683     StdMethod(HRESULT, "SetFontStretch", [(DWRITE_FONT_STRETCH, "fontStretch"), (DWRITE_TEXT_RANGE, "textRange")]),
684     StdMethod(HRESULT, "SetFontSize", [(FLOAT, "fontSize"), (DWRITE_TEXT_RANGE, "textRange")]),
685     StdMethod(HRESULT, "SetUnderline", [(BOOL, "hasUnderline"), (DWRITE_TEXT_RANGE, "textRange")]),
686     StdMethod(HRESULT, "SetStrikethrough", [(BOOL, "hasStrikethrough"), (DWRITE_TEXT_RANGE, "textRange")]),
687     StdMethod(HRESULT, "SetDrawingEffect", [(ObjPointer(IUnknown), "drawingEffect"), (DWRITE_TEXT_RANGE, "textRange")]),
688     StdMethod(HRESULT, "SetInlineObject", [(ObjPointer(IDWriteInlineObject), "inlineObject"), (DWRITE_TEXT_RANGE, "textRange")]),
689     StdMethod(HRESULT, "SetTypography", [(ObjPointer(IDWriteTypography), "typography"), (DWRITE_TEXT_RANGE, "textRange")]),
690     StdMethod(HRESULT, "SetLocaleName", [(Pointer(Const(WCHAR)), "localeName"), (DWRITE_TEXT_RANGE, "textRange")]),
691     StdMethod(FLOAT, "GetMaxWidth", []),
692     StdMethod(FLOAT, "GetMaxHeight", []),
693     StdMethod(HRESULT, "GetFontCollection", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
694     StdMethod(HRESULT, "GetFontFamilyNameLength", [(UINT32, "currentPosition"), Out(Pointer(UINT32), "nameLength"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
695     StdMethod(HRESULT, "GetFontFamilyName", [(UINT32, "currentPosition"), Out(Pointer(WCHAR), "fontFamilyName"), (UINT32, "nameSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
696     StdMethod(HRESULT, "GetFontWeight", [(UINT32, "currentPosition"), Out(Pointer(DWRITE_FONT_WEIGHT), "fontWeight"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
697     StdMethod(HRESULT, "GetFontStyle", [(UINT32, "currentPosition"), Out(Pointer(DWRITE_FONT_STYLE), "fontStyle"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
698     StdMethod(HRESULT, "GetFontStretch", [(UINT32, "currentPosition"), Out(Pointer(DWRITE_FONT_STRETCH), "fontStretch"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
699     StdMethod(HRESULT, "GetFontSize", [(UINT32, "currentPosition"), Out(Pointer(FLOAT), "fontSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
700     StdMethod(HRESULT, "GetUnderline", [(UINT32, "currentPosition"), Out(Pointer(BOOL), "hasUnderline"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
701     StdMethod(HRESULT, "GetStrikethrough", [(UINT32, "currentPosition"), Out(Pointer(BOOL), "hasStrikethrough"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
702     StdMethod(HRESULT, "GetDrawingEffect", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IUnknown)), "drawingEffect"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
703     StdMethod(HRESULT, "GetInlineObject", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteInlineObject)), "inlineObject"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
704     StdMethod(HRESULT, "GetTypography", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteTypography)), "typography"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
705     StdMethod(HRESULT, "GetLocaleNameLength", [(UINT32, "currentPosition"), Out(Pointer(UINT32), "nameLength"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
706     StdMethod(HRESULT, "GetLocaleName", [(UINT32, "currentPosition"), Out(Pointer(WCHAR), "localeName"), (UINT32, "nameSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
707     StdMethod(HRESULT, "Draw", [(OpaquePointer(Void), "clientDrawingContext"), (OpaquePointer(IDWriteTextRenderer), "renderer"), (FLOAT, "originX"), (FLOAT, "originY")]),
708     StdMethod(HRESULT, "GetLineMetrics", [Out(Pointer(DWRITE_LINE_METRICS), "lineMetrics"), (UINT32, "maxLineCount"), Out(Pointer(UINT32), "actualLineCount")]),
709     StdMethod(HRESULT, "GetMetrics", [Out(Pointer(DWRITE_TEXT_METRICS), "textMetrics")]),
710     StdMethod(HRESULT, "GetOverhangMetrics", [Out(Pointer(DWRITE_OVERHANG_METRICS), "overhangs")]),
711     StdMethod(HRESULT, "GetClusterMetrics", [Out(Pointer(DWRITE_CLUSTER_METRICS), "clusterMetrics"), (UINT32, "maxClusterCount"), Out(Pointer(UINT32), "actualClusterCount")]),
712     StdMethod(HRESULT, "DetermineMinWidth", [Out(Pointer(FLOAT), "minWidth")]),
713     StdMethod(HRESULT, "HitTestPoint", [(FLOAT, "pointX"), (FLOAT, "pointY"), Out(Pointer(BOOL), "isTrailingHit"), Out(Pointer(BOOL), "isInside"), Out(Pointer(DWRITE_HIT_TEST_METRICS), "hitTestMetrics")]),
714     StdMethod(HRESULT, "HitTestTextPosition", [(UINT32, "textPosition"), (BOOL, "isTrailingHit"), Out(Pointer(FLOAT), "pointX"), Out(Pointer(FLOAT), "pointY"), Out(Pointer(DWRITE_HIT_TEST_METRICS), "hitTestMetrics")]),
715     StdMethod(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     StdMethod(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     StdMethod(HDC, "GetMemoryDC", []),
721     StdMethod(FLOAT, "GetPixelsPerDip", []),
722     StdMethod(HRESULT, "SetPixelsPerDip", [(FLOAT, "pixelsPerDip")]),
723     StdMethod(HRESULT, "GetCurrentTransform", [Out(Pointer(DWRITE_MATRIX), "transform")]),
724     StdMethod(HRESULT, "SetCurrentTransform", [(Pointer(Const(DWRITE_MATRIX)), "transform")]),
725     StdMethod(HRESULT, "GetSize", [Out(Pointer(SIZE), "size")]),
726     StdMethod(HRESULT, "Resize", [(UINT32, "width"), (UINT32, "height")]),
727 ]
728
729 IDWriteGdiInterop.methods += [
730     StdMethod(HRESULT, "CreateFontFromLOGFONT", [(Pointer(Const(LOGFONTW)), "logFont"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
731     StdMethod(HRESULT, "ConvertFontToLOGFONT", [(ObjPointer(IDWriteFont), "font"), Out(Pointer(LOGFONTW), "logFont"), Out(Pointer(BOOL), "isSystemFont")]),
732     StdMethod(HRESULT, "ConvertFontFaceToLOGFONT", [(ObjPointer(IDWriteFontFace), "font"), Out(Pointer(LOGFONTW), "logFont")]),
733     StdMethod(HRESULT, "CreateFontFaceFromHdc", [(HDC, "hdc"), Out(Pointer(ObjPointer(IDWriteFontFace)), "fontFace")]),
734     StdMethod(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     StdMethod(HRESULT, "GetAlphaTextureBounds", [(DWRITE_TEXTURE_TYPE, "textureType"), Out(Pointer(RECT), "textureBounds")]),
744     StdMethod(HRESULT, "CreateAlphaTexture", [(DWRITE_TEXTURE_TYPE, "textureType"), (Pointer(Const(RECT)), "textureBounds"), Out(Pointer(BYTE), "alphaValues"), (UINT32, "bufferSize")]),
745     StdMethod(HRESULT, "GetAlphaBlendParams", [(ObjPointer(IDWriteRenderingParams), "renderingParams"), Out(Pointer(FLOAT), "blendGamma"), Out(Pointer(FLOAT), "blendEnhancedContrast"), Out(Pointer(FLOAT), "blendClearTypeLevel")]),
746 ]
747
748 IDWriteFactory.methods += [
749     StdMethod(HRESULT, "GetSystemFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection"), (BOOL, "checkForUpdates")]),
750     StdMethod(HRESULT, "CreateCustomFontCollection", [(ObjPointer(IDWriteFontCollectionLoader), "collectionLoader"), (OpaquePointer(Const(Void)), "collectionKey"), (UINT32, "collectionKeySize"), Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
751     StdMethod(HRESULT, "RegisterFontCollectionLoader", [(ObjPointer(IDWriteFontCollectionLoader), "fontCollectionLoader")]),
752     StdMethod(HRESULT, "UnregisterFontCollectionLoader", [(ObjPointer(IDWriteFontCollectionLoader), "fontCollectionLoader")]),
753     StdMethod(HRESULT, "CreateFontFileReference", [(Pointer(Const(WCHAR)), "filePath"), (Pointer(Const(FILETIME)), "lastWriteTime"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
754     StdMethod(HRESULT, "CreateCustomFontFileReference", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), (ObjPointer(IDWriteFontFileLoader), "fontFileLoader"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
755     StdMethod(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     StdMethod(HRESULT, "CreateRenderingParams", [Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
757     StdMethod(HRESULT, "CreateMonitorRenderingParams", [(HMONITOR, "monitor"), Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
758     StdMethod(HRESULT, "CreateCustomRenderingParams", [(FLOAT, "gamma"), (FLOAT, "enhancedContrast"), (FLOAT, "clearTypeLevel"), (DWRITE_PIXEL_GEOMETRY, "pixelGeometry"), (DWRITE_RENDERING_MODE, "renderingMode"), Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
759     StdMethod(HRESULT, "RegisterFontFileLoader", [(ObjPointer(IDWriteFontFileLoader), "fontFileLoader")]),
760     StdMethod(HRESULT, "UnregisterFontFileLoader", [(ObjPointer(IDWriteFontFileLoader), "fontFileLoader")]),
761     StdMethod(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     StdMethod(HRESULT, "CreateTypography", [Out(Pointer(ObjPointer(IDWriteTypography)), "typography")]),
763     StdMethod(HRESULT, "GetGdiInterop", [Out(Pointer(ObjPointer(IDWriteGdiInterop)), "gdiInterop")]),
764     StdMethod(HRESULT, "CreateTextLayout", [(Pointer(Const(WCHAR)), "string"), (UINT32, "stringLength"), (ObjPointer(IDWriteTextFormat), "textFormat"), (FLOAT, "maxWidth"), (FLOAT, "maxHeight"), Out(Pointer(ObjPointer(IDWriteTextLayout)), "textLayout")]),
765     StdMethod(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     StdMethod(HRESULT, "CreateEllipsisTrimmingSign", [(ObjPointer(IDWriteTextFormat), "textFormat"), Out(Pointer(ObjPointer(IDWriteInlineObject)), "trimmingSign")]),
767     StdMethod(HRESULT, "CreateTextAnalyzer", [Out(Pointer(ObjPointer(IDWriteTextAnalyzer)), "textAnalyzer")]),
768     StdMethod(HRESULT, "CreateNumberSubstitution", [(DWRITE_NUMBER_SUBSTITUTION_METHOD, "substitutionMethod"), (Pointer(Const(WCHAR)), "localeName"), (BOOL, "ignoreUserOverride"), Out(Pointer(ObjPointer(IDWriteNumberSubstitution)), "numberSubstitution")]),
769     StdMethod(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 = Module("dwrite")
773 dwrite.addInterfaces([
774     IDWriteFactory
775 ])
776 dwrite.addFunctions([
777     StdFunction(HRESULT, "DWriteCreateFactory", [(DWRITE_FACTORY_TYPE, "factoryType"), (REFIID, "iid"), Out(Pointer(ObjPointer(IUnknown)), "factory")]),
778 ])