From b36e624c89c4920c48f4ca0a85390b8868149eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Wed, 12 Oct 2022 14:25:18 +0200 Subject: [PATCH] wasm: use public API for converting from Uint8Array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the new QByteAaray::fromUint8Array() function. Change-Id: I7bb7a8184e1bfde2a89af2efb331db64f0b4d285 Reviewed-by: Morten Johan Sørvig Reviewed-by: Mikołaj Boc --- .../platforms/wasm/qwasmfontdatabase.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmfontdatabase.cpp b/src/plugins/platforms/wasm/qwasmfontdatabase.cpp index 37f80279e0..7b8265ca23 100644 --- a/src/plugins/platforms/wasm/qwasmfontdatabase.cpp +++ b/src/plugins/platforms/wasm/qwasmfontdatabase.cpp @@ -12,21 +12,6 @@ #include #include -// FIXME: replace with shared implementation from qstdweb -QByteArray fromUint8Array(emscripten::val uint8array) -{ - qstdweb::ArrayBuffer arrayBuffer(uint8array); - - using qstdweb::Uint8Array; - Uint8Array sourceArray(arrayBuffer); - if (sourceArray.length() > std::numeric_limits::max()) - return QByteArray(); - QByteArray destinationArray; - destinationArray.resize(sourceArray.length()); - sourceArray.copyTo(destinationArray.data()); - return destinationArray; -} - QT_BEGIN_NAMESPACE using namespace emscripten; @@ -121,7 +106,7 @@ void QWasmFontDatabase::populateFamily(const QString &familyName) .thenFunc = [](val status) { qCDebug(lcQpaFonts) << "onArrayBuffer" ; - QByteArray fontByteArray = fromUint8Array(status); + QByteArray fontByteArray = QByteArray::fromUint8Array(status); QFreeTypeFontDatabase::addTTFile(fontByteArray, QByteArray());