mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
<!-- Please read the "Making a PR" section of [`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md) before opening a Pull Request! * Keep your PR:s small and focused. * The PR title is what ends up in the changelog, so make it descriptive! * If applicable, add a screenshot or gif. * If it is a non-trivial addition, consider adding a demo for it to `egui_demo_lib`, or a new example. * Do NOT open PR:s from your `master` branch, as that makes it hard for maintainers to test and add commits to your PR. * Remember to run `cargo fmt` and `cargo clippy`. * Open the PR as a draft until you have self-reviewed it and run `./scripts/check.sh`. * When you have addressed a PR comment, mark it as resolved. Please be patient! I will review your PR, but my time is limited! --> * Closes N/A * [x] I have followed the instructions in the PR template This was mostly from last month, but I never got around to submitting it. This PR adds font variation coordinates to the `TextFormat` struct, and uses them when rendering text. The coordinates are stored in a `SmallVec`; I've chosen to store up to 2 inline, which makes it take up 24 bytes (the minimum possible for a `SmallVec`). The variation axis tags are stored as the `font_types::Tag` type, which I've chosen to re-export from `epaint::text`. The variation coordinates are resolved to a `skrifa::Location` during font rendering/scaling, and are cached in the same way as all the other scaled metrics. I've renamed the `ScaledMetrics` struct to `StyledMetrics`, since it now also contains the resolved variation coordinates. I haven't benchmarked the performance of text layout with variation coordinates, but the existing text layout performance is unchanged. I've replaced the API for manually overriding a font's weight (https://github.com/emilk/egui/pull/7790) with an API for manually overriding any variation coordinates via `FontTweak`. This should support the same use case as #7790 while being substantially more flexible. I have *not* yet added any higher-level API for mapping style attributes (weight, width, slant, etc) to variation coordinates or to different font faces within a single family. That's a pretty huge can of worms, and it'd involve rethinking the split between `FontId` and `TextFormat` (and whether `FontId` is so big that we should provide a way to reuse it). This API is intentionally pretty low-level for now. Likewise, I've intentionally not used variation coordinates when computing a font's row height. I can't think of any fonts that change their vertical metrics depending on variation axes, so this should be fine for now. --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
97 lines
2.9 KiB
TOML
97 lines
2.9 KiB
TOML
[package]
|
|
name = "epaint"
|
|
version.workspace = true
|
|
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
|
description = "Minimal 2D graphics library for GUI work"
|
|
edition.workspace = true
|
|
rust-version.workspace = true
|
|
homepage = "https://github.com/emilk/egui/tree/main/crates/epaint"
|
|
license = "MIT OR Apache-2.0"
|
|
readme = "README.md"
|
|
repository = "https://github.com/emilk/egui/tree/main/crates/epaint"
|
|
categories = ["graphics", "gui"]
|
|
keywords = ["graphics", "gui", "egui"]
|
|
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.docs.rs]
|
|
all-features = true
|
|
rustdoc-args = ["--generate-link-to-definition"]
|
|
|
|
[lib]
|
|
|
|
|
|
[features]
|
|
default = ["default_fonts"]
|
|
|
|
## [`bytemuck`](https://docs.rs/bytemuck) enables you to cast [`Vertex`] to `&[u8]`.
|
|
bytemuck = ["dep:bytemuck", "emath/bytemuck", "ecolor/bytemuck"]
|
|
|
|
## [`cint`](https://docs.rs/cint) enables interoperability with other color libraries.
|
|
cint = ["ecolor/cint"]
|
|
|
|
## Enable the [`hex_color`] macro.
|
|
color-hex = ["ecolor/color-hex"]
|
|
|
|
## If set, epaint will use `include_bytes!` to bundle some fonts.
|
|
## If you plan on specifying your own fonts you may disable this feature.
|
|
default_fonts = ["epaint_default_fonts"]
|
|
|
|
## [`mint`](https://docs.rs/mint) enables interoperability with other math libraries such as [`glam`](https://docs.rs/glam) and [`nalgebra`](https://docs.rs/nalgebra).
|
|
mint = ["emath/mint"]
|
|
|
|
## Enable parallel tessellation using [`rayon`](https://docs.rs/rayon).
|
|
##
|
|
## This can help performance for graphics-intense applications.
|
|
rayon = ["dep:rayon"]
|
|
|
|
## Allow serialization using [`serde`](https://docs.rs/serde).
|
|
serde = ["dep:serde", "ahash/serde", "emath/serde", "ecolor/serde", "font-types/serde", "smallvec/serde"]
|
|
|
|
## Change Vertex layout to be compatible with unity
|
|
unity = []
|
|
|
|
## Override and disable the unity feature
|
|
## This exists, so that when testing with --all-features, snapshots render correctly.
|
|
_override_unity = []
|
|
|
|
[dependencies]
|
|
emath.workspace = true
|
|
ecolor.workspace = true
|
|
|
|
ahash.workspace = true
|
|
font-types.workspace = true
|
|
log.workspace = true
|
|
nohash-hasher.workspace = true
|
|
parking_lot.workspace = true # Using parking_lot over std::sync::Mutex gives 50% speedups in some real-world scenarios.
|
|
profiling.workspace = true
|
|
self_cell.workspace = true
|
|
skrifa.workspace = true
|
|
smallvec.workspace = true
|
|
vello_cpu.workspace = true
|
|
|
|
#! ### Optional dependencies
|
|
bytemuck = { workspace = true, optional = true, features = ["derive"] }
|
|
|
|
## Enable this when generating docs.
|
|
document-features = { workspace = true, optional = true }
|
|
|
|
rayon = { workspace = true, optional = true }
|
|
|
|
## Allow serialization using [`serde`](https://docs.rs/serde) .
|
|
serde = { workspace = true, optional = true, features = ["derive", "rc"] }
|
|
|
|
epaint_default_fonts = { workspace = true, optional = true }
|
|
|
|
[dev-dependencies]
|
|
criterion.workspace = true
|
|
mimalloc.workspace = true
|
|
similar-asserts.workspace = true
|
|
|
|
|
|
[[bench]]
|
|
name = "benchmark"
|
|
harness = false
|