]> git.lyx.org Git - features.git/blob - src/RowPainter.cpp
Fix computation of LABEL_MANUAL label separation
[features.git] / src / RowPainter.cpp
1 /**
2  * \file RowPainter.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author various
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "RowPainter.h"
15
16 #include "Buffer.h"
17 #include "CoordCache.h"
18 #include "Cursor.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
21 #include "Changes.h"
22 #include "Language.h"
23 #include "Layout.h"
24 #include "LyXRC.h"
25 #include "Row.h"
26 #include "MetricsInfo.h"
27 #include "Paragraph.h"
28 #include "ParagraphList.h"
29 #include "ParagraphParameters.h"
30 #include "Text.h"
31 #include "TextMetrics.h"
32
33 #include "frontends/FontMetrics.h"
34 #include "frontends/Painter.h"
35
36 #include "support/debug.h"
37 #include "support/gettext.h"
38 #include "support/lassert.h"
39
40 #include <algorithm>
41
42 using namespace std;
43
44 namespace lyx {
45
46 using frontend::Painter;
47 using frontend::FontMetrics;
48
49
50 RowPainter::RowPainter(PainterInfo & pi,
51         Text const & text, Row const & row, int x, int y)
52         : pi_(pi), text_(text),
53           tm_(pi_.base.bv->textMetrics(&text)),
54           row_(row), par_(text.paragraphs()[row.pit()]),
55           xo_(x), yo_(y)
56 {
57         x_ = row_.left_margin + xo_;
58
59         //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
60         //row_.dump();
61
62         LBUFERR(row.pit() >= 0);
63         LBUFERR(row.pit() < int(text.paragraphs().size()));
64 }
65
66
67 FontInfo RowPainter::labelFont(bool end) const
68 {
69         FontInfo f = text_.labelFont(par_);
70         // selected text?
71         if ((end ? row_.end_margin_sel : row_.begin_margin_sel)
72             || pi_.selected)
73                 f.setPaintColor(Color_selectiontext);
74         return f;
75 }
76
77
78 // If you want to debug inset metrics uncomment the following line:
79 //#define DEBUG_METRICS
80 // This draws green lines around each inset.
81
82
83 void RowPainter::paintInset(Row::Element const & e) const
84 {
85         // Handle selection (first left/right, then middle).
86         pi_.selected_left = pi_.selected
87                             || (row_.isRTL() ? row_.end_margin_sel : row_.begin_margin_sel);
88         pi_.selected_right = pi_.selected
89                              || (row_.isRTL() ? row_.begin_margin_sel : row_.end_margin_sel);
90         bool const pi_selected = pi_.selected;
91         Cursor const & cur = pi_.base.bv->cursor();
92         if (cur.selection() && cur.text() == &text_
93                 && cur.normalAnchor().text() == &text_)
94                 pi_.selected = row_.sel_beg <= e.pos && row_.sel_end > e.pos;
95
96         LASSERT(e.inset, return);
97         // Backup full_repaint status because some insets (InsetTabular)
98         // requires a full repaint
99         bool const pi_full_repaint = pi_.full_repaint;
100         bool const pi_do_spellcheck = pi_.do_spellcheck;
101         Change const pi_change = pi_.change;
102
103         pi_.base.font = e.inset->inheritFont() ? e.font.fontInfo() :
104                 pi_.base.bv->buffer().params().getFont().fontInfo();
105         pi_.ltr_pos = !e.font.isVisibleRightToLeft();
106         pi_.change = pi_.change.changed() ? pi_.change : e.change;
107         pi_.do_spellcheck &= e.inset->allowSpellCheck();
108
109         int const x1 = int(x_);
110         pi_.base.bv->coordCache().insets().add(e.inset, x1, yo_);
111         // insets are painted completely. Recursive
112         // FIXME: it is wrong to completely paint the background
113         // if we want to do single row painting.
114         e.inset->drawBackground(pi_, x1, yo_);
115         e.inset->drawSelection(pi_, x1, yo_);
116         e.inset->draw(pi_, x1, yo_);
117         paintTextDecoration(e);
118
119         // Restore full_repaint status.
120         pi_.full_repaint = pi_full_repaint;
121         pi_.change = pi_change;
122         pi_.do_spellcheck = pi_do_spellcheck;
123         pi_.selected = pi_selected;
124
125 #ifdef DEBUG_METRICS
126         Dimension const & dim = pi_.base.bv->coordCache().insets().dim(e.inset);
127         int const x2 = x1 + dim.wid;
128         int const y1 = yo_ + dim.des;
129         int const y2 = yo_ - dim.asc;
130         pi_.pain.line(x1, y1, x1, y2, Color_green);
131         pi_.pain.line(x1, y1, x2, y1, Color_green);
132         pi_.pain.line(x2, y1, x2, y2, Color_green);
133         pi_.pain.line(x1, y2, x2, y2, Color_green);
134 #endif
135 }
136
137
138 void RowPainter::paintLanguageMarkings(Row::Element const & e) const
139 {
140         paintForeignMark(e);
141         paintNoSpellingMark(e);
142 }
143
144
145 void RowPainter::paintForeignMark(Row::Element const & e) const
146 {
147         Language const * lang = e.font.language();
148         if (!lyxrc.mark_foreign_language)
149                 return;
150         if (lang == latex_language)
151                 return;
152         if (lang == pi_.base.bv->buffer().params().language)
153                 return;
154
155         int const desc = e.inset ? e.dim.descent() : 0;
156         int const y = yo_ + min(3 * pi_.base.solidLineOffset() / 2 + desc,
157                                 row_.descent() - 1);
158         pi_.pain.line(int(x_), y, int(x_ + e.full_width() - 1), y, Color_language,
159                       Painter::line_solid, pi_.base.solidLineThickness());
160 }
161
162
163 void RowPainter::paintNoSpellingMark(Row::Element const & e) const
164 {
165         //if (!lyxrc.mark_no_spelling)
166         //      return;
167         if (e.font.language() == latex_language)
168                 return;
169         if (e.font.fontInfo().nospellcheck() != FONT_ON)
170                 return;
171
172         // We at the same voffset than the misspelled mark, since
173         // these two are mutually exclusive
174         int const desc = e.inset ? e.dim.descent() : 0;
175         int y = yo_ + pi_.base.solidLineOffset() + desc
176                 + pi_.base.solidLineThickness()
177                 + (e.change.changed() ? pi_.base.solidLineThickness() + 1 : 0)
178                 + 1;
179         // Make sure that the mark does not go below the row rectangle
180         y = min(y, yo_ + row_.descent() - 1);
181
182         pi_.pain.line(int(x_), y, int(x_ + e.full_width()), y, Color_language,
183                       Painter::line_onoffdash, pi_.base.solidLineThickness());
184 }
185
186
187 void RowPainter::paintMisspelledMark(Row::Element const & e) const
188 {
189         if (e.font.fontInfo().nospellcheck() == FONT_ON)
190                 return;
191         // if changed the misspelled marker gets placed slightly lower than normal
192         // to avoid drawing at the same vertical offset
193         FontMetrics const & fm = theFontMetrics(e.font);
194         int const thickness = max(fm.lineWidth(), 2);
195         int y = yo_ + pi_.base.solidLineOffset() + pi_.base.solidLineThickness()
196                 + (e.change.changed() ? pi_.base.solidLineThickness() + 1 : 0)
197                 + 1 + thickness / 2;
198         // Make sure that the mark does not go below the row rectangle
199         y = min(y, yo_ + row_.descent() - 1);
200
201         //FIXME: this could be computed only once, it is probably not costly.
202         // check for cursor position
203         // don't draw misspelled marker for words at cursor position
204         // we don't want to disturb the process of text editing
205         DocIterator const nw = pi_.base.bv->cursor().newWord();
206         pos_type cpos = -1;
207         if (!nw.empty() && par_.id() == nw.paragraph().id()) {
208                 cpos = nw.pos();
209                 if (cpos > 0 && cpos == par_.size() && !par_.isWordSeparator(cpos-1))
210                         --cpos;
211                 else if (cpos > 0 && par_.isWordSeparator(cpos))
212                         --cpos;
213         }
214
215         pos_type pos = e.pos;
216         while (pos < e.pos + pos_type(e.str.length())) {
217                 if (!par_.isMisspelled(pos)) {
218                         ++pos;
219                         continue;
220                 }
221
222                 FontSpan const & range = par_.getSpellRange(pos);
223
224                 // Skip element which are being edited
225                 if (range.contains(cpos)) {
226                         // the range includes the last element
227                         pos = range.last + 1;
228                         continue;
229                 }
230
231                 int x1 = fm.pos2x(e.str, range.first - e.pos,
232                                   e.isRTL(), e.extra);
233                 int x2 = fm.pos2x(e.str, min(range.last - e.pos + 1,
234                                                                          pos_type(e.str.length())),
235                                                                          e.isRTL(), e.extra);
236                 if (x1 > x2)
237                         swap(x1, x2);
238
239                 pi_.pain.line(int(x_ + x1), y, int(x_ + x2), y,
240                               Color_error,
241                               Painter::line_onoffdash, thickness);
242                 pos = range.last + 1;
243         }
244 }
245
246
247 void RowPainter::paintStringAndSel(Row::Element const & e) const
248 {
249         // at least part of text selected?
250         bool const some_sel = (e.endpos >= row_.sel_beg && e.pos < row_.sel_end)
251                 || pi_.selected;
252         // all the text selected?
253         bool const all_sel = (e.pos >= row_.sel_beg && e.endpos < row_.sel_end)
254                 || pi_.selected;
255
256         if (all_sel || e.change.changed()) {
257                 Font copy = e.font;
258                 Color const col = e.change.changed() ? e.change.color()
259                                                      : Color_selectiontext;
260                 copy.fontInfo().setPaintColor(col);
261                 pi_.pain.text(int(x_), yo_, e.str, copy, e.extra, e.full_width());
262         } else if (!some_sel) {
263                 pi_.pain.text(int(x_), yo_, e.str, e.font, e.extra, e.full_width());
264         } else {
265                 pi_.pain.text(int(x_), yo_, e.str, e.font, Color_selectiontext,
266                               max(row_.sel_beg, e.pos) - e.pos,
267                               min(row_.sel_end, e.endpos) - e.pos,
268                               e.extra, e.full_width());
269         }
270 }
271
272
273 void RowPainter::paintTextDecoration(Row::Element const & e) const
274 {
275         // element selected?
276         bool const sel = (e.pos >= row_.sel_beg && e.endpos <= row_.sel_end)
277                 || pi_.selected;
278         FontInfo copy = e.font.fontInfo();
279         if (sel || e.change.changed()) {
280                 Color const col = e.change.changed() ? e.change.color()
281                                                      : Color_selectiontext;
282                 copy.setPaintColor(col);
283         }
284         pi_.pain.textDecoration(copy, int(x_), yo_, int(e.full_width()));
285 }
286
287
288 void RowPainter::paintChange(Row::Element const & e) const
289 {
290         e.change.paintCue(pi_, x_, yo_, x_ + e.full_width(), e.font.fontInfo());
291 }
292
293
294 void RowPainter::paintChangeBar() const
295 {
296         int const x = pi_.base.bv->leftMargin() - pi_.base.bv->zoomedPixels(7);
297         Dimension const & cdim = row_.contents_dim();
298         pi_.pain.fillRectangle(x, yo_ - cdim.ascent(),
299                                3, cdim.height(), Color_changebar);
300 }
301
302
303 void RowPainter::paintAppendix() const
304 {
305         // only draw the appendix frame once (for the main text)
306         if (!par_.params().appendix() || !text_.isMainText())
307                 return;
308
309         int y = yo_ - row_.ascent();
310
311         if (par_.params().startOfAppendix())
312                 y += 2 * defaultRowHeight();
313
314         pi_.pain.line(1, y, 1, yo_ + row_.height(), Color_appendix);
315         pi_.pain.line(tm_.width() - 2, y, tm_.width() - 2, yo_ + row_.height(), Color_appendix);
316 }
317
318
319 void RowPainter::paintDepthBar() const
320 {
321         depth_type const depth = par_.getDepth();
322         ParagraphList const & pars = text_.paragraphs();
323
324         if (depth <= 0)
325                 return;
326
327         depth_type prev_depth = 0;
328         if (!tm_.isFirstRow(row_)) {
329                 pit_type pit2 = row_.pit();
330                 if (row_.pos() == 0)
331                         --pit2;
332                 prev_depth = pars[pit2].getDepth();
333         }
334
335         depth_type next_depth = 0;
336         if (!tm_.isLastRow(row_)) {
337                 pit_type pit2 = row_.pit();
338                 if (row_.endpos() >= pars[pit2].size())
339                         ++pit2;
340                 next_depth = pars[pit2].getDepth();
341         }
342
343         for (depth_type i = 1; i <= depth; ++i) {
344                 int const w = nestMargin() / 5;
345                 int x = int(xo_) + w * i;
346                 // consider the bufferview left margin if we're drawing outermost text
347                 if (text_.isMainText())
348                         x += pi_.base.bv->leftMargin();
349
350                 int const starty = yo_ - row_.ascent();
351                 int const h =  row_.height() - 1 - (i - next_depth - 1) * 3;
352
353                 pi_.pain.line(x, starty, x, starty + h, Color_depthbar);
354
355                 if (i > prev_depth)
356                         pi_.pain.fillRectangle(x, starty, w, 2, Color_depthbar);
357                 if (i > next_depth)
358                         pi_.pain.fillRectangle(x, starty + h, w, 2, Color_depthbar);
359         }
360 }
361
362
363 void RowPainter::paintAppendixStart(int y) const
364 {
365         FontInfo pb_font = sane_font;
366         pb_font.setColor(Color_appendix);
367         pb_font.decSize();
368
369         int w = 0;
370         int a = 0;
371         int d = 0;
372
373         docstring const label = _("Appendix");
374         theFontMetrics(pb_font).rectText(label, w, a, d);
375
376         int const text_start = int(xo_ + (tm_.width() - w) / 2);
377         int const text_end = text_start + w;
378
379         pi_.pain.rectText(text_start, y + d, label, pb_font, Color_none, Color_none);
380
381         pi_.pain.line(int(xo_ + 1), y, text_start, y, Color_appendix);
382         pi_.pain.line(text_end, y, int(xo_ + tm_.width() - 2), y, Color_appendix);
383 }
384
385
386 void RowPainter::paintTooLargeMarks(bool const left, bool const right) const
387 {
388         int const lwid = pi_.base.dottedLineThickness();
389         Dimension const & cdim = row_.contents_dim();
390         if (left) {
391                 int const x = pi_.base.bv->leftMargin() - lwid;
392                 pi_.pain.line(x, yo_ - cdim.ascent(), x, yo_ + cdim.descent(),
393                               Color_scroll, Painter::line_onoffdash, lwid);
394         }
395         if (right) {
396                 int const x = pi_.base.bv->workWidth() - pi_.base.bv->rightMargin();
397                 pi_.pain.line(x, yo_ - cdim.ascent(), x, yo_ + cdim.descent(),
398                               Color_scroll, Painter::line_onoffdash, lwid);
399         }
400 }
401
402
403 void RowPainter::paintFirst() const
404 {
405         Layout const & layout = par_.layout();
406
407         // start of appendix?
408         if (par_.params().startOfAppendix())
409             paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
410
411         bool const is_first =
412                 text_.isFirstInSequence(row_.pit()) || !layout.isParagraphGroup();
413         //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
414
415         if (layout.labelIsInline()
416             && (layout.labeltype != LABEL_STATIC || is_first))
417                 paintLabel();
418         else if (is_first && layout.labelIsAbove())
419                 paintTopLevelLabel();
420 }
421
422
423 void RowPainter::paintLabel() const
424 {
425         docstring const & str = par_.labelString();
426         if (str.empty())
427                 return;
428
429         Layout const & layout = par_.layout();
430         FontInfo const font = labelFont(false);
431         FontMetrics const & fm = theFontMetrics(font);
432         int const x = row_.isRTL() ? row_.width() + fm.width(layout.labelsep)
433                                    : row_.left_margin - fm.width(layout.labelsep) - fm.width(str);
434
435         pi_.pain.text(int(xo_) + x, yo_, str, font);
436 }
437
438
439 void RowPainter::paintTopLevelLabel() const
440 {
441         BufferParams const & bparams = pi_.base.bv->buffer().params();
442         ParagraphParameters const & pparams = par_.params();
443         Layout const & layout = par_.layout();
444         FontInfo const font = labelFont(false);
445         docstring const str = par_.labelString();
446         if (str.empty())
447                 return;
448
449         double spacing_val = 1.0;
450         if (!pparams.spacing().isDefault())
451                 spacing_val = pparams.spacing().getValue();
452         else
453                 spacing_val = bparams.spacing().getValue();
454
455         FontMetrics const & fm = theFontMetrics(font);
456
457         int const labeladdon = int(fm.maxHeight()
458                 * layout.spacing.getValue() * spacing_val);
459
460         int maxdesc =
461                 int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
462                 + (layout.labelbottomsep * defaultRowHeight()));
463
464         double x = x_;
465         if (layout.labeltype == LABEL_CENTERED) {
466                 // The 'size + 1' is weird, but it makes sure that we get the
467                 // left margin of non-first row.
468                 int leftm = tm_.leftMargin(row_.pit(), par_.size() + 1);
469                 int rightm = tm_.rightMargin(row_.pit());
470                 if (row_.isRTL())
471                         swap(leftm, rightm);
472                 /* Currently, x points at row_.left_margin (which contains the
473                  * indent). First remove that, and then center the title with
474                  * respect to the left and right margins.
475                  */
476                 x += leftm - row_.left_margin + (tm_.width() - leftm -rightm) / 2
477                         - fm.width(str) / 2;
478         } else if (row_.isRTL()) {
479                 x = xo_ + tm_.width() - row_.right_margin - fm.width(str);
480         }
481         pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
482 }
483
484
485 void RowPainter::paintLast() const
486 {
487         int const endlabel = text_.getEndLabel(row_.pit());
488         switch (endlabel) {
489         case END_LABEL_BOX:
490         case END_LABEL_FILLED_BOX: {
491                 FontInfo font = labelFont(true);
492                 if (font.realColor() != Color_selectiontext)
493                         font.setPaintColor(Color_eolmarker);
494                 FontMetrics const & fm = theFontMetrics(font);
495                 int const size = int(0.75 * fm.maxAscent());
496                 int const y = yo_ - size;
497
498                 // If needed, move the box a bit to avoid overlapping with text.
499                 int x = 0;
500                 if (row_.isRTL()) {
501                         int const normal_x = nestMargin() + changebarMargin();
502                         x = min(normal_x, row_.left_margin - size - Inset::textOffset(pi_.base.bv));
503                 } else {
504                         int const normal_x = tm_.width() - row_.right_margin
505                                 - size - Inset::textOffset(pi_.base.bv);
506                         x = max(normal_x, row_.width());
507                 }
508
509                 if (endlabel == END_LABEL_BOX)
510                         pi_.pain.rectangle(int(xo_) + x, y, size, size, font.realColor());
511                 else
512                         pi_.pain.fillRectangle(int(xo_) + x, y, size, size, font.realColor());
513                 break;
514         }
515
516         case END_LABEL_STATIC: {
517                 FontInfo const font = labelFont(true);
518                 FontMetrics const & fm = theFontMetrics(font);
519                 docstring const & str = par_.layout().endlabelstring();
520                 double const x = row_.isRTL() ? row_.left_margin - fm.width(str) : row_.width();
521                 pi_.pain.text(xo_ + x, yo_, str, font);
522                 break;
523         }
524
525         case END_LABEL_NO_LABEL:
526                 break;
527         }
528 }
529
530
531 void RowPainter::paintOnlyInsets()
532 {
533         for (Row::Element const & e : row_) {
534                 if (e.type == Row::INSET) {
535                         paintInset(e);
536                         // The markings of foreign languages
537                         // and of text ignored for spellchecking
538                         paintLanguageMarkings(e);
539                         // change tracking (not for insets that handle it themselves)
540                         if (!e.inset->canPaintChange(*pi_.base.bv))
541                                 paintChange(e);
542                 }
543
544                 x_ += e.full_width();
545         }
546 }
547
548
549 void RowPainter::paintText()
550 {
551         for (Row::Element const & e : row_) {
552                 switch (e.type) {
553                 case Row::STRING:
554                 case Row::VIRTUAL:
555                         paintStringAndSel(e);
556
557                         // Paint the spelling marks if enabled.
558                         if (lyxrc.spellcheck_continuously && pi_.do_spellcheck && !pi_.pain.isNull())
559                                 paintMisspelledMark(e);
560                         break;
561
562                 case Row::INSET:
563                         paintInset(e);
564                         break;
565
566                 case Row::SPACE:
567                 case Row::MARGINSPACE:
568                         paintTextDecoration(e);
569                 }
570
571                 // The markings of foreign languages
572                 // and of text ignored for spellchecking
573                 paintLanguageMarkings(e);
574
575                 // change tracking (not for insets that handle it themselves)
576                 if (e.type != Row::INSET || ! e.inset->canPaintChange(*pi_.base.bv))
577                         paintChange(e);
578
579                 x_ += e.full_width();
580         }
581 }
582
583
584 void RowPainter::paintSelection() const
585 {
586         if (!row_.selection())
587                 return;
588
589         int const y1 = yo_ - row_.contents_dim().asc;
590         int const y2 = yo_ + row_.contents_dim().des;
591
592         // The top selection
593         if (row_.begin_margin_sel)
594                 pi_.pain.fillRectangle(int(xo_), yo_ - row_.ascent(),
595                                        tm_.width(), row_.ascent() - row_.contents_dim().asc,
596                                        Color_selection);
597
598         // The left margin selection
599         if (row_.isRTL() ? row_.end_margin_sel : row_.begin_margin_sel)
600                 pi_.pain.fillRectangle(int(xo_), y1, row_.left_margin, y2 - y1,
601                                        Color_selection);
602
603         // go through row and draw from RTL boundary to RTL boundary
604         double x = xo_ + row_.left_margin;
605         for (auto const & e : row_) {
606                 // These are the same tests as in paintStringAndSel, except
607                 // that all_sel has an additional clause that triggers for end
608                 // of paragraph markers. The clause was not used in
609                 // paintStringAndSel to avoid changing the drawing color.
610                 // at least part of text selected?
611                 bool const some_sel = (e.endpos >= row_.sel_beg && e.pos < row_.sel_end)
612                         || pi_.selected;
613                 // all the text selected?
614                 bool const all_sel = (e.pos >= row_.sel_beg && e.endpos < row_.sel_end)
615                     || (e.isVirtual() && e.pos == row_.endpos() && row_.end_margin_sel)
616                     || pi_.selected;
617
618                 if (all_sel) {
619                         // the 3rd argument is written like that to avoid rounding issues
620                         pi_.pain.fillRectangle(int(x), y1,
621                                                int(x + e.full_width()) - int(x), y2 - y1,
622                                                Color_selection);
623                 } else if (some_sel) {
624                         pos_type const from = min(max(row_.sel_beg, e.pos), e.endpos);
625                         pos_type const to = max(min(row_.sel_end, e.endpos), e.pos);
626                         double x1 = e.pos2x(from);
627                         double x2 = e.pos2x(to);
628                         if (x1 > x2)
629                                 swap(x1, x2);
630                         // the 3rd argument is written like that to avoid rounding issues
631                         pi_.pain.fillRectangle(int(x + x1), y1, int(x2 + x) - int(x1 + x),
632                                                y2 - y1, Color_selection);
633                 }
634                 x += e.full_width();
635         }
636
637         // the right margin selection
638         if (row_.isRTL() ? row_.begin_margin_sel : row_.end_margin_sel)
639                 pi_.pain.fillRectangle(int(x), y1,
640                                        int(xo_ + tm_.width()) - int(x), y2 - y1,
641                                        Color_selection);
642         // The bottom selection
643         if (row_.end_margin_sel)
644                 pi_.pain.fillRectangle(int(xo_), yo_ + row_.contents_dim().des,
645                                        tm_.width(), row_.descent() - row_.contents_dim().des,
646                                        Color_selection);
647 }
648
649
650 void RowPainter::paintBookmark(int num) const
651 {
652         BufferView const * bv = pi_.base.bv;
653         FontInfo fi = bv->buffer().params().getFont().fontInfo();
654         FontMetrics const & fm = theFontMetrics(fi);
655         fi.setColor(Color_bookmark);
656         // ❶ U+2776 DINGBAT NEGATIVE CIRCLED DIGIT ONE
657         char_type const ch = 0x2775 + num;
658         int const x = row_.isRTL()
659                 ? bv->workWidth() - bv->rightMargin() + (bv->defaultMargin() - fm.width(ch)) / 2
660                 : bv->leftMargin() - (bv->defaultMargin() + fm.width(ch)) / 2;
661         pi_.pain.text(x, yo_, ch, fi);
662 }
663
664
665 } // namespace lyx