From 79e2777adeab665ed7eb18ad0f8623692b0931c4 Mon Sep 17 00:00:00 2001 From: Patryk Kubiak Date: Mon, 5 Oct 2026 15:05:54 +0200 Subject: [PATCH] Assets: blur key of an image's .ini, SVG images by default - `blur = pixels` in an image's .ini (todmvi -b): a Gaussian blur of that standard deviation, after scaling. - svg is among the default DMOD_IMAGE_EXTENSIONS: dmimg_svg rasterizes it (an inline todmvs writes next to a view, for one). Co-Authored-By: Claude Opus 5.5 --- docs/cmake-functions.md | 2 +- scripts/CMakeLists.txt | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/cmake-functions.md b/docs/cmake-functions.md index 0efdb20..4a65ad1 100644 --- a/docs/cmake-functions.md +++ b/docs/cmake-functions.md @@ -337,7 +337,7 @@ The following variables should be set before calling `dmod_add_executable` or `d - `DMOD_COMPRESSION_METHOD` - Compression method for DMFC files (default: "fastlz") - `DMOD_ASSETS_PATHS` - List of directories with the sources of a module's assets (views, images, fonts). When set, they are converted into `DMOD_VIEWS_DIR` (default: `/views`) by the `dmod_assets` target, which the module depends on - with tools `dmf-get` downloads at configure time, only for the kinds of files found: - `*.dmvs` views - `todmv` - `.dmv`; - - images (`DMOD_IMAGE_EXTENSIONS`, default `png jpg jpeg jpe jfif bmp qoi gif tif tiff`) - `todmvi` with the `dmimg` decoder of each extension (`dmimg_png`, `dmimg_jpeg` for `.jpg`, ...; `DMOD_IMAGE_DECODERS` overrides the list) - `.dmvi`, next to the views, so a view finds them by name. An optional `.ini` next to an image (`logo.png.ini`) sets its conversion: `format` (`auto`, `rgb565`, `rgb565a8`, `argb8888`, `i8`, `a8`, `a4`), `size` (`WIDTHxHEIGHT`, scaled down to fit), `compression` (`fastlz`, `none`), `dither` (`on`/`off`). Keys before any section apply to every output; each `[section]` is an output `
.dmvi` of its own (e.g. `[logo]` and `[logo-mask]` from one image). + - images (`DMOD_IMAGE_EXTENSIONS`, default `png jpg jpeg jpe jfif bmp qoi gif tif tiff svg`) - `todmvi` with the `dmimg` decoder of each extension (`dmimg_png`, `dmimg_jpeg` for `.jpg`, ...; `DMOD_IMAGE_DECODERS` overrides the list) - `.dmvi`, next to the views, so a view finds them by name. An optional `.ini` next to an image (`logo.png.ini`) sets its conversion: `format` (`auto`, `rgb565`, `rgb565a8`, `argb8888`, `i8`, `a8`, `a4`), `size` (`WIDTHxHEIGHT`, scaled down to fit), `compression` (`fastlz`, `none`), `dither` (`on`/`off`), `blur` (pixels: a Gaussian blur of that standard deviation, after scaling). Keys before any section apply to every output; each `[section]` is an output `
.dmvi` of its own (e.g. `[logo]` and `[logo-mask]` from one image). - fonts (`DMOD_FONT_EXTENSIONS`, default `ttf otf ttc`) - `todmvf` - `.dmvf`, next to the views. A font needs its `.ini` (`Roboto-Regular.ttf.ini`), as a font is made for one pixel size: each `[section]` is an output `
.dmvf` with its `size` (pixel size, `4` ... `127`, required) and optional `chars` (codepoint ranges, e.g. `0x20-0x7E,0x104`; default: printable ASCII, Latin-1, Latin Extended-A) and `tracking` (letter spacing added to every advance, in pixels, e.g. `-2.4`, like CSS `letter-spacing`). A font without an `.ini` is left out with a warning. Two sources of one output name are a configuration error. diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index a430b60..a26d5bc 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -209,6 +209,7 @@ endfunction() # size = WIDTHxHEIGHT (scaled down to fit), WIDTHx, xHEIGHT # compression = fastlz | ... | none # dither = on | off +# blur = pixels - a Gaussian blur of that standard deviation, after scaling # # A font needs its .ini (e.g. Roboto-Regular.ttf.ini), the same way: # a font is made for one pixel size, so each output has one - each @@ -228,7 +229,7 @@ endfunction() # DMOD_LOADER dmod_loader executable that runs the tools # (default: searched in tools dir and PATH) # DMOD_IMAGE_EXTENSIONS image file extensions (default: png jpg jpeg jpe -# jfif bmp qoi gif tif tiff) +# jfif bmp qoi gif tif tiff svg) # DMOD_IMAGE_DECODERS decoder modules to download (default: # dmimg_ of each extension found) # DMOD_FONT_EXTENSIONS font file extensions (default: ttf otf ttc) @@ -285,6 +286,11 @@ function(_dmod_image_option iniPath key value outVar) set(ARGS -s ${value}) elseif(key STREQUAL "compression") set(ARGS -c ${value}) + elseif(key STREQUAL "blur") + if(NOT value MATCHES "^[0-9]+$") + message(SEND_ERROR "${iniPath}: blur is a number of pixels, e.g. 8 (got '${value}')") + endif() + set(ARGS -b ${value}) elseif(key STREQUAL "dither") string(TOLOWER "${value}" V) if(V MATCHES "^(off|no|false|0)$") @@ -293,7 +299,7 @@ function(_dmod_image_option iniPath key value outVar) message(SEND_ERROR "${iniPath}: dither is on or off, not '${value}'") endif() else() - message(SEND_ERROR "${iniPath}: unknown key '${key}' (format, size, compression, dither)") + message(SEND_ERROR "${iniPath}: unknown key '${key}' (format, size, compression, dither, blur)") endif() set(${outVar} "${ARGS}" PARENT_SCOPE) endfunction() @@ -415,7 +421,7 @@ function(dmod_setup_assets moduleName) set(DMOD_VIEWS_TOOLS_NAME "arch/x86_64") endif() if(NOT DEFINED DMOD_IMAGE_EXTENSIONS OR "${DMOD_IMAGE_EXTENSIONS}" STREQUAL "") - set(DMOD_IMAGE_EXTENSIONS png jpg jpeg jpe jfif bmp qoi gif tif tiff) + set(DMOD_IMAGE_EXTENSIONS png jpg jpeg jpe jfif bmp qoi gif tif tiff svg) endif() if(NOT DEFINED DMOD_FONT_EXTENSIONS OR "${DMOD_FONT_EXTENSIONS}" STREQUAL "") set(DMOD_FONT_EXTENSIONS ttf otf ttc)