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
2 changes: 1 addition & 1 deletion docs/cmake-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<build>/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` - `<name>.dmv`;
- 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) - `<name>.dmvi`, next to the views, so a view finds them by name. An optional `<image>.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 `<section>.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) - `<name>.dmvi`, next to the views, so a view finds them by name. An optional `<image>.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), `crop` (`X,Y,W,H`: only that of it, after scaling and blurring - what a box shows), `radius` (pixels: its corners rounded after `crop`, transparent outside them - an image in a rounded box). Keys before any section apply to every output; each `[section]` is an output `<section>.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 `<font>.ini` (`Roboto-Regular.ttf.ini`), as a font is made for one pixel size: each `[section]` is an output `<section>.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.
Expand Down
14 changes: 13 additions & 1 deletion scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ endfunction()
# compression = fastlz | ... | none
# dither = on | off
# blur = pixels - a Gaussian blur of that standard deviation, after scaling
# crop = X,Y,W,H - only that of it (after scaling and blurring): what a box shows
# radius = pixels - its corners rounded (after crop), transparent outside them
#
# A font needs its <font>.ini (e.g. Roboto-Regular.ttf.ini), the same way:
# a font is made for one pixel size, so each output has one - each
Expand Down Expand Up @@ -291,6 +293,16 @@ function(_dmod_image_option iniPath key value outVar)
message(SEND_ERROR "${iniPath}: blur is a number of pixels, e.g. 8 (got '${value}')")
endif()
set(ARGS -b ${value})
elseif(key STREQUAL "crop")
if(NOT value MATCHES "^[0-9]+,[0-9]+,[0-9]+,[0-9]+$")
message(SEND_ERROR "${iniPath}: crop is X,Y,W,H in pixels, e.g. 0,22,88,88 (got '${value}')")
endif()
set(ARGS -k ${value})
elseif(key STREQUAL "radius")
if(NOT value MATCHES "^[0-9]+$")
message(SEND_ERROR "${iniPath}: radius is a number of pixels, e.g. 30 (got '${value}')")
endif()
set(ARGS -r ${value})
elseif(key STREQUAL "dither")
string(TOLOWER "${value}" V)
if(V MATCHES "^(off|no|false|0)$")
Expand All @@ -299,7 +311,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, blur)")
message(SEND_ERROR "${iniPath}: unknown key '${key}' (format, size, compression, dither, blur, crop, radius)")
endif()
set(${outVar} "${ARGS}" PARENT_SCOPE)
endfunction()
Expand Down
Loading