1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_gfx_NativeFontResourceFontconfig_h
8 #define mozilla_gfx_NativeFontResourceFontconfig_h
9 
10 #include "2D.h"
11 
12 #include <cairo-ft.h>
13 #include "mozilla/UniquePtr.h"
14 
15 namespace mozilla {
16 namespace gfx {
17 
18 class NativeFontResourceFontconfig final : public NativeFontResource {
19  public:
20   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(NativeFontResourceFontconfig,
21                                           override)
22 
23   static already_AddRefed<NativeFontResourceFontconfig> Create(
24       uint8_t* aFontData, uint32_t aDataLength,
25       FT_Library aFTLibrary = nullptr);
26 
27   already_AddRefed<UnscaledFont> CreateUnscaledFont(
28       uint32_t aIndex, const uint8_t* aInstanceData,
29       uint32_t aInstanceDataLength) final;
30 
31   ~NativeFontResourceFontconfig();
32 
33  private:
34   NativeFontResourceFontconfig(UniquePtr<uint8_t[]>&& aFontData, FT_Face aFace);
35 
36   UniquePtr<uint8_t[]> mFontData;
37   FT_Face mFace;
38 };
39 
40 }  // namespace gfx
41 }  // namespace mozilla
42 
43 #endif  // mozilla_gfx_NativeFontResourceFontconfig_h
44