From 06481d77d6e43f0899538ab25b1f5ef24cf68104 Mon Sep 17 00:00:00 2001 From: Bauke Date: Tue, 9 Jan 2024 13:49:28 +0100 Subject: [PATCH] Add an option to clip icons with a radius. --- utilities/icon-with-text.typ | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/utilities/icon-with-text.typ b/utilities/icon-with-text.typ index 93562c9..88011fe 100644 --- a/utilities/icon-with-text.typ +++ b/utilities/icon-with-text.typ @@ -1,4 +1,10 @@ -#let icon_with_text(icon: "", icon_alt_text: "", icon_size: 1.25em, body) = { +#let icon_with_text(clip_icon: false, icon: "", icon_alt_text: "", icon_size: 1.25em, body) = { + let image_box_properties = if clip_icon { + (clip: true, radius: icon_size / 6) + } else { + (clip: false) + } + // Use a box for the container so it is rendered inline. box( // Then use a grid inside to size and space the icon out perfectly. @@ -7,7 +13,10 @@ // directly against the text. columns: (icon_size + 0.2em, auto), // Render the image with the icon size as the wanted width. - image(icon, width: icon_size, alt: icon_alt_text), + box( + ..image_box_properties, + image(icon, width: icon_size, alt: icon_alt_text), + ), // And finally vertically align the text. align(horizon, body), ),