[dwrite] GCC/mingw/msys2 compatibility (#884)
This commit is contained in:
parent
93f8f89ded
commit
d4907e83ef
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright © 2015-2016 Ebrahim Byagowi
|
* Copyright © 2015-2018 Ebrahim Byagowi
|
||||||
*
|
*
|
||||||
* This is part of HarfBuzz, a text shaping library.
|
* This is part of HarfBuzz, a text shaping library.
|
||||||
*
|
*
|
||||||
|
@ -48,7 +48,8 @@ class DWriteFontFileLoader : public IDWriteFontFileLoader
|
||||||
private:
|
private:
|
||||||
IDWriteFontFileStream *mFontFileStream;
|
IDWriteFontFileStream *mFontFileStream;
|
||||||
public:
|
public:
|
||||||
DWriteFontFileLoader (IDWriteFontFileStream *fontFileStream) {
|
void init (IDWriteFontFileStream *fontFileStream)
|
||||||
|
{
|
||||||
mFontFileStream = fontFileStream;
|
mFontFileStream = fontFileStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ private:
|
||||||
uint8_t *mData;
|
uint8_t *mData;
|
||||||
uint32_t mSize;
|
uint32_t mSize;
|
||||||
public:
|
public:
|
||||||
DWriteFontFileStream(uint8_t *aData, uint32_t aSize)
|
void init (uint8_t *aData, uint32_t aSize)
|
||||||
{
|
{
|
||||||
mData = aData;
|
mData = aData;
|
||||||
mSize = aSize;
|
mSize = aSize;
|
||||||
|
@ -150,10 +151,14 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face)
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hb_blob_t *blob = hb_face_reference_blob (face);
|
hb_blob_t *blob = hb_face_reference_blob (face);
|
||||||
IDWriteFontFileStream *fontFileStream = new DWriteFontFileStream (
|
DWriteFontFileStream *fontFileStream = (DWriteFontFileStream*)
|
||||||
(uint8_t*) hb_blob_get_data (blob, nullptr), hb_blob_get_length (blob));
|
malloc (sizeof (DWriteFontFileStream));
|
||||||
|
fontFileStream->init ((uint8_t*) hb_blob_get_data (blob, nullptr),
|
||||||
|
hb_blob_get_length (blob));
|
||||||
|
|
||||||
IDWriteFontFileLoader *fontFileLoader = new DWriteFontFileLoader (fontFileStream);
|
DWriteFontFileLoader *fontFileLoader = (DWriteFontFileLoader*)
|
||||||
|
malloc (sizeof (DWriteFontFileLoader));
|
||||||
|
fontFileLoader->init (fontFileStream);
|
||||||
dwriteFactory->RegisterFontFileLoader (fontFileLoader);
|
dwriteFactory->RegisterFontFileLoader (fontFileLoader);
|
||||||
|
|
||||||
IDWriteFontFile *fontFile;
|
IDWriteFontFile *fontFile;
|
||||||
|
@ -164,12 +169,12 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face)
|
||||||
#define FAIL(...) \
|
#define FAIL(...) \
|
||||||
HB_STMT_START { \
|
HB_STMT_START { \
|
||||||
DEBUG_MSG (DIRECTWRITE, nullptr, __VA_ARGS__); \
|
DEBUG_MSG (DIRECTWRITE, nullptr, __VA_ARGS__); \
|
||||||
return false; \
|
return nullptr; \
|
||||||
} HB_STMT_END;
|
} HB_STMT_END;
|
||||||
|
|
||||||
if (FAILED (hr)) {
|
if (FAILED (hr)) {
|
||||||
FAIL ("Failed to load font file from data!");
|
FAIL ("Failed to load font file from data!");
|
||||||
return false;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL isSupported;
|
BOOL isSupported;
|
||||||
|
@ -179,7 +184,7 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face)
|
||||||
hr = fontFile->Analyze (&isSupported, &fileType, &faceType, &numberOfFaces);
|
hr = fontFile->Analyze (&isSupported, &fileType, &faceType, &numberOfFaces);
|
||||||
if (FAILED (hr) || !isSupported) {
|
if (FAILED (hr) || !isSupported) {
|
||||||
FAIL ("Font file is not supported.");
|
FAIL ("Font file is not supported.");
|
||||||
return false;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef FAIL
|
#undef FAIL
|
||||||
|
@ -211,9 +216,9 @@ _hb_directwrite_shaper_face_data_destroy(hb_directwrite_shaper_face_data_t *data
|
||||||
data->dwriteFactory->Release ();
|
data->dwriteFactory->Release ();
|
||||||
}
|
}
|
||||||
if (data->fontFileLoader)
|
if (data->fontFileLoader)
|
||||||
delete data->fontFileLoader;
|
free (data->fontFileLoader);
|
||||||
if (data->fontFileStream)
|
if (data->fontFileStream)
|
||||||
delete data->fontFileStream;
|
free (data->fontFileStream);
|
||||||
if (data->faceBlob)
|
if (data->faceBlob)
|
||||||
hb_blob_destroy (data->faceBlob);
|
hb_blob_destroy (data->faceBlob);
|
||||||
if (data)
|
if (data)
|
||||||
|
@ -280,14 +285,14 @@ public:
|
||||||
IFACEMETHOD_(ULONG, AddRef)() { return 1; }
|
IFACEMETHOD_(ULONG, AddRef)() { return 1; }
|
||||||
IFACEMETHOD_(ULONG, Release)() { return 1; }
|
IFACEMETHOD_(ULONG, Release)() { return 1; }
|
||||||
|
|
||||||
// A single contiguous run of characters containing the same analysis
|
// A single contiguous run of characters containing the same analysis
|
||||||
// results.
|
// results.
|
||||||
struct Run
|
struct Run
|
||||||
{
|
{
|
||||||
uint32_t mTextStart; // starting text position of this run
|
uint32_t mTextStart; // starting text position of this run
|
||||||
uint32_t mTextLength; // number of contiguous code units covered
|
uint32_t mTextLength; // number of contiguous code units covered
|
||||||
uint32_t mGlyphStart; // starting glyph in the glyphs array
|
uint32_t mGlyphStart; // starting glyph in the glyphs array
|
||||||
uint32_t mGlyphCount; // number of glyphs associated with this run of
|
uint32_t mGlyphCount; // number of glyphs associated with this run
|
||||||
// text
|
// text
|
||||||
DWRITE_SCRIPT_ANALYSIS mScript;
|
DWRITE_SCRIPT_ANALYSIS mScript;
|
||||||
uint8_t mBidiLevel;
|
uint8_t mBidiLevel;
|
||||||
|
@ -604,7 +609,7 @@ _hb_directwrite_shape_full(hb_shape_plan_t *shape_plan,
|
||||||
|
|
||||||
// TODO: Handle TEST_DISABLE_OPTIONAL_LIGATURES
|
// TODO: Handle TEST_DISABLE_OPTIONAL_LIGATURES
|
||||||
|
|
||||||
DWRITE_READING_DIRECTION readingDirection = buffer->props.direction ?
|
DWRITE_READING_DIRECTION readingDirection = buffer->props.direction ?
|
||||||
DWRITE_READING_DIRECTION_RIGHT_TO_LEFT :
|
DWRITE_READING_DIRECTION_RIGHT_TO_LEFT :
|
||||||
DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
|
DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
|
||||||
|
|
||||||
|
@ -919,7 +924,7 @@ hb_directwrite_shape_experimental_width(hb_font_t *font,
|
||||||
unsigned int num_features,
|
unsigned int num_features,
|
||||||
float width)
|
float width)
|
||||||
{
|
{
|
||||||
static char *shapers = "directwrite";
|
static char *shapers = (char *) "directwrite";
|
||||||
hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face,
|
hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face,
|
||||||
&buffer->props, features, num_features, &shapers);
|
&buffer->props, features, num_features, &shapers);
|
||||||
hb_bool_t res = _hb_directwrite_shape_full (shape_plan, font, buffer,
|
hb_bool_t res = _hb_directwrite_shape_full (shape_plan, font, buffer,
|
||||||
|
|
Loading…
Reference in New Issue