33#include < string>
44#include < iostream>
55#include < span>
6+ #include < format>
67
78#include < FreeTypeWrapper/FreeTypeConnector.h>
89#include < FreeTypeRenderer.h>
@@ -198,7 +199,7 @@ namespace FreeType
198199
199200 FT_Glyph glyph;
200201 if (FT_Error error = FT_Get_Glyph (face->glyph , &glyph))
201- LL_EXCEPTION (LLUtils::Exception::ErrorCode::RuntimeError, " FreeType error, unable to render glyph" );
202+ LL_EXCEPTION (LLUtils::Exception::ErrorCode::RuntimeError, std::format ( " FreeType error {0}, {1} " , error, GenerateFreeTypeErrorString ( " unable to render glyph" ,error)) );
202203
203204 if (glyph->format != FT_GLYPH_FORMAT_BITMAP)
204205 {
@@ -271,13 +272,13 @@ namespace FreeType
271272 template <typename source_type, typename dest_type>
272273 void FreeTypeConnector::ResolvePremultipoliedBUffer (LLUtils::Buffer& dest, const LLUtils::Buffer& source, uint32_t width, uint32_t height)
273274 {
274- std::span destPtr ( reinterpret_cast <dest_type*> (dest. data ()), width * height );
275- const std::span sourcePtr ( reinterpret_cast <const source_type*> (source. data ()), width * height );
275+ std::span<dest_type> destPtr (dest);
276+ const std::span<const source_type> sourcePtr (source);
276277
277278 for (auto y = 0u ; y < height;y++)
278279 for (auto x = 0u ; x < width; x++)
279280 destPtr[y * width + x] = static_cast <dest_type>(sourcePtr[y * width + x].DivideAlpha ());
280- }
281+ }
281282
282283
283284 void FreeTypeConnector::CreateBitmap (const TextCreateParams& textCreateParams
@@ -334,8 +335,7 @@ namespace FreeType
334335
335336 ColorF32 textBackgroundBuffer = renderOutline ? ColorF32 (0 .0f ,0 .0f ,0 .0f ,0 .0f ) : static_cast <ColorF32>(backgroundColor).MultiplyAlpha ();
336337
337- std::span textBufferColor (reinterpret_cast <ColorF32*>(textBuffer.data ()), totalTexels);
338-
338+ std::span<ColorF32> textBufferColor (textBuffer);
339339
340340 for (size_t i = 0 ; i < totalTexels; i++)
341341 textBufferColor[i] = textBackgroundBuffer;
@@ -345,7 +345,7 @@ namespace FreeType
345345 if (renderOutline)
346346 {
347347 outlineBuffer.Allocate (sizeOfDestBuffer);
348- std::span outlineBufferColor ( reinterpret_cast <ColorF32*> (outlineBuffer. data ()), totalTexels );
348+ std::span<ColorF32> outlineBufferColor (outlineBuffer);
349349
350350 // Reset outline buffer to background color.
351351 for (size_t i = 0 ; i < totalTexels; i++)
@@ -443,7 +443,7 @@ namespace FreeType
443443
444444 FT_Glyph glyph;
445445 if (FT_Error error = FT_Get_Glyph (face->glyph , &glyph))
446- LL_EXCEPTION (LLUtils::Exception::ErrorCode::RuntimeError, " FreeType error, unable to render glyph" );
446+ LL_EXCEPTION (LLUtils::Exception::ErrorCode::RuntimeError, std::format ( " FreeType error {0}, {1} " ,error, GenerateFreeTypeErrorString ( " unable to render glyph" , error)) );
447447
448448 if (glyph->format != FT_GLYPH_FORMAT_BITMAP)
449449 {
0 commit comments