summaryrefslogtreecommitdiffstats
path: root/vcl/win/gdi/dw-extra.h
blob: 4c07d81d2126c65ee7f8e63aa6bd7f58e0e22301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//
// copied from:
// https://hg.mozilla.org/mozilla-central/file/704f09a557a4dfc9057f1672b711789f64f74a82/gfx/2d/dw-extra.h
//

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/*
 * New DirectWrite interfaces based on Win10 Fall Creators Update versions
 * of dwrite_3.h and dcommon.h (from SDK 10.0.17061.0). This particular
 * subset of declarations is intended to be just sufficient to compile the
 * Gecko DirectWrite font code; it omits many other new interfaces, etc.
 */

#ifndef DWRITE_EXTRA_H
#define DWRITE_EXTRA_H

#pragma once

interface IDWriteFontResource;
interface IDWriteFontFaceReference1;

enum DWRITE_GLYPH_IMAGE_FORMATS {
  DWRITE_GLYPH_IMAGE_FORMATS_NONE = 0x00000000,
  DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE = 0x00000001,
  DWRITE_GLYPH_IMAGE_FORMATS_CFF = 0x00000002,
  DWRITE_GLYPH_IMAGE_FORMATS_COLR = 0x00000004,
  DWRITE_GLYPH_IMAGE_FORMATS_SVG = 0x00000008,
  DWRITE_GLYPH_IMAGE_FORMATS_PNG = 0x00000010,
  DWRITE_GLYPH_IMAGE_FORMATS_JPEG = 0x00000020,
  DWRITE_GLYPH_IMAGE_FORMATS_TIFF = 0x00000040,
  DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8 = 0x00000080,
};

#ifdef DEFINE_ENUM_FLAG_OPERATORS
DEFINE_ENUM_FLAG_OPERATORS(DWRITE_GLYPH_IMAGE_FORMATS);
#endif

#define DWRITE_MAKE_FONT_AXIS_TAG(a, b, c, d) \
  (static_cast<DWRITE_FONT_AXIS_TAG>(DWRITE_MAKE_OPENTYPE_TAG(a, b, c, d)))

enum DWRITE_FONT_AXIS_TAG : UINT32 {
  DWRITE_FONT_AXIS_TAG_WEIGHT = DWRITE_MAKE_FONT_AXIS_TAG('w', 'g', 'h', 't'),
  DWRITE_FONT_AXIS_TAG_WIDTH = DWRITE_MAKE_FONT_AXIS_TAG('w', 'd', 't', 'h'),
  DWRITE_FONT_AXIS_TAG_SLANT = DWRITE_MAKE_FONT_AXIS_TAG('s', 'l', 'n', 't'),
  DWRITE_FONT_AXIS_TAG_OPTICAL_SIZE =
      DWRITE_MAKE_FONT_AXIS_TAG('o', 'p', 's', 'z'),
  DWRITE_FONT_AXIS_TAG_ITALIC = DWRITE_MAKE_FONT_AXIS_TAG('i', 't', 'a', 'l'),
};

enum DWRITE_FONT_AXIS_ATTRIBUTES {
  DWRITE_FONT_AXIS_ATTRIBUTES_NONE = 0x0000,
  DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE = 0x0001,
  DWRITE_FONT_AXIS_ATTRIBUTES_HIDDEN = 0x0002,
};

struct DWRITE_FONT_AXIS_VALUE {
  DWRITE_FONT_AXIS_TAG axisTag;
  FLOAT value;
};

struct DWRITE_FONT_AXIS_RANGE {
  DWRITE_FONT_AXIS_TAG axisTag;
  FLOAT minValue;
  FLOAT maxValue;
};

struct DWRITE_GLYPH_IMAGE_DATA {
  const void* imageData;
  UINT32 imageDataSize;
  UINT32 uniqueDataId;
  UINT32 pixelsPerEm;
  D2D1_SIZE_U pixelSize;
  D2D1_POINT_2L horizontalLeftOrigin;
  D2D1_POINT_2L horizontalRightOrigin;
  D2D1_POINT_2L verticalTopOrigin;
  D2D1_POINT_2L verticalBottomOrigin;
};

