Skip to content
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

various updates and improvements for v0.3.0 #17

Merged
merged 33 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ea1d351
Allow `clippy::large_stack_frames` lint
toothbrush7777777 Jan 3, 2024
85bc20b
Use font metrics to calculate `FONT_SIZE_TO_RASTER_HEIGHT_RATIO` and …
toothbrush7777777 Jan 3, 2024
4d9110e
Update NotoSansMono fonts to latest version
toothbrush7777777 Jan 3, 2024
0e83145
misc: init .envrc
phip1611 Jan 9, 2024
60bae6d
misc: update .editorconfig
phip1611 Jan 9, 2024
13d9dd5
nix: add missing dependencies to shell
phip1611 Jan 9, 2024
540413c
Merge pull request #16 from toothbrush7777777/main
phip1611 Jan 9, 2024
a135a0b
example: print multiple lines
phip1611 Jan 9, 2024
f5b93b1
Center glyphs if they are too big
toothbrush7777777 Jan 29, 2024
b78b9e0
Prevent last pixel in row or column from being overwritten
toothbrush7777777 Jan 29, 2024
865668a
Merge pull request #18 from toothbrush7777777/main
phip1611 Mar 31, 2024
4795b8e
style: fix code fmt and style
phip1611 Jan 9, 2024
5584559
misc
phip1611 Mar 31, 2024
ffec949
updates
phip1611 Mar 31, 2024
04af2b8
doc: changelog
phip1611 Mar 31, 2024
bc64608
gitignore update
phip1611 Mar 31, 2024
9103752
ci: github adjustments
phip1611 Mar 31, 2024
8d53d9d
treewide: typo fixes
phip1611 Apr 1, 2024
bbe6a9f
misc: various small changes
phip1611 Apr 1, 2024
24c035d
doc: README updates
phip1611 Apr 1, 2024
f673b64
misc
phip1611 Apr 1, 2024
7a5f074
ci: github ci refresh
phip1611 Apr 1, 2024
53bae7c
misc + check-msrv helper
phip1611 Apr 1, 2024
2f11673
msrv-check -> check-msrv
phip1611 Apr 2, 2024
07efdba
ci: more adjustments
phip1611 Apr 2, 2024
17e6c45
doc: msrv
phip1611 Apr 2, 2024
0122d1b
ci: fix
phip1611 Apr 2, 2024
fb5a069
ci: more fine tuning
phip1611 Apr 2, 2024
cbda2e1
misc: more various improvements
phip1611 Apr 2, 2024
6e70328
misc: more various improvements
phip1611 Apr 2, 2024
55d3ac1
misc: wording
phip1611 Apr 2, 2024
a48a7f8
Merge pull request #19 from phip1611/misc
phip1611 Apr 2, 2024
7ccf1c3
doc: readme update
phip1611 Apr 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 2 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
max_line_length = 80

[Makefile]
indent_style = tab

[*.yml]
[{*.nix,*.sh,*.yml}]
indent_size = 2
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
ignore:
- dependency-name: "*"
update-types: [ "version-update:semver-patch" ]
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Please add a before/after screenshot of the effective font rendering changes.
For example, you can screenshot the output from
`$ cargo run --example show_chars_in_window --features all`
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This tests the generated crate.
name: Build crate

on: [ merge_group, push, pull_request ]

env:
CARGO_TERM_COLOR: always

jobs:
check_msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.56.1 # MSRV for library consumers
- name: Build Lib as Dependency with MSRV
run: cd external/check-msrv && cargo check --all-targets --verbose

build:
strategy:
fail-fast: false
matrix:
runs-on: [ macos-latest, ubuntu-latest, windows-latest ]
rust: [ stable, nightly ]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
with:
key: "${{ matrix.runs-on }}-${{ matrix.rust }}"
- name: cargo check (debug)
run: cargo check --all-targets --features all --verbose
- name: cargo check (release)
run: cargo check --all-targets --features all --verbose --release
- name: cargo build (debug)
run: cargo build --all-targets --features all --verbose
- name: cargo build (release)
run: cargo build --all-targets --features all --verbose --release
- run: cargo test --doc --features all --verbose
- run: cargo test --all-targets --features all --verbose

build_no_std:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [ stable, nightly ]
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
with:
key: "${{ matrix.runs-on }}-${{ matrix.rust }}"
- name: "Rustup: install some no_std target"
run: rustup target add thumbv7em-none-eabihf
- name: Build (no_std)
run: cargo build --target thumbv7em-none-eabihf --features all

codestyle:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [ stable, nightly ]
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Rustfmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy --features all
- name: Rustdoc
run: cargo doc --features all --document-private-items --no-deps
37 changes: 37 additions & 0 deletions .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Checks that the codegen helper generates the exact same sources that are
# currently checked.
name: Check codegen

on: [ merge_group, push, pull_request ]

env:
CARGO_TERM_COLOR: always

jobs:
check_codegen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.56.1 # MSRV for library consumers
components: rustfmt
- name: generate crate
run: ./codegen_n_build.sh --skip-checks
- name: check diff crate
run: git diff --quiet

codestyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- run: cd codegen
- name: Rustfmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy --features all
12 changes: 12 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: QA

on: [ merge_group, push, pull_request ]

jobs:
spellcheck:
name: Spellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Executes "typos ."
- uses: crate-ci/typos@v1.19.0
89 changes: 0 additions & 89 deletions .github/workflows/rust.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.direnv
/target
Cargo.lock
/Cargo.lock
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# v0.3.0 (2024-04-xx)
- Improved alignment of characters in a line. As a consequence, they are now
slightly smaller. The correct line height to font size ratio is about 0.75
rather than the previous 0.84. A lot of thanks to
[toothbrush7777777](https://github.com/toothbrush7777777) for their
contribution!
- The replacement character `�` is cut off on the left and right. There is no
better solution at this point. However, other programs, such as Jetbrains
IDEs also cut it off in some scenarios (depending on font and other
properties), so this should be okay. (I'm not 100% sure yet, but I think this
letter is not part of the noto-sans-mono font, so we only can get it from the
font rendering lib, which uses different metrics.)
- Some internal code improvements

# v0.2.0 (2022-10-07)
- **Breaking** renamed `get_bitmap` to `get_raster`
- **Breaking** renamed `get_bitmap_width` to `get_raster_width`
Expand Down
11 changes: 0 additions & 11 deletions CODEGEN.md

This file was deleted.

30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contributing, Developer Guide, and Codegen Overview

This crate is generated by the Rust binary in `./codegen`. The script
`codegen_n_build.sh` takes care of the code-generation process. Generally
speaking, most changes to the crate should be done in the template files there
instead in the main crate.

## Repository Structure

- `codegen/` : Rust helper project to generate the actual crate.
- `examples/`: Examples for the generated code following the Cargo convention
for examples
- `external/`: Independent consumers of the generated code to perform various
checks.
- `src/` : Generated source. The actual crate / library.

- `check_crate_size.sh`: Helper to check the size of the packaged crate (raw
source size)
- `./codegen_n_build.sh`: Helper to execute the tool from `codegen/`.

## Build Prerequisites

Because the examples use `minifb` as dependency, on Linux the package `libxkbcommon-dev` is
required.

## Contributing Tips

For every pull request, please add a before/after screenshot of the effective
font rendering changes. For example, you can screenshot the output from
`$ cargo run --example show_chars_in_window --features all`
24 changes: 14 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# THIS FILE GETS AUTO GENERATED BY THE PROJECT IN "../codegen" (see repository!)
# THIS FILE IS AUTO GENERATED BY THE PROJECT IN "../codegen" (see repository!)

[package]
name = "noto-sans-mono-bitmap"
Expand All @@ -9,8 +9,8 @@ point operations. Useful in kernels and bootloaders when only "soft-float" is av
speaking, this crate is more than a basic bitmap font, because it encodes each pixel as a byte
and not as a bit, which results in a much nicer result on the screen.
"""
version = "0.2.0"
edition = "2018"
version = "0.3.0"
edition = "2021"
keywords = ["bitmap", "font", "noto-sans-mono"]
categories = ["text-processing", "no-std"]
readme = "README.md"
Expand All @@ -20,14 +20,19 @@ repository = "https://github.com/phip1611/noto-sans-mono-bitmap-rs"
documentation = "https://docs.rs/noto-sans-mono-bitmap"

exclude = [
".direnv",
".github",
".editorconfig",
"check-size",
"codegen_n_build.sh",
"CODEGEN.md",
"examples",
".envrc",
"/external",
"shell.nix",
]

# THIS FILE GETS AUTO GENERATED BY THE PROJECT IN "../codegen" (see repository!)
[[example]]
name = "show_chars_in_window"
required-features = ["all"]

# THIS FILE IS AUTO GENERATED BY THE PROJECT IN "../codegen" (see repository!)

[features]
# My testing showed that rustc reliably discards unused raster heights or font weights.
Expand Down Expand Up @@ -108,6 +113,5 @@ unicode_ranges_all = [


[dev-dependencies]
# Pinned as long as MSRV is 1.56.1
minifb = "=0.22.0"
minifb = "~0.25.0"

Loading