1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkTypeface_win_DEFINED
9 #define SkTypeface_win_DEFINED
10 
11 #include "include/core/SkTypeface.h"
12 #include "include/core/SkTypes.h"
13 
14 #ifdef SK_BUILD_FOR_WIN
15 
16 #ifdef UNICODE
17 typedef struct tagLOGFONTW LOGFONTW;
18 typedef LOGFONTW LOGFONT;
19 #else
20 typedef struct tagLOGFONTA LOGFONTA;
21 typedef LOGFONTA LOGFONT;
22 #endif  // UNICODE
23 
24 /**
25  *  Like the other Typeface create methods, this returns a new reference to the
26  *  corresponding typeface for the specified logfont. The caller is responsible
27  *  for calling unref() when it is finished.
28  */
29 SK_API SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT&);
30 
31 /**
32  *  Copy the LOGFONT associated with this typeface into the lf parameter. Note
33  *  that the lfHeight will need to be set afterwards, since the typeface does
34  *  not track this (the paint does).
35  *  typeface may be NULL, in which case we return the logfont for the default font.
36  */
37 SK_API void SkLOGFONTFromTypeface(const SkTypeface* typeface, LOGFONT* lf);
38 
39 /**
40   *  Set an optional callback to ensure that the data behind a LOGFONT is loaded.
41   *  This will get called if Skia tries to access the data but hits a failure.
42   *  Normally this is null, and is only required if the font data needs to be
43   *  remotely (re)loaded.
44   */
45 SK_API void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*)(const LOGFONT&));
46 
47 // Experimental!
48 //
49 class SkFontMgr;
50 class SkRemotableFontMgr;
51 struct IDWriteFactory;
52 struct IDWriteFontCollection;
53 struct IDWriteFontFallback;
54 struct IDWriteFontFace;
55 
56 /**
57  *  Like the other Typeface create methods, this returns a new reference to the
58  *  corresponding typeface for the specified dwrite font. The caller is responsible
59  *  for calling unref() when it is finished.
60  */
61 SK_API SkTypeface* SkCreateTypefaceFromDWriteFont(IDWriteFactory* aFactory,
62                                                   IDWriteFontFace* aFontFace,
63                                                   SkFontStyle aStyle,
64                                                   int aRenderingMode,
65                                                   float aGamma,
66                                                   float aContrast,
67                                                   float aClearTypeLevel);
68 
69 SK_API sk_sp<SkFontMgr> SkFontMgr_New_GDI();
70 SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL,
71                                                   IDWriteFontCollection* collection = NULL);
72 SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
73                                                   IDWriteFontCollection* collection,
74                                                   IDWriteFontFallback* fallback);
75 
76 /**
77  *  Creates an SkFontMgr which renders using DirectWrite and obtains its data
78  *  from the SkRemotableFontMgr.
79  *
80  *  If DirectWrite could not be initialized, will return NULL.
81  */
82 SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr>);
83 
84 /**
85  *  Creates an SkRemotableFontMgr backed by DirectWrite using the default
86  *  system font collection in the current locale.
87  *
88  *  If DirectWrite could not be initialized, will return NULL.
89  */
90 SK_API sk_sp<SkRemotableFontMgr> SkRemotableFontMgr_New_DirectWrite();
91 
92 #endif  // SK_BUILD_FOR_WIN
93 #endif  // SkTypeface_win_DEFINED
94