-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v0.9.0 unexpectedly justifies text #151
Comments
I don't see any of the cosmic-text examples showing this behavior. Please provide instructions on how I can reproduce the issue. |
Here is a repository demonstrating the issue, using nothing but I then upgrade to diff --git a/Cargo.toml b/Cargo.toml
index 077e591..5de006f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-cosmic-text = "0.8.0"
+cosmic-text = "0.9.0"
tiny-skia = "0.11.1"
tracing-subscriber = "0.3.17"
diff --git a/after.png b/after.png
new file mode 100644
index 0000000..3230e43
Binary files /dev/null and b/after.png differ
diff --git a/src/main.rs b/src/main.rs
index d4f1e65..5c0cdc8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
// MIT/Apache2 License.
//! Reproduction of cosmic text issue #151
-//!
-//! This version uses cosmic_text v0.8.0, which works and does not justify text.
+//!
+//! This version uses cosmic_text v0.9.0, which unexpectedly justifies text.
use cosmic_text::{self as ct, Buffer, BufferLine, Color, FontSystem};
@@ -102,7 +102,7 @@ fn main() {
);
// Create and format the text.
- let line = BufferLine::new(TEXT, list);
+ let line = BufferLine::new(TEXT, list, ct::Shaping::Advanced);
buffer.lines = vec![line];
buffer.set_wrap(&mut fs, ct::Wrap::Word);
buffer.set_size(&mut fs, 250.0, 300.0); This is the resulting image: |
Oddly, when I comment out the change in the font family... diff --git a/src/main.rs b/src/main.rs
index 5c0cdc8..750eee7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -96,7 +96,7 @@ fn main() {
240..346,
ct::Attrs {
color_opt: Some(RED),
- family: ct::Family::Monospace,
+// family: ct::Family::Monospace,
..default_attrs
},
); ...it seems to lay out the text without justifying it. Maybe there's a bug in the code used to switch fonts? |
A bisection reveals that the issue started after e1e9fb5. It doesn't seem like this change would cause this? Maybe it just exposed a previously inaccessible bug. Edit: For font reasons I suppose that it's worth mentioning that I'm on Ubuntu 22.04 Linux. |
Here is an example program adapted from
piet
I wrote in mypiet-cosmic-text
crate. It is usingcosmic-text
v0.8.0Here is the program after I update it to v0.9.0:
It appears that the text has been justified for some reason, despite there being no changes in the inputs to the code. The shaping is in
Advanced
mode, as this particular text sample does not render properly inBasic
mode.As far as I can tell, this is a problem on the
cosmic-text
side, as very little actual changes on my end were conducted between the two above samples. Here is the commit: notgull/piet-cosmic-text@d323edeJust to see if it was my alignment system, I manually set each line's alignment to be
Some(Align::Left)
.I did not witness any changes in the text.
I suppose that my usage of
PhysicalGlyph
could be wrong, but I do not see how this could lead to justified text.The text was updated successfully, but these errors were encountered: