Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions .github/osv-scanner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
# request against requirements-semgrep.in, and this entry has nothing left to
# hide - remove it then. If that has not happened by the date below, the weekly
# scan goes red again, which is the reminder.
#
# The reminder came on 2026-11-16, and semgrep 1.185.0 of 2026-11-10, the
# newest on PyPI that day, still asks for mcp==1.29.0 and
# opentelemetry-api~=1.37.0. Every date in this file moved four weeks on.
[[IgnoredVulns]]
id = "GHSA-84m7-p3x7-pcfv"
ignoreUntil = 2026-11-15
ignoreUntil = 2026-12-14
reason = "semgrep pins mcp==1.29.0 in every release, and the advisory is about an MCP HTTP server, which semgrep scan never starts"

# opentelemetry-api 1.37.0, in requirements-semgrep.txt for the scanner and
Expand All @@ -42,9 +46,20 @@ reason = "semgrep pins mcp==1.29.0 in every release, and the advisory is about a
# moves its pins, and both come back on one reminder.
[[IgnoredVulns]]
id = "GHSA-xcq7-p3pf-p88h"
ignoreUntil = 2026-11-15
ignoreUntil = 2026-12-14
reason = "semgrep pins opentelemetry-api~=1.37.0 in every release, and the advisory is about parsing an inbound tracestate header in a server, which semgrep scan never runs"

# A second advisory against opentelemetry-api 1.37.0, found by the weekly scan
# of 2026-11-16, fixed in 1.45.2. The same class as the entry above: parsing an
# inbound traceparent header takes quadratic time, reached through
# TraceContextTextMapPropagator.extract() in a server receiving requests.
# semgrep 1.185.0 still asks for ~=1.37.0, and semgrep scan receives no
# request. The same date as the rest, for the same one reminder.
[[IgnoredVulns]]
id = "GHSA-mf5v-w3w3-f6cg"
ignoreUntil = 2026-12-14
reason = "semgrep pins opentelemetry-api~=1.37.0 in every release, and the advisory is about parsing an inbound traceparent header in a server, which semgrep scan never runs"

# Three more advisories against mcp 1.29.0, published 2026-11-02, all fixed in
# the same 1.30.0 as the first entry above.
#
Expand All @@ -65,15 +80,15 @@ reason = "semgrep pins opentelemetry-api~=1.37.0 in every release, and the advis
# its pin, and all of them come back on one reminder.
[[IgnoredVulns]]
id = "GHSA-5h93-6whr-6q8j"
ignoreUntil = 2026-11-15
ignoreUntil = 2026-12-14
reason = "semgrep pins mcp==1.29.0 in every release, and the advisory is about the MCP client following cross-origin redirects, which semgrep scan never starts"

[[IgnoredVulns]]
id = "GHSA-rwrf-2pqf-9j8j"
ignoreUntil = 2026-11-15
ignoreUntil = 2026-12-14
reason = "semgrep pins mcp==1.29.0 in every release, and the advisory is about the MCP client fetching server-chosen $ref addresses, which semgrep scan never starts"

[[IgnoredVulns]]
id = "GHSA-w4fh-qvv9-3v23"
ignoreUntil = 2026-11-15
ignoreUntil = 2026-12-14
reason = "semgrep pins mcp==1.29.0 in every release, and the advisory is about an MCP server checking bearer tokens, which semgrep scan never starts"
3 changes: 3 additions & 0 deletions .github/race-weights
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# scaled up by its part: on 2026-11-12 the listed tests of two parts on an AMD
# EPYC 9V74 took 1/1.20 and 1/1.15 of their weights.
# Listed: every test that took 10 s or more. "unlisted" is the mean of the rest.
# TestSmallestIsTheSmallestFile came on 2026-11-16: 79.3 s in a part whose
# listed tests took 0.61 of their weights, so 130.1.
#
# A test that is not here and takes 60 s or more fails its part with the line
# to add. A test that is here and no longer exists fails every part.
Expand All @@ -23,6 +25,7 @@ unlisted 0.58
162.6 TestEveryScreenStillDrawsItsStoredPicture
142.2 TestEveryTileOfAFilmIsGav1dsCodingOfItsPixelsAndDecodesAsItDoesAlone
134.0 TestEveryAvifRungStillFitsInsideItsDeclaredCeilings
130.1 TestSmallestIsTheSmallestFile
130.0 TestTheMinimumThisToolPrintsStandsWhateverTheSeedIs
124.3 TestFreeBoxesCarryPaddingOfAnyLength
99.9 TestEveryBase64TextSizeIsExact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/osv-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:

