kuhy_credit: LaTeX page-corner logo, 0.3.0
Some checks are pending
file length / file-length (push) Waiting to run
kuhy_credit drift / drift (push) Waiting to run
kuhy_credit tests / python (push) Waiting to run
kuhy_credit tests / web (push) Waiting to run
kuhy_credit tests / flutter (push) Waiting to run
kuhy_credit tests / godot (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run

\kuhycreditcorner[<inset>] puts the linked logo on every page's
bottom-right corner via the shipout/foreground hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-20 22:30:30 +01:00
parent 96fedf6442
commit c394641272
9 changed files with 38 additions and 15 deletions

View File

@ -42,7 +42,7 @@ Nothing loads over the network and nothing opens without a click.
```jsonc
// package.json
"@kuhyx/kuhy-credit": "github:kuhyx/utils#kuhy-credit-v0.2.0&path:kuhy_credit/web"
"@kuhyx/kuhy-credit": "github:kuhyx/utils#kuhy-credit-v0.3.0&path:kuhy_credit/web"
```
```html
@ -68,7 +68,7 @@ dependencies:
kuhy_credit:
git:
url: https://github.com/kuhyx/utils
ref: kuhy-credit-v0.2.0
ref: kuhy-credit-v0.3.0
path: kuhy_credit/flutter
```
@ -85,7 +85,7 @@ app on Android). Back closes an open panel. Demo: `flutter/example`.
```bash
cache="$(mktemp -d)"
git clone --depth 1 --branch kuhy-credit-v0.2.0 https://github.com/kuhyx/utils "$cache"
git clone --depth 1 --branch kuhy-credit-v0.3.0 https://github.com/kuhyx/utils "$cache"
cp -r "$cache/kuhy_credit/godot/addons/kuhy_credit" addons/
```
@ -101,7 +101,7 @@ The script opens the site with `OS.shell_open`. Demo:
## Python / Tkinter
```bash
pip install "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.2.0#subdirectory=kuhy_credit"
pip install "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.3.0#subdirectory=kuhy_credit"
```
```python
@ -122,7 +122,7 @@ vector TikZ, no image file) and makes it a link to the site. No words appear.
```bash
# vendor the generated package from the tag, like the Godot addon
cache="$(mktemp -d)"
git clone --depth 1 --branch kuhy-credit-v0.2.0 https://github.com/kuhyx/utils "$cache"
git clone --depth 1 --branch kuhy-credit-v0.3.0 https://github.com/kuhyx/utils "$cache"
cp "$cache/kuhy_credit/latex/kuhy-credit.sty" kuhy-credit/
TEXINPUTS="$PWD/kuhy-credit//:" pdflatex doc.tex
```
@ -133,7 +133,9 @@ TEXINPUTS="$PWD/kuhy-credit//:" pdflatex doc.tex
\fancyfoot[R]{\kuhycredit} % \kuhycredit[8mm] for another size
```
`\kuhycreditlogo[<size>]` draws the logo without a link. The default size is
`\kuhycreditcorner[<inset>]` (preamble, LaTeX 2020-10+) puts the linked logo
on every page, `<inset>` (default 4mm) from the paper's bottom-right corner,
which keeps it in the margin of a full page. `\kuhycreditlogo[<size>]` draws the logo without a link. The default size is
`\kuhycreditsize` (12mm). Demo: `latex/demo/demo.tex`.
## Terminal programs

View File

@ -70,7 +70,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.0"
version: "0.3.0"
leak_tracker:
dependency: transitive
description:

View File

@ -3,7 +3,7 @@ description: >-
The shared "Created by kuhy" credit: an M1 logo button that opens a small
panel, whose tap opens kuhy.duckdns.org. Android and Flutter web.
publish_to: 'none'
version: 0.2.0
version: 0.3.0
environment:
sdk: ^3.12.2

View File

@ -205,7 +205,7 @@ def latex(c: Credit) -> str:
f"% The kuhy credit for LaTeX ({MARK}).\n"
"% \\kuhycredit[<size>] draws the logo linked to the site (needs hyperref);\n"
"% \\kuhycreditlogo[<size>] draws it without a link. Size defaults to\n"
"% \\kuhycreditsize (12mm, about the web stack's 48px).\n"
"% \\kuhycreditsize (12mm, about the web stack's 48px). Needs LaTeX 2020-10+.\n"
"\\NeedsTeXFormat{LaTeX2e}\n"
"\\ProvidesPackage{kuhy-credit}[kuhy credit]\n"
"\\RequirePackage{tikz}\n"
@ -224,6 +224,11 @@ def latex(c: Credit) -> str:
" \\ifdefined\\href{\\hypersetup{pdfborder={0 0 0}}%\n"
" \\href{\\kuhycreditURL}{\\kuhycreditlogo[#1]}}%\n"
" \\else\\kuhycreditlogo[#1]\\fi}\n"
"% \\kuhycreditcorner[<inset>] (preamble) puts \\kuhycredit on every page,\n"
"% <inset> (default 4mm) from the bottom-right corner of the paper.\n"
"\\newcommand\\kuhycreditcorner[1][4mm]{\\AddToHook{shipout/foreground}{%\n"
" \\put(\\strip@pt\\dimexpr\\paperwidth-#1-\\kuhycreditsize\\relax,\n"
" \\strip@pt\\dimexpr#1-\\paperheight\\relax){\\kuhycredit}}}\n"
"\\AtBeginDocument{\\ifdefined\\href\\else\\PackageWarningNoLine{kuhy-credit}%\n"
" {hyperref is not loaded: \\string\\kuhycredit\\space draws no link}\\fi}\n"
"\\endinput\n"

