From 957e7756634a4fdf1654041e20e883cf964ecac9 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 19 Mar 2018 12:19:42 +0330 Subject: [PATCH] [dwrite] Use new again and enable the build on msys2 bots (#890) --- appveyor.yml | 7 ++++--- src/hb-directwrite.cc | 19 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5971337cd..b68572062 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,11 +20,11 @@ environment: - compiler: msys2 - MINGW_PREFIX: /c/msys2/mingw64/ + MINGW_PREFIX: /mingw64 MINGW_CHOST: x86_64-w64-mingw32 MSYS2_ARCH: x86_64 - compiler: msys2 - MINGW_PREFIX: /c/msys2/mingw32/ + MINGW_PREFIX: /mingw32 MINGW_CHOST: i686-w64-mingw32 MSYS2_ARCH: i686 @@ -44,7 +44,8 @@ build_script: - 'if "%compiler%"=="msvc" if not "%platform%"=="ARM" ctest --output-on-failure -C %configuration%' - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-$MSYS2_ARCH-{freetype,cairo,icu,gettext,gobject-introspection,gcc,gcc-libs,glib2,graphite2,pkg-config,python2}"' - - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; ./autogen.sh --with-uniscribe --with-freetype --with-glib --with-gobject --with-cairo --with-icu --with-graphite2 --build=%MINGW_CHOST% --host=%MINGW_CHOST% --prefix=%MINGW_PREFIX%; make; make check || .ci/fail.sh"' + - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "curl https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-headers/include/dwrite_1.h?format=raw > %MINGW_PREFIX%/%MINGW_CHOST%/include/dwrite_1.h"' + - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; ./autogen.sh --with-uniscribe --with-freetype --with-glib --with-gobject --with-cairo --with-icu --with-graphite2 --with-directwrite --build=%MINGW_CHOST% --host=%MINGW_CHOST% --prefix=%MINGW_PREFIX%; make; make check || .ci/fail.sh"' cache: - c:\tools\vcpkg\installed\ diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index 40e9e39bf..0d3b1c2e4 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -48,7 +48,7 @@ class DWriteFontFileLoader : public IDWriteFontFileLoader private: IDWriteFontFileStream *mFontFileStream; public: - void init (IDWriteFontFileStream *fontFileStream) + DWriteFontFileLoader (IDWriteFontFileStream *fontFileStream) { mFontFileStream = fontFileStream; } @@ -74,7 +74,7 @@ private: uint8_t *mData; uint32_t mSize; public: - void init (uint8_t *aData, uint32_t aSize) + DWriteFontFileStream (uint8_t *aData, uint32_t aSize) { mData = aData; mSize = aSize; @@ -151,14 +151,11 @@ _hb_directwrite_shaper_face_data_create(hb_face_t *face) HRESULT hr; hb_blob_t *blob = hb_face_reference_blob (face); - DWriteFontFileStream *fontFileStream = (DWriteFontFileStream*) - malloc (sizeof (DWriteFontFileStream)); - fontFileStream->init ((uint8_t*) hb_blob_get_data (blob, nullptr), + DWriteFontFileStream *fontFileStream = new DWriteFontFileStream ( + (uint8_t *) hb_blob_get_data (blob, nullptr), hb_blob_get_length (blob)); - DWriteFontFileLoader *fontFileLoader = (DWriteFontFileLoader*) - malloc (sizeof (DWriteFontFileLoader)); - fontFileLoader->init (fontFileStream); + DWriteFontFileLoader *fontFileLoader = new DWriteFontFileLoader (fontFileStream); dwriteFactory->RegisterFontFileLoader (fontFileLoader); IDWriteFontFile *fontFile; @@ -216,9 +213,9 @@ _hb_directwrite_shaper_face_data_destroy(hb_directwrite_shaper_face_data_t *data data->dwriteFactory->Release (); } if (data->fontFileLoader) - free (data->fontFileLoader); + delete data->fontFileLoader; if (data->fontFileStream) - free (data->fontFileStream); + delete data->fontFileStream; if (data->faceBlob) hb_blob_destroy (data->faceBlob); if (data) @@ -924,7 +921,7 @@ hb_directwrite_shape_experimental_width(hb_font_t *font, unsigned int num_features, float width) { - static char *shapers = (char *) "directwrite"; + static const char *shapers = "directwrite"; hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, features, num_features, &shapers); hb_bool_t res = _hb_directwrite_shape_full (shape_plan, font, buffer,