interface DWRITE_DECLARE_INTERFACE("27F2A904-4EB8-441D-9678-0563F53E3E2F")
    IDWriteFontFace4 : public IDWriteFontFace3 {
  STDMETHOD_(DWRITE_GLYPH_IMAGE_FORMATS, GetGlyphImageFormats)() PURE;
  STDMETHOD(GetGlyphImageFormats)
  (UINT16 glyphId, UINT32 pixelsPerEmFirst, UINT32 pixelsPerEmLast,
   _Out_ DWRITE_GLYPH_IMAGE_FORMATS* glyphImageFormats) PURE;
  STDMETHOD(GetGlyphImageData)
  (_In_ UINT16 glyphId, UINT32 pixelsPerEm,
   DWRITE_GLYPH_IMAGE_FORMATS glyphImageFormat,
   _Out_ DWRITE_GLYPH_IMAGE_DATA* glyphData,
   _Outptr_result_maybenull_ void** glyphDataContext) PURE;
  STDMETHOD_(void, ReleaseGlyphImageData)(void* glyphDataContext) PURE;
};

interface DWRITE_DECLARE_INTERFACE("98EFF3A5-B667-479A-B145-E2FA5B9FDC29")
    IDWriteFontFace5 : public IDWriteFontFace4 {
  STDMETHOD_(UINT32, GetFontAxisValueCount)() PURE;
  STDMETHOD(GetFontAxisValues)
  (_Out_writes_(fontAxisValueCount) DWRITE_FONT_AXIS_VALUE* fontAxisValues,
   UINT32 fontAxisValueCount) PURE;
  STDMETHOD_(BOOL, HasVariations)() PURE;
  STDMETHOD(GetFontResource)
  (_COM_Outptr_ IDWriteFontResource** fontResource) PURE;
  STDMETHOD_(BOOL, Equals)(IDWriteFontFace* fontFace) PURE;
};

interface DWRITE_DECLARE_INTERFACE("1F803A76-6871-48E8-987F-B975551C50F2")
    IDWriteFontResource : public IUnknown {
  STDMETHOD(GetFontFile)(_COM_Outptr_ IDWriteFontFile** fontFile) PURE;
  STDMETHOD_(UINT32, GetFontFaceIndex)() PURE;
  STDMETHOD_(UINT32, GetFontAxisCount)() PURE;
  STDMETHOD(GetDefaultFontAxisValues)
  (_Out_writes_(fontAxisValueCount) DWRITE_FONT_AXIS_VALUE* fontAxisValues,
   UINT32 fontAxisValueCount) PURE;
  STDMETHOD(GetFontAxisRanges)
  (_Out_writes_(fontAxisRangeCount) DWRITE_FONT_AXIS_RANGE* fontAxisRanges,
   UINT32 fontAxisRangeCount) PURE;
  STDMETHOD_(DWRITE_FONT_AXIS_ATTRIBUTES, GetFontAxisAttributes)
  (UINT32 axisIndex) PURE;
  STDMETHOD(GetAxisNames)
  (UINT32 axisIndex, _COM_Outptr_ IDWriteLocalizedStrings** names) PURE;
  STDMETHOD_(UINT32, GetAxisValueNameCount)(UINT32 axisIndex) PURE;
  STDMETHOD(GetAxisValueNames)
  (UINT32 axisIndex, UINT32 axisValueIndex,
   _Out_ DWRITE_FONT_AXIS_RANGE* fontAxisRange,
   _COM_Outptr_ IDWriteLocalizedStrings** names) PURE;
  STDMETHOD_(BOOL, HasVariations)() PURE;
  STDMETHOD(CreateFontFace)
  (DWRITE_FONT_SIMULATIONS fontSimulations,
   _In_reads_(fontAxisValueCount) DWRITE_FONT_AXIS_VALUE const* fontAxisValues,
   UINT32 fontAxisValueCount, _COM_Outptr_ IDWriteFontFace5** fontFace) PURE;
  STDMETHOD(CreateFontFaceReference)
  (DWRITE_FONT_SIMULATIONS fontSimulations,
   _In_reads_(fontAxisValueCount) DWRITE_FONT_AXIS_VALUE const* fontAxisValues,
   UINT32 fontAxisValueCount,
   _COM_Outptr_ IDWriteFontFaceReference1** fontFaceReference) PURE;
};

#endif /* DWRITE_EXTRA_H */