- name: upload to the Security tab
if: ${{ !cancelled() && hashFiles('osv-results.sarif') != '' }}
uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
sarif_file: osv-results.sarif
category: osv-scanner
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ because it turns other people's test suites red.

### Added

- **Placeholder pictures.** `--set content=placeholder` on `png`, `jpg` and
`svg` draws a flat colour with words in the middle, for laying out a page
before the real pictures exist. The words are the picture's size unless
`text` says otherwise, and `{width}`, `{height}`, `{index}` and
`{index:04}` in it become each file's size and number. `background` and
`foreground` take a colour such as `cccccc`, and `guides` draws a frame,
both diagonals and a circle. In a recipe write a colour without the `#` or
in quotes, because YAML reads `#` as the start of a comment. The test
pattern is unchanged.

- **`smallest` as a size.** `--size smallest`, or `size: smallest` in a
recipe, makes each picture as small as it can be at the `width` and
`height` you set, in all ten picture formats, and `--dry-run` still says the
size to the byte. With the label on, the label states the file's size and
its numerals change how a PNG or a JPG compresses, so it can carry up to
about a kilobyte more than its picture needs. With `--clean` the file is the
picture alone.

- **Generate into the same folder again.** A run into an output directory
that already holds an earlier run is added beside it: every name of the run,
its manifest's too, gets a number, such as `files-2_0001.pdf` and
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ needs it finds out it exists.
the right extension.
- **Take settings per format** - image dimensions, JPEG quality, PDF pages,
spreadsheet rows and columns.
- **Draw placeholder pictures** - a flat colour with its size written in the
middle, for laying out a page before the real pictures exist, as PNG, JPG or
SVG and as small as the picture allows.
- **Fit into CI** - an exit code for every ending, machine readable output, and
nothing on standard output when a run fails.
- **Clean up after itself** - `verify` tells you nothing moved, `cleanup`
Expand Down Expand Up @@ -207,6 +210,13 @@ tfg cleanup ./logs/manifest.json --yes
logs matches ./logs/manifest.json: 10000 files checked
```

**4. Make placeholders for a page.** Six pictures of 1200 by 630 that say
`Hero 1` to `Hero 6`, each as small as it can be:

```
tfg generate --format png --size smallest --count 6 --set content=placeholder --set width=1200 --set height=630 --set "text=Hero {index}" --out ./hero
```

**Sizes count in 1024s**, the way your file manager does, so `2mb` means
2097152 bytes. A plain byte count works too: `--size 2097152`.

Expand Down Expand Up @@ -360,7 +370,7 @@ tfg generate --format txt --size 1mb settings come from the flags
| flag | what it does |
|---|---|
| `--format <id>` | format of the files, for example `txt` |
| `--size <size>` | exact size of every file, such as `10mb` or a plain byte count |
| `--size <size>` | exact size of every file, such as `10mb` or a plain byte count. `smallest` makes each picture as small as it can be at the `width` and `height` you set |
| `--size-range <a-b>` | a size drawn per file from a range, such as `1kb-8kb`. The draw comes from the seed |
| `--boundary <size>` | three files around a limit: one byte under, the limit, one byte over |
| `--count <n>` | how many files to produce. Default `1` |
Expand Down Expand Up @@ -621,7 +631,7 @@ next to the recipe. Give an absolute path, or `--out`, when you want it fixed.
| `id` | names the target, and is the anchor its seeds are derived from |
| `format` | one of the formats below |
| `count` | how many files. Default `1` |
| `size` | exact size of every file |
| `size` | exact size of every file, or `smallest` for a picture with its `width` and `height` set |
| `size-range` | a size drawn per file from a range, such as `1kb-8kb` |
| `boundary` | three files around a limit: under, at, over |
| `contains` | for archives: entries of `format`, `count` and `size` |
Expand Down Expand Up @@ -718,9 +728,11 @@ recipe. `tfg formats <id>` prints the allowed range or list for each:
| format | settings |
|---|---|
| `pdf` | `pages`, `page_size`, `orientation`, `rotate`, `pdf_version`, and the document properties `title`, `author`, `subject`, `keywords`, `creator`, `producer`, `created`, `modified` |
| `png`, `bmp`, `tiff`, `webp` | `width`, `height` |
| `png` | `width`, `height`, `content`, `text`, `background`, `foreground`, `guides` |
| `bmp`, `tiff`, `webp` | `width`, `height` |
| `gif` | `width`, `height`, `frames` |
| `avif`, `jpg`, `jxl` | `width`, `height`, `quality` |
| `jpg` | `width`, `height`, `quality`, `content`, `text`, `background`, `foreground`, `guides` |
| `avif`, `jxl` | `width`, `height`, `quality` |
| `ico` | `width`, `height`, `embed` |
| `wav` | `sample_rate`, `bit_depth`, `channels`, `content` |
| `webm`, `mp4` | `width`, `height`, `duration`, `change_interval`, `frame_rate`, `keyframe_interval`, `quality` |
Expand All @@ -737,7 +749,7 @@ recipe. `tfg formats <id>` prints the allowed range or list for each:
| `geojson` | `geometry`, `formatting`, `precision`, `altitude`, `vertices`, `holes`, `winding`, `antimeridian`, `unlocated`, `ids`, `bbox` |
| `otlp` | `signal`, `formatting`, `batch`, `start`, `rate`, `depth`, `status_mix`, `level_mix`, `trace_context`, `metric_kind`, `temporality`, `exemplars`, `interval`, `id_encoding`, `enum_encoding`, `key_case`, `large_numbers`, `bom`, `time_order`, `end_before_start`, `empty_envelope`, `body`, `non_finite` |
| `eml` | `body`, `layout`, `text_encoding`, `charset`, `headers`, `recipients`, `line_endings`, `attachments`, `attachment_format`, `attachment_size`, `filename_style`, `message_depth`, `inline`, `inline_format`, `inline_size` |
| `svg` | `width`, `height` |
| `svg` | `width`, `height`, `content`, `text`, `background`, `foreground`, `guides` |
| `html` | `structure`, `nesting`, `characters`, `elements`, `links`, `bom`, `formatting`, `styles`, `inline`, `inline_format`, `inline_size` |
| `yaml`, `toml` | none in this build - the document is a fixed shape, and a size is the only thing to ask for |

Expand Down
23 changes: 15 additions & 8 deletions THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ is the module's own MIT, carried unchanged.
| `github.com/yuin/goldmark` | v1.8.2 | MIT | (c) 2019 Yusuke Inuzuka |
| `golang.org/x/image` | v0.46.0 | BSD-3-Clause | 2009 The Go Authors. |
| `golang.org/x/net` | v0.62.0 | BSD-3-Clause | 2009 The Go Authors. |
| `golang.org/x/sys` | v0.49.0 | BSD-3-Clause | 2009 The Go Authors. |
| `golang.org/x/sys` | v0.50.0 | BSD-3-Clause | 2009 The Go Authors. |

The five licence texts follow, one copy each. They differ only in the copyright
line, which is in the table above for every module.
Expand Down Expand Up @@ -612,7 +612,7 @@ THE SOFTWARE.

---

## Files the window binary carries that are not code
## Files the binaries carry that are not code

The toolkit compiles fonts and drawings into the binary. They are not modules,
so a list of modules never mentions them - which is how they shipped unnamed
Expand All @@ -621,7 +621,8 @@ images arrive this way from the toolkit, and their licences ask for their
notices to travel with them. Two more font files arrive from a package of this
project itself: Inter, the face the window has been set in since 2026-09-15,
is embedded by `internal/gui/font` rather than by the toolkit, and is listed
here under the same rule.
here under the same rule. So is one file made from one of them, the outlines
of the letters a placeholder picture is drawn with, which both binaries carry.

What is listed here was measured by asking the compiler which files each
package embeds, not by reading its source. The copyright lines were read out of
Expand All @@ -632,15 +633,20 @@ the font files themselves.
| Noto Sans, four styles | `fyne.io/fyne/v2/theme` | OFL-1.1 | Copyright 2015 Google Inc. All Rights Reserved. |
| Inter Symbols, the toolkit's symbol glyphs only | `fyne.io/fyne/v2/theme` | OFL-1.1 | (c) 2020 The Inter Project Authors |
| Inter, Regular and Bold, the text of the window - static instances from the v4.1 release of github.com/rsms/inter | `internal/gui/font` in this project | OFL-1.1 | Copyright 2016 The Inter Project Authors |
| Inter Bold outlines, the letters of a placeholder picture - 548 characters of the Inter Bold file above, as whole numbers | `internal/format/placeholder/glyphs` in this project | OFL-1.1 | Copyright 2016 The Inter Project Authors |
| DejaVu Sans Mono for Powerline | `fyne.io/fyne/v2/theme` | Bitstream-Vera | (c) 2003 Bitstream, Inc. DejaVu changes are in the public domain |
| EmojiOne Color | `fyne.io/fyne/v2/theme` | MIT, and read the note below | Copyright 2016 Adobe Systems Incorporated |
| Fyne icon set, 96 drawings and one image | `fyne.io/fyne/v2/theme` | BSD-3-Clause | (C) 2018 Fyne.io developers (see AUTHORS) |
| Fyne translations, 15 files of toolkit wording | `fyne.io/fyne/v2/lang` | BSD-3-Clause | (C) 2018 Fyne.io developers (see AUTHORS) |
| Fyne shaders, 14 programs that draw the screen | `fyne.io/fyne/v2/internal/painter/gl` | BSD-3-Clause | (C) 2018 Fyne.io developers (see AUTHORS) |

`tfg`, the command line binary, embeds none of this. It has no toolkit in it.
`tfg`, the command line binary, has no toolkit in it and carries one file of
this list: the Inter Bold outlines. They are a Modified Version in the terms
of the Open Font License - a subset of the font's letters written in another
format, each shape point for point the font's own - so they travel under that
licence, reproduced below, with the font's copyright line.

None of the three fonts under the Open Font License declares a Reserved Font
None of the fonts under the Open Font License declares a Reserved Font
Name - checked in the licence file of each and in the name table of each font
file - so the identifier above is OFL-1.1 rather than OFL-1.1-RFN. Inter is a
trademark of Rasmus Andersson.
Expand All @@ -663,7 +669,7 @@ and only those were replaced by their plain equivalents.

### SIL Open Font License 1.1

Applies to Noto Sans, to Inter Symbols and to Inter.
Applies to Noto Sans, to Inter Symbols, to Inter and to the Inter Bold outlines.

```
------------------------------
Expand Down Expand Up @@ -937,8 +943,9 @@ above.

## Not used

`tfg`, the command line binary, embeds no fonts, images, sound or other
third party assets. The window binary does, and they are listed above. The pixel
`tfg`, the command line binary, embeds no font files, images, sound or other
third party assets apart from the Inter Bold outlines listed above. The window
binary does, and they are listed above. The pixel
font that draws the label on a generated image is drawn in this repository, in
`internal/format/imagelabel/font.go`, so that a font licence is not a question
this project has to answer. The filler vocabulary is a short list of ordinary
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ require (
github.com/gen2brain/jxl v0.2.0
github.com/goccy/go-yaml v1.19.2
github.com/nicksnyder/go-i18n/v2 v2.7.0
golang.org/x/sys v0.49.0
golang.org/x/image v0.46.0
golang.org/x/sys v0.50.0
golang.org/x/text v0.43.0
)

Expand Down Expand Up @@ -127,7 +128,6 @@ require (
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/yuin/goldmark v1.8.2 // indirect
golang.org/x/image v0.46.0 // indirect
golang.org/x/net v0.62.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ golang.org/x/image v0.46.0 h1:b1+oYj0Jbp6K5MDT4i4/eZpYlk3V8SJhhDKh6LBHAyQ=
golang.org/x/image v0.46.0/go.mod h1:3B3W05VGVQyuXucLINLjXKrqISASfi4Xj+iCVkLMwew=
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
9 changes: 8 additions & 1 deletion internal/cli/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func generateFlagSet(errOut io.Writer, g *generateOpts) (*flag.FlagSet, func(io.

fs.StringVar(&g.presetID, "preset", "", "build the set a named test question calls for. Run \"tfg preset list\" to see them")
fs.StringVar(&g.formatID, "format", "", "format of the files to produce, for example txt")
fs.StringVar(&g.sizeStr, "size", "", "exact size of each file. Units count in 1024s, so 10mb is 10485760 bytes. Also accepts a plain byte count")
fs.StringVar(&g.sizeStr, "size", "", "exact size of each file. Units count in 1024s, so 10mb is 10485760 bytes. Also accepts a plain byte count, or smallest for a picture with its width and height set")
fs.StringVar(&g.sizeRange, "size-range", "", "a size drawn from a range for each file, as 1kb-8kb. The draw comes from the seed, so the same seed gives the same sizes")
fs.StringVar(&g.boundary, "boundary", "", "three files around a limit: one byte under it, the limit itself, one byte over")
fs.IntVar(&g.count, "count", 1, "how many files to produce")
Expand Down Expand Up @@ -352,6 +352,7 @@ func targetsFromFlags(g *generateOpts, given map[string]bool, errOut io.Writer)
ID: g.id,
Format: g.formatID,
Sizes: sizes,
Smallest: g.sizeStr == core.SizeSmallest,
Range: engine.SizeRange{Used: g.sizeRange != "", Min: rangeLow, Max: rangeHigh},
BoundaryLimit: boundaryLimit,
NameTmpl: g.name,
Expand Down Expand Up @@ -404,6 +405,11 @@ func sizesFromFlags(g *generateOpts, errOut io.Writer) (sizes []int64, low, high
}
return sizes, 0, 0, limit, ExitOK

case g.sizeStr == core.SizeSmallest:
// The count alone, as for a range. The engine plans each file at the
// smallest its format makes (engine.Target.Smallest).
return engine.Uniform(g.count, 0), 0, 0, 0, ExitOK

default:
bytesWanted, err := core.ParseSize(g.sizeStr)
if err != nil {
Expand Down Expand Up @@ -548,6 +554,7 @@ func engineTarget(t recipe.Target, label bool) engine.Target {
Sizes: t.Sizes,
Contains: contentsOf(t),
SizeFromContents: t.SizeFromContents,
Smallest: t.Smallest,
Range: engine.SizeRange(t.Range),
BoundaryLimit: t.BoundaryLimit,
NameTmpl: t.Name,
Expand Down
8 changes: 8 additions & 0 deletions internal/core/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import (
"strings"
)

// SizeSmallest is the word a size can be instead of a number: the smallest
// file the format makes at its settings, with nothing added to reach a size.
// For a picture with its width and height set, that is the picture alone - a
// placeholder as a page would get it. It is not a number, so ParseSize refuses
// it and the two places that read a size ask for it by name first: a recipe
// (recipe.resolveSize) and the --size flag. docs/PLACEHOLDER-2026-11-14.md.
const SizeSmallest = "smallest"

// ParseSize turns a human written size into an exact number of bytes.
//
// 10mb -> 10 485 760
Expand Down
Loading
Loading