Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ smithay-client-toolkit = { version = "0.20.0", default-features = false }
crossfont = { version = "0.9.0", optional = true }
# Draw title text using ab_glyph `--features ab_glyph`
ab_glyph = { version = "0.2.17", optional = true }
# Draw title text using skrifa + vello_cpu `--features skrifa`
skrifa = { version = "0.40", optional = true }
vello_cpu = { version = "0.0.6", optional = true }

[dev-dependencies]
tiny-skia = { version = "0.12", default-features = false, features = [
Expand All @@ -38,3 +41,4 @@ tiny-skia = { version = "0.12", default-features = false, features = [
default = ["ab_glyph"]
crossfont = ["dep:crossfont"]
ab_glyph = ["dep:ab_glyph", "memmap2"]
skrifa = ["dep:skrifa", "dep:vello_cpu", "memmap2"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
## Title text: ab_glyph
By default title text is drawn with _ab_glyph_ crate. This can be disabled by disabling default features.

## Title text: skrifa + vello_cpu
Title text can be drawn with _skrifa_ (font parsing/hinting) and _vello_cpu_ (CPU rasterization). No dynamically linked dependencies required.

```toml
sctk-adwaita = { default-features = false, features = ["skrifa"] }
```

## Title text: crossfont
Alternatively title text may be drawn with _crossfont_ crate. This adds a requirement on _freetype_.

Expand Down
26 changes: 18 additions & 8 deletions src/title.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
use tiny_skia::{Color, Pixmap};

#[cfg(any(feature = "crossfont", feature = "ab_glyph"))]
#[cfg(any(feature = "crossfont", feature = "skrifa", feature = "ab_glyph"))]
mod config;
#[cfg(any(feature = "crossfont", feature = "ab_glyph"))]
#[cfg(any(feature = "crossfont", feature = "skrifa", feature = "ab_glyph"))]
mod font_preference;

#[cfg(feature = "crossfont")]
mod crossfont_renderer;

#[cfg(all(not(feature = "crossfont"), feature = "ab_glyph"))]
#[cfg(all(not(feature = "crossfont"), feature = "skrifa"))]
mod skrifa_renderer;

#[cfg(all(not(feature = "crossfont"), not(feature = "skrifa"), feature = "ab_glyph"))]
mod ab_glyph_renderer;

#[cfg(all(not(feature = "crossfont"), not(feature = "ab_glyph")))]
#[cfg(all(not(feature = "crossfont"), not(feature = "skrifa"), not(feature = "ab_glyph")))]
mod dumb;

#[derive(Debug)]
pub struct TitleText {
#[cfg(feature = "crossfont")]
imp: crossfont_renderer::CrossfontTitleText,
#[cfg(all(not(feature = "crossfont"), feature = "ab_glyph"))]
#[cfg(all(not(feature = "crossfont"), feature = "skrifa"))]
imp: skrifa_renderer::SkrifaTitleText,
#[cfg(all(not(feature = "crossfont"), not(feature = "skrifa"), feature = "ab_glyph"))]
imp: ab_glyph_renderer::AbGlyphTitleText,
#[cfg(all(not(feature = "crossfont"), not(feature = "ab_glyph")))]
#[cfg(all(not(feature = "crossfont"), not(feature = "skrifa"), not(feature = "ab_glyph")))]
imp: dumb::DumbTitleText,
}

Expand All @@ -31,12 +36,17 @@ impl TitleText {
.ok()
.map(|imp| Self { imp });

#[cfg(all(not(feature = "crossfont"), feature = "ab_glyph"))]
#[cfg(all(not(feature = "crossfont"), feature = "skrifa"))]
return Some(Self {
imp: skrifa_renderer::SkrifaTitleText::new(color),
});

#[cfg(all(not(feature = "crossfont"), not(feature = "skrifa"), feature = "ab_glyph"))]
return Some(Self {
imp: ab_glyph_renderer::AbGlyphTitleText::new(color),
});

#[cfg(all(not(feature = "crossfont"), not(feature = "ab_glyph")))]
#[cfg(all(not(feature = "crossfont"), not(feature = "skrifa"), not(feature = "ab_glyph")))]
{
let _ = color;
return None;
Expand Down
Loading