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 
55 SK_API sk_sp<SkFontMgr> SkFontMgr_New_GDI();
56 SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL,
57                                                   IDWriteFontCollection* collection = NULL);
58 SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
59                                                   IDWriteFontCollection* collection,
60                                                   IDWriteFontFallback* fallback);
61 
62 /**
63  *  Creates an SkFontMgr which renders using DirectWrite and obtains its data
64  *  from the SkRemotableFontMgr.
65  *
66  *  If DirectWrite could not be initialized, will return NULL.
67  */
68 SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr>);
69 
70 /**
71  *  Creates an SkRemotableFontMgr backed by DirectWrite using the default
72  *  system font collection in the current locale.
73  *
74  *  If DirectWrite could not be initialized, will return NULL.
75  */
76 SK_API sk_sp<SkRemotableFontMgr> SkRemotableFontMgr_New_DirectWrite();
77 
78 #endif  // SK_BUILD_FOR_WIN
79 #endif  // SkTypeface_win_DEFINED
80