Skip to content

Commit fc346a9

Browse files
committed
Fixed: warnings
1 parent cc757bd commit fc346a9

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

FreeTypeWrapper/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ if (FREETYPE_WRAPPER_DISABLE_WARNINGS_EXTERNAL_LIBS)
6060
-Wno-missing-noreturn
6161
-Wno-extra-semi-stmt
6262
-Wno-switch-default
63+
-Wno-reserved-identifier
64+
-Wno-cast-function-type-strict
65+
-Wno-reserved-identifier
66+
-Wno-cast-function-type-mismatch
6367
)
6468
if (FREETYPE_WRAPPER_BUILD_FRIBIDI)
6569
target_compile_options(libfribidi PRIVATE
@@ -78,6 +82,7 @@ if (FREETYPE_WRAPPER_DISABLE_WARNINGS_EXTERNAL_LIBS)
7882
-Wno-unsafe-buffer-usage
7983
-Wno-reserved-identifier
8084
-Wno-switch-default
85+
-Wno-format
8186
)
8287
endif()
8388

FreeTypeWrapper/Source/FreeTypeConnector.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace FreeType
198198

199199
FT_Glyph glyph;
200200
if (FT_Error error = FT_Get_Glyph(face->glyph, &glyph))
201-
LL_EXCEPTION(LLUtils::Exception::ErrorCode::RuntimeError, "FreeType error, unable to render glyph");
201+
LL_EXCEPTION(LLUtils::Exception::ErrorCode::RuntimeError, std::format("FreeType error {0}, {1}", error, GenerateFreeTypeErrorString("unable to render glyph",error)));
202202

203203
if (glyph->format != FT_GLYPH_FORMAT_BITMAP)
204204
{
@@ -271,13 +271,13 @@ namespace FreeType
271271
template <typename source_type, typename dest_type>
272272
void FreeTypeConnector::ResolvePremultipoliedBUffer(LLUtils::Buffer& dest, const LLUtils::Buffer& source, uint32_t width, uint32_t height)
273273
{
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);
274+
std::span<dest_type> destPtr(dest);
275+
const std::span<const source_type> sourcePtr(source);
276276

277277
for (auto y = 0u ; y < height;y++)
278278
for (auto x = 0u; x < width; x++)
279279
destPtr[y * width + x] = static_cast<dest_type>(sourcePtr[y * width + x].DivideAlpha());
280-
}
280+
}
281281

282282

283283
void FreeTypeConnector::CreateBitmap(const TextCreateParams& textCreateParams
@@ -334,8 +334,7 @@ namespace FreeType
334334

335335
ColorF32 textBackgroundBuffer = renderOutline ? ColorF32(0.0f,0.0f,0.0f,0.0f) : static_cast<ColorF32>(backgroundColor).MultiplyAlpha();
336336

337-
std::span textBufferColor(reinterpret_cast<ColorF32*>(textBuffer.data()), totalTexels);
338-
337+
std::span<ColorF32> textBufferColor(textBuffer);
339338

340339
for (size_t i = 0; i < totalTexels; i++)
341340
textBufferColor[i] = textBackgroundBuffer;
@@ -345,7 +344,7 @@ namespace FreeType
345344
if (renderOutline)
346345
{
347346
outlineBuffer.Allocate(sizeOfDestBuffer);
348-
std::span outlineBufferColor(reinterpret_cast<ColorF32*>(outlineBuffer.data()), totalTexels);
347+
std::span<ColorF32> outlineBufferColor(outlineBuffer);
349348

350349
//Reset outline buffer to background color.
351350
for (size_t i = 0; i < totalTexels; i++)
@@ -443,7 +442,7 @@ namespace FreeType
443442

444443
FT_Glyph glyph;
445444
if (FT_Error error = FT_Get_Glyph(face->glyph, &glyph))
446-
LL_EXCEPTION(LLUtils::Exception::ErrorCode::RuntimeError, "FreeType error, unable to render glyph");
445+
LL_EXCEPTION(LLUtils::Exception::ErrorCode::RuntimeError, std::format("FreeType error {0}, {1}",error, GenerateFreeTypeErrorString("unable to render glyph", error)));
447446

448447
if (glyph->format != FT_GLYPH_FORMAT_BITMAP)
449448
{

FreeTypeWrapper/Source/FreeTypeRenderer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ namespace FreeType
7575
using namespace LLUtils;
7676

7777
FT_Bitmap bitmap = params.bitmapGlyph->bitmap;
78-
std::span bitmapBuffer = std::span(params.bitmapGlyph->bitmap.buffer, static_cast<size_t>(bitmap.rows * static_cast<unsigned int>(bitmap.pitch)));
78+
LLUtils::Buffer glyphBuffer( reinterpret_cast<const std::byte*>(params.bitmapGlyph->bitmap.buffer),
79+
static_cast<size_t>(bitmap.rows * static_cast<unsigned int>(bitmap.pitch)));
80+
81+
std::span<uint8_t> bitmapBuffer(glyphBuffer);
7982

8083
const int destPixelSize = sizeof(ColorF32);
8184
const uint32_t HeightInPixels = params.bitmapProperties.height;
@@ -86,7 +89,7 @@ namespace FreeType
8689
const size_t bufferSize = widthInPixels * HeightInPixels * destPixelSize;
8790
LLUtils::Buffer RGBABitmap(bufferSize);
8891
memset(RGBABitmap.data(), 0, RGBABitmap.size());
89-
std::span<ColorF32,std::dynamic_extent> RGBABitmapPtr(reinterpret_cast<ColorF32*>(RGBABitmap.data()), widthInPixels * HeightInPixels);
92+
std::span<ColorF32> RGBABitmapPtr(RGBABitmap);
9093

9194
uint32_t sourceRowStart = 0;
9295

0 commit comments

Comments
 (0)