]> git.lyx.org Git - lyx.git/blobdiff - src/Text2.cpp
Paragraph::inInset() shall not be used if the owner inset was not initialized. Make...
[lyx.git] / src / Text2.cpp
index 1254fbf99ce9eafcb84961dbbac5558ae3d6c7c2..65c08044c2160156ffdaabadfa3b7b3e77ba8266 100644 (file)
@@ -74,6 +74,7 @@ bool Text::isMainText(Buffer const & buffer) const
 }
 
 
+// Note that this is supposed to return a fully realized font.
 FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const
 {
        Layout const & layout = pars_[pit].layout();
@@ -83,10 +84,19 @@ FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const
                // In case the default family has been customized
                if (layout.font.family() == INHERIT_FAMILY)
                        lf.setFamily(buffer.params().getFont().fontInfo().family());
-               InsetCollapsable const * icp = pars_[pit].inInset()->asInsetCollapsable();
-               if (icp)
-                       lf.update(icp->getLayout().font(), false);
-               return lf;
+               // FIXME
+               // It ought to be possible here just to use Inset::getLayout() and skip
+               // the asInsetCollapsable() bit. Unfortunatley, that doesn't work right
+               // now, because Inset::getLayout() will return a default-constructed
+               // InsetLayout, and that e.g. sets the foreground color to red. So we
+               // need to do some work to make that possible.
+               Inset const * inset = pars_[pit].inInset();
+               InsetCollapsable const * icp = inset? inset->asInsetCollapsable() : 0;
+               if (!icp)
+                       return lf;
+               FontInfo icf = icp->getLayout().font();
+               icf.realize(lf);
+               return icf;
        }
 
        FontInfo font = layout.font;
@@ -98,6 +108,7 @@ FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const
 }
 
 
+// Note that this is supposed to return a fully realized font.
 FontInfo Text::labelFont(Buffer const & buffer, Paragraph const & par) const
 {
        Layout const & layout = par.layout();
@@ -107,10 +118,14 @@ FontInfo Text::labelFont(Buffer const & buffer, Paragraph const & par) const
                // In case the default family has been customized
                if (layout.labelfont.family() == INHERIT_FAMILY)
                        lf.setFamily(buffer.params().getFont().fontInfo().family());
-               InsetCollapsable const * icp = par.inInset()->asInsetCollapsable();
-               if (icp)
-                       lf.update(icp->getLayout().labelfont(), false);
-               return lf;
+               // FIXME As above....
+               Inset const * inset = par.inInset();
+               InsetCollapsable const * icp = inset? inset->asInsetCollapsable() : 0;
+               if (!icp)
+                       return lf;
+               FontInfo icf = icp->getLayout().labelfont();
+               icf.realize(lf);
+               return icf;
        }
 
        FontInfo font = layout.labelfont;