View File

@ -2,7 +2,7 @@
% TEXINPUTS=../: pdflatex demo.tex (from kuhy_credit/latex/demo)
\pdfcompresslevel=0
\pdfobjcompresslevel=0
\documentclass{article}
\documentclass[letterpaper]{article}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{kuhy-credit}
@ -11,6 +11,7 @@
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\kuhycredit}
\kuhycreditcorner[4mm]
\begin{document}
\centering
\kuhycredit[40mm]\par\bigskip

View File

@ -1,7 +1,7 @@
% The kuhy credit for LaTeX (generated by kuhy_credit/generator/generate.py; DO NOT EDIT).
% \kuhycredit[<size>] draws the logo linked to the site (needs hyperref);
% \kuhycreditlogo[<size>] draws it without a link. Size defaults to
% \kuhycreditsize (12mm, about the web stack's 48px).
% \kuhycreditsize (12mm, about the web stack's 48px). Needs LaTeX 2020-10+.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{kuhy-credit}[kuhy credit]
\RequirePackage{tikz}
@ -136,6 +136,11 @@
\ifdefined\href{\hypersetup{pdfborder={0 0 0}}%
\href{\kuhycreditURL}{\kuhycreditlogo[#1]}}%
\else\kuhycreditlogo[#1]\fi}
% \kuhycreditcorner[<inset>] (preamble) puts \kuhycredit on every page,
% <inset> (default 4mm) from the bottom-right corner of the paper.
\newcommand\kuhycreditcorner[1][4mm]{\AddToHook{shipout/foreground}{%
\put(\strip@pt\dimexpr\paperwidth-#1-\kuhycreditsize\relax,
\strip@pt\dimexpr#1-\paperheight\relax){\kuhycredit}}}
\AtBeginDocument{\ifdefined\href\else\PackageWarningNoLine{kuhy-credit}%
{hyperref is not loaded: \string\kuhycredit\space draws no link}\fi}
\endinput

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "kuhy-credit"
version = "0.2.0"
version = "0.3.0"
description = "The shared 'Created by kuhy' logo credit: Tkinter widget and terminal line"
requires-python = ">=3.14"
dependencies = [] # pure stdlib: tkinter and webbrowser ship with Python

View File

@ -41,8 +41,8 @@ def _compile(tmp_path: Path) -> bytes:
def test_demo_pdf_links_the_logo_to_the_site(tmp_path: Path) -> None:
pdf = _compile(tmp_path)
url = json.loads((CREDIT_DIR / "credit.json").read_text())["url"]
# One link per \kuhycredit call in the demo, each with the shared URL.
assert pdf.count(f"/URI({url})".encode()) == 2
# One link per \kuhycredit call in the demo (footer, body, page corner).
assert pdf.count(f"/URI({url})".encode()) == 3
# The field and both glyph colours are painted (non-stroking rgb fills).
for rgb in (b"0.12941 0.11374 0.10588", b"0.72157 0.5255 0.18039", b"0.92549 0.91765 0.91374"):
assert rgb + b" rg" in pdf
@ -64,3 +64,13 @@ def test_tex_special_characters_are_refused(value: str) -> None:
with pytest.raises(ValueError, match="TeX-special"):
emit._tex_safe(value)
def test_corner_logo_sits_in_the_bottom_right_margin(tmp_path: Path) -> None:
"""\\kuhycreditcorner[4mm] puts a 12mm logo 4mm from the page's corner."""
pdf = _compile(tmp_path)
rects = [tuple(float(v) for v in m.split()) for m in re.findall(rb"/Rect\s*\[([^\]]*)\]", pdf)]
mm = 72 / 25.4
width = 8.5 * 72 # letterpaper in the demo
want = (width - 16 * mm, 4 * mm, width - 4 * mm, 16 * mm)
assert any(all(abs(a - b) < 1 for a, b in zip(r, want, strict=True)) for r in rects), rects

View File

@ -1,6 +1,6 @@
{
"name": "@kuhyx/kuhy-credit",
"version": "0.2.0",
"version": "0.3.0",
"private": false,
"type": "module",
"description": "<kuhy-credit>: the shared 'Created by kuhy' logo credit as a dependency-free custom element.",