+string const LaTeXFont::getLaTeXCode(bool dryrun, bool ot1, bool complete, bool sc,
+ bool osf, bool nomath, int const & scale)
+{
+ ostringstream os;
+
+ docstring const usedfont = getUsedFont(ot1, complete, nomath);
+ if (usedfont.empty())
+ return string();
+ else if (usedfont != name_)
+ return altFont(usedfont).getLaTeXCode(dryrun, ot1, complete, sc, osf, nomath, scale);
+
+ if (switchdefault_) {
+ if (family_.empty()) {
+ LYXERR0("Error: Font `" << name_ << "' has no family defined!");
+ return string();
+ }
+ if (available(ot1, nomath) || dryrun)
+ os << "\\renewcommand{\\" << to_ascii(family_) << "default}{"
+ << to_ascii(name_) << "}\n";
+ else
+ frontend::Alert::warning(_("Font not available"),
+ bformat(_("The LaTeX package `%1$s' needed for the font `%2$s'\n"
+ "is not available on your system. LyX will fall back to the default font."),
+ requires_, guiname_), true);
+ } else {
+ string const package =
+ getAvailablePackage(dryrun);
+ string const packageopts = getPackageOptions(ot1, complete, sc, osf, scale, nomath);
+ if (packageopts.empty() && !package.empty())
+ os << "\\usepackage{" << package << "}\n";
+ else if (!packageopts.empty() && !package.empty())
+ os << "\\usepackage[" << packageopts << "]{" << package << "}\n";
+ }
+ if (osf && providesOSF(ot1, complete, nomath) && !osffont_.empty())
+ os << altFont(osffont_).getLaTeXCode(dryrun, ot1, complete, sc, osf, nomath, scale);
+
+ if (!preamble_.empty())
+ os << to_utf8(preamble_);
+
+ return os.str();
+}
+
+