]> git.lyx.org Git - lyx.git/commitdiff
Fixed calculation of row ascent/descent.
authorJürgen Vigna <jug@sad.it>
Tue, 31 Jul 2001 12:57:06 +0000 (12:57 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 31 Jul 2001 12:57:06 +0000 (12:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2395 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/paragraph.C
src/paragraph.h
src/text.C

index 8314d5b2325a9b1de45af853e1f8af11813512e6..8def1ba3ee367e2892d672116ea23bfb44df9e90 100644 (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
 
index 643289168cd8125bfbcb31ce137607c0ee413a42..f4b2e2e6143f65d31ef7fd7a9000f2dd0953b96e 100644 (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;
        }
index 102f685b7d0b0b12a18982b77ef215fc094a15b2..0266d24054f489c14429b62b4c715c65c0b6be18 100644 (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);
        ///
index 88e107f083c6c9cf9a89278e51a35c47a3135130..ee3b5e26e6350a5893b945176735fa0e0560f158 100644 (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);