]> git.lyx.org Git - features.git/commitdiff
preamble.cpp: correct recognition of all cases of font scalings (fix for method intro...
authorUwe Stöhr <uwestoehr@web.de>
Thu, 6 Dec 2007 22:09:31 +0000 (22:09 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Thu, 6 Dec 2007 22:09:31 +0000 (22:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21994 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/preamble.cpp

index b2ad48c85697509f985703fae5f7050acc366ce5..1b59214a7436543c71ac4dc7ea51ce356e3e7774 100644 (file)
@@ -18,6 +18,7 @@
 #include "Layout.h"
 #include "Lexer.h"
 #include "TextClass.h"
+#include "support/convert.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
 
@@ -42,6 +43,7 @@ using std::find;
 
 using support::FileName;
 using support::libFileSearch;
+using support::isStrDbl;
 
 // special columntypes
 extern std::map<char, int> special_columns;
@@ -218,8 +220,17 @@ void handle_package(string const & name, string const & opts)
                h_font_sans = name;
                if (!opts.empty()) {
                        scale = opts;
-                       pos = scale.find(".");
-                       h_font_sf_scale = scale.erase(0, pos + 1);
+                       // the option is in the form "scaled=0.9"
+                       // therefore cut of before the "="
+                       pos = scale.find("=");
+                       if (pos != string::npos) { 
+                               scale.erase(0, pos + 1);
+                               if (isStrDbl(scale)) {
+                                       // LyX needs the scale as integer, therfore multiply by 100
+                                       scale = convert<string>(100 * convert<double>(scale));
+                                       h_font_sf_scale = scale;
+                               }
+                       }
                }
        }
        // typewriter fonts
@@ -227,8 +238,17 @@ void handle_package(string const & name, string const & opts)
                h_font_typewriter = name;
                if (!opts.empty()) {
                        scale = opts;
-                       pos = scale.find(".");
-                       h_font_tt_scale = scale.erase(0, pos + 1);
+                       // the option is in the form "scaled=0.9"
+                       // therefore cut of before the "="
+                       pos = scale.find("=");
+                       if (pos != string::npos) { 
+                               scale.erase(0, pos + 1);
+                               if (isStrDbl(scale)) {
+                                       // LyX needs the scale as integer, therfore multiply by 100
+                                       scale = convert<string>(100 * convert<double>(scale));
+                                       h_font_tt_scale = scale;
+                               }
+                       }
                }
        }
        // font uses old-style figure