Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf588528ca | ||
|
|
db98ba627b | ||
|
|
479b7196cf | ||
|
|
a338ff02f1 |
No files matched your search
+12
-1
@@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
## [Unreleased] - ReleaseDate
|
## [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
|
## [0.2.4] - 2025-10-30
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -83,8 +93,9 @@
|
|||||||
- First release
|
- First release
|
||||||
|
|
||||||
<!-- next-url -->
|
<!-- 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.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.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
|
[0.2.2]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.1...v0.2.2
|
||||||
|
|||||||
Generated
+1
-1
@@ -2530,7 +2530,7 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusty-path-of-building"
|
name = "rusty-path-of-building"
|
||||||
version = "0.2.4"
|
version = "0.2.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ authors = ["meehl"]
|
|||||||
description = "Cross-platform runtime for Path of Building"
|
description = "Cross-platform runtime for Path of Building"
|
||||||
repository = "https://github.com/meehl/rusty-path-of-building"
|
repository = "https://github.com/meehl/rusty-path-of-building"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
version = "0.2.4"
|
version = "0.2.5"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::{
|
|||||||
api::image_handle::ImageHandle,
|
api::image_handle::ImageHandle,
|
||||||
color::Srgba,
|
color::Srgba,
|
||||||
dpi::Uv,
|
dpi::Uv,
|
||||||
fonts::{Alignment, LayoutJob},
|
fonts::{Alignment, FontStyle, LayoutJob},
|
||||||
lua::ContextSocket,
|
lua::ContextSocket,
|
||||||
math::{Point, Quad, Rect, Size},
|
math::{Point, Quad, Rect, Size},
|
||||||
};
|
};
|
||||||
@@ -468,6 +468,7 @@ fn build_layout_job<'a>(
|
|||||||
alignment: Option<Alignment>,
|
alignment: Option<Alignment>,
|
||||||
) -> LayoutJob<'a> {
|
) -> LayoutJob<'a> {
|
||||||
let mut font_weight = None;
|
let mut font_weight = None;
|
||||||
|
let mut font_style = FontStyle::default();
|
||||||
let font_family = match font_type {
|
let font_family = match font_type {
|
||||||
PoBFontType::Fixed => FontFamily::Named(Cow::Borrowed("Bitstream Vera Sans Mono")),
|
PoBFontType::Fixed => FontFamily::Named(Cow::Borrowed("Bitstream Vera Sans Mono")),
|
||||||
PoBFontType::Var => FontFamily::Named(Cow::Borrowed("Liberation Sans")),
|
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::FontinItalic => FontFamily::Named(Cow::Borrowed("Fontin")),
|
||||||
PoBFontType::FontinSmallcaps => FontFamily::Named(Cow::Borrowed("Fontin SmallCaps")),
|
PoBFontType::FontinSmallcaps => FontFamily::Named(Cow::Borrowed("Fontin SmallCaps")),
|
||||||
PoBFontType::FontinSmallcapsItalic => {
|
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"))
|
FontFamily::Named(Cow::Borrowed("Fontin SmallCaps"))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -492,6 +494,7 @@ fn build_layout_job<'a>(
|
|||||||
line_height as f32,
|
line_height as f32,
|
||||||
alignment,
|
alignment,
|
||||||
font_weight,
|
font_weight,
|
||||||
|
font_style,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (color, segment) in PoBString(text).into_iter() {
|
for (color, segment) in PoBString(text).into_iter() {
|
||||||
|
|||||||
+7
-1
@@ -16,7 +16,7 @@ use parley::{
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub use atlas::FontAtlasSize;
|
pub use atlas::FontAtlasSize;
|
||||||
pub use layout::{Alignment, Layout, LayoutJob};
|
pub use layout::{Alignment, FontStyle, Layout, LayoutJob};
|
||||||
|
|
||||||
mod atlas;
|
mod atlas;
|
||||||
mod glyph_key;
|
mod glyph_key;
|
||||||
@@ -124,18 +124,21 @@ impl Fonts {
|
|||||||
font_size,
|
font_size,
|
||||||
FontFamily::Generic(GenericFamily::Monospace),
|
FontFamily::Generic(GenericFamily::Monospace),
|
||||||
None,
|
None,
|
||||||
|
parley::FontStyle::Normal,
|
||||||
);
|
);
|
||||||
self.preload_text(
|
self.preload_text(
|
||||||
&common_chars,
|
&common_chars,
|
||||||
font_size,
|
font_size,
|
||||||
FontFamily::Generic(GenericFamily::SansSerif),
|
FontFamily::Generic(GenericFamily::SansSerif),
|
||||||
None,
|
None,
|
||||||
|
parley::FontStyle::Normal,
|
||||||
);
|
);
|
||||||
self.preload_text(
|
self.preload_text(
|
||||||
&common_chars,
|
&common_chars,
|
||||||
font_size,
|
font_size,
|
||||||
FontFamily::Generic(GenericFamily::SansSerif),
|
FontFamily::Generic(GenericFamily::SansSerif),
|
||||||
Some(FontWeight::BOLD),
|
Some(FontWeight::BOLD),
|
||||||
|
parley::FontStyle::Normal,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,12 +148,14 @@ impl Fonts {
|
|||||||
font_size: f32,
|
font_size: f32,
|
||||||
font_family: FontFamily,
|
font_family: FontFamily,
|
||||||
font_weight: Option<FontWeight>,
|
font_weight: Option<FontWeight>,
|
||||||
|
font_style: parley::FontStyle,
|
||||||
) {
|
) {
|
||||||
profiling::scope!("preload_text");
|
profiling::scope!("preload_text");
|
||||||
|
|
||||||
let style = TextStyle {
|
let style = TextStyle {
|
||||||
font_stack: FontStack::Single(font_family),
|
font_stack: FontStack::Single(font_family),
|
||||||
font_weight: font_weight.unwrap_or(FontWeight::NORMAL),
|
font_weight: font_weight.unwrap_or(FontWeight::NORMAL),
|
||||||
|
font_style,
|
||||||
font_size,
|
font_size,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
@@ -202,6 +207,7 @@ impl Fonts {
|
|||||||
.font_weight
|
.font_weight
|
||||||
.map(|w| parley::FontWeight::new(w.into()))
|
.map(|w| parley::FontWeight::new(w.into()))
|
||||||
.unwrap_or(default_style.font_weight),
|
.unwrap_or(default_style.font_weight),
|
||||||
|
font_style: job.font_style.into(),
|
||||||
..default_style
|
..default_style
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+22
-1
@@ -2,13 +2,30 @@ use crate::{color::Srgba, dpi::LogicalPoint, fonts::rasterizer::RasterizedGlyph}
|
|||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use parley::FontFamily;
|
use parley::FontFamily;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Hash)]
|
#[derive(Copy, Clone, Default, Debug, Hash, PartialEq)]
|
||||||
pub enum Alignment {
|
pub enum Alignment {
|
||||||
|
#[default]
|
||||||
Min,
|
Min,
|
||||||
Center,
|
Center,
|
||||||
Max,
|
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)]
|
#[derive(Clone, Debug, Hash)]
|
||||||
pub struct LayoutSegment<'s> {
|
pub struct LayoutSegment<'s> {
|
||||||
pub text: &'s str,
|
pub text: &'s str,
|
||||||
@@ -23,6 +40,7 @@ pub struct LayoutJob<'s> {
|
|||||||
pub line_height: OrderedFloat<f32>,
|
pub line_height: OrderedFloat<f32>,
|
||||||
pub alignment: Option<Alignment>,
|
pub alignment: Option<Alignment>,
|
||||||
pub font_weight: Option<OrderedFloat<f32>>,
|
pub font_weight: Option<OrderedFloat<f32>>,
|
||||||
|
pub font_style: FontStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> LayoutJob<'s> {
|
impl<'s> LayoutJob<'s> {
|
||||||
@@ -32,6 +50,7 @@ impl<'s> LayoutJob<'s> {
|
|||||||
line_height: f32,
|
line_height: f32,
|
||||||
alignment: Option<Alignment>,
|
alignment: Option<Alignment>,
|
||||||
font_weight: Option<f32>,
|
font_weight: Option<f32>,
|
||||||
|
font_style: FontStyle,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
segments: Vec::new(),
|
segments: Vec::new(),
|
||||||
@@ -40,6 +59,7 @@ impl<'s> LayoutJob<'s> {
|
|||||||
line_height: line_height.into(),
|
line_height: line_height.into(),
|
||||||
alignment,
|
alignment,
|
||||||
font_weight: font_weight.map(OrderedFloat),
|
font_weight: font_weight.map(OrderedFloat),
|
||||||
|
font_style,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +83,7 @@ impl std::hash::Hash for LayoutJob<'_> {
|
|||||||
self.line_height.hash(state);
|
self.line_height.hash(state);
|
||||||
self.alignment.hash(state);
|
self.alignment.hash(state);
|
||||||
self.font_weight.hash(state);
|
self.font_weight.hash(state);
|
||||||
|
self.font_style.hash(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-4
@@ -14,6 +14,7 @@ use image::GenericImage;
|
|||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use parley::{FontData, GlyphRun};
|
use parley::{FontData, GlyphRun};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use swash::zeno;
|
||||||
|
|
||||||
type FontBlobId = u64;
|
type FontBlobId = u64;
|
||||||
type FontIndex = u32;
|
type FontIndex = u32;
|
||||||
@@ -25,14 +26,21 @@ struct StyleKey<'a> {
|
|||||||
font_blob_id: FontBlobId,
|
font_blob_id: FontBlobId,
|
||||||
font_size: OrderedFloat<f32>,
|
font_size: OrderedFloat<f32>,
|
||||||
normalized_coords: Cow<'a, [i16]>,
|
normalized_coords: Cow<'a, [i16]>,
|
||||||
|
skew: i8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> StyleKey<'a> {
|
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 {
|
Self {
|
||||||
font_blob_id,
|
font_blob_id,
|
||||||
font_size: font_size.into(),
|
font_size: font_size.into(),
|
||||||
normalized_coords: Cow::Borrowed(normalized_coords),
|
normalized_coords: Cow::Borrowed(normalized_coords),
|
||||||
|
skew,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,8 +143,9 @@ impl GlyphRasterizer {
|
|||||||
font_data: &FontData,
|
font_data: &FontData,
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
norm_coords: &[i16],
|
norm_coords: &[i16],
|
||||||
|
skew: i8,
|
||||||
) -> StyleId {
|
) -> 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) {
|
match self.style_ids.get(&style_key) {
|
||||||
Some(key) => *key,
|
Some(key) => *key,
|
||||||
None => *self
|
None => *self
|
||||||
@@ -164,9 +173,16 @@ impl GlyphRasterizer {
|
|||||||
let color = glyph_run.style().brush;
|
let color = glyph_run.style().brush;
|
||||||
let font_size = run.font_size() * pixels_per_point;
|
let font_size = run.font_size() * pixels_per_point;
|
||||||
let normalized_coords = run.normalized_coords();
|
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 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
|
let mut scaler = self
|
||||||
.scale_context
|
.scale_context
|
||||||
@@ -198,7 +214,10 @@ impl GlyphRasterizer {
|
|||||||
swash::scale::Source::ColorBitmap(swash::scale::StrikeWith::BestFit),
|
swash::scale::Source::ColorBitmap(swash::scale::StrikeWith::BestFit),
|
||||||
swash::scale::Source::Outline,
|
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)
|
.offset(fract_offset)
|
||||||
.render_into(&mut scaler, glyph.id as u16, image);
|
.render_into(&mut scaler, glyph.id as u16, image);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ impl GraphicsContext {
|
|||||||
let surface_format = surface_caps
|
let surface_format = surface_caps
|
||||||
.formats
|
.formats
|
||||||
.iter()
|
.iter()
|
||||||
.find(|f| !f.is_srgb())
|
.find(|f| !f.is_srgb() && f.required_features().is_empty())
|
||||||
.copied()
|
.copied()
|
||||||
.unwrap_or(surface_caps.formats[0]);
|
.unwrap_or(surface_caps.formats[0]);
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -3,7 +3,7 @@ use crate::{
|
|||||||
args::Game,
|
args::Game,
|
||||||
color::Srgba,
|
color::Srgba,
|
||||||
dpi::{LogicalPoint, LogicalRect},
|
dpi::{LogicalPoint, LogicalRect},
|
||||||
fonts::{Alignment, LayoutJob},
|
fonts::{Alignment, FontStyle, LayoutJob},
|
||||||
mode::{AppEvent, ModeFrameOutput, ModeTransition},
|
mode::{AppEvent, ModeFrameOutput, ModeTransition},
|
||||||
renderer::primitives::{ClippedPrimitive, DrawPrimitive, TextPrimitive},
|
renderer::primitives::{ClippedPrimitive, DrawPrimitive, TextPrimitive},
|
||||||
};
|
};
|
||||||
@@ -120,6 +120,7 @@ impl InstallMode {
|
|||||||
34.0,
|
34.0,
|
||||||
Some(Alignment::Center),
|
Some(Alignment::Center),
|
||||||
Some(700.0),
|
Some(700.0),
|
||||||
|
FontStyle::Normal,
|
||||||
);
|
);
|
||||||
|
|
||||||
let progress_text = match &self.current_progress {
|
let progress_text = match &self.current_progress {
|
||||||
|
|||||||
Reference in new issue
Block a user