Lines Matching +full:data +full:- +full:width

15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
64 dst->unit = def == SCALE_MAX ? SCALE_BU : def;
65 dst->scale = strtod(src, &endptr);
71 dst->unit = SCALE_CM;
74 dst->unit = SCALE_IN;
77 dst->unit = SCALE_FS;
80 dst->unit = SCALE_MM;
83 dst->unit = SCALE_EM;
86 dst->unit = SCALE_EN;
89 dst->unit = SCALE_PC;
92 dst->unit = SCALE_PT;
95 dst->unit = SCALE_BU;
98 dst->unit = SCALE_VS;
101 endptr--;
104 dst->unit = def;
114 * used for the actual width calculations.
127 size_t ewidth, min1, min2, wanted, width, xwidth;
136 assert(tbl->cols == NULL);
137 tbl->cols = mandoc_calloc((size_t)sp_first->opts->cols,
139 opts = sp_first->opts;
141 maxcol = -1;
143 for (sp = sp_first; sp != NULL; sp = sp->next) {
144 if (sp->pos != TBL_SPAN_DATA)
148 * Account for the data cells in the layout, matching it
149 * to data cells in the data section.
152 for (dp = sp->first; dp != NULL; dp = dp->next) {
153 icol = dp->layout->col;
154 while (maxcol < icol + dp->hspans)
155 tbl->cols[++maxcol].spacing = SIZE_MAX;
156 col = tbl->cols + icol;
157 col->flags |= dp->layout->flags;
158 if (dp->layout->flags & TBL_CELL_WIGN)
161 /* Handle explicit width specifications. */
163 if (dp->layout->wstr != NULL &&
164 dp->layout->width == 0 &&
165 a2roffsu(dp->layout->wstr, &su, SCALE_EN)
167 dp->layout->width =
168 (*tbl->sulen)(&su, tbl->arg);
169 if (col->width < dp->layout->width)
170 col->width = dp->layout->width;
171 if (dp->layout->spacing != SIZE_MAX &&
172 (col->spacing == SIZE_MAX ||
173 col->spacing < dp->layout->spacing))
174 col->spacing = dp->layout->spacing;
177 * Calculate an automatic width.
181 width = tblcalc_data(tbl,
182 dp->hspans == 0 ? col : NULL,
184 dp->block == 0 ? 0 :
185 dp->layout->width ? dp->layout->width :
186 rmargin ? (rmargin + sp->opts->cols / 2)
187 / (sp->opts->cols + 1) : 0);
188 if (dp->hspans == 0)
194 * recording the minimum width for each group.
198 while (*gp != NULL && ((*gp)->startcol != icol ||
199 (*gp)->endcol != icol + dp->hspans))
200 gp = &(*gp)->next;
203 g->next = *gp;
204 g->wanted = width;
205 g->startcol = icol;
206 g->endcol = icol + dp->hspans;
208 } else if ((*gp)->wanted < width)
209 (*gp)->wanted = width;
214 * The minimum width of columns explicitly specified
218 if (maxcol < sp_first->opts->cols - 1)
219 maxcol = sp_first->opts->cols - 1;
221 col = tbl->cols + icol;
222 if (col->width < 1)
223 col->width = 1;
226 * Column spacings are needed for span width
230 if (col->spacing == SIZE_MAX || icol == maxcol)
231 col->spacing = 3;
242 for (icol = g->startcol; icol <= g->endcol; icol++) {
243 width = tbl->cols[icol].width;
244 if (icol < g->endcol)
245 width += tbl->cols[icol].spacing;
246 if (g->wanted <= width) {
250 g->wanted -= width;
253 *gp = g->next;
256 gp = &g->next;
269 for (g = first_group; g != NULL; g = g->next)
270 for (icol = g->startcol; icol <= g->endcol; icol++)
271 colwidth[icol] = tbl->cols[icol].width;
274 * Find the smallest and second smallest column width
280 width = colwidth[icol];
281 if (min1 > width) {
283 min1 = width;
284 } else if (min1 < width && min2 > width)
285 min2 = width;
289 * Find the minimum wanted width
291 * and mark the columns wanting that width.
295 for (g = first_group; g != NULL; g = g->next) {
297 for (icol = g->startcol; icol <= g->endcol; icol++)
302 width = min1 + (g->wanted - 1) / necol + 1;
303 if (width > min2)
304 width = min2;
305 if (wanted > width)
306 wanted = width;
314 for (icol = g->startcol; icol <= g->endcol; icol++) {
317 if (g->wanted <= wanted - min1) {
318 tbl->cols[icol].width += g->wanted;
322 tbl->cols[icol].width = wanted;
323 g->wanted -= wanted - min1;
326 *gp = g->next;
329 gp = &g->next;
337 * Find maximum width of the columns to equalize.
338 * Find total width of the columns *not* to maximize.
344 col = tbl->cols + icol;
345 if (col->width > col->nwidth)
346 col->decimal += (col->width - col->nwidth) / 2;
347 if (col->flags & TBL_CELL_EQUAL) {
349 if (ewidth < col->width)
350 ewidth = col->width;
352 if (col->flags & TBL_CELL_WMAX)
355 xwidth += col->width;
360 * Update total width of the columns not to maximize.
365 col = tbl->cols + icol;
366 if ( ! (col->flags & TBL_CELL_EQUAL))
368 if (col->width == ewidth)
371 xwidth += ewidth - col->width;
372 col->width = ewidth;
378 * available width, deducting 3n margins between columns.
379 * Distribute the available width evenly.
384 (opts->opts & (TBL_OPT_BOX | TBL_OPT_DBOX) ?
385 2 : !!opts->lvert + !!opts->rvert);
388 xwidth = rmargin - offset - xwidth;
391 * Emulate a bug in GNU tbl width calculation that
392 * manifests itself for large numbers of x-columns.
393 * Emulating it for 5 x-columns gives identical
394 * behaviour for up to 6 x-columns.
400 quirkcol = -1;
402 quirkcol = -1;
407 col = tbl->cols + icol;
408 if ( ! (col->flags & TBL_CELL_WMAX))
410 col->width = (double)xwidth * ++necol / nxcol
411 - ewidth + 0.4995;
413 col->width--;
414 ewidth += col->width;
425 /* Branch down into data sub-types. */
427 switch (dp->layout->pos) {
430 sz = (*tbl->len)(1, tbl->arg);
431 if (col != NULL && col->width < sz)
432 col->width = sz;
459 if (dp->string == NULL || *dp->string == '\0')
461 str = mw ? mandoc_strdup(dp->string) : dp->string;
470 wsz = (*tbl->slen)(beg, tbl->arg);
480 if (col != NULL && col->width < msz)
481 col->width = msz;
493 if (dp->string == NULL || *dp->string == '\0')
496 totsz = (*tbl->slen)(dp->string, tbl->arg);
507 for (cp = dp->string; cp[0] != '\0'; cp++) {
511 } else if (cp[0] == opts->decimal &&
513 (cp > dp->string && isdigit((unsigned char)cp[-1]))))
522 if (col != NULL && col->width < totsz)
523 col->width = totsz;
527 /* Measure the width of the integer part. */
533 for (cp = dp->string; cp < lastpoint; cp++) {
535 intsz += (*tbl->slen)(buf, tbl->arg);
544 if (intsz > col->decimal) {
545 col->nwidth += intsz - col->decimal;
546 col->decimal = intsz;
548 totsz += col->decimal - intsz;
550 /* Update the maximum total width seen so far. */
552 if (totsz > col->nwidth)
553 col->nwidth = totsz;
554 if (col->nwidth > col->width)
555 col->width = col->nwidth;