Compare commits

...
4 Commits
Author SHA1 Message Date
meehl bf588528ca chore: Release rusty-path-of-building version 0.2.5
Release / create-release (push) Successful in 5s
2025-10-30 20:18:42 +01:00
meehl db98ba627b Update CHANGELOG for new release 2025-10-30 20:17:50 +01:00
meehl 479b7196cf Add support for "faux italics" 2025-10-30 20:15:02 +01:00
David Truby a338ff02f1 Fix bug accidentally requiring extra features for surface format
On my system, surface_formats() has `Rgba16Unorm` as the first format in
the surface_caps.formats vector that isn't SRGB. However if this format
is used it requires a couple of extra WGPU features that weren't
requested for the device.

This specific format isn't actually required and so the features aren't
required, so instead we can just skip over any formats that require
features when skipping srgb ones. This results in an appropriate format
being selected and gets rid of a potential wgpu crash.
2025-10-30 19:32:31 +01:00
9 changed files with 74 additions and 13 deletions

No files matched your search

+12 -1
View File
@@ -2,6 +2,16 @@
## [Unreleased] - ReleaseDate
## [0.2.5] - 2025-10-30
### Added
- Add support for "faux italics"
### Fixed
- Fix crash that occurs due to surface format selection not filtering out formats that require unrequested GPU features
## [0.2.4] - 2025-10-30
### Added
@@ -83,8 +93,9 @@
- First release
<!-- next-url -->
[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.4...HEAD
[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.5...HEAD
[0.2.5]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.4...v0.2.5
[0.2.4]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.3...v0.2.4
[0.2.3]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.2...v0.2.3
[0.2.2]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.1...v0.2.2
Generated
+1 -1
View File
@@ -2530,7 +2530,7 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
name = "rusty-path-of-building"
version = "0.2.4"
version = "0.2.5"
dependencies = [
"ahash",
"anyhow",
+1 -1
View File
@@ -4,7 +4,7 @@ authors = ["meehl"]
description = "Cross-platform runtime for Path of Building"
repository = "https://github.com/meehl/rusty-path-of-building"
license = "MIT"
version = "0.2.4"
version = "0.2.5"
edition = "2024"
publish = false
+5 -2
View File
@@ -2,7 +2,7 @@ use crate::{
api::image_handle::ImageHandle,
color::Srgba,
dpi::Uv,
fonts::{Alignment, LayoutJob},
fonts::{Alignment, FontStyle, LayoutJob},
lua::ContextSocket,
math::{Point, Quad, Rect, Size},
};
@@ -468,6 +468,7 @@ fn build_layout_job<'a>(
alignment: Option<Alignment>,
) -> LayoutJob<'a> {
let mut font_weight = None;
let mut font_style = FontStyle::default();
let font_family = match font_type {
PoBFontType::Fixed => FontFamily::Named(Cow::Borrowed("Bitstream Vera Sans Mono")),
PoBFontType::Var => FontFamily::Named(Cow::Borrowed("Liberation Sans")),
@@ -478,7 +479,8 @@ fn build_layout_job<'a>(
PoBFontType::FontinItalic => FontFamily::Named(Cow::Borrowed("Fontin")),
PoBFontType::FontinSmallcaps => FontFamily::Named(Cow::Borrowed("Fontin SmallCaps")),
PoBFontType::FontinSmallcapsItalic => {
// TODO: use regular Smallcaps for now, add "faux italics" later
font_style = FontStyle::Italic;
// use regular Smallcaps with "faux italics"
FontFamily::Named(Cow::Borrowed("Fontin SmallCaps"))
}
};
@@ -492,6 +494,7 @@ fn build_layout_job<'a>(
line_height as f32,
alignment,
font_weight,
font_style,
);
for (color, segment) in PoBString(text).into_iter() {
+7 -1
View File
@@ -16,7 +16,7 @@ use parley::{
use std::sync::Arc;
pub use atlas::FontAtlasSize;
pub use layout::{Alignment, Layout, LayoutJob};
pub use layout::{Alignment, FontStyle, Layout, LayoutJob};
mod atlas;
mod glyph_key;
@@ -124,18 +124,21 @@ impl Fonts {
font_size,
FontFamily::Generic(GenericFamily::Monospace),
None,
parley::FontStyle::Normal,
);
self.preload_text(
&common_chars,
font_size,
FontFamily::Generic(GenericFamily::SansSerif),
None,
parley::FontStyle::Normal,
);
self.preload_text(
&common_chars,
font_size,
FontFamily::Generic(GenericFamily::SansSerif),
Some(FontWeight::BOLD),
parley::FontStyle::Normal,
);
}
@@ -145,12 +148,14 @@ impl Fonts {
font_size: f32,
font_family: FontFamily,
font_weight: Option<FontWeight>,
font_style: parley::FontStyle,
) {
profiling::scope!("preload_text");
let style = TextStyle {
font_stack: FontStack::Single(font_family),
font_weight: font_weight.unwrap_or(FontWeight::NORMAL),
font_style,
font_size,
..Default::default()
};
@@ -202,6 +207,7 @@ impl Fonts {
.font_weight
.map(|w| parley::FontWeight::new(w.into()))
.unwrap_or(default_style.font_weight),
font_style: job.font_style.into(),
..default_style
};
+22 -1
View File
@@ -2,13 +2,30 @@ use crate::{color::Srgba, dpi::LogicalPoint, fonts::rasterizer::RasterizedGlyph}
use ordered_float::OrderedFloat;
use parley::FontFamily;
#[derive(Copy, Clone, Debug, Hash)]
#[derive(Copy, Clone, Default, Debug, Hash, PartialEq)]
pub enum Alignment {
#[default]
Min,
Center,
Max,
}
#[derive(Copy, Clone, Default, Debug, Hash, PartialEq)]
pub enum FontStyle {
#[default]
Normal,
Italic,
}
impl From<FontStyle> for parley::FontStyle {
fn from(value: FontStyle) -> Self {
match value {
FontStyle::Normal => parley::FontStyle::Normal,
FontStyle::Italic => parley::FontStyle::Italic,
}
}
}
#[derive(Clone, Debug, Hash)]
pub struct LayoutSegment<'s> {
pub text: &'s str,
@@ -23,6 +40,7 @@ pub struct LayoutJob<'s> {
pub line_height: OrderedFloat<f32>,
pub alignment: Option<Alignment>,
pub font_weight: Option<OrderedFloat<f32>>,
pub font_style: FontStyle,
}
impl<'s> LayoutJob<'s> {
@@ -32,6 +50,7 @@ impl<'s> LayoutJob<'s> {
line_height: f32,
alignment: Option<Alignment>,
font_weight: Option<f32>,
font_style: FontStyle,
) -> Self {
Self {
segments: Vec::new(),
@@ -40,6 +59,7 @@ impl<'s> LayoutJob<'s> {
line_height: line_height.into(),
alignment,
font_weight: font_weight.map(OrderedFloat),
font_style,
}
}
@@ -63,6 +83,7 @@ impl std::hash::Hash for LayoutJob<'_> {
self.line_height.hash(state);
self.alignment.hash(state);
self.font_weight.hash(state);
self.font_style.hash(state);
}
}
+23 -4
View File
@@ -14,6 +14,7 @@ use image::GenericImage;
use ordered_float::OrderedFloat;
use parley::{FontData, GlyphRun};
use std::borrow::Cow;
use swash::zeno;
type FontBlobId = u64;
type FontIndex = u32;
@@ -25,14 +26,21 @@ struct StyleKey<'a> {
font_blob_id: FontBlobId,
font_size: OrderedFloat<f32>,
normalized_coords: Cow<'a, [i16]>,
skew: i8,
}
impl<'a> StyleKey<'a> {
fn new(font_blob_id: FontBlobId, font_size: f32, normalized_coords: &'a [i16]) -> Self {
fn new(
font_blob_id: FontBlobId,
font_size: f32,
normalized_coords: &'a [i16],
skew: i8,
) -> Self {
Self {
font_blob_id,
font_size: font_size.into(),
normalized_coords: Cow::Borrowed(normalized_coords),
skew,
}
}
@@ -135,8 +143,9 @@ impl GlyphRasterizer {
font_data: &FontData,
font_size: f32,
norm_coords: &[i16],
skew: i8,
) -> StyleId {
let style_key = StyleKey::new(font_data.data.id(), font_size, norm_coords);
let style_key = StyleKey::new(font_data.data.id(), font_size, norm_coords, skew);
match self.style_ids.get(&style_key) {
Some(key) => *key,
None => *self
@@ -164,9 +173,16 @@ impl GlyphRasterizer {
let color = glyph_run.style().brush;
let font_size = run.font_size() * pixels_per_point;
let normalized_coords = run.normalized_coords();
let skew = run.synthesis().skew(); // skew angle for faux italic
let font_ref = self.get_font_ref(run.font());
let style_id = self.get_style_id(run.font(), font_size, normalized_coords);
let style_id = self.get_style_id(
run.font(),
font_size,
normalized_coords,
// parley stores skew as i8 internally so this conversion is ok
skew.unwrap_or_default() as i8,
);
let mut scaler = self
.scale_context
@@ -198,7 +214,10 @@ impl GlyphRasterizer {
swash::scale::Source::ColorBitmap(swash::scale::StrikeWith::BestFit),
swash::scale::Source::Outline,
])
.format(swash::zeno::Format::Alpha)
.format(zeno::Format::Alpha)
.transform(skew.map(|skew| {
zeno::Transform::skew(zeno::Angle::from_degrees(skew), zeno::Angle::ZERO)
}))
.offset(fract_offset)
.render_into(&mut scaler, glyph.id as u16, image);
+1 -1
View File
@@ -95,7 +95,7 @@ impl GraphicsContext {
let surface_format = surface_caps
.formats
.iter()
.find(|f| !f.is_srgb())
.find(|f| !f.is_srgb() && f.required_features().is_empty())
.copied()
.unwrap_or(surface_caps.formats[0]);
+2 -1
View File
@@ -3,7 +3,7 @@ use crate::{
args::Game,
color::Srgba,
dpi::{LogicalPoint, LogicalRect},
fonts::{Alignment, LayoutJob},
fonts::{Alignment, FontStyle, LayoutJob},
mode::{AppEvent, ModeFrameOutput, ModeTransition},
renderer::primitives::{ClippedPrimitive, DrawPrimitive, TextPrimitive},
};
@@ -120,6 +120,7 @@ impl InstallMode {
34.0,
Some(Alignment::Center),
Some(700.0),
FontStyle::Normal,
);
let progress_text = match &self.current_progress {