From 605c3cbb36dbe59c6a6e187b37923bedfec41e3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Tue, 31 Jul 2001 12:57:06 +0000 Subject: [PATCH] Fixed calculation of row ascent/descent. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2395 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/paragraph.C | 9 ++++++--- src/paragraph.h | 3 ++- src/text.C | 14 +++++++++----- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8314d5b232..8def1ba3ee 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2001-07-31 Juergen Vigna + * 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 diff --git a/src/paragraph.C b/src/paragraph.C index 643289168c..f4b2e2e614 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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; } diff --git a/src/paragraph.h b/src/paragraph.h index 102f685b7d..0266d24054 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -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); /// diff --git a/src/text.C b/src/text.C index 88e107f083..ee3b5e26e6 100644 --- a/src/text.C +++ b/src/text.C @@ -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); -- 2.39.5