the patch to get the default fontsize from the classfile if the "default" was chosen from inside LyX.
Herbert -- http://www.lyx.org/help/
? PreviewLoader.o.lock Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/ChangeLog,v retrieving revision 1.86 diff -u -r1.86 ChangeLog --- ChangeLog 8 Jul 2002 13:01:09 -0000 1.86 +++ ChangeLog 8 Jul 2002 16:50:45 -0000 @@ -1,3 +1,8 @@ +2002-07-08 Herbert Voss <[EMAIL PROTECTED]> + + * PreviewLoader.C: use of preview_size_factor to get the right + font-size! 0.9 is the default. + 2002-07-08 Angus Leeming <[EMAIL PROTECTED]> * PreviewLoader.C: Add "delayed" and "showlabels" options to the Index: PreviewLoader.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/PreviewLoader.C,v retrieving revision 1.5 diff -u -r1.5 PreviewLoader.C --- PreviewLoader.C 8 Jul 2002 13:01:09 -0000 1.5 +++ PreviewLoader.C 8 Jul 2002 16:50:46 -0000 @@ -18,6 +18,7 @@ #include "buffer.h" #include "bufferparams.h" +#include "lyxtextclasslist.h" #include "converter.h" #include "debug.h" #include "lyxrc.h" @@ -49,6 +50,7 @@ using std::sort; using std::map; +using std::ifstream; using std::ofstream; using std::ostream; using std::pair; @@ -57,6 +59,7 @@ namespace { typedef pair<string, string> StrPair; +float preview_size_factor; struct CompSecond { bool operator()(StrPair const & lhs, StrPair const & rhs) @@ -428,7 +431,7 @@ // The conversion command. ostringstream cs; cs << pconverter_->command << " " << latexfile << " " - << tostr(0.01 * lyxrc.dpi * lyxrc.zoom); + << tostr(int(::preview_size_factor * 0.01 * lyxrc.dpi * lyxrc.zoom)); string const command = cs.str().c_str(); @@ -520,6 +523,58 @@ // Dump the preamble only. tmp.makeLaTeXFile(os, string(), true, false, true); + /* build the correct size_factor for the preview + \documentclass[xxpt]{anything}, divide by xxpt + without a defines fontsize we have to scan the classfile + for the dewfault setting */ + LyXTextClass const & tclass = textclasslist[tmp.params.textclass]; + string const textclass_(tclass.latexname() + ".cls"); + string const fontsize_(tmp.params.fontsize + "pt"); + lyxerr[Debug::GRAPHICS] + << "PreviewLoader::textclass = " << textclass_ + << "\n\tfontsize = " << fontsize_ << endl; + + if (!isValidLength(fontsize_)) { + // get the default fontsize from the classfile + string const filename(findtexfile(textclass_, "cls")); + lyxerr[Debug::GRAPHICS] + << "\tdefault fontsize -> I look into the classfile " + << filename << endl; + if (!IsFileReadable(filename)) { + lyxerr[Debug::GRAPHICS] + << "\tcan't read classfile; I choose factor 0.9\n"; + ::preview_size_factor = 0.9; + } else { + ifstream ifs(filename.c_str()); + string str; + bool ready = false; + while (!ready) { + getline(ifs, str); + // looking for a line like + // +"\ExecuteOptions{letterpaper,10pt,oneside,onecolumn,final}" + // to get the default font size + if (contains(str, "\\ExecuteOptions")) { + str = split(str, '{'); + int count = 0; + string tok = token(str, ',', count++); + lyxerr[Debug::GRAPHICS] << tok << endl; + while (!isValidLength(tok) && !tok.empty()) + tok = token(str, ',', count++); + if (!tok.empty()) { + LyXLength fsize(tok); + ::preview_size_factor = 9.0 / +fsize.value(); + } else // all others with default are set to +1.0 + ::preview_size_factor = 1.0 ; + ready = true; + } + } + } + } else + ::preview_size_factor = 9.0 / strToDbl(fontsize_) ; + lyxerr[Debug::GRAPHICS] + << "PreviewLoader::preview_size_factor = " + << preview_size_factor << endl; + // Loop over the insets in the buffer and dump all the math-macros. Buffer::inset_iterator it = buffer_.inset_const_iterator_begin(); Buffer::inset_iterator end = buffer_.inset_const_iterator_end(); @@ -543,7 +598,7 @@ string bg = lyx_gui::hexname(LColor::background); if (bg.empty()) bg = "ffffff"; - + os << "\\AtBeginDocument{\\AtBeginDvi{%\n" << "\\special{!userdict begin/bop-hook{//bop-hook exec\n" << "<" << fg << bg << ">{255 div}forall setrgbcolor\n"