The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 2e8ed3b3b5b8edefc0dc2a888ac0fa314f87618e
Author: Uwe Stöhr <[email protected]>
Date:   Tue Jun 26 00:46:02 2012 +0200

    tex2lyx: support fontspec scale option
    
    Preamble.cpp:
     - support the font scaling
     - improve coding style
    
    text.cpp: - improve logic/coding style
    
    XeTeX-polyglossia.tex:
     - add scaling
     - change document so that it is compilable using the Libertine font

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index b40bf8f..e4dc488 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -1158,12 +1158,13 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
                                // check if the option contains a variant, if 
yes, extract it
                                string::size_type pos_var = 
langopts.find("variant");
                                string::size_type i = langopts.find(',', 
pos_var);
+                               string::size_type k = langopts.find('=', 
pos_var);
                                if (pos_var != string::npos){
                                        string variant;
                                        if (i == string::npos)
-                                               variant = 
langopts.substr(pos_var + 8, langopts.length() - pos_var - 9);
+                                               variant = langopts.substr(k + 
1, langopts.length() - k - 2);
                                        else
-                                               variant = 
langopts.substr(pos_var + 8, i - pos_var - 8);
+                                               variant = langopts.substr(k + 
1, i - k - 1);
                                        h_language = variant;
                                }
                                p.verbatim_item();
@@ -1186,16 +1187,30 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
                        h_font_roman = p.getArg('{', '}');
                }
 
-               else if (t.cs() == "setsansfont") {
-                       // we don't care about the option
-                       p.hasOpt() ? p.getOpt() : string();
-                       h_font_sans = p.getArg('{', '}');
-               }
-
-               else if (t.cs() == "setmonofont") {
-                       // we don't care about the option
-                       p.hasOpt() ? p.getOpt() : string();
-                       h_font_typewriter = p.getArg('{', '}');
+               else if (t.cs() == "setsansfont" || t.cs() == "setmonofont") {
+                       // LyX currently only supports the scale option
+                       string scale;
+                       if (p.hasOpt()) {
+                               string fontopts = p.getArg('[', ']');
+                               // check if the option contains a scaling, if 
yes, extract it
+                               string::size_type pos = fontopts.find("Scale");
+                               if (pos != string::npos) {
+                                       string::size_type i = 
fontopts.find(',');
+                                       if (i == string::npos)
+                                               scale = 
scale_as_percentage(fontopts.substr(pos + 1));
+                                       else
+                                               scale = 
scale_as_percentage(fontopts.substr(pos, i - pos));
+                               }
+                       }
+                       if (t.cs() == "setsansfont") {
+                               if (!scale.empty())
+                                       h_font_sf_scale = scale;
+                               h_font_sans = p.getArg('{', '}');
+                       } else {
+                               if (!scale.empty())
+                                       h_font_tt_scale = scale;
+                               h_font_typewriter = p.getArg('{', '}');
+                       }
                }
 
                else if (t.cs() == "date") {
diff --git a/src/tex2lyx/test/XeTeX-polyglossia.tex 
b/src/tex2lyx/test/XeTeX-polyglossia.tex
index fb783c6..95c4c82 100644
--- a/src/tex2lyx/test/XeTeX-polyglossia.tex
+++ b/src/tex2lyx/test/XeTeX-polyglossia.tex
@@ -1,8 +1,8 @@
 \documentclass{article}
 \usepackage{fontspec}
-\setmainfont{Aharoni}
-\setsansfont[Mapping=tex-text]{AngsanaUPC}
-\setmonofont{Arial Black}
+\setmainfont[Mapping=tex-text]{Linux Libertine O}
+\setsansfont[Mapping=tex-text,Scale=0.75]{Linux Biolinum O}
+\setmonofont{Linux Biolinum O}
 \usepackage{xunicode}
 \usepackage{polyglossia}
 \setdefaultlanguage[variant=british, ordinalmonthday = false]{english}
@@ -14,7 +14,7 @@
 \part{df}
 
 1 English \textgreek[variant=ancient]{ancient Greek} English
-\textgreek[numerals=arabic, variant=ancient]{ancient Greek with Arabic 
numerals} English
+\textgreek[numerals=arabic, variant=ancient]{ancient G\textsf{reek} with 
Arabic numerals} English
 
 \begin{albanian}%
 
@@ -23,13 +23,13 @@
 2 Albanian \textgreek{Greek} Albanian \textsc{smallcaps}
 
 \end{albanian}%
-\begin{syriac}%
+\begin{hebrew}%
 
 \part{df}
 
-3 Syriac
+3 Hebrew
 
-\end{syriac}%
+\end{hebrew}%
 
 %empty language paragraph
 \begin{albanian}%
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index beb37bd..6d32c8b 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -3585,17 +3585,14 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                                // check if the option contains a variant, if 
yes, extract it
                                string::size_type pos_var = 
langopts.find("variant");
                                string::size_type i = langopts.find(',');
-                               if (pos_var != string::npos){
+                               string::size_type k = langopts.find('=', 
pos_var);
+                               if (pos_var != string::npos && i == 
string::npos) {
                                        string variant;
-                                       if (i == string::npos) {
-                                               variant = 
langopts.substr(pos_var + 8, langopts.length() - pos_var - 9);
-                                               lang = polyglossia2lyx(variant);
-                                               parse_text_attributes(p, os, 
FLAG_ITEM, outer,
-                                                                         
context, "\\lang",
-                                                                         
context.font.language, lang);
-                                       }
-                                       else
-                                               handle_ert(os, t.asInput() + 
langopts, context);
+                                       variant = langopts.substr(k + 1, 
langopts.length() - k - 2);
+                                       lang = polyglossia2lyx(variant);
+                                       parse_text_attributes(p, os, FLAG_ITEM, 
outer,
+                                                                 context, 
"\\lang",
+                                                                 
context.font.language, lang);
                                } else
                                        handle_ert(os, t.asInput() + langopts, 
context);
                        } else {

-----------------------------------------------------------------------

Summary of changes:
 src/tex2lyx/Preamble.cpp               |   39 ++++++++++++++++++++++---------
 src/tex2lyx/test/XeTeX-polyglossia.tex |   14 +++++-----
 src/tex2lyx/text.cpp                   |   17 +++++--------
 3 files changed, 41 insertions(+), 29 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to