- return &buffer.text() == this;
-}
-
-
-// Gets the fully instantiated font at a given position in a paragraph
-// Basically the same routine as Paragraph::getFont() in Paragraph.cpp.
-// The difference is that this one is used for displaying, and thus we
-// are allowed to make cosmetic improvements. For instance make footnotes
-// smaller. (Asger)
-Font Text::getFont(Buffer const & buffer, Paragraph const & par,
- pos_type const pos) const
-{
- BOOST_ASSERT(pos >= 0);
-
- LayoutPtr const & layout = par.layout();
- // FIXME: broken?
- BufferParams const & params = buffer.params();
- pos_type const body_pos = par.beginOfBody();
-
- // We specialize the 95% common case:
- if (!par.getDepth()) {
- Font f = par.getFontSettings(params, pos);
- if (!isMainText(buffer))
- applyOuterFont(buffer, f);
- Font lf;
- Font rlf;
- if (layout->labeltype == LABEL_MANUAL && pos < body_pos) {
- lf = layout->labelfont;
- rlf = layout->reslabelfont;
- } else {
- lf = layout->font;
- rlf = layout->resfont;
- }
- // In case the default family has been customized
- if (lf.family() == Font::INHERIT_FAMILY)
- rlf.setFamily(params.getFont().family());
- return f.realize(rlf);
- }
-
- // The uncommon case need not be optimized as much
- Font layoutfont;
- if (pos < body_pos)
- layoutfont = layout->labelfont;
- else
- layoutfont = layout->font;
-
- Font font = par.getFontSettings(params, pos);
- font.realize(layoutfont);
-
- if (!isMainText(buffer))
- applyOuterFont(buffer, font);
-
- // Find the pit value belonging to paragraph. This will not break
- // even if pars_ would not be a vector anymore.
- // Performance appears acceptable.
-
- pit_type pit = pars_.size();
- for (pit_type it = 0; it < pit; ++it)
- if (&pars_[it] == &par) {
- pit = it;
- break;
- }
- // Realize against environment font information
- // NOTE: the cast to pit_type should be removed when pit_type
- // changes to a unsigned integer.
- if (pit < pit_type(pars_.size()))
- font.realize(outerFont(pit, pars_));
-
- // Realize with the fonts of lesser depth.
- font.realize(params.getFont());
-
- return font;
-}
-
-// There are currently two font mechanisms in LyX:
-// 1. The font attributes in a lyxtext, and
-// 2. The inset-specific font properties, defined in an inset's
-// metrics() and draw() methods and handed down the inset chain through
-// the pi/mi parameters, and stored locally in a lyxtext in font_.
-// This is where the two are integrated in the final fully realized
-// font.
-void Text::applyOuterFont(Buffer const & buffer, Font & font) const {
- Font lf(font_);
- lf.reduce(buffer.params().getFont());
- lf.realize(font);
- lf.setLanguage(font.language());
- font = lf;