Skip to content

Commit efc9d4b

Browse files
committed
Fixed: warnings
1 parent cc757bd commit efc9d4b

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
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
{

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)