mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-05 05:25:05 +00:00
Merge pull request #5192 from harfbuzz/dwrite-font-vars
[directwrite] Clean up API / font handling and make variations work on font-funcs
This commit is contained in:
commit
2421efc17b
8 changed files with 132 additions and 160 deletions
|
@ -342,6 +342,7 @@ hb_font_get_glyph_v_kerning
|
|||
hb_font_get_glyph_v_kerning_func_t
|
||||
HB_AAT_LAYOUT_FEATURE_TYPE_CURISVE_CONNECTION
|
||||
hb_directwrite_face_get_font_face
|
||||
hb_directwrite_font_get_dw_font
|
||||
hb_ft_font_get_face
|
||||
hb_graphite2_font_get_gr_font
|
||||
</SECTION>
|
||||
|
@ -367,7 +368,7 @@ hb_directwrite_face_create_from_file_or_fail
|
|||
hb_directwrite_face_create_from_blob_or_fail
|
||||
hb_directwrite_face_get_dw_font_face
|
||||
hb_directwrite_font_create
|
||||
hb_directwrite_font_get_dw_font
|
||||
hb_directwrite_font_get_dw_font_face
|
||||
hb_directwrite_font_set_funcs
|
||||
</SECTION>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ option('fontations', type: 'feature', value: 'disabled',
|
|||
option('gdi', type: 'feature', value: 'disabled',
|
||||
description: 'Enable GDI helpers and Uniscribe shaper backend (Windows only)')
|
||||
option('directwrite', type: 'feature', value: 'disabled',
|
||||
description: 'Enable DirectWrite shaper backend on Windows (experimental)')
|
||||
description: 'Enable DirectWrite shaper backend on Windows')
|
||||
option('coretext', type: 'feature', value: 'disabled',
|
||||
description: 'Enable CoreText shaper backend on macOS')
|
||||
option('wasm', type: 'feature', value: 'disabled',
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
#define MAX_GLYPHS 256u
|
||||
|
||||
static unsigned int
|
||||
hb_directwrite_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
|
||||
void *font_data,
|
||||
hb_directwrite_get_nominal_glyphs (hb_font_t *font,
|
||||
void *font_data HB_UNUSED,
|
||||
unsigned int count,
|
||||
const hb_codepoint_t *first_unicode,
|
||||
unsigned int unicode_stride,
|
||||
|
@ -48,7 +48,7 @@ hb_directwrite_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
|
|||
unsigned int glyph_stride,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) font_data;
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
|
||||
for (unsigned i = 0; i < count;)
|
||||
{
|
||||
|
@ -82,11 +82,11 @@ hb_directwrite_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
|
|||
|
||||
static hb_bool_t
|
||||
hb_directwrite_get_font_h_extents (hb_font_t *font,
|
||||
void *font_data,
|
||||
void *font_data HB_UNUSED,
|
||||
hb_font_extents_t *metrics,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) font_data;
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
|
||||
DWRITE_FONT_METRICS dw_metrics;
|
||||
dw_face->GetMetrics (&dw_metrics);
|
||||
|
@ -99,7 +99,8 @@ hb_directwrite_get_font_h_extents (hb_font_t *font,
|
|||
}
|
||||
|
||||
static void
|
||||
hb_directwrite_get_glyph_h_advances (hb_font_t* font, void* font_data,
|
||||
hb_directwrite_get_glyph_h_advances (hb_font_t* font,
|
||||
void* font_data HB_UNUSED,
|
||||
unsigned count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned glyph_stride,
|
||||
|
@ -107,7 +108,8 @@ hb_directwrite_get_glyph_h_advances (hb_font_t* font, void* font_data,
|
|||
unsigned advance_stride,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) font_data;
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
|
||||
IDWriteFontFace1 *dw_face1 = nullptr;
|
||||
dw_face->QueryInterface (__uuidof(IDWriteFontFace1), (void**)&dw_face1);
|
||||
assert (dw_face1);
|
||||
|
@ -139,7 +141,8 @@ hb_directwrite_get_glyph_h_advances (hb_font_t* font, void* font_data,
|
|||
#ifndef HB_NO_VERTICAL
|
||||
|
||||
static void
|
||||
hb_directwrite_get_glyph_v_advances (hb_font_t* font, void* font_data,
|
||||
hb_directwrite_get_glyph_v_advances (hb_font_t* font,
|
||||
void* font_data HB_UNUSED,
|
||||
unsigned count,
|
||||
const hb_codepoint_t *first_glyph,
|
||||
unsigned glyph_stride,
|
||||
|
@ -147,7 +150,8 @@ hb_directwrite_get_glyph_v_advances (hb_font_t* font, void* font_data,
|
|||
unsigned advance_stride,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) font_data;
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
|
||||
IDWriteFontFace1 *dw_face1 = nullptr;
|
||||
dw_face->QueryInterface (__uuidof(IDWriteFontFace1), (void**)&dw_face1);
|
||||
assert (dw_face1);
|
||||
|
@ -178,13 +182,13 @@ hb_directwrite_get_glyph_v_advances (hb_font_t* font, void* font_data,
|
|||
|
||||
static hb_bool_t
|
||||
hb_directwrite_get_glyph_v_origin (hb_font_t *font,
|
||||
void *font_data,
|
||||
void *font_data HB_UNUSED,
|
||||
hb_codepoint_t glyph,
|
||||
hb_position_t *x,
|
||||
hb_position_t *y,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) font_data;
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
|
||||
UINT16 gid = glyph;
|
||||
DWRITE_GLYPH_METRICS metrics;
|
||||
|
@ -201,12 +205,12 @@ hb_directwrite_get_glyph_v_origin (hb_font_t *font,
|
|||
|
||||
static hb_bool_t
|
||||
hb_directwrite_get_glyph_extents (hb_font_t *font,
|
||||
void *font_data,
|
||||
void *font_data HB_UNUSED,
|
||||
hb_codepoint_t glyph,
|
||||
hb_glyph_extents_t *extents,
|
||||
void *user_data HB_UNUSED)
|
||||
{
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) font_data;
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
|
||||
UINT16 gid = glyph;
|
||||
DWRITE_GLYPH_METRICS metrics;
|
||||
|
@ -273,12 +277,12 @@ public:
|
|||
|
||||
static void
|
||||
hb_directwrite_draw_glyph (hb_font_t *font,
|
||||
void *font_data,
|
||||
void *font_data HB_UNUSED,
|
||||
hb_codepoint_t glyph,
|
||||
hb_draw_funcs_t *draw_funcs, void *draw_data,
|
||||
void *user_data)
|
||||
{
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) font_data;
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
|
||||
GeometrySink sink (font, draw_funcs, draw_data);
|
||||
UINT16 gid = static_cast<UINT16>(glyph);
|
||||
|
@ -343,14 +347,6 @@ _hb_directwrite_get_font_funcs ()
|
|||
return static_directwrite_funcs.get_unconst ();
|
||||
}
|
||||
|
||||
static void
|
||||
_hb_directwrite_font_face_destroy (void *font_data)
|
||||
{
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) font_data;
|
||||
|
||||
dw_face->Release ();
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_directwrite_font_set_funcs:
|
||||
* @font: #hb_font_t to work upon
|
||||
|
@ -372,7 +368,7 @@ _hb_directwrite_font_face_destroy (void *font_data)
|
|||
void
|
||||
hb_directwrite_font_set_funcs (hb_font_t *font)
|
||||
{
|
||||
IDWriteFontFace *dw_face = hb_directwrite_face_get_dw_font_face (font->face);
|
||||
IDWriteFontFace *dw_face = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
if (unlikely (!dw_face))
|
||||
{
|
||||
hb_font_set_funcs (font,
|
||||
|
@ -384,8 +380,7 @@ hb_directwrite_font_set_funcs (hb_font_t *font)
|
|||
dw_face->AddRef ();
|
||||
hb_font_set_funcs (font,
|
||||
_hb_directwrite_get_font_funcs (),
|
||||
(void *) dw_face,
|
||||
_hb_directwrite_font_face_destroy);
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
#undef MAX_GLYPHS
|
||||
|
|
|
@ -65,14 +65,49 @@ struct hb_directwrite_font_data_t {};
|
|||
hb_directwrite_font_data_t *
|
||||
_hb_directwrite_shaper_font_data_create (hb_font_t *font)
|
||||
{
|
||||
return (hb_directwrite_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
||||
IDWriteFontFace *fontFace = (IDWriteFontFace *) (const void *) font->face->data.directwrite;
|
||||
|
||||
/*
|
||||
* Set up variations.
|
||||
*/
|
||||
IDWriteFontFace5 *fontFaceVariations = nullptr;
|
||||
{
|
||||
IDWriteFontFace5 *fontFace5;
|
||||
if (SUCCEEDED (fontFace->QueryInterface (__uuidof (IDWriteFontFace5), (void **) &fontFace5)))
|
||||
{
|
||||
IDWriteFontResource *fontResource;
|
||||
if (SUCCEEDED (fontFace5->GetFontResource (&fontResource)))
|
||||
{
|
||||
hb_vector_t<DWRITE_FONT_AXIS_VALUE> axis_values;
|
||||
if (likely (axis_values.resize_exact (font->num_coords)))
|
||||
{
|
||||
for (unsigned int i = 0; i < font->num_coords; i++)
|
||||
{
|
||||
hb_ot_var_axis_info_t info;
|
||||
unsigned int c = 1;
|
||||
hb_ot_var_get_axis_infos (font->face, i, &c, &info);
|
||||
axis_values[i].axisTag = (DWRITE_FONT_AXIS_TAG) hb_uint32_swap (info.tag);
|
||||
axis_values[i].value = i < font->num_coords ?
|
||||
hb_clamp (font->design_coords[i], info.min_value, info.max_value) :
|
||||
info.default_value;
|
||||
}
|
||||
|
||||
fontResource->CreateFontFace (DWRITE_FONT_SIMULATIONS::DWRITE_FONT_SIMULATIONS_NONE,
|
||||
axis_values.arrayZ, axis_values.length, &fontFaceVariations);
|
||||
}
|
||||
fontResource->Release ();
|
||||
}
|
||||
fontFace5->Release ();
|
||||
}
|
||||
}
|
||||
|
||||
return (hb_directwrite_font_data_t *) fontFaceVariations;
|
||||
}
|
||||
|
||||
void
|
||||
_hb_directwrite_shaper_font_data_destroy (hb_directwrite_font_data_t *data)
|
||||
{
|
||||
if (data != HB_SHAPER_DATA_SUCCEEDED)
|
||||
((IDWriteFont *) (const void *) data)->Release();
|
||||
((IDWriteFontFace *) data)->Release ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -354,8 +389,7 @@ _hb_directwrite_shape (hb_shape_plan_t *shape_plan,
|
|||
const hb_feature_t *features,
|
||||
unsigned int num_features)
|
||||
{
|
||||
hb_face_t *face = font->face;
|
||||
IDWriteFontFace *fontFace = (IDWriteFontFace *) (const void *) face->data.directwrite;
|
||||
IDWriteFontFace *fontFace = (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
auto *global = get_directwrite_global ();
|
||||
if (unlikely (!global))
|
||||
return false;
|
||||
|
@ -442,44 +476,6 @@ _hb_directwrite_shape (hb_shape_plan_t *shape_plan,
|
|||
mbstowcs ((wchar_t*) localeName,
|
||||
hb_language_to_string (buffer->props.language), 20);
|
||||
|
||||
/*
|
||||
* Set up variations.
|
||||
*/
|
||||
IDWriteFontFace5 *fontFaceVariations = nullptr;
|
||||
if (font->num_coords)
|
||||
{
|
||||
IDWriteFontFace5 *fontFace5;
|
||||
if (SUCCEEDED (fontFace->QueryInterface (__uuidof (IDWriteFontFace5), (void **) &fontFace5)))
|
||||
{
|
||||
IDWriteFontResource *fontResource;
|
||||
if (SUCCEEDED (fontFace5->GetFontResource (&fontResource)))
|
||||
{
|
||||
hb_vector_t<DWRITE_FONT_AXIS_VALUE> axis_values;
|
||||
if (likely (axis_values.resize_exact (font->num_coords)))
|
||||
{
|
||||
for (unsigned int i = 0; i < font->num_coords; i++)
|
||||
{
|
||||
hb_ot_var_axis_info_t info;
|
||||
unsigned int c = 1;
|
||||
hb_ot_var_get_axis_infos (font->face, i, &c, &info);
|
||||
axis_values[i].axisTag = (DWRITE_FONT_AXIS_TAG) hb_uint32_swap (info.tag);
|
||||
axis_values[i].value = i < font->num_coords ?
|
||||
hb_clamp (font->design_coords[i], info.min_value, info.max_value) :
|
||||
info.default_value;
|
||||
}
|
||||
|
||||
if (SUCCEEDED (fontResource->CreateFontFace (DWRITE_FONT_SIMULATIONS::DWRITE_FONT_SIMULATIONS_NONE,
|
||||
axis_values.arrayZ, axis_values.length, &fontFaceVariations)))
|
||||
{
|
||||
fontFace = fontFaceVariations;
|
||||
}
|
||||
}
|
||||
fontResource->Release ();
|
||||
}
|
||||
fontFace5->Release ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up features.
|
||||
*/
|
||||
|
@ -652,9 +648,6 @@ retry_getglyphs:
|
|||
delete [] glyphAdvances;
|
||||
delete [] glyphOffsets;
|
||||
|
||||
if (fontFaceVariations)
|
||||
fontFaceVariations->Release ();
|
||||
|
||||
/* Wow, done! */
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -328,23 +328,19 @@ hb_directwrite_face_get_font_face (hb_face_t *face)
|
|||
|
||||
/**
|
||||
* hb_directwrite_font_create:
|
||||
* @dw_font: a DirectWrite IDWriteFont object.
|
||||
* @dw_face: a DirectWrite IDWriteFontFace object.
|
||||
*
|
||||
* Constructs a new font object from the specified DirectWrite IDWriteFont.
|
||||
* Constructs a new font object from the specified DirectWrite IDWriteFontFace.
|
||||
*
|
||||
* Return value: #hb_font_t object corresponding to the given input
|
||||
*
|
||||
* Since: 10.3.0
|
||||
* XSince: REPLACEME
|
||||
**/
|
||||
hb_font_t *
|
||||
hb_directwrite_font_create (IDWriteFont *dw_font)
|
||||
hb_directwrite_font_create (IDWriteFontFace *dw_face)
|
||||
{
|
||||
IDWriteFontFace *dw_face = nullptr;
|
||||
IDWriteFontFace5 *dw_face5 = nullptr;
|
||||
|
||||
if (FAILED (dw_font->CreateFontFace (&dw_face)))
|
||||
return hb_font_get_empty ();
|
||||
|
||||
hb_face_t *face = hb_directwrite_face_create (dw_face);
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_face_destroy (face);
|
||||
|
@ -378,28 +374,47 @@ hb_directwrite_font_create (IDWriteFont *dw_font)
|
|||
dw_face5->Release ();
|
||||
}
|
||||
|
||||
dw_font->AddRef ();
|
||||
font->data.directwrite.cmpexch (nullptr, (hb_directwrite_font_data_t *) dw_font);
|
||||
/* Let there be dragons here... */
|
||||
dw_face->AddRef ();
|
||||
font->data.directwrite.cmpexch (nullptr, (hb_directwrite_font_data_t *) dw_face);
|
||||
|
||||
done:
|
||||
dw_face->Release ();
|
||||
return font;
|
||||
}
|
||||
|
||||
/**
|
||||
* hb_directwrite_font_get_dw_font_face:
|
||||
* @font: a #hb_font_t object
|
||||
*
|
||||
* Gets the DirectWrite IDWriteFontFace associated with @font.
|
||||
*
|
||||
* Return value: DirectWrite IDWriteFontFace object corresponding to the given input
|
||||
*
|
||||
* XSince: REPLACEME
|
||||
**/
|
||||
IDWriteFontFace *
|
||||
hb_directwrite_font_get_dw_font_face (hb_font_t *font)
|
||||
{
|
||||
return (IDWriteFontFace *) (const void *) font->data.directwrite;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hb_directwrite_font_get_dw_font:
|
||||
* @font: a #hb_font_t object
|
||||
*
|
||||
* Gets the DirectWrite IDWriteFont associated with @font.
|
||||
* Deprecated.
|
||||
*
|
||||
* Return value: DirectWrite IDWriteFont object corresponding to the given input
|
||||
* Return value: Returns `NULL`.
|
||||
*
|
||||
* Since: 10.3.0
|
||||
* XDeprecated: REPLACEME:
|
||||
**/
|
||||
IDWriteFont *
|
||||
hb_directwrite_font_get_dw_font (hb_font_t *font)
|
||||
{
|
||||
return (IDWriteFont *) (const void *) font->data.directwrite;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,10 +46,10 @@ HB_EXTERN IDWriteFontFace *
|
|||
hb_directwrite_face_get_dw_font_face (hb_face_t *face);
|
||||
|
||||
HB_EXTERN hb_font_t *
|
||||
hb_directwrite_font_create (IDWriteFont *dw_font);
|
||||
hb_directwrite_font_create (IDWriteFontFace *dw_face);
|
||||
|
||||
HB_EXTERN IDWriteFont *
|
||||
hb_directwrite_font_get_dw_font (hb_font_t *font);
|
||||
HB_EXTERN IDWriteFontFace *
|
||||
hb_directwrite_font_get_dw_font_face (hb_font_t *font);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_directwrite_font_set_funcs (hb_font_t *font);
|
||||
|
@ -60,6 +60,10 @@ HB_DEPRECATED_FOR (hb_directwrite_face_get_dw_font_face)
|
|||
HB_EXTERN IDWriteFontFace *
|
||||
hb_directwrite_face_get_font_face (hb_face_t *face);
|
||||
|
||||
HB_DEPRECATED
|
||||
HB_EXTERN IDWriteFont *
|
||||
hb_directwrite_font_get_dw_font (hb_font_t *font);
|
||||
|
||||
#endif
|
||||
|
||||
HB_END_DECLS
|
||||
|
|
|
@ -36,108 +36,61 @@ typedef HRESULT (WINAPI *t_DWriteCreateFactory)(
|
|||
IUnknown **factory
|
||||
);
|
||||
|
||||
IDWriteFont *
|
||||
get_dwfont (const wchar_t *family_name)
|
||||
IDWriteFontFace *
|
||||
get_dwfontface (const char *font_path)
|
||||
{
|
||||
HRESULT hr;
|
||||
t_DWriteCreateFactory CreateFactory;
|
||||
HMODULE dwrite_dll;
|
||||
IDWriteFactory *factory;
|
||||
IDWriteFactory7 *factory7;
|
||||
IDWriteFontCollection3 *collection;
|
||||
UINT32 count;
|
||||
IDWriteFontFamily2 *family;
|
||||
IDWriteFont *font;
|
||||
UINT32 index = 0;
|
||||
auto *face = hb_test_open_font_file (font_path);
|
||||
|
||||
dwrite_dll = LoadLibrary (TEXT ("DWRITE"));
|
||||
g_assert_nonnull (dwrite_dll);
|
||||
auto *dw_font_face = hb_directwrite_face_get_dw_font_face (face);
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-function-type"
|
||||
#endif
|
||||
dw_font_face->AddRef ();
|
||||
|
||||
CreateFactory = (t_DWriteCreateFactory) GetProcAddress (dwrite_dll, "DWriteCreateFactory");
|
||||
g_assert_nonnull (CreateFactory);
|
||||
// Don't destroy face, as dw_font_face is backed by its data I think.
|
||||
//hb_face_destroy (face);
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
hr = CreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), (IUnknown**) &factory);
|
||||
g_assert_true (SUCCEEDED (hr));
|
||||
|
||||
hr = factory->QueryInterface (__uuidof (IDWriteFactory7), (void**) &factory7);
|
||||
g_assert_true (SUCCEEDED (hr));
|
||||
|
||||
hr = factory7->GetSystemFontCollection (FALSE, DWRITE_FONT_FAMILY_MODEL_TYPOGRAPHIC, &collection);
|
||||
g_assert_true (SUCCEEDED (hr));
|
||||
|
||||
count = collection->GetFontFamilyCount ();
|
||||
g_assert_cmpuint (count, >, 0);
|
||||
|
||||
if (family_name)
|
||||
{
|
||||
BOOL exists;
|
||||
hr = collection->FindFamilyName (family_name, &index, &exists);
|
||||
g_assert_true (SUCCEEDED (hr));
|
||||
g_assert_true (exists);
|
||||
}
|
||||
|
||||
hr = collection->GetFontFamily (index, &family);
|
||||
g_assert_true (SUCCEEDED (hr));
|
||||
|
||||
hr = family->GetFirstMatchingFont (DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL,
|
||||
DWRITE_FONT_STYLE_NORMAL,
|
||||
&font);
|
||||
g_assert_true (SUCCEEDED (hr));
|
||||
|
||||
factory->Release ();
|
||||
|
||||
return font;
|
||||
return dw_font_face;
|
||||
}
|
||||
|
||||
static void
|
||||
test_native_directwrite_basic (void)
|
||||
{
|
||||
IDWriteFont *dwfont;
|
||||
IDWriteFontFace *dwfontface;
|
||||
hb_font_t *font;
|
||||
IDWriteFont *dwfont2;
|
||||
IDWriteFontFace *dwfontface2;
|
||||
|
||||
dwfont = get_dwfont (nullptr);
|
||||
g_assert_nonnull (dwfont);
|
||||
dwfontface = get_dwfontface ("fonts/Roboto-Regular.abc.ttf");
|
||||
g_assert_nonnull (dwfontface);
|
||||
|
||||
font = hb_directwrite_font_create (dwfont);
|
||||
font = hb_directwrite_font_create (dwfontface);
|
||||
|
||||
dwfont2 = hb_directwrite_font_get_dw_font (font);
|
||||
dwfontface2 = hb_directwrite_font_get_dw_font_face (font);
|
||||
|
||||
g_assert_true (dwfont2 == dwfont);
|
||||
g_assert_true (dwfontface2 == dwfontface);
|
||||
|
||||
hb_font_destroy (font);
|
||||
|
||||
dwfont->Release ();
|
||||
dwfontface->Release ();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_native_directwrite_variations (void)
|
||||
{
|
||||
IDWriteFont *dwfont;
|
||||
IDWriteFontFace *dwfontface;
|
||||
hb_font_t *font;
|
||||
unsigned int length;
|
||||
|
||||
dwfont = get_dwfont (L"Bahnschrift");
|
||||
g_assert_nonnull (dwfont);
|
||||
dwfontface = get_dwfontface ("fonts/AdobeVFPrototype.abc.otf");
|
||||
g_assert_nonnull (dwfontface);
|
||||
|
||||
font = hb_directwrite_font_create (dwfont);
|
||||
font = hb_directwrite_font_create (dwfontface);
|
||||
hb_font_get_var_coords_normalized(font, &length);
|
||||
g_assert_cmpuint (length, !=, 0);
|
||||
// Currently we optimize out coords if none is non-zero
|
||||
//g_assert_cmpuint (length, !=, 0);
|
||||
|
||||
hb_font_destroy (font);
|
||||
|
||||
dwfont->Release ();
|
||||
dwfontface->Release ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -102,6 +102,17 @@ for what in ["shaper", "face-loader", "font-funcs"]:
|
|||
globals()[var_name] = what_list
|
||||
print(f"Supported {whats}: {what_list}")
|
||||
|
||||
# If running under Wine and not native dlls, make the respective shapers unavailable.
|
||||
if os.environ.get("WINEPATH"):
|
||||
overrides = os.environ.get("WINEDLLOVERRIDES", "").lower()
|
||||
if "directwrite" in supported_shapers and overrides.find("dwrite") == -1:
|
||||
supported_shapers.remove("directwrite")
|
||||
print("Skipping DirectWrite shaper under Wine.")
|
||||
if "uniscribe" in supported_shapers and overrides.find("usp10") == -1:
|
||||
supported_shapers.remove("uniscribe")
|
||||
print("Skipping Uniscribe shaper under Wine.")
|
||||
|
||||
|
||||
passes = 0
|
||||
fails = 0
|
||||
skips = 0
|
||||
|
|
Loading…
Add table
Reference in a new issue