Skip to content

v0.1.0

Choose a tag to compare

@rizukirr rizukirr released this 15 Aug 06:28
· 45 commits to main since this release
fd34431

First release off the 0.x stable track, after three v0.0.1-alpha builds. Builds on v0.0.1-alpha03.

This release contains a breaking API change. CC_LoadGlobalFont is removed. See Migration below — it is a one-line edit per call site.

Breaking: CC_InitFont replaces CC_LoadGlobalFont

CC_LoadGlobalFont(const char *path, int base_size) did two unrelated things: load a font file and mark it the global default. A font already loaded through CC_LoadFont could not become the global one without loading it a second time and burning a second slot (there are only 16).

int CC_InitFont(int fontId, int base_size);

It takes an id instead of a path, so selection composes with loading rather than duplicating it:

int FONT_BODY = CC_LoadFont("resources/Inter-Regular.ttf", 28);
CC_InitFont(FONT_BODY, 16);

Text("Status");                     // global font, global size
Text("Heading", .fontSize = 32);    // size override
Text("code", .fontId = FONT_MONO);  // font override

Returns fontId, or -1 if that id was never handed out by CC_LoadFont — in which case both globals are left unchanged. Passing 0 selects the raylib default font.

The global default text size is now runtime-settable

base_size sets the size Text() renders at when a call omits .fontSize. That fallback was previously the compile-time constant CC_DEFAULT_FONT_SIZE, which now only supplies the initial value (16). base_size <= 0 leaves the current value alone.

This separates two sizes that CC_LoadGlobalFont conflated:

  • CC_LoadFont's base_size — the size the glyph atlas is rasterized at. Raise it for text that renders large, so it stays crisp.
  • CC_InitFont's base_size — the size text renders at by default.

examples/landing.c uses both: rasterize at 96 for the hero heading, default body text to 16.

Also new

  • int CC_GetGlobalFontSize(void) — returns the current global default text size.
  • CC_InitFont works in headless builds (CCOMPOSE_NO_BACKEND), unlike the rest of the font API. No font loads, but the id and size still flow into emitted text render commands. Only the fontId bounds check is backend-specific.
  • One shared implementation replaces the two duplicated CC_LoadGlobalFont bodies in src/ccompose.c.

Migration

- CC_LoadGlobalFont("resources/Inter-Regular.ttf", 28);
+ CC_InitFont(CC_LoadFont("resources/Inter-Regular.ttf", 28), 16);

Pass the size you want text to render at as the second argument, not the rasterization size you hand to CC_LoadFont. Passing the rasterization size verbatim will scale up every Text() that omits .fontSize.

Callers that always set .fontSize explicitly are unaffected by the second argument.

Other changes

  • PROJECT_VERSION in CMakeLists.txt is now 0.1.0. It had read 0.2.0 since the initial commit — a placeholder that never matched a shipped tag, and one that would have made find_package(ccompose 0.2.0) succeed against this release.
  • README: suggested .clang-format overrides for downstream projects (BlockIndent, no arg bin-packing) so ccompose's DSL blocks format cleanly in your own tree.
  • Wiki updated: Lifecycle, Text, Headless-Mode, and Architecture pages document CC_InitFont and both meanings of base_size.

Verification

All 7 CI checks pass on Linux (gcc + clang), macOS, Windows (MSVC), and Emscripten, plus clang-format and cppcheck. Headless ctest suite: 3/3 pass.

Consuming via FetchContent

include(FetchContent)
FetchContent_Declare(ccompose
    GIT_REPOSITORY https://github.com/rizukirr/ccompose.git
    GIT_TAG v0.1.0
    GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(ccompose)

target_link_libraries(your_target PRIVATE ccompose)

Full changelog

v0.0.1-alpha03...v0.1.0