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_NativeFontResourceMac_h
8 #define mozilla_gfx_NativeFontResourceMac_h
9 
10 #include "2D.h"
11 #include "mozilla/AlreadyAddRefed.h"
12 #include "ScaledFontMac.h"
13 
14 namespace mozilla {
15 namespace gfx {
16 
17 class NativeFontResourceMac final : public NativeFontResource {
18  public:
19   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(NativeFontResourceMac, override)
20 
21   static already_AddRefed<NativeFontResourceMac> Create(uint8_t* aFontData,
22                                                         uint32_t aDataLength);
23 
24   already_AddRefed<UnscaledFont> CreateUnscaledFont(
25       uint32_t aIndex, const uint8_t* aInstanceData,
26       uint32_t aInstanceDataLength) final;
27 
~NativeFontResourceMac()28   ~NativeFontResourceMac() { CFRelease(mFontRef); }
29 
30  private:
NativeFontResourceMac(CGFontRef aFontRef,size_t aDataLength)31   explicit NativeFontResourceMac(CGFontRef aFontRef, size_t aDataLength)
32       : NativeFontResource(aDataLength), mFontRef(aFontRef) {}
33 
34   CGFontRef mFontRef;
35 };
36 
37 }  // namespace gfx
38 }  // namespace mozilla
39 
40 #endif  // mozilla_gfx_NativeFontResourceMac_h
41