pimpl_->macros = MacroTable::globalMacros();
// Now add our own.
- ParagraphList & pars = text().paragraphs();
+ ParagraphList const & pars = text().paragraphs();
for (size_t i = 0, n = pars.size(); i != n; ++i) {
//lyxerr << "searching main par " << i
// << " for macro definitions" << std::endl;
- InsetList::iterator it = pars[i].insetlist.begin();
- InsetList::iterator end = pars[i].insetlist.end();
+ InsetList const & insets = pars[i].insetlist;
+ InsetList::const_iterator it = insets.begin();
+ InsetList::const_iterator end = insets.end();
for ( ; it != end; ++it) {
//lyxerr << "found inset code " << it->inset->lyxCode() << std::endl;
if (it->inset->lyxCode() == InsetBase::MATHMACRO_CODE) {
- MathMacroTemplate & mac
- = static_cast<MathMacroTemplate &>(*it->inset);
+ MathMacroTemplate const & mac
+ = static_cast<MathMacroTemplate const &>(*it->inset);
insertMacro(mac.name(), mac.asMacroData());
}
}
/// return left margin
int leftMargin() const;
- /// return the font at the given pos
- LyXFont const getFont(lyx::pos_type pos) const;
-
/// return the label font for this row
LyXFont const getLabelFont() const;
- /// return pixel width for the given pos
- int singleWidth(lyx::pos_type pos) const;
- int singleWidth(lyx::pos_type pos, char c) const;
-
/// bufferview to paint on
BufferView const & bv_;
}
-/// "temporary"
-LyXFont const RowPainter::getFont(pos_type pos) const
-{
- LyXFont pf(text_.getFont(par_, pos));
- text_.applyOuterFont(pf);
- return pf;
-}
-
-
-int RowPainter::singleWidth(lyx::pos_type pos) const
-{
- return text_.singleWidth(par_, pos);
-}
-
-
-int RowPainter::singleWidth(lyx::pos_type pos, char c) const
-{
- LyXFont const & font = text_.getFont(par_, pos);
- return text_.singleWidth(par_, pos, c, font);
-}
-
-
LyXFont const RowPainter::getLabelFont() const
{
return text_.getLabelFont(par_);
c = par_.getChar(i);
if (!Encodings::IsComposeChar_hebrew(c)) {
if (IsPrintableNonspace(c)) {
- int const width2 = singleWidth(i, c);
+ int const width2 =
+ text_.singleWidth(par_, i, c, text_.getFont(par_, i));
// dalet / resh
dx = (c == 'ø' || c == 'ã')
? width2 - width
c = par_.getChar(i);
if (!Encodings::IsComposeChar_arabic(c)) {
if (IsPrintableNonspace(c)) {
- int const width2 = singleWidth(i, c);
+ int const width2 =
+ text_.singleWidth(par_, i, c, text_.getFont(par_, i));
dx = (width2 - width) / 2;
}
break;
void RowPainter::paintFromPos(pos_type & vpos)
{
pos_type const pos = text_.bidi.vis2log(vpos);
-
- LyXFont const & orig_font = getFont(pos);
+ LyXFont orig_font = text_.getFont(par_, pos);
+ text_.applyOuterFont(orig_font);
double const orig_x = x_;
// usual characters, no insets
// special case languages
- bool const hebrew = (orig_font.language()->lang() == "hebrew");
- bool const arabic =
- orig_font.language()->lang() == "arabic" &&
+ std::string const & lang = orig_font.language()->lang();
+ bool const hebrew = lang == "hebrew";
+ bool const arabic = lang == "arabic" &&
(lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
lyxrc.font_norm_type == LyXRC::ISO_10646_1);
if (!par_.getLabelstring().empty()) {
string const str = par_.getLabelstring();
double spacing_val = 1.0;
- if (!parparams.spacing().isDefault()) {
+ if (!parparams.spacing().isDefault())
spacing_val = parparams.spacing().getValue();
- } else {
+ else
spacing_val = buffer.params().spacing().getValue();
- }
int maxdesc =
int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
bool is_struckout = false;
int last_strikeout_x = 0;
+ // Use font span to speed things up, see below
+ FontSpan font_span;
+ LyXFont font;
+
for (pos_type vpos = row_.pos(); vpos < end; ) {
if (x_ > bv_.workWidth())
break;
continue;
}
- const int width_pos = singleWidth(pos);
+ // Use font span to speed things up, see above
+ if (vpos < font_span.first || vpos > font_span.last) {
+ font_span = par_.fontSpan(vpos);
+ font = text_.getFont(par_, vpos);
+ }
+
+ const int width_pos =
+ text_.singleWidth(par_, vpos, par_.getChar(vpos), font);
+
if (x_ + width_pos < 0) {
x_ += width_pos;
++vpos;
bool const highly_editable_inset = par_.isInset(pos)
&& isHighlyEditableInset(par_.getInset(pos));
- // if we reach the end of a struck out range, paint it
- // we also don't paint across things like tables
+ // If we reach the end of a struck out range, paint it.
+ // We also don't paint across things like tables
if (running_strikeout && (highly_editable_inset || !is_struckout)) {
- // calculate 1/3 height of the buffer's default font
+ // Calculate 1/3 height of the buffer's default font
int const middle =
yo_ - font_metrics::maxAscent(text_.defaultfont_) / 3;
pain_.line(last_strikeout_x, middle, int(x_), middle,