summaryrefslogtreecommitdiff
path: root/core/fxge/win32/dwrite_int.h
blob: 8e8908a7a1193b098c5c76fe8f0df7f1a9faf13b (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
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_FXGE_WIN32_DWRITE_INT_H_
#define CORE_FXGE_WIN32_DWRITE_INT_H_

#ifndef DECLSPEC_UUID
#if (_MSC_VER >= 1100) && defined(__cplusplus)
#define DECLSPEC_UUID(x) __declspec(uuid(x))
#else
#define DECLSPEC_UUID(x)
#endif
#endif
#ifndef DECLSPEC_NOVTABLE
#if (_MSC_VER >= 1100) && defined(__cplusplus)
#define DECLSPEC_NOVTABLE __declspec(novtable)
#else
#define DECLSPEC_NOVTABLE
#endif
#endif
#if (WINVER < 0x0500)
#ifndef _MAC
DECLARE_HANDLE(HMONITOR);
#endif
#endif
class CDWriteExt {
 public:
  CDWriteExt();
  ~CDWriteExt();

  void Load();
  void Unload();

  bool IsAvailable() { return !!m_pDWriteFactory; }

  void* DwCreateFontFaceFromStream(uint8_t* pData,
                                   uint32_t size,
                                   int simulation_style);
  bool DwCreateRenderingTarget(const CFX_RetainPtr<CFX_DIBitmap>& pSrc,
                               void** renderTarget);
  void DwDeleteRenderingTarget(void* renderTarget);
  bool DwRendingString(void* renderTarget,
                       CFX_ClipRgn* pClipRgn,
                       FX_RECT& stringRect,
                       CFX_Matrix* pMatrix,
                       void* font,
                       float font_size,
                       FX_ARGB text_color,
                       int glyph_count,
                       unsigned short* glyph_indices,
                       float baselineOriginX,
                       float baselineOriginY,
                       void* glyph_offsets,
                       float* glyph_advances);
  void DwDeleteFont(void* pFont);

 protected:
  void* m_hModule;
  void* m_pDWriteFactory;
  void* m_pDwFontContext;
  void* m_pDwTextRenderer;
};

#endif  // CORE_FXGE_WIN32_DWRITE_INT_H_