diff --git a/README.md b/README.md index 4b28dbd..8126c1a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,16 @@ A command-line label printer driver for Brother P-touch printers on Linux. Prints text labels directly from your terminal. +## Example + +Too print a label, provide your text and optionally a font and a font size. This command will print the label below on a Brother P-Touch P700: + +```bash +ptprnt --font "NotoMono Nerd Font" --fontsize 32 --text "🖶 ptprnt v0.2.0 🥰" +``` + +![Printed label that proudly reads 🖶 ptprnt v0.2.0 🥰](docs/assets/label_print_v0_2_0.jpg) + ## Quick Start **Install dependencies:** @@ -24,6 +34,144 @@ ninja -C builddir builddir/ptprnt --help ``` +## Usage + +### Basic Text Printing + +Print a simple label with text: +```bash +ptprnt --text "Hello World" +``` + +### Formatting Options + +Control the appearance of your labels with these options: + +- `--font FONT_NAME` - Set the font (e.g., "NotoMono Nerd Font", "DejaVu Sans") +- `--fontsize SIZE` - Set font size in points (default: 24) +- `--halign ALIGNMENT` - Horizontal alignment: `left`, `center`, `right` (default: center) +- `--valign ALIGNMENT` - Vertical alignment: `top`, `center`, `bottom` (default: center) + +**Example with formatting:** +```bash +ptprnt --font "DejaVu Sans Mono" --fontsize 28 --halign left --text "Left aligned text" +``` + +### Multiple Text Elements + +You can add multiple text elements to a single label. Formatting options apply to all subsequent `--text` arguments until changed: + +```bash +ptprnt \ + --font "DejaVu Sans" --fontsize 32 --text "Large Title" \ + --fontsize 18 --text "Smaller subtitle" +``` + +### Multiple Labels (Stitching) + +Create multiple labels that will be stitched together horizontally using the `--new` flag: + +```bash +ptprnt \ + --text "Label 1" \ + --new \ + --text "Label 2" \ + --new \ + --text "Label 3" +``` + +Each `--new` starts a fresh label. The labels are automatically stitched together with 60 pixels of spacing. + +**Example - Creating a series of address labels:** +```bash +ptprnt \ + --font "DejaVu Sans" --fontsize 20 \ + --text "Peter Lustig" --text "Am Bauwagen 1" \ + --new \ + --text "Donald Duck" --text "Blumenstraße 13" \ + --new \ + --text "Homer Simpson" --text "742 Evergreen Terrace" +``` + +**Example - Mixed formatting across labels:** +```bash +ptprnt \ + --fontsize 32 --text "BIG" \ + --new \ + --fontsize 16 --text "small" \ + --new \ + --fontsize 24 --text "medium" +``` + +### Printer Selection + +By default, ptprnt auto-detects your printer. You can explicitly select a printer: + +```bash +ptprnt --printer P700 --text "Hello" +``` + +List all available printer drivers: +```bash +ptprnt --list-all-drivers +``` + +### Testing with Fake Printer + +Before printing to your real printer, you can test your label output using the built-in fake printer. This generates a PNG image file instead of printing: + +```bash +ptprnt --printer FakePrinter --text "Test Label" +``` + +This will create a file named `fakelabel_YYYYMMDD_HHMMSS.png` in your current directory with a preview of your label. Use this to: +- Verify text formatting and layout +- Test multi-label stitching +- Preview before wasting label tape + +**Example workflow:** +```bash +# First, test your label design +ptprnt --printer FakePrinter \ + --font "DejaVu Sans" --fontsize 28 \ + --text "Test Design" --text "Check Layout" + +# View the generated PNG file to verify +# If satisfied, print to real printer +ptprnt --printer P700 \ + --font "DejaVu Sans" --fontsize 28 \ + --text "Test Design" --text "Check Layout" +``` + +### Verbose Output + +Enable detailed logging for debugging: + +```bash +ptprnt --verbose --text "Debug mode" +``` + +Enable USB trace to see raw USB communication: +```bash +ptprnt --trace --text "USB trace mode" +``` + +### Complete Example + +An example using a mixed bag of features: + +```bash +ptprnt \ + --verbose \ + --printer P700 \ + --font "NotoMono Nerd Font" \ + --fontsize 28 --halign center --text "Product Label" \ + --fontsize 20 --text "SKU: 12345" \ + --new \ + --fontsize 24 --text "Backup Label" \ + --fontsize 18 --text "Date: 2025-10-16" +``` + ## Supported Printers (I need more printers for verification 😉) diff --git a/docs/assets/label_print_v0_2_0.jpg b/docs/assets/label_print_v0_2_0.jpg new file mode 100644 index 0000000..a5afd4b Binary files /dev/null and b/docs/assets/label_print_v0_2_0.jpg differ diff --git a/generate_coverage.sh b/scripts/generate_coverage.sh similarity index 97% rename from generate_coverage.sh rename to scripts/generate_coverage.sh index 28a43af..9b4f4a7 100755 --- a/generate_coverage.sh +++ b/scripts/generate_coverage.sh @@ -7,6 +7,8 @@ HTML_START_FILE="index.html" echo "Generating Coverage report for ptprnt" +cd $SCRIPT_PATH/.. + ninja -C builddir ninja -C builddir test