DWriteCreateFactory function (dwrite.h)

Creates a DirectWrite factory object that is used for subsequent creation of individual DirectWrite objects.

Syntax

HRESULT DWriteCreateFactory(
  [in]  DWRITE_FACTORY_TYPE factoryType,
  [in]  REFIID              iid,
  [out] IUnknown            **factory
);

Parameters

[in] factoryType

Type: DWRITE_FACTORY_TYPE

A value that specifies whether the factory object will be shared or isolated.

[in] iid

Type: REFIID

A GUID value that identifies the DirectWrite factory interface, such as __uuidof(IDWriteFactory).

[out] factory

Type: IUnknown**

An address of a pointer to the newly created DirectWrite factory object.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

This function creates a DirectWrite factory object that is used for subsequent creation of individual DirectWrite objects. DirectWrite factory contains internal state data such as font loader registration and cached font data. In most cases it is recommended you use the shared factory object, because it allows multiple components that use DirectWrite to share internal DirectWrite state data, and thereby reduce memory usage. However, there are cases when it is desirable to reduce the impact of a component, such as a plug-in from an untrusted source, on the rest of the process, by sandboxing and isolating it from the rest of the process components. In such cases, it is recommended you use an isolated factory for the sandboxed component.

The following example shows how to create a shared DirectWrite factory.


if (SUCCEEDED(hr))
{
    hr = DWriteCreateFactory(
        DWRITE_FACTORY_TYPE_SHARED,
        __uuidof(IDWriteFactory),
        reinterpret_cast<IUnknown**>(&pDWriteFactory_)
        );
}


Requirements

Requirement Value
Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header dwrite.h
Library Dwrite.lib
DLL Dwrite.dll