Upgrade parley to v0.11
This commit is contained in:
1 parent
a1cea10218
commit
a2afd2de54
6 files changed
+177
-149
No files matched your search
+16
-8
@@ -11,7 +11,7 @@ use mlua::{
|
||||
LightUserData, Lua, Result as LuaResult, UserDataRefMut, Value,
|
||||
ffi::{self},
|
||||
};
|
||||
use parley::FontFamily;
|
||||
use parley::{FontFamily, FontFamilyName};
|
||||
use regex::Regex;
|
||||
use std::{borrow::Cow, sync::LazyLock};
|
||||
|
||||
@@ -483,19 +483,27 @@ fn build_layout_job<'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")),
|
||||
PoBFontType::Fixed => FontFamily::Single(FontFamilyName::Named(Cow::Borrowed(
|
||||
"Bitstream Vera Sans Mono",
|
||||
))),
|
||||
PoBFontType::Var => {
|
||||
FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Liberation Sans")))
|
||||
}
|
||||
PoBFontType::VarBold => {
|
||||
font_weight = Some(700.0);
|
||||
FontFamily::Named(Cow::Borrowed("Liberation Sans"))
|
||||
FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Liberation Sans")))
|
||||
}
|
||||
PoBFontType::Fontin => FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Fontin"))),
|
||||
PoBFontType::FontinItalic => {
|
||||
FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Fontin")))
|
||||
}
|
||||
PoBFontType::FontinSmallcaps => {
|
||||
FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Fontin SmallCaps")))
|
||||
}
|
||||
PoBFontType::Fontin => FontFamily::Named(Cow::Borrowed("Fontin")),
|
||||
PoBFontType::FontinItalic => FontFamily::Named(Cow::Borrowed("Fontin")),
|
||||
PoBFontType::FontinSmallcaps => FontFamily::Named(Cow::Borrowed("Fontin SmallCaps")),
|
||||
PoBFontType::FontinSmallcapsItalic => {
|
||||
font_style = FontStyle::Italic;
|
||||
// use regular Smallcaps with "faux italics"
|
||||
FontFamily::Named(Cow::Borrowed("Fontin SmallCaps"))
|
||||
FontFamily::Single(FontFamilyName::Named(Cow::Borrowed("Fontin SmallCaps")))
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+8
-8
@@ -10,8 +10,8 @@ use crate::{
|
||||
use ahash::HashMap;
|
||||
use ordered_float::OrderedFloat;
|
||||
use parley::{
|
||||
FontContext, FontFamily, FontStack, FontWeight, GenericFamily, LayoutContext, StyleProperty,
|
||||
TextStyle, fontique::Blob,
|
||||
FontContext, FontFamily, FontFamilyName, FontWeight, GenericFamily, LayoutContext,
|
||||
StyleProperty, TextStyle, fontique::Blob,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -122,21 +122,21 @@ impl Fonts {
|
||||
self.preload_text(
|
||||
&common_chars,
|
||||
font_size,
|
||||
FontFamily::Generic(GenericFamily::Monospace),
|
||||
FontFamily::Single(FontFamilyName::Generic(GenericFamily::Monospace)),
|
||||
None,
|
||||
parley::FontStyle::Normal,
|
||||
);
|
||||
self.preload_text(
|
||||
&common_chars,
|
||||
font_size,
|
||||
FontFamily::Generic(GenericFamily::SansSerif),
|
||||
FontFamily::Single(FontFamilyName::Generic(GenericFamily::SansSerif)),
|
||||
None,
|
||||
parley::FontStyle::Normal,
|
||||
);
|
||||
self.preload_text(
|
||||
&common_chars,
|
||||
font_size,
|
||||
FontFamily::Generic(GenericFamily::SansSerif),
|
||||
FontFamily::Single(FontFamilyName::Generic(GenericFamily::SansSerif)),
|
||||
Some(FontWeight::BOLD),
|
||||
parley::FontStyle::Normal,
|
||||
);
|
||||
@@ -153,7 +153,7 @@ impl Fonts {
|
||||
profiling::scope!("preload_text");
|
||||
|
||||
let style = TextStyle {
|
||||
font_stack: FontStack::Single(font_family),
|
||||
font_family,
|
||||
font_weight: font_weight.unwrap_or(FontWeight::NORMAL),
|
||||
font_style,
|
||||
font_size,
|
||||
@@ -200,7 +200,7 @@ impl Fonts {
|
||||
|
||||
let default_style = TextStyle::default();
|
||||
let style = TextStyle {
|
||||
font_stack: parley::FontStack::Single(job.font_family),
|
||||
font_family: job.font_family,
|
||||
font_size: job.font_size.into(),
|
||||
line_height: parley::LineHeight::Absolute(job.line_height.into()),
|
||||
font_weight: job
|
||||
@@ -239,7 +239,7 @@ impl Fonts {
|
||||
parley::Alignment::End
|
||||
}
|
||||
};
|
||||
parley_layout.align(None, alignment, parley::AlignmentOptions::default());
|
||||
parley_layout.align(alignment, parley::AlignmentOptions::default());
|
||||
}
|
||||
|
||||
let mut layout_rows = Vec::new();
|
||||
|
||||
+18
-3
@@ -1,6 +1,6 @@
|
||||
use crate::{color::Srgba, dpi::LogicalPoint, fonts::rasterizer::RasterizedGlyph};
|
||||
use ordered_float::OrderedFloat;
|
||||
use parley::FontFamily;
|
||||
use parley::{FontFamily, FontFamilyName};
|
||||
|
||||
#[derive(Copy, Clone, Default, Debug, Hash, PartialEq)]
|
||||
pub enum Alignment {
|
||||
@@ -72,12 +72,27 @@ impl std::hash::Hash for LayoutJob<'_> {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.segments.hash(state);
|
||||
match &self.font_family {
|
||||
FontFamily::Named(cow) => {
|
||||
FontFamily::Single(FontFamilyName::Named(cow)) => {
|
||||
cow.hash(state);
|
||||
}
|
||||
FontFamily::Generic(generic_family) => {
|
||||
FontFamily::Single(FontFamilyName::Generic(generic_family)) => {
|
||||
generic_family.hash(state);
|
||||
}
|
||||
FontFamily::Source(cow) => {
|
||||
cow.hash(state);
|
||||
}
|
||||
FontFamily::List(cow) => {
|
||||
for name in cow.iter() {
|
||||
match name {
|
||||
FontFamilyName::Named(cow) => {
|
||||
cow.hash(state);
|
||||
}
|
||||
FontFamilyName::Generic(generic_family) => {
|
||||
generic_family.hash(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.font_size.hash(state);
|
||||
self.line_height.hash(state);
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ use crate::{
|
||||
renderer::primitives::{ClippedPrimitive, DrawPrimitive, TextPrimitive},
|
||||
util::replace_in_matching_lines,
|
||||
};
|
||||
use parley::{FontFamily, GenericFamily};
|
||||
use parley::{FontFamily, FontFamilyName, GenericFamily};
|
||||
use regex::Regex;
|
||||
use std::{
|
||||
fs,
|
||||
@@ -111,7 +111,7 @@ impl InstallMode {
|
||||
app_state: &mut AppState,
|
||||
) -> Box<dyn Iterator<Item = ClippedPrimitive>> {
|
||||
let mut job = LayoutJob::new(
|
||||
FontFamily::Generic(GenericFamily::SansSerif),
|
||||
FontFamily::Single(FontFamilyName::Generic(GenericFamily::SansSerif)),
|
||||
32.0,
|
||||
34.0,
|
||||
Some(Alignment::Center),
|
||||
|
||||
Reference in new issue
Block a user