"Migrated" dwrite.cpp back. Not much to say here; it'll do for now.

This commit is contained in:
Pietro Gagliardi 2018-03-17 14:44:38 -04:00
parent 1d1b6c3162
commit 8352cd72b8
3 changed files with 28 additions and 26 deletions

View File

@ -1,14 +1 @@
// dwrite.cpp
extern IDWriteFactory *dwfactory;
extern HRESULT initDrawText(void);
extern void uninitDrawText(void);
struct fontCollection {
IDWriteFontCollection *fonts;
WCHAR userLocale[LOCALE_NAME_MAX_LENGTH];
int userLocaleSuccess;
};
extern fontCollection *loadFontCollection(void);
extern WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family);
extern void fontCollectionFree(fontCollection *fc);
extern WCHAR *fontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names);

View File

@ -3,6 +3,20 @@ extern "C" {
#include "../common/attrstr.h"
}
// dwrite.cpp
extern IDWriteFactory *dwfactory;
extern HRESULT uiprivInitDrawText(void);
extern void uiprivUninitDrawText(void);
struct fontCollection {
IDWriteFontCollection *fonts;
WCHAR userLocale[LOCALE_NAME_MAX_LENGTH];
int userLocaleSuccess;
};
extern fontCollection *uiprivLoadFontCollection(void);
extern WCHAR *uiprivFontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family);
extern void uiprivFontCollectionFree(fontCollection *fc);
extern WCHAR *uiprivFontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names);
// opentype.cpp
extern IDWriteTypography *uiprivOpenTypeFeaturesToIDWriteTypography(const uiOpenTypeFeatures *otf);

View File

@ -1,10 +1,11 @@
// 14 april 2016
#include "uipriv_windows.hpp"
// TODO really migrate? (TODO what did I mean by this?)
#include "attrstr.hpp"
IDWriteFactory *dwfactory = NULL;
HRESULT initDrawText(void)
// TOOD rename to something else, maybe
HRESULT uiprivInitDrawText(void)
{
// TOOD use DWRITE_FACTORY_TYPE_ISOLATED instead?
return DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
@ -12,17 +13,17 @@ HRESULT initDrawText(void)
(IUnknown **) (&dwfactory));
}
void uninitDrawText(void)
void uiprivUninitDrawText(void)
{
dwfactory->Release();
}
fontCollection *loadFontCollection(void)
fontCollection *uiprivLoadFontCollection(void)
{
fontCollection *fc;
HRESULT hr;
fc = uiNew(fontCollection);
fc = uiprivNew(fontCollection);
// always get the latest available font information
hr = dwfactory->GetSystemFontCollection(&(fc->fonts), TRUE);
if (hr != S_OK)
@ -31,7 +32,13 @@ fontCollection *loadFontCollection(void)
return fc;
}
WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family)
void uiprivFontCollectionFree(fontCollection *fc)
{
fc->fonts->Release();
uiprivFree(fc);
}
WCHAR *uiprivFontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family)
{
IDWriteLocalizedStrings *names;
WCHAR *str;
@ -45,7 +52,7 @@ WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family)
return str;
}
WCHAR *fontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names)
WCHAR *uiprivFontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names)
{
UINT32 index;
BOOL exists;
@ -81,9 +88,3 @@ WCHAR *fontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *
return wname;
}
void fontCollectionFree(fontCollection *fc)
{
fc->fonts->Release();
uiFree(fc);
}