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

  1. Prepare measured font or typeset-layout values and the explicit design policy requested. For text or font bytes, use the supported syntax explained below.
  2. Enter usableTextWidthPx, callerMinimumColumnWidthPx, gutterPx using the field table and calculation rules, then run the tool.
  3. Read maximumWholeColumns, resolvedEqualColumnWidthPx, unusedWidthBelowMinimumColumnPx. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. 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 fieldMeaningValue type; see rules belowRequirement
usableTextWidthPxUsable text width pxnumberRequired
callerMinimumColumnWidthPxCaller minimum column width pxnumberRequired
gutterPxGutter pxnumberRequired

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 fieldMeaningValue type
maximumWholeColumnsMaximum whole columnsnumber
resolvedEqualColumnWidthPxResolved equal column width pxnumber
unusedWidthBelowMinimumColumnPxUnused width below minimum column pxnumber
json
{
  "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

  1. 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.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies