-#if !USING_NEW_PREVIEW_STY
-double setFontScalingFactor(Buffer & buffer)
-{
- double scale_factor = 0.01 * lyxrc.dpi * lyxrc.zoom *
- lyxrc.preview_scale_factor;
-
- // Has the font size been set explicitly?
- string const & fontsize = buffer.params.fontsize;
- lyxerr[Debug::GRAPHICS] << "PreviewLoader::scaleToFitLyXView()\n"
- << "font size is " << fontsize << endl;
-
- if (isStrUnsignedInt(fontsize))
- return 10.0 * scale_factor / strToDbl(fontsize);
-
- // No. We must extract it from the LaTeX class file.
- LyXTextClass const & tclass = buffer.params.getLyXTextClass();
- string const textclass(tclass.latexname() + ".cls");
- string const classfile(findtexfile(textclass, "cls"));
-
- lyxerr[Debug::GRAPHICS] << "text class is " << textclass << '\n'
- << "class file is " << classfile << endl;
-
- ifstream ifs(classfile.c_str());
- if (!ifs.good()) {
- lyxerr[Debug::GRAPHICS] << "Unable to open class file!" << endl;
- return scale_factor;
- }
-
- string str;
- double scaling = scale_factor;
-
- while (ifs.good()) {
- getline(ifs, str);
- // To get the default font size, look for a line like
- // "\ExecuteOptions{letterpaper,10pt,oneside,onecolumn,final}"
- if (!prefixIs(ltrim(str), "\\ExecuteOptions"))
- continue;
-
- // str contains just the options of \ExecuteOptions
- string const tmp = split(str, '{');
- split(tmp, str, '}');
-
- int count = 0;
- string tok = token(str, ',', count++);
- while (!isValidLength(tok) && !tok.empty())
- tok = token(str, ',', count++);
-
- if (!tok.empty()) {
- lyxerr[Debug::GRAPHICS]
- << "Extracted default font size from "
- "LaTeX class file successfully!" << endl;
- LyXLength fsize(tok);
- scaling *= 10.0 / fsize.value();
- break;
- }
- }
-
- return scaling;
-}
-#endif
-
-