- // the labels at the top of an environment.
- // More or less for bibliography
- } else if (is_seq &&
- (layout.labeltype == LABEL_TOP_ENVIRONMENT ||
- layout.labeltype == LABEL_BIBLIO ||
- layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
- FontInfo const font = labelFont();
- docstring const str = par_.labelString();
- if (!str.empty()) {
- double spacing_val = 1.0;
- if (!pparams.spacing().isDefault())
- spacing_val = pparams.spacing().getValue();
- else
- spacing_val = bparams.spacing().getValue();
-
- FontMetrics const & fm = theFontMetrics(font);
-
- int const labeladdon = int(fm.maxHeight()
- * layout.spacing.getValue() * spacing_val);
-
- int maxdesc =
- int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
- + (layout.labelbottomsep * defaultRowHeight()));
-
- double x = x_;
- if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
- if (is_rtl)
- x = leftMargin();
- x += (width_ - text_metrics_.rightMargin(pm_) - leftMargin()) / 2;
- x -= fm.width(str) / 2;
- } else if (is_rtl) {
- x = width_ - leftMargin() - fm.width(str);
- }
- pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
- }
+ bool const is_rtl = text_.isRTL(par_);
+ Layout const & layout = par_.layout();
+ FontInfo const font = labelFont();
+ FontMetrics const & fm = theFontMetrics(font);
+ double x = x_;
+
+ if (is_rtl) {
+ x = width_ - leftMargin()
+ + fm.width(layout.labelsep);
+ } else {
+ x = x_ - fm.width(layout.labelsep)
+ - fm.width(str);
+ }
+
+ pi_.pain.text(int(x), yo_, str, font);
+}
+
+
+void RowPainter::paintTopLevelLabel()
+{
+ BufferParams const & bparams = pi_.base.bv->buffer().params();
+ bool const is_rtl = text_.isRTL(par_);
+ ParagraphParameters const & pparams = par_.params();
+ Layout const & layout = par_.layout();
+ FontInfo const font = labelFont();
+ docstring const str = par_.labelString();
+ if (str.empty())
+ return;
+
+ double spacing_val = 1.0;
+ if (!pparams.spacing().isDefault())
+ spacing_val = pparams.spacing().getValue();
+ else
+ spacing_val = bparams.spacing().getValue();
+
+ FontMetrics const & fm = theFontMetrics(font);
+
+ int const labeladdon = int(fm.maxHeight()
+ * layout.spacing.getValue() * spacing_val);
+
+ int maxdesc =
+ int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
+ + (layout.labelbottomsep * defaultRowHeight()));
+
+ double x = x_;
+ if (layout.labeltype == LABEL_CENTERED) {
+ if (is_rtl)
+ x = leftMargin();
+ x += (width_ - text_metrics_.rightMargin(pm_) - leftMargin()) / 2;
+ x -= fm.width(str) / 2;
+ } else if (is_rtl) {
+ x = width_ - leftMargin() - fm.width(str);