Iced Font - Create a custom monospace font to display dollar amounts
⚓ Rust 📅 2026-05-07 👤 surdeus 👁️ 1I have a program that displays dates and dollar amounts in adjacent columns. The dollar amounts look better if their font is monospaced. I can create a semi custom monospaced font, money_font in the program, but would like more functionality. Is there a way to create a monospaced font where I can control the typeface and weight so I can attempt to more closely match the look of the dates. The dates are in column 1 and the dollars are in column 2. Any assistance will be appreciated.
let money_font = Font {
family: iced::font::Family::Monospace,
weight: iced::font::Weight::Medium,
stretch: iced::font::Stretch::Normal,
style: iced::font::Style::Normal,
};
for result in query_results {
col1 = col1.push(widget::container(
widget::text(&result.date)
.size(17.0)
)
.width(Length::Fixed(cell_width))
.height(Length::Fixed(cell_height))
.align_x(Horizontal::Right)
.padding(right(18))
.align_y(Vertical::Center)
.style(spreadsheet)
);
col2 = col2.push(widget::container(
widget::text(&result.close)
.size(17.0)
.font(money_font)
)
.width(Length::Fixed(100.0))
.height(Length::Fixed(cell_height))
.align_x(Horizontal::Right)
.padding(right(12.0))
.align_y(Vertical::Center)
.style(spreadsheet)
);
col3 = col3.push(widget::container(
widget::text(&result.minormax)
.size(17.0)
)
.width(Length::Fixed(80.0))
.height(Length::Fixed(cell_height))
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.style(spreadsheet)
);
}
1 post - 1 participant
🏷️ Rust_feed