diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 0f4cb3b5a..eb216e038 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -18,16 +18,13 @@ jobs: url: "https://jay3332.github.io/ril/benchmark/index.html" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install latest stable Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true + uses: dtolnay/rust-toolchain@stable - name: Setup cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 - name: Install gnuplot and neofetch run: sudo apt update && sudo apt install gnuplot neofetch @@ -36,12 +33,12 @@ jobs: run: neofetch --stdout - name: Install cargo-criterion - uses: zbraniecki/cached-cargo-install@v0 + uses: Cryptex-github/cached-cargo-install@main with: crate-name: cargo-criterion - name: Install criterion-table - uses: zbraniecki/cached-cargo-install@v0 + uses: Cryptex-github/cached-cargo-install@main with: crate-name: criterion-table @@ -61,7 +58,7 @@ jobs: run: cat BENCHMARKS.md >> $GITHUB_STEP_SUMMARY - name: Append benchmark webpage to job summary - run: echo "For more details, visit [https://jay3332.github.io/ril/benchmark/index.html](https://jay3332.github.io/ril/benchmark/index.html)" > $GITHUB_STEP_SUMMARY + run: echo "For more details, visit [https://jay3332.github.io/ril/benchmark/index.html](https://jay3332.github.io/ril/benchmark/index.html)" >> $GITHUB_STEP_SUMMARY - name: Deploy uses: peaceiris/actions-gh-pages@v3 @@ -82,4 +79,4 @@ jobs: publish_branch: benchmarks - name: Set output URL - run: echo "::set-output name=env_url::https://jay3332.github.io/ril/benchmark/index.html" + run: echo "env_url=https://jay3332.github.io/ril/benchmark/index.html" >> $GITHUB_OUTPUT diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 643be698e..098814c0d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,24 +14,22 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install latest stable Rust toolchain with clippy - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - toolchain: stable - override: true components: clippy - name: Setup cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 - name: Build rustdocs run: cargo doc --no-deps --all-features env: RUSTDOCFLAGS: --cfg docsrs - - run: echo "" > target/doc/index.html + - run: echo "" >> target/doc/index.html - run: cp -r target/doc ./docs - name: Deploy diff --git a/.github/workflows/rust-checks.yml b/.github/workflows/rust-checks.yml index e0292a9a1..390160f17 100644 --- a/.github/workflows/rust-checks.yml +++ b/.github/workflows/rust-checks.yml @@ -14,17 +14,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install latest stable Rust toolchain with clippy - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - toolchain: stable - override: true components: clippy - name: Setup cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 - name: Build run: cargo build --features=all --verbose diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index aa94e079c..018b8c80d 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -14,19 +14,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install latest stable Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true + uses: dtolnay/rust-toolchain@stable - name: Add wasm targets run: rustup target add wasm32-unknown-unknown wasm32-wasi - name: Setup cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2 - name: Build wasm32-unknown-unknown run: cargo build --features=all-pure --target wasm32-unknown-unknown diff --git a/CHANGELOG.md b/CHANGELOG.md index 211d53d53..8f5c3485a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Versions prior to v0.7 are not tagged/released on GitHub. ## v0.11 (dev) - Add `PngEncoderOptions::new` +### Bug fixes +- Fix text alignment rendering duplicately ([#28](https://github.com/jay3332/ril/issues/28)) +- Fix `TextLayout`s with varying fonts not registering properly ([#29](https://github.com/jay3332/ril/issues/29)) + ## v0.10.1 (2023-10-14) - Fix encoding image sequences not respecting delay and disposal method diff --git a/README.md b/README.md index 652e84170..371991b4c 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,7 @@ let layout = TextLayout::new() .centered() // Shorthand for centering horizontally and vertically .with_wrap(WrapStyle::Word) // RIL supports word wrapping .with_width(image.width()) // This is the width to wrap text at. Only required if you want to wrap text. - .with_position(x, y); // Position the anchor (which is the center) at the center of the image + .with_position(x, y) // Position the anchor (which is the center) at the center of the image .with_segment(&TextSegment::new(&font, "Here is some ", Rgb::white())) .with_segment(&TextSegment::new(&bold, "bold ", Rgb::white())) .with_segment(&TextSegment::new(&font, "text.", Rgb::white())); diff --git a/src/text.rs b/src/text.rs index 4229e18b4..54c62822f 100644 --- a/src/text.rs +++ b/src/text.rs @@ -503,7 +503,7 @@ impl<'a, P: Pixel> TextLayout<'a, P> { &TextStyle::with_user_data( &segment.text, segment.size, - 0, + self.fonts.len() - 1, (segment.fill, segment.overlay), ), ); @@ -698,8 +698,12 @@ impl<'a, P: Pixel> Draw

for TextLayout<'a, P> { let image = &mut *image; // Skips the calculation of offsets - if self.x_anchor == HorizontalAnchor::Left && self.y_anchor == VerticalAnchor::Top { + if self.x_anchor == HorizontalAnchor::Left + && self.y_anchor == VerticalAnchor::Top + && self.align == TextAlign::Left + { render_layout(image, &self.fonts, &self.inner); + return; } let (widths, max_width, fx, ox, oy) = self.calculate_offsets();