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
28 changes: 2 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ opt-level = 2 # fast and small wasm, basically same as `opt-level = 's'`
# debug = true # include debug symbols, useful when profiling wasm


[profile.dev]
[profile.dev.'cfg(!windows)']
split-debuginfo = "unpacked" # faster debug builds on mac
# opt-level = 1 # Make debug builds run faster

Expand Down
3 changes: 2 additions & 1 deletion crates/epaint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ serde = ["dep:serde", "ahash/serde", "emath/serde"]
[dependencies]
emath = { version = "0.19.0", path = "../emath" }

ab_glyph = "0.2.11"
freetype-rs = "0.26.0"
# ab_glyph = "0.2.11"
ahash = { version = "0.8.1", default-features = false, features = [
"no-rng", # we don't need DOS-protection, so we let users opt-in to it instead
"std",
Expand Down
25 changes: 13 additions & 12 deletions crates/epaint/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ pub struct FontImage {
/// The coverage value.
///
/// Often you want to use [`Self::srgba_pixels`] instead.
pub pixels: Vec<f32>,
pub pixels: Vec<Color32>,
}

impl FontImage {
pub fn new(size: [usize; 2]) -> Self {
Self {
size,
pixels: vec![0.0; size[0] * size[1]],
pixels: vec![Color32::TRANSPARENT; size[0] * size[1]],
}
}

Expand All @@ -217,13 +217,14 @@ impl FontImage {
&'_ self,
gamma: Option<f32>,
) -> impl ExactSizeIterator<Item = Color32> + '_ {
let gamma = gamma.unwrap_or(0.55); // TODO(emilk): this default coverage gamma is a magic constant, chosen by eye. I don't even know why we need it.
self.pixels.iter().map(move |coverage| {
let alpha = coverage.powf(gamma);
// We want to multiply with `vec4(alpha)` in the fragment shader:
let a = fast_round(alpha * 255.0);
Color32::from_rgba_premultiplied(a, a, a, a)
})
self.pixels.iter().copied()
// let gamma = gamma.unwrap_or(0.55); // TODO(emilk): this default coverage gamma is a magic constant, chosen by eye. I don't even know why we need it.
// self.pixels.iter().map(move |coverage| {
// let alpha = coverage.powf(gamma);
// // We want to multiply with `vec4(alpha)` in the fragment shader:
// let a = fast_round(alpha * 255.0);
// Color32::from_rgba_premultiplied(a, a, a, a)
// })
}

/// Clone a sub-region as a new image.
Expand All @@ -245,10 +246,10 @@ impl FontImage {
}

impl std::ops::Index<(usize, usize)> for FontImage {
type Output = f32;
type Output = Color32;

#[inline]
fn index(&self, (x, y): (usize, usize)) -> &f32 {
fn index(&self, (x, y): (usize, usize)) -> &Color32 {
let [w, h] = self.size;
assert!(x < w && y < h);
&self.pixels[y * w + x]
Expand All @@ -257,7 +258,7 @@ impl std::ops::Index<(usize, usize)> for FontImage {

impl std::ops::IndexMut<(usize, usize)> for FontImage {
#[inline]
fn index_mut(&mut self, (x, y): (usize, usize)) -> &mut f32 {
fn index_mut(&mut self, (x, y): (usize, usize)) -> &mut Color32 {
let [w, h] = self.size;
assert!(x < w && y < h);
&mut self.pixels[y * w + x]
Expand Down
Loading