manpagez: man pages & more
html files: goocanvas
Home | html | info | man

DWrite Fonts

DWrite Fonts — Font support for Microsoft DWrite

Description

The Microsoft DWrite font backend is primarily used to render text on Microsoft Windows systems.

Functions

cairo_dwrite_font_face_create_for_dwrite_fontface ()

cairo_font_face_t *
cairo_dwrite_font_face_create_for_dwrite_fontface
                               (void *dwrite_font_face);

Creates a new font for the DWrite font backend based on a DWrite font face. This font can then be used with cairo_set_font_face() or cairo_scaled_font_create().

Here is an example of how this function might be used:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <cairo-win32.h>
#include <dwrite.h>

IDWriteFactory* dWriteFactory = NULL;
HRESULT hr = DWriteCreateFactory(
    DWRITE_FACTORY_TYPE_SHARED,
    __uuidof(IDWriteFactory),
   reinterpret_cast<IUnknown**>(&dWriteFactory));

IDWriteFontCollection *systemCollection;
hr = dWriteFactory->GetSystemFontCollection(&systemCollection);

UINT32 idx;
BOOL found;
systemCollection->FindFamilyName(L"Segoe UI Emoji", &idx, &found);

IDWriteFontFamily *family;
systemCollection->GetFontFamily(idx, &family);

IDWriteFont *dwritefont;
DWRITE_FONT_WEIGHT weight = DWRITE_FONT_WEIGHT_NORMAL;
DWRITE_FONT_STYLE style = DWRITE_FONT_STYLE_NORMAL;
hr = family->GetFirstMatchingFont(weight, DWRITE_FONT_STRETCH_NORMAL, style, &dwritefont);

IDWriteFontFace *dwriteface;
hr = dwritefont->CreateFontFace(&dwriteface);

cairo_font_face_t *face;
face = cairo_dwrite_font_face_create_for_dwrite_fontface(dwriteface);
cairo_set_font_face(cr, face);
cairo_set_font_size(cr, 70);
cairo_move_to(cr, 100, 100);
cairo_show_text(cr, "😃");

Parameters

dwrite_font_face

A pointer to an IDWriteFontFace specifying the DWrite font to use.

 

Returns

a newly created cairo_font_face_t. Free with cairo_font_face_destroy() when you are done using it.

Since: 1.18

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.