Skip to content

Commit fffef60

Browse files
committed
fix: restore cross-platform CI compatibility
1 parent acdc129 commit fffef60

4 files changed

Lines changed: 33 additions & 6 deletions

File tree

include/ege.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ typedef struct {
401401
DWORD bV4GammaBlue;
402402
} BITMAPV4HEADER, *PBITMAPV4HEADER;
403403

404+
#ifndef LF_FACESIZE
405+
#define LF_FACESIZE 32
406+
#endif
407+
404408
typedef struct tagLOGFONTA {
405409
LONG lfHeight;
406410
LONG lfWidth;
@@ -415,7 +419,7 @@ typedef struct tagLOGFONTA {
415419
BYTE lfClipPrecision;
416420
BYTE lfQuality;
417421
BYTE lfPitchAndFamily;
418-
char lfFaceName[32];
422+
char lfFaceName[LF_FACESIZE];
419423
} LOGFONTA, *PLOGFONTA, *LPLOGFONTA;
420424

421425
typedef struct tagLOGFONTW {
@@ -432,7 +436,7 @@ typedef struct tagLOGFONTW {
432436
BYTE lfClipPrecision;
433437
BYTE lfQuality;
434438
BYTE lfPitchAndFamily;
435-
wchar_t lfFaceName[32];
439+
wchar_t lfFaceName[LF_FACESIZE];
436440
} LOGFONTW, *PLOGFONTW, *LPLOGFONTW;
437441

438442
#define CALLBACK
@@ -3874,6 +3878,8 @@ void EGEAPI ege_setpattern_texture(PIMAGE imgSrc, float x, float y, float w, flo
38743878

38753879
void EGEAPI ege_drawimage(PCIMAGE imgSrc,int xDest, int yDest, PIMAGE pimg = NULL);
38763880
void EGEAPI ege_drawimage(PCIMAGE imgSrc,int xDest, int yDest, int widthDest, int heightDest, int xSrc, int ySrc, int widthSrc, int heightSrc,PIMAGE pimg = NULL);
3881+
void EGEAPI ege_drawtext(const char* text, float x, float y, PIMAGE pimg = NULL);
3882+
void EGEAPI ege_drawtext(const wchar_t* text, float x, float y, PIMAGE pimg = NULL);
38773883

38783884
void EGEAPI ege_transform_rotate(float angle, PIMAGE pimg = NULL);
38793885
void EGEAPI ege_transform_translate(float x, float y, PIMAGE pimg = NULL);

tests/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ if(WIN32)
118118
add_test_executable(attach_hwnd_test tests/attach_hwnd_test.cpp)
119119
add_test_executable(console_contract_test tests/console_contract_test.cpp)
120120
add_test_executable(inputbox_contract_test tests/inputbox_contract_test.cpp)
121+
if(MINGW)
122+
# These process-isolation tests intentionally use wmain so their
123+
# quoted executable path and child arguments stay Unicode end to end.
124+
target_link_options(console_contract_test PRIVATE -municode)
125+
target_link_options(inputbox_contract_test PRIVATE -municode)
126+
endif()
121127
endif()
122128
if(EGE_ENABLE_CAMERA_CAPTURE AND (APPLE OR WIN32))
123129
add_test_executable(camera_capture_test tests/camera_capture_test.cpp)

tests/tests/public_headers_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ static_assert(sizeof(LONG) == sizeof(std::int32_t), "LONG must be 32-bit");
77
static_assert(sizeof(LONG_PTR) == sizeof(void*), "LONG_PTR must match pointer width");
88
static_assert(sizeof(BITMAPFILEHEADER) == 14, "BITMAPFILEHEADER must be packed");
99
static_assert(sizeof(BITMAPINFOHEADER) == 40, "BITMAPINFOHEADER must match Win32 ABI");
10+
static_assert(LF_FACESIZE == 32, "LF_FACESIZE must match the Win32 API contract");
11+
static_assert(sizeof(((LOGFONTA*)nullptr)->lfFaceName) == LF_FACESIZE,
12+
"LOGFONTA face storage must match LF_FACESIZE");
13+
static_assert(sizeof(((LOGFONTW*)nullptr)->lfFaceName) / sizeof(wchar_t) == LF_FACESIZE,
14+
"LOGFONTW face storage must match LF_FACESIZE");
1015

1116
#ifdef EGE_BUILD_OPENGL
1217
static_assert(ege::INIT_OPENGL == 0x80, "OpenGL builds must expose INIT_OPENGL");

tests/tests/rendering_correctness_test.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,7 @@ void testEnhancedImageTransform()
16971697
ege::delimage(source);
16981698
}
16991699

1700+
#ifdef EGE_GDIPLUS
17001701
void testTextureAndEnhancedImageTransferOverloads()
17011702
{
17021703
ege::PIMAGE source = ege::newimage(3, 2);
@@ -1943,6 +1944,7 @@ void testEnhancedPathApi()
19431944
ege::ege_path_destroy(rectanglePath);
19441945
ege::delimage(image);
19451946
}
1947+
#endif
19461948

19471949
void testRasterOperations()
19481950
{
@@ -2436,6 +2438,7 @@ void testAdditionalEnhancedEntryPoints()
24362438
ege::ege_enable_aa(true, image);
24372439
ege::ege_circle(40.0f, 32.0f, 12.0f, image);
24382440

2441+
#ifdef EGE_GDIPLUS
24392442
const ege::ege_point openCurve[] = {
24402443
{4.0f, 8.0f}, {16.0f, 2.0f}, {28.0f, 14.0f}, {40.0f, 8.0f}
24412444
};
@@ -2474,6 +2477,7 @@ void testAdditionalEnhancedEntryPoints()
24742477
ege::ege_fillpie(28.0f, 46.0f, 18.0f, 14.0f, 0.0f, 90.0f, image);
24752478
expect(countPixelsDifferentFrom(image, ege::BLACK) > 40,
24762479
"enhanced rectangle, round-rectangle, arc, and pie routes draw pixels");
2480+
#endif
24772481

24782482
resetImage(image, ege::BLACK);
24792483
const ege::ege_point gradientBoundary[] = {
@@ -2509,18 +2513,22 @@ void testAdditionalEnhancedEntryPoints()
25092513
texturePixels[1] = ege::GREEN;
25102514
texturePixels[2] = ege::BLUE;
25112515
texturePixels[3] = ege::WHITE;
2516+
#ifdef EGE_GDIPLUS
25122517
ege::ege_gentexture(true, texture);
2518+
#endif
25132519
resetImage(image, ege::BLACK);
25142520
ege::ege_setpattern_texture(texture, 0.0f, 0.0f, 2.0f, 2.0f, image);
25152521
ege::ege_fillrect(2.0f, 2.0f, 20.0f, 16.0f, image);
25162522
expect(countPixelsDifferentFrom(image, ege::BLACK) > 200,
25172523
"texture pattern repeats source pixels across a fill");
2524+
#ifdef EGE_GDIPLUS
25182525
resetImage(image, ege::BLACK);
25192526
const ege::ege_rect textureDestination = {4.0f, 4.0f, 16.0f, 16.0f};
25202527
ege::ege_puttexture(texture, textureDestination, image);
25212528
expect(countPixelsDifferentFrom(image, ege::BLACK) > 100,
25222529
"ege_puttexture draws a generated texture");
25232530
ege::ege_gentexture(false, texture);
2531+
#endif
25242532
ege::ege_setpattern_none(image);
25252533

25262534
ege::delimage(texture);
@@ -2870,12 +2878,11 @@ void testFontCompatibilityDetails()
28702878
advancedWideFont.lfWeight == 500 && advancedWideFont.lfUnderline,
28712879
"advanced wide setfont overload preserves its native font state");
28722880

2873-
#ifdef _WIN32
28742881
LOGFONTW wideFont = {};
28752882
wideFont.lfHeight = 25;
28762883
wideFont.lfWeight = 550;
28772884
wideFont.lfItalic = TRUE;
2878-
lstrcpyW(wideFont.lfFaceName, L"Arial");
2885+
std::copy_n(L"Arial", 6, wideFont.lfFaceName);
28792886
ege::setfont(&wideFont, image);
28802887
LOGFONTW selectedWideFont = {};
28812888
ege::getfont(&selectedWideFont, image);
@@ -2887,14 +2894,13 @@ void testFontCompatibilityDetails()
28872894
ansiFont.lfHeight = 26;
28882895
ansiFont.lfWeight = 450;
28892896
ansiFont.lfUnderline = TRUE;
2890-
lstrcpyA(ansiFont.lfFaceName, "Arial");
2897+
std::copy_n("Arial", 6, ansiFont.lfFaceName);
28912898
ege::setfont(&ansiFont, image);
28922899
LOGFONTW selectedAnsiFont = {};
28932900
ege::getfont(&selectedAnsiFont, image);
28942901
expect(selectedAnsiFont.lfHeight == 26 && selectedAnsiFont.lfWeight == 450 &&
28952902
selectedAnsiFont.lfUnderline,
28962903
"LOGFONTA setfont overload selects the supplied native font state");
2897-
#endif
28982904

28992905
ege::setfont(22, 0, "Arial", 120, 70, 650, true, true, true, image);
29002906
LOGFONTW font = {};
@@ -2917,6 +2923,7 @@ void testFontCompatibilityDetails()
29172923
expect(underlinedPixels > ordinaryPixels,
29182924
"underline font style adds visible decoration pixels");
29192925

2926+
#ifdef _WIN32
29202927
resetImage(image, ege::BLACK);
29212928
ege::setfont(28, 0, "Arial", 0, 0, 400, false, false, false, image);
29222929
ege::outtextxy(4, 4, "Bold text", image);
@@ -2942,6 +2949,7 @@ void testFontCompatibilityDetails()
29422949
const ege::color_t* italicStylePixels = ege::getbuffer(image);
29432950
expect(!std::equal(regularStylePixels.begin(), regularStylePixels.end(), italicStylePixels),
29442951
"italic font style selects distinct glyph geometry");
2952+
#endif
29452953

29462954
resetImage(image, ege::BLACK);
29472955
ege::setfont(22, 0, "Arial", image);
@@ -3336,8 +3344,10 @@ int main()
33363344
testAlphaTransferOverloadsAndClipping();
33373345
testImageRotationCoordinatesAndAspectRatio();
33383346
testEnhancedImageTransform();
3347+
#ifdef EGE_GDIPLUS
33393348
testTextureAndEnhancedImageTransferOverloads();
33403349
testEnhancedPathApi();
3350+
#endif
33413351
testRasterOperations();
33423352
testCurrentPositionAndAdditionalPrimitiveRoutes();
33433353
testSurfaceFloodFillAndColorConversion();

0 commit comments

Comments
 (0)