if (pos > 0) {
TextMetrics const & tm = bv().textMetrics(&text);
if (pos == sl.lastpos()
- || (par.isSeparator(pos) &&
- !tm.isRTLBoundary(par, pos)))
+ || (par.isSeparator(pos)
+ && !tm.isRTLBoundary(sl.pit(), pos)))
--pos;
}
// abc| def -> font of c
// abc |[WERBEH], i.e. boundary==true -> font of c
// abc [WERBEH]| def, font of the space
- if (!tm.isRTLBoundary(par, cpos))
+ if (!tm.isRTLBoundary(pit(), cpos))
--cpos;
}
}
// get font
BufferParams const & bufparams = buffer().params();
current_font = par.getFontSettings(bufparams, cpos);
- real_current_font = tm.getDisplayFont(par, cpos);
+ real_current_font = tm.getDisplayFont(pit(), cpos);
// special case for paragraph end
if (pos() == lastpos()
- && tm.isRTLBoundary(par, pos())
+ && tm.isRTLBoundary(pit(), pos())
&& !boundary()) {
Language const * lang = par.getParLanguage(bufparams);
current_font.setLanguage(lang);
FontIterator::FontIterator(TextMetrics const & tm,
- Paragraph const & par, pos_type pos)
- : tm_(tm), par_(par), pos_(pos),
- font_(tm.getDisplayFont(par, pos)),
+ Paragraph const & par, pit_type pit, pos_type pos)
+ : tm_(tm), par_(par), pit_(pit), pos_(pos),
+ font_(tm.getDisplayFont(pit, pos)),
endspan_(par.fontSpan(pos).last),
bodypos_(par.beginOfBody())
{}
{
++pos_;
if (pos_ > endspan_ || pos_ == bodypos_) {
- font_ = tm_.getDisplayFont(par_, pos_);
+ font_ = tm_.getDisplayFont(pit_, pos_);
endspan_ = par_.fontSpan(pos_).last;
}
return *this;
public:
///
FontIterator(TextMetrics const & tm,
- Paragraph const & par, pos_type pos);
+ Paragraph const & par, pit_type pit, pos_type pos);
///
Font const & operator*() const;
///
///
Paragraph const & par_;
///
+ pit_type pit_;
+ ///
pos_type pos_;
///
Font font_;
!(contains(number_seperators, c) &&
cur.pos() != 0 &&
cur.pos() != cur.lastpos() &&
- tm.getDisplayFont(par, cur.pos()).number() == Font::ON &&
- tm.getDisplayFont(par, cur.pos() - 1).number() == Font::ON)
+ tm.getDisplayFont(pit, cur.pos()).number() == Font::ON &&
+ tm.getDisplayFont(pit, cur.pos() - 1).number() == Font::ON)
)
number(cur); // Set current_font.number to OFF
} else if (isDigit(c) &&
tm.font_);
} else if (contains(number_seperators, c)
&& cur.pos() >= 2
- && tm.getDisplayFont(par, cur.pos() - 2).number() == Font::ON) {
+ && tm.getDisplayFont(pit, cur.pos() - 2).number() == Font::ON) {
setCharFont(buffer, pit, cur.pos() - 1, cur.current_font,
tm.font_);
}
if ((cur.pos() >= 2) && (par.isLineSeparator(cur.pos() - 1))) {
// get font in front and behind the space in question. But do NOT
// use getFont(cur.pos()) because the character c is not inserted yet
- Font const & pre_space_font = tm.getDisplayFont(par, cur.pos() - 2);
+ Font const & pre_space_font = tm.getDisplayFont(cur.pit(), cur.pos() - 2);
Font const & post_space_font = cur.real_current_font;
bool pre_space_rtl = pre_space_font.isVisibleRightToLeft();
bool post_space_rtl = post_space_font.isVisibleRightToLeft();
(pre_space_rtl == par.isRightToLeftPar(buffer.params())) ?
pre_space_font.language() : post_space_font.language();
- Font space_font = tm.getDisplayFont(par, cur.pos() - 1);
+ Font space_font = tm.getDisplayFont(cur.pit(), cur.pos() - 1);
space_font.setLanguage(lang);
par.setFont(cur.pos() - 1, space_font);
}
// of noFontChange in Inset.h
setInsetFont(bv, pit, pos, font, toggleall);
TextMetrics const & tm = bv.textMetrics(this);
- Font f = tm.getDisplayFont(dit.paragraph(), pos);
+ Font f = tm.getDisplayFont(pit, pos);
f.update(font, language, toggleall);
setCharFont(buffer, pit, pos, f, tm.font_);
}
TextMetrics const & tm = cur.bv().textMetrics(this);
// if left of boundary -> just jump to right side
// but for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
- if (cur.boundary() && !tm.isRTLBoundary(cur.paragraph(), cur.pos()))
+ if (cur.boundary() && !tm.isRTLBoundary(cur.pit(), cur.pos()))
return setCursor(cur, cur.pit(), cur.pos(), true, false);
// next position is left of boundary,
// in front of RTL boundary? Stay on this side of the boundary because:
// ab|cDDEEFFghi -> abc|DDEEFFghi
- if (tm.isRTLBoundary(cur.paragraph(), cur.pos() + 1))
+ if (tm.isRTLBoundary(cur.pit(), cur.pos() + 1))
return setCursor(cur, cur.pit(), cur.pos() + 1, true, true);
// move right
if (font.language() != ignore_language ||
font.number() != Font::IGNORE) {
- Paragraph & par = cur.paragraph();
TextMetrics const & tm = cur.bv().textMetrics(text);
- if (cur.boundary() != tm.isRTLBoundary(par,
+ if (cur.boundary() != tm.isRTLBoundary(cur.pit(),
cur.pos(), cur.real_current_font))
text->setCursor(cur, cur.pit(), cur.pos(),
false, !cur.boundary());
}
-Font TextMetrics::getDisplayFont(Paragraph const & par,
- pos_type const pos) const
+Font TextMetrics::getDisplayFont(pit_type pit, pos_type pos) const
{
BOOST_ASSERT(pos >= 0);
+ ParagraphList const & pars = text_->paragraphs();
+ Paragraph const & par = pars[pit];
LayoutPtr const & layout = par.layout();
Buffer const & buffer = bv_->buffer();
// FIXME: broken?
if (!text_->isMainText(buffer))
applyOuterFont(font);
- // Find the pit value belonging to paragraph. This will not break
- // even if pars_ would not be a vector anymore.
- // Performance appears acceptable.
-
- ParagraphList const & pars = text_->paragraphs();
-
- 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 (boundary && sl.pos() > 0)
correction = -1;
- Paragraph const & par = text_->getPar(sl.pit());
- return getDisplayFont(par, sl.pos() + correction).isVisibleRightToLeft();
+ return getDisplayFont(sl.pit(), sl.pos() + correction).isVisibleRightToLeft();
}
-bool TextMetrics::isRTLBoundary(Paragraph const & par,
- pos_type pos) const
+bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos) const
{
if (!lyxrc.rtl_support)
return false;
if (pos == 0)
return false;
- bool left = getDisplayFont(par, pos - 1).isVisibleRightToLeft();
+ Paragraph const & par = text_->getPar(pit);
+
+ bool left = getDisplayFont(pit, pos - 1).isVisibleRightToLeft();
bool right;
if (pos == par.size())
right = par.isRightToLeftPar(bv_->buffer().params());
else
- right = getDisplayFont(par, pos).isVisibleRightToLeft();
+ right = getDisplayFont(pit, pos).isVisibleRightToLeft();
return left != right;
}
-bool TextMetrics::isRTLBoundary(Paragraph const & par,
- pos_type pos, Font const & font) const
+bool TextMetrics::isRTLBoundary(pit_type pit, pos_type pos,
+ Font const & font) const
{
if (!lyxrc.rtl_support)
return false;
+ Paragraph const & par = text_->getPar(pit);
bool left = font.isVisibleRightToLeft();
bool right;
if (pos == par.size())
right = par.isRightToLeftPar(bv_->buffer().params());
else
- right = getDisplayFont(par, pos).isVisibleRightToLeft();
+ right = getDisplayFont(pit, pos).isVisibleRightToLeft();
return left != right;
}
int const w = max_width_ - leftMargin(max_width_, pit, ii->pos)
- right_margin;
Font const & font = ii->inset->noFontChange() ?
- bufferfont : getDisplayFont(par, ii->pos);
+ bufferfont : getDisplayFont(pit, ii->pos);
MetricsInfo mi(bv_, font, w);
changed |= ii->inset->metrics(mi, dim);
changed |= (old_dim != dim);
// pixel width since last breakpoint
int chunkwidth = 0;
- FontIterator fi = FontIterator(*this, par, pos);
+ FontIterator fi = FontIterator(*this, par, pit, pos);
pos_type point = end;
pos_type i = pos;
for ( ; i < end; ++i, ++fi) {
pos_type i = first;
if (i < end) {
- FontIterator fi = FontIterator(*this, par, i);
+ FontIterator fi = FontIterator(*this, par, pit, i);
for ( ; i < end; ++i, ++fi) {
if (body_pos > 0 && i == body_pos) {
FontMetrics const & fm = theFontMetrics(
// start with so we don't have to do the assignment below too
// often.
Buffer const & buffer = bv_->buffer();
- Font font = getDisplayFont(par, first);
+ Font font = getDisplayFont(pit, first);
Font::FONT_SIZE const tmpsize = font.size();
font = text_->getLayoutFont(buffer, pit);
Font::FONT_SIZE const size = font.size();
bool const rtl = (bidi.level(c) % 2 == 1);
if (left_side == rtl) {
++c;
- boundary = isRTLBoundary(par, c);
+ boundary = isRTLBoundary(pit, c);
}
}
// Use font span to speed things up, see above
if (pos < font_span.first || pos > font_span.last) {
font_span = par.fontSpan(pos);
- font = getDisplayFont(par, pos);
+ font = getDisplayFont(pit, pos);
}
x += pm.singleWidth(pos, font);
{
ParagraphMetrics const & pm = par_metrics_[pit];
- return pm.singleWidth(pos, getDisplayFont(text_->getPar(pit), pos));
+ return pm.singleWidth(pos, getDisplayFont(pit, pos));
}
// but for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
if (cur.boundary()) {
cur.boundary(false);
- } else if (isRTLBoundary(cur.paragraph(), cur.pos() + 1)) {
+ } else if (isRTLBoundary(cur.pit(), cur.pos() + 1)) {
// in front of RTL boundary -> Stay on this side of the boundary because:
// ab|cDDEEFFghi -> abc|DDEEFFghi
++cur.pos();
/// 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 getDisplayFont(Paragraph const & par,
+ Font getDisplayFont(pit_type pit,
pos_type pos) const;
/// There are currently two font mechanisms in LyX:
/// is this position in the paragraph right-to-left?
bool isRTL(CursorSlice const & sl, bool boundary) const;
/// is between pos-1 and pos an RTL<->LTR boundary?
- bool isRTLBoundary(Paragraph const & par,
+ bool isRTLBoundary(pit_type pit,
pos_type pos) const;
/// would be a RTL<->LTR boundary between pos and the given font?
- bool isRTLBoundary(Paragraph const & par,
+ bool isRTLBoundary(pit_type pit,
pos_type pos, Font const & font) const;
// we can only set this if we are not too far right
if (cols < columns) {
shared_ptr<InsetText> inset = loctab->getCellInset(cell);
- Paragraph & par = inset->text_.getPar(0);
Font const font = bv.textMetrics(&inset->text_).
- getDisplayFont(par, 0);
+ getDisplayFont(0, 0);
inset->setText(buf.substr(op, p - op), font,
buffer.params().trackChanges);
++cols;
// we can only set this if we are not too far right
if (cols < columns) {
shared_ptr<InsetText> inset = tabular.getCellInset(cell);
- Paragraph & par = inset->text_.getPar(0);
Font const font = bv.textMetrics(&inset->text_).
- getDisplayFont(par, 0);
+ getDisplayFont(0, 0);
inset->setText(buf.substr(op, p - op), font,
buffer.params().trackChanges);
}
// check for the last cell if there is no trailing '\n'
if (cell < cells && op < len) {
shared_ptr<InsetText> inset = loctab->getCellInset(cell);
- Paragraph & par = inset->text_.getPar(0);
- Font const font = bv.textMetrics(&inset->text_).getDisplayFont(par, 0);
+ Font const font = bv.textMetrics(&inset->text_).getDisplayFont(0, 0);
inset->setText(buf.substr(op, len - op), font,
buffer.params().trackChanges);
}
void RowPainter::paintInset(Inset const * inset, pos_type const pos)
{
- Font font = text_metrics_.getDisplayFont(par_, pos);
+ Font font = text_metrics_.getDisplayFont(pit_, pos);
BOOST_ASSERT(inset);
// FIXME: We should always use font, see documentation of
if (!Encodings::isComposeChar_hebrew(c)) {
if (isPrintableNonspace(c)) {
int const width2 = pm_.singleWidth(i,
- text_metrics_.getDisplayFont(par_, i));
+ text_metrics_.getDisplayFont(pit_, i));
dx = (c == 0x05e8 || // resh
c == 0x05d3) // dalet
? width2 - width
if (!Encodings::isComposeChar_arabic(c)) {
if (isPrintableNonspace(c)) {
int const width2 = pm_.singleWidth(i,
- text_metrics_.getDisplayFont(par_, i));
+ text_metrics_.getDisplayFont(pit_, i));
dx = (width2 - width) / 2;
}
break;
void RowPainter::paintFromPos(pos_type & vpos)
{
pos_type const pos = bidi_.vis2log(vpos);
- Font orig_font = text_metrics_.getDisplayFont(par_, pos);
+ Font orig_font = text_metrics_.getDisplayFont(pit_, pos);
double const orig_x = x_;
// usual characters, no insets
// 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_metrics_.getDisplayFont(par_, vpos);
+ font = text_metrics_.getDisplayFont(pit_, vpos);
}
const int width_pos = pm_.singleWidth(pos, font);
++vpos;
} else if (par_.isSeparator(pos)) {
- Font orig_font = text_metrics_.getDisplayFont(par_, pos);
+ Font orig_font = text_metrics_.getDisplayFont(pit_, pos);
double const orig_x = x_;
x_ += width_pos;
if (pos >= body_pos)