Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ if(RTEXTJP_BUILD_EXAMPLES)
04_vertical_writing
05_text_input
06_utf8_tools
07_character_sets)
07_character_sets
08_text_rotate
)

foreach(example IN LISTS RTEXTJP_EXAMPLE_SOURCES)
add_executable(rtextjp_${example} "examples/${example}.c")
Expand Down
113 changes: 113 additions & 0 deletions examples/08_text_rotate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#include "raylib.h"

#define RTEXTJP_IMPLEMENTATION
#include "rtextjp.h"

int main(void)
{
const int screenWidth = 1280;
const int screenHeight = 720;

InitWindow(screenWidth, screenHeight, "RTextJP DrawEx Test");
SetTargetFPS(60);

// JIS X 0208:
// 非漢字 + 第1水準 + 第2水準
Font font = RTextJPLoadFontFromCharacterSet(
"resources/japanese.ttf",
48,
RTEXTJP_CHARACTER_SET_JIS_X_0208,
NULL
);

if (!IsFontValid(font))
{
TraceLog(LOG_ERROR, "Failed to load Japanese font.");
CloseWindow();
return 1;
}

RTextJPStyle style =
RTextJPStyleDefault(font, 48.0f, WHITE);

while (!WindowShouldClose())
{
BeginDrawing();

ClearBackground((Color) { 30, 30, 30, 255 });

// =========================================================
// rotation = 0
// =========================================================

Vector2 position0 = { 300.0f, 150.0f };
Vector2 origin0 = position0;

DrawCircleV(origin0, 5.0f, RED);

RTextJPDraw("RTextJP 日本語 TEST NORMAL Draw API", (Vector2){300.f,70.f}, style);

RTextJPDrawEx(
"RTextJP 日本語 TEST",
position0,
origin0,
0.0f,
48.0f,
2.0f,
style
);

// =========================================================
// rotation = 15
// =========================================================

Vector2 position15 = { 300.0f, 300.0f };
Vector2 origin15 = position15;

DrawCircleV(origin15, 5.0f, RED);

RTextJPDrawEx(
"RTextJP 日本語 TEST",
position15,
origin15,
15.0f,
48.0f,
2.0f,
style
);

// =========================================================
// rotation = 45
// =========================================================

Vector2 position45 = { 300.0f, 500.0f };
Vector2 origin45 = position45;

DrawCircleV(origin45, 5.0f, RED);

RTextJPDrawEx(
"RTextJP 日本語 TEST",
position45,
origin45,
45.0f,
48.0f,
2.0f,
style
);

DrawText(
"Red point = rotation origin",
20,
20,
20,
LIGHTGRAY
);

EndDrawing();
}

UnloadFont(font);
CloseWindow();

return 0;
}
Loading