+void LyXText::SetCharFont(BufferView * bv, LyXParagraph * par,
+ LyXParagraph::size_type pos, LyXFont const & fnt,
+ bool toggleall)
+{
+ Buffer const * buf = bv->buffer();
+ LyXFont font = GetFont(buf, par, pos);
+ font.update(fnt, buf->params.language, toggleall);
+ // Let the insets convert their font
+ if (par->GetChar(pos) == LyXParagraph::META_INSET) {
+ Inset * inset = par->GetInset(pos);
+ if (inset) {
+ if (inset->Editable()==Inset::HIGHLY_EDITABLE) {
+ UpdatableInset * uinset = static_cast<UpdatableInset *>(inset);
+ uinset->SetFont(bv, fnt, toggleall, true);
+ }
+ font = inset->ConvertFont(font);
+ }
+ }
+
+ LyXLayout const & layout =
+ textclasslist.Style(buf->params.textclass,
+ par->GetLayout());
+
+ // Get concrete layout font to reduce against
+ LyXFont layoutfont;
+
+ if (pos < BeginningOfMainBody(buf, par))
+ layoutfont = layout.labelfont;
+ else
+ layoutfont = layout.font;
+
+ // Realize against environment font information
+ if (par->GetDepth()){
+ LyXParagraph * tp = par;
+ while (!layoutfont.resolved() && tp && tp->GetDepth()) {
+ tp = tp->DepthHook(tp->GetDepth()-1);
+ if (tp)
+ layoutfont.realize(textclasslist.
+ Style(buf->params.textclass,
+ tp->GetLayout()).font);
+ }
+ }
+
+ layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+
+ // Now, reduce font against full layout font
+ font.reduce(layoutfont);
+
+ par->SetFont(pos, font);
+}
+