On Thu, Oct 05, 2006 at 07:03:36PM +0200, Abdelrazak Younes wrote: > --- src/frontends/font_metrics.h (revision 15255) > +++ src/frontends/font_metrics.h (working copy) > [...] > -class LyXFont; > - > -/** > - * A namespace holding helper functions for determining > - * the screen dimensions of fonts. > - * > - * The geometry is the standard typographical geometry, > - * as follows : > - * > - * --------------+------------------<maxAscent > - * | | > - * <-------> (right bearing) > - * <-> (left bearing) > - * char ascent>___ | > - * ^ oooo | oooo > - * origin>____ | oo oo | oo oo > - * \| oo oo | oo oo > - * --------------+---ooooo--|--oooo-<baseline > - * | oo | > - * char | oo oo | > - * descent>______| oooo | > - * <- width -> > - * --------------+----------+-------<maxDescent > - * > - */
This comment should be tretained somewhere. > + if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) { > + metrics.reset(new GuiFontMetrics(font)); > + } > + else { > + // handle small caps ourselves ... > + LyXFont smallfont = f; > + smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE); > + QFont font2(font); > + > font2.setPointSizeF(convert<double>(lyxrc.font_sizes[smallfont.size()]) > + * lyxrc.zoom / 100.0); > + > + metrics.reset(new GuiFontMetrics(font, font2)); > + } Ok, you got rid of the smallcaps special casing at the price of one more indirection. Even if this is probably a good deal I wonder whether we could get rid of that some day... (nothing to be taken serious now...) And now something completly different: > -#include "font_metrics.h" > +#include "frontends/Application.h" > +#include "frontends/FontLoader.h" > +#include "frontends/FontMetrics.h" > + > #include "funcrequest.h" > #include "lyx_gui.h" > #include "lyxfunc.h" > @@ -372,8 +375,9 @@ > shape = BAR_SHAPE; > > LyXFont const font = buffer_view_->cursor().getFont(); > - int const asc = font_metrics::maxAscent(font); > - int const des = font_metrics::maxDescent(font); > + FontMetrics const & fm = theApp->fontLoader().metrics(font); > + int const asc = fm.maxAscent(); > + int const des = fm.maxDescent(); This is why I don't like the 'single singleton approach': More line noise. Instead of -#include "font_metrics.h" you need +#include "frontends/Application.h" +#include "frontends/FontMetrics.h" and theApp->fontLoader() could as well be theFontLoader() > pain_.text(int(x_), yo_, &str[0], str.size(), font); > - x_ += font_metrics::width(&str[0], str.size(), font); > + x_ += theApp->fontLoader().metrics(font).width(&str[0], str.size()); I think I'd prefer something like + x_ += theFontMetrics(font).width(&str[0], str.size()); Going 'optically' through four layers is not adding clarity. Ok, it looks that even if the patch is largish most of the changes are mechanical so I don't think it can do much harm. The small caps changes seem sensible, so from my point of view it is ok. Andre'