Column Count From Text Width
Pack complete equal-width columns using N−1 gutters, with caller minimum measure; differs from measuring a single ch-based column, zero columns is explicit.
Description
Column packing accounts for N−1 gutters between N columns.
Column packing accounts for N−1 gutters between N columns. Insufficient width should yield an explicit zero-column result.1
Enter nonnegative usable/gutter widths and positive column minimum. Return maximum whole columns, resolved equal width and excess above minimum; zero columns return width zero and all usable width as unused.
When to use Column Count From Text Width
Use Column Count From Text Width when you need to evaluate the supplied records under the calculation and evidence rules below. No actual text wrapping or universal minimum measure is supplied.
Prepare measured font or typeset-layout values and the explicit design policy requested. For text or font bytes, use the supported syntax explained below.
How to use Column Count From Text Width and understand its results
- Prepare measured font or typeset-layout values and the explicit design policy requested. For text or font bytes, use the supported syntax explained below.
- Enter usableTextWidthPx, callerMinimumColumnWidthPx, gutterPx using the field table and calculation rules, then run the tool.
- Read maximumWholeColumns, resolvedEqualColumnWidthPx, unusedWidthBelowMinimumColumnPx. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| usableTextWidthPx | Usable text width px | number | Required |
| callerMinimumColumnWidthPx | Caller minimum column width px | number | Required |
| gutterPx | Gutter px | number | Required |
Enter nonnegative usable/gutter widths and positive column minimum. Return maximum whole columns, resolved equal width and excess above minimum; zero columns return width zero and all usable width as unused.
N=floor((usableWidth+gutter)/(minimumColumn+gutter)) Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| maximumWholeColumns | Maximum whole columns | number |
| resolvedEqualColumnWidthPx | Resolved equal column width px | number |
| unusedWidthBelowMinimumColumnPx | Unused width below minimum column px | number |
{
"input": {
"usableTextWidthPx": 650,
"callerMinimumColumnWidthPx": 200,
"gutterPx": 20
},
"output": {
"maximumWholeColumns": 3,
"resolvedEqualColumnWidthPx": 203.33333333333334,
"unusedWidthBelowMinimumColumnPx": 10
}
} Limitations and assumptions
No actual text wrapping or universal minimum measure is supplied.
Numeric inputs, where present, must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use Gutter Width Column Grid Share: A grid’s total gutter share is distributed across one fewer gutter than columns. It is distinct from a percentage per gutter. For a complementary task, use Optimal Measure Characters-Per-Line: Characters per line depend on word advances and wrapping, not just nominal font size. A greedy word model makes unbreakable overflows visible.
References
-
Column Count From Text Width — tool.io
Similar or alternative tools
- Gutter Width Column Grid Share
A grid’s total gutter share is distributed across one fewer gutter than columns. It is distinct from a percentage per gutter.
- Optimal Measure Characters-Per-Line
Characters per line depend on word advances and wrapping, not just nominal font size. A greedy word model makes unbreakable overflows visible.