- // Check if any custom fonts are larger (Asger)
- // This is not completely correct, but we can live with the small,
- // cosmetic error for now.
- int labeladdon = 0;
-
- FontSize maxsize =
- par.highestFontInRange(first, end, size);
- if (maxsize > font.fontInfo().size()) {
- // use standard paragraph font with the maximal size
- FontInfo maxfont = font.fontInfo();
- maxfont.setSize(maxsize);
- FontMetrics const & maxfontmetrics = theFontMetrics(maxfont);
- maxasc = max(maxasc, maxfontmetrics.maxAscent());
- maxdesc = max(maxdesc, maxfontmetrics.maxDescent());
- }
-
- // This is nicer with box insets:
- ++maxasc;
- ++maxdesc;
-
- ParagraphList const & pars = text_->paragraphs();
- Inset const & inset = text_->inset();
-
- // is it a top line?
- if (first == 0 && topBottomSpace) {
- BufferParams const & bufparams = buffer.params();
- // some parskips VERY EASY IMPLEMENTATION
- if (bufparams.paragraph_separation
- == BufferParams::ParagraphSkipSeparation
- && inset.lyxCode() != ERT_CODE
- && inset.lyxCode() != LISTINGS_CODE
- && pit > 0
- && ((layout.isParagraph() && par.getDepth() == 0)
- || (pars[pit - 1].layout().isParagraph()
- && pars[pit - 1].getDepth() == 0)))
- {
- maxasc += bufparams.getDefSkip().inPixels(*bv_);
- }
-
- if (par.params().startOfAppendix())
- maxasc += int(3 * dh);
-
- // This is special code for the chapter, since the label of this
- // layout is printed in an extra row
- if (layout.counter == "chapter"
- && !par.params().labelString().empty()) {
- labeladdon = int(labelfont_metrics.maxHeight()
- * layout.spacing.getValue()
- * text_->spacing(par));
- }
-
- // special code for the top label
- if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
- || layout.labeltype == LABEL_BIBLIO
- || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
- && text_->isFirstInSequence(pit)
- && !par.labelString().empty())
- {
- labeladdon = int(
- labelfont_metrics.maxHeight()
- * layout.spacing.getValue()
- * text_->spacing(par)
- + (layout.topsep + layout.labelbottomsep) * dh);
- }
-
- // Add the layout spaces, for example before and after
- // a section, or between the items of a itemize or enumerate
- // environment.
-
- pit_type prev = text_->depthHook(pit, par.getDepth());
- Paragraph const & prevpar = pars[prev];
- if (prev != pit
- && prevpar.layout() == layout
- && prevpar.getDepth() == par.getDepth()
- && prevpar.getLabelWidthString()
- == par.getLabelWidthString()) {
- layoutasc = layout.itemsep * dh;
- } else if (pit != 0 || first != 0) {
- if (layout.topsep > 0)
- layoutasc = layout.topsep * dh;
- }
-
- prev = text_->outerHook(pit);
- if (prev != pit_type(pars.size())) {
- maxasc += int(pars[prev].layout().parsep * dh);
- } else if (pit != 0) {
- Paragraph const & prevpar = pars[pit - 1];
- if (prevpar.getDepth() != 0 ||
- prevpar.layout() == layout) {
- maxasc += int(layout.parsep * dh);
- }
- }
- }