Compare commits

...

22 commits

Author SHA1 Message Date
Simon Bruder 0cbfe8d373
fixup! Add CI workflow
All checks were successful
/ build (push) Successful in 27s
2024-07-20 13:29:16 +02:00
Simon Bruder 719b35c4b4
fixup! Add CI workflow
All checks were successful
/ build (push) Successful in 27s
2024-07-20 13:28:44 +02:00
Simon Bruder 93657205ba
fixup! Add CI workflow
Some checks failed
/ build (push) Failing after 38s
2024-07-20 13:27:18 +02:00
Simon Bruder 5b6a1ca4b4
fixup! Add CI workflow
All checks were successful
/ build (push) Successful in 26s
2024-07-20 13:26:19 +02:00
Simon Bruder 01d0c0d6b7
fixup! Add CI workflow
All checks were successful
/ build (push) Successful in 27s
2024-07-20 13:25:06 +02:00
Simon Bruder 8ddaaee4ba
fixup! Add CI workflow
All checks were successful
/ build (push) Successful in 26s
2024-07-20 13:24:18 +02:00
Simon Bruder c1bcc7860d
fixup! Add CI workflow
All checks were successful
/ build (push) Successful in 27s
2024-07-20 13:22:28 +02:00
Simon Bruder 06afd021d3
fixup! Add CI workflow
Some checks failed
/ build (push) Failing after 38s
2024-07-20 13:21:07 +02:00
Simon Bruder 657d37b1eb
fixup! Add CI workflow
Some checks failed
/ build (push) Failing after 38s
2024-07-20 13:19:25 +02:00
Simon Bruder 8b123cfec2
fixup! Add CI workflow
Some checks failed
/ build (push) Failing after 38s
2024-07-20 13:18:39 +02:00
Simon Bruder 4a8ab0eb33
fixup! Add CI workflow
Some checks failed
/ build (push) Failing after 38s
2024-07-20 13:17:43 +02:00
Simon Bruder 67e7a15f77
fixup! Add CI workflow
Some checks failed
/ build (push) Failing after 38s
2024-07-20 13:15:14 +02:00
Simon Bruder e608d62fce
fixup! Add CI workflow
All checks were successful
/ build (push) Successful in 27s
2024-07-20 13:13:15 +02:00
Simon Bruder edf3e42522
fixup! Add CI workflow
Some checks failed
/ build (push) Has been cancelled
2024-07-20 13:12:37 +02:00
Simon Bruder dcfa5a660d
fixup! Add CI workflow
Some checks failed
/ build (push) Failing after 0s
2024-07-20 13:12:10 +02:00
Simon Bruder 4d34c1c6fc
fixup! Add CI workflow
Some checks failed
/ build (push) Failing after 2m20s
2024-07-20 13:07:46 +02:00
Simon Bruder ebc112e06e
fixup! Add CI workflow
All checks were successful
/ build (push) Successful in 29s
2024-07-20 12:54:40 +02:00
Simon Bruder 152f5b3780
fixup! Add CI workflow
Some checks failed
/ build (push) Has been cancelled
2024-07-20 12:52:49 +02:00
Simon Bruder 898965558f
fixup! Add CI workflow
Some checks failed
/ build (push) Has been cancelled
2024-07-20 12:44:54 +02:00
Simon Bruder 47bd048199
label: Add Square28 preset
All checks were successful
/ build (push) Successful in 5s
2024-07-19 18:02:28 +02:00
Simon Bruder 40497e83ab
label: Add text wrapping 2024-07-19 18:02:03 +02:00
Simon Bruder e4fb62f1c9
Add CI workflow
All checks were successful
/ build (push) Successful in 26s
2024-07-19 15:29:24 +02:00
3 changed files with 95 additions and 7 deletions

View file

@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
on:
push:
branches:
- master
jobs:
build:
runs-on: nix
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout LFS
run: |
# You have the choice:
# Either it sets the Authorization header twice (which git-lfs does not accept)
# or it sets it not at all.
# As the repository is public, the latter case is acceptable.
git config --unset "http.${GITHUB_SERVER_URL}/.extraHeader"
git lfs install --local
git lfs pull
- name: Build
run: nix build -L .#li7y .#li7y-oci
- name: Push OCI image
run: |
nix build .#li7y-oci
podman image load -i ./result
podman tag li7y git.sbruder.de/simon/li7y:latest
podman login --username simon --password "${{ secrets.REGISTRY_PASSWORD }}" git.sbruder.de
podman push git.sbruder.de/simon/li7y:latest

View file

@ -124,6 +124,7 @@ impl Code128Config {
pub struct TextConfig {
font_size: f32,
position: (Mm, Mm),
wrap: Option<usize>,
}
impl TextConfig {
@ -133,15 +134,38 @@ impl TextConfig {
font: &IndirectFontRef,
text: Option<S>,
) -> Result<()> {
layer.use_text(
text.ok_or(Error::DataIncomplete("ID text".to_string()))?,
self.font_size,
self.position.0,
self.position.1,
font,
);
layer.begin_text_section();
layer.set_font(font, self.font_size);
layer.set_line_height(self.font_size);
layer.set_text_cursor(self.position.0, self.position.1);
if let Some(text) = self.wrap(text) {
for line in text.split('\n') {
layer.write_text(line, font);
layer.add_line_break();
}
} else {
return Err(Error::DataIncomplete("ID text".to_string()));
}
layer.end_text_section();
Ok(())
}
fn wrap<S: Into<String>>(&self, text: Option<S>) -> Option<String> {
if let Some(wrap) = self.wrap {
let mut inserted = 0;
text.map(|s| {
let s = s.into();
let mut chars: Vec<char> = s.chars().collect();
for i in (wrap..s.len()).step_by(wrap) {
chars.insert(i + inserted, '\n');
inserted += 1;
}
chars.iter().collect()
})
} else {
text.map(|s| s.into())
}
}
}
#[derive(Debug)]

View file

@ -16,6 +16,7 @@ pub enum LabelPreset {
SeikoSlpMrlDataMatrix,
SeikoSlpMrlCode128,
SeikoSlpMrl,
Square28,
}
impl fmt::Display for LabelPreset {
@ -27,6 +28,7 @@ impl fmt::Display for LabelPreset {
Self::SeikoSlpMrlDataMatrix => "Seiko SLP MRL (Data Matrix only)",
Self::SeikoSlpMrlCode128 => "Seiko SLP MRL (Code128 only)",
Self::SeikoSlpMrl => "Seiko SLP MRL",
Self::Square28 => "Square 28 × 28mm",
}
)
}
@ -53,14 +55,17 @@ impl Into<LabelConfig> for LabelPreset {
id_text: Some(TextConfig {
font_size: 7.0,
position: (Mm(0.0), Mm(22.0)),
wrap: None,
}),
short_id_text: Some(TextConfig {
font_size: 7.0,
position: (Mm(21.0), Mm(0.6)),
wrap: None,
}),
branding: Some(TextConfig {
font_size: 7.0,
position: (Mm(39.5), Mm(0.6)),
wrap: None,
}),
},
Self::SeikoSlpMrlCode128 => LabelConfig {
@ -74,14 +79,17 @@ impl Into<LabelConfig> for LabelPreset {
id_text: Some(TextConfig {
font_size: 7.0,
position: (Mm(0.0), Mm(22.0)),
wrap: None,
}),
short_id_text: Some(TextConfig {
font_size: 7.0,
position: (Mm(0.0), Mm(0.0)),
wrap: None,
}),
branding: Some(TextConfig {
font_size: 7.0,
position: (Mm(39.5), Mm(0.6)),
wrap: None,
}),
},
Self::SeikoSlpMrl => LabelConfig {
@ -98,14 +106,37 @@ impl Into<LabelConfig> for LabelPreset {
id_text: Some(TextConfig {
font_size: 7.0,
position: (Mm(0.0), Mm(22.0)),
wrap: None,
}),
short_id_text: Some(TextConfig {
font_size: 7.0,
position: (Mm(17.0), Mm(0.0)),
wrap: None,
}),
branding: Some(TextConfig {
font_size: 7.0,
position: (Mm(39.5), Mm(0.6)),
wrap: None,
}),
},
Self::Square28 => LabelConfig {
width: Mm(20.0),
height: Mm(24.0),
data_matrix: Some(DataMatrixConfig {
scale: Mm(20.0),
position: (Mm(0.0), Mm(4.0)),
}),
code128: None,
id_text: Some(TextConfig {
font_size: 5.0,
position: (Mm(0.0), Mm(2.0)),
wrap: Some(19),
}),
short_id_text: None,
branding: Some(TextConfig {
font_size: 4.0,
position: (Mm(17.0), Mm(0.5)),
wrap: None,
}),
},
}