Fixed calculation of row ascent/descent.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2395 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2001-07-31 12:57:06 +00:00
parent f97e06c961
commit 605c3cbb36
4 changed files with 22 additions and 9 deletions

View File

@ -1,5 +1,10 @@
2001-07-31 Juergen Vigna <jug@sad.it>
* text.C (setHeightOfRow): fixed setting of ascent/descent based on
the font (wrong since using of Paragraph::highestFontInRange).
* paragraph.C (highestFontInRange): added a default_size parameter.
* text.C (getVisibleRow): minor clear row changes (still not perfect).
(setHeightOfRow): reformat

View File

@ -661,12 +661,13 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams,
/// Returns the height of the highest font in range
LyXFont::FONT_SIZE
Paragraph::highestFontInRange(Paragraph::size_type startpos,
Paragraph::size_type endpos) const
Paragraph::size_type endpos,
LyXFont::FONT_SIZE const def_size) const
{
LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
if (pimpl_->fontlist.empty())
return maxsize;
return def_size;
LyXFont::FONT_SIZE maxsize = LyXFont::SIZE_TINY;
Pimpl::FontTable end_search(endpos, LyXFont());
Pimpl::FontList::const_iterator end_it =
lower_bound(pimpl_->fontlist.begin(),
@ -683,6 +684,8 @@ Paragraph::highestFontInRange(Paragraph::size_type startpos,
cit != end_it; ++cit)
{
LyXFont::FONT_SIZE size = cit->font().size();
if (size == LyXFont::INHERIT_SIZE)
size = def_size;
if (size > maxsize && size <= LyXFont::SIZE_HUGER)
maxsize = size;
}

View File

@ -262,7 +262,8 @@ public:
void setFont(size_type pos, LyXFont const & font);
/// Returns the height of the highest font in range
LyXFont::FONT_SIZE highestFontInRange(size_type startpos,
size_type endpos) const;
size_type endpos,
LyXFont::FONT_SIZE const def_size) const;
///
void insertChar(size_type pos, value_type c);
///

View File

@ -1203,10 +1203,14 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
firstpar->getLayout());
LyXFont font = getFont(bview->buffer(), par, par->size() - 1);
LyXFont::FONT_SIZE const size = font.size();
// as max get the first character of this row then it can increes but not
// decrees the height. Just some point to start with so we don't have to
// do the assignment below too often.
LyXFont font = getFont(bview->buffer(), par, row_ptr->pos());
LyXFont::FONT_SIZE const tmpsize = font.size();
font = getFont(bview->buffer(), par, -1);
font.setSize(size);
LyXFont::FONT_SIZE const size = font.size();
font.setSize(tmpsize);
LyXFont labelfont = getFont(bview->buffer(), par, -2);
@ -1251,8 +1255,8 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
// Check if any custom fonts are larger (Asger)
// This is not completely correct, but we can live with the small,
// cosmetic error for now.
LyXFont::FONT_SIZE const maxsize =
row_ptr->par()->highestFontInRange(row_ptr->pos(), pos_end);
LyXFont::FONT_SIZE maxsize =
row_ptr->par()->highestFontInRange(row_ptr->pos(), pos_end, size);
if (maxsize > font.size()) {
font.setSize(maxsize);