-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTextAnalysis.h
More file actions
100 lines (78 loc) · 2.45 KB
/
Copy pathTextAnalysis.h
File metadata and controls
100 lines (78 loc) · 2.45 KB
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
class TextAnalysis : public IDWriteTextAnalysisSource
{
public:
TextAnalysis(IDWriteFactory3* factory, const std::wstring& text, const std::wstring& localeName) : factory_(factory), text_(text), localeName_(localeName)
{}
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
_COM_Outptr_ void** obj
) override;
ULONG STDMETHODCALLTYPE AddRef(void) override;
ULONG STDMETHODCALLTYPE Release(void) override;
HRESULT STDMETHODCALLTYPE GetTextAtPosition(
UINT32 textPosition,
_Outptr_result_buffer_(*textLength) WCHAR const** textString,
_Out_ UINT32* textLength
) override;
HRESULT STDMETHODCALLTYPE GetTextBeforePosition(
UINT32 textPosition,
_Outptr_result_buffer_(*textLength) WCHAR const** textString,
_Out_ UINT32* textLength
) override;
DWRITE_READING_DIRECTION STDMETHODCALLTYPE GetParagraphReadingDirection() override;
HRESULT STDMETHODCALLTYPE GetLocaleName(
UINT32 textPosition,
_Out_ UINT32* textLength,
_Outptr_result_z_ WCHAR const** localeName
) override;
HRESULT STDMETHODCALLTYPE GetNumberSubstitution(
UINT32 textPosition,
_Out_ UINT32* textLength,
_COM_Outptr_ IDWriteNumberSubstitution** numberSubstitution
) override;
private:
std::wstring text_;
std::wstring localeName_;
uint32_t refCount_ = 0;
CComPtr<IDWriteFactory3> factory_;
};
class TextAnalysisSink : public IDWriteTextAnalysisSink
{
public:
TextAnalysisSink() {};
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
_COM_Outptr_ void** obj
) override;
ULONG STDMETHODCALLTYPE AddRef(void) override;
ULONG STDMETHODCALLTYPE Release(void) override;
HRESULT STDMETHODCALLTYPE SetScriptAnalysis(
UINT32 textPosition,
UINT32 textLength,
__in DWRITE_SCRIPT_ANALYSIS const* scriptAnalysis
) override;
HRESULT STDMETHODCALLTYPE SetLineBreakpoints(
UINT32 textPosition,
UINT32 textLength,
__in_ecount(textLength) DWRITE_LINE_BREAKPOINT const* lineBreakpoints
) override;
HRESULT STDMETHODCALLTYPE SetBidiLevel(
UINT32 textPosition,
UINT32 textLength,
UINT8 explicitLevel,
UINT8 resolvedLevel
) override;
HRESULT STDMETHODCALLTYPE SetNumberSubstitution(
UINT32 textPosition,
UINT32 textLength,
_In_ IDWriteNumberSubstitution* numberSubstitution
) override;
const DWRITE_SCRIPT_ANALYSIS* GetScriptAnalysis();
private:
uint32_t refCount_ = 0;
DWRITE_SCRIPT_ANALYSIS scriptAnalysis_ = { 0 };
bool scriptAnalysisSet_ = false;
};