[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-devel
Subject:    Re: Experience using XeTeX with XeTeX?
From:       Jürgen Spitzmüller <j.spitzmueller () gmx ! de>
Date:       2008-10-08 20:38:19
Message-ID: gcj5nr$nhe$1 () ger ! gmane ! org
[Download RAW message or body]

Uwe Stöhr wrote:
> MiKTeX updates the XeTeX version evey month, 
> while TeXLive will only do this once a year. This could make problems.

I don't think this is true. Binary packages are regularly updated via the TeXLive \
manager.

> > Moving to XeTeX would increase the potential user base of LyX and
> > suppress all the weird problems when an user manage to type something in
> > Arabic / Hebrew/ ... but cannot print it because the correct LaTeX fonts
> > are not installed.

I would not talk of "moving". We should provide support for XeTeX, but not at the \
price of dropping support for other LaTeX variants. There will always be enough \
reasons to not use XeTeX (as long as it misses support for micro typographic \
extensions, I will not use it, for instance).

Also, most "goodies" of XeTeX will eventually also be available in pdftex2 a.k.a. \
LuaTeX. There's no reason why we should not provide alternatives.

> I absolutely agree, but it will take a while until XeTeX is stable enough
> to use it for LyX. Nevertheless I will have a look at this in LyX's 1.7
> development cycle.

FWIW, attached is what I have done so far. This is basic XeTeX support. You can \
select fonts and it sets a few things. Yet quite some stuff is missing, and I have \
not tested it beyond very simple documents. Not least, it's a file format change.

But this is 1.7 stuff anyway.

Jürgen


["xetex.diff" (text/x-patch)]

Index: src/BufferParams.h
===================================================================
--- src/BufferParams.h	(Revision 26816)
+++ src/BufferParams.h	(Arbeitskopie)
@@ -189,6 +189,8 @@
 	std::string fontsTypewriter;
 	/// the default family (rm, sf, tt)
 	std::string fontsDefaultFamily;
+	/// use the XeTeX processor
+	bool useXetex;
 	/// use expert Small Caps
 	bool fontsSC;
 	/// use Old Style Figures
@@ -309,11 +311,14 @@
 	/// handle inputenc etc.
 	void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
 					      TexRow & texrow) const;
+	///
+	std::string const parseFontName(std::string const & name) const;
 	/// set up the document fonts
 	std::string const loadFonts(std::string const & rm,
 				     std::string const & sf, std::string const & tt,
 				     bool const & sc, bool const & osf,
-				     int const & sfscale, int const & ttscale) const;
+				     int const & sfscale, int const & ttscale,
+				     bool const & xetex) const;
 
 	/// get the appropriate cite engine (natbib handling)
 	CiteEngine citeEngine() const;
Index: src/frontends/qt4/GuiDocument.h
===================================================================
--- src/frontends/qt4/GuiDocument.h	(Revision 26816)
+++ src/frontends/qt4/GuiDocument.h	(Arbeitskopie)
@@ -69,6 +69,7 @@
 	void apply(BufferParams & params);
 
 	void updateFontsize(std::string const &, std::string const &);
+	void updateFontlist();
 	void updatePagestyle(std::string const &, std::string const &);
 
 	void showPreamble();
@@ -94,7 +95,8 @@
 	void browseMaster();
 	void classChanged();
 	void updateModuleInfo();
-
+	void xetexChanged(bool);
+	
 private:
 	/// validate listings parameters and return an error message, if any
 	QString validateListingsParameters();
Index: src/frontends/qt4/GuiDocument.cpp
===================================================================
--- src/frontends/qt4/GuiDocument.cpp	(Revision 26816)
+++ src/frontends/qt4/GuiDocument.cpp	(Arbeitskopie)
@@ -53,6 +53,7 @@
 
 #include <QAbstractItemModel>
 #include <QCloseEvent>
+#include <QFontDatabase>
 #include <QScrollBar>
 #include <QTextCursor>
 
@@ -641,25 +642,12 @@
 		this, SLOT(change_adaptor()));
 	connect(fontModule->fontOsfCB, SIGNAL(clicked()),
 		this, SLOT(change_adaptor()));
+	connect(fontModule->xetexCB, SIGNAL(clicked()),
+		this, SLOT(change_adaptor()));
+	connect(fontModule->xetexCB, SIGNAL(toggled(bool)),
+		this, SLOT(xetexChanged(bool)));
 
-	for (int n = 0; tex_fonts_roman[n][0]; ++n) {
-		QString font = qt_(tex_fonts_roman_gui[n]);
-		if (!isFontAvailable(tex_fonts_roman[n]))
-			font += qt_(" (not installed)");
-		fontModule->fontsRomanCO->addItem(font);
-	}
-	for (int n = 0; tex_fonts_sans[n][0]; ++n) {
-		QString font = qt_(tex_fonts_sans_gui[n]);
-		if (!isFontAvailable(tex_fonts_sans[n]))
-			font += qt_(" (not installed)");
-		fontModule->fontsSansCO->addItem(font);
-	}
-	for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
-		QString font = qt_(tex_fonts_monospaced_gui[n]);
-		if (!isFontAvailable(tex_fonts_monospaced[n]))
-			font += qt_(" (not installed)");
-		fontModule->fontsTypewriterCO->addItem(font);
-	}
+	updateFontlist();
 
 	fontModule->fontsizeCO->addItem(qt_("Default"));
 	fontModule->fontsizeCO->addItem(qt_("10"));
@@ -1112,11 +1100,13 @@
 		setSkip(textLayoutModule->skipCO->currentIndex());
 }
 
+
 void GuiDocument::portraitChanged()
 {
 	setMargins(pageLayoutModule->papersizeCO->currentIndex());
 }
 
+
 void GuiDocument::setMargins(bool custom)
 {
 	marginsModule->marginCB->setChecked(custom);
@@ -1182,6 +1172,16 @@
 }
 
 
+void GuiDocument::xetexChanged(bool xetex)
+{
+	updateFontlist();
+	langModule->encodingCO->setEnabled(!xetex &&
+		!langModule->defaultencodingRB->isChecked());
+	langModule->defaultencodingRB->setEnabled(!xetex);
+	langModule->otherencodingRB->setEnabled(!xetex);
+}
+
+
 void GuiDocument::updateFontsize(string const & items, string const & sel)
 {
 	fontModule->fontsizeCO->clear();
@@ -1200,8 +1200,55 @@
 }
 
 
+void GuiDocument::updateFontlist()
+{
+	fontModule->fontsRomanCO->clear();
+	fontModule->fontsSansCO->clear();
+	fontModule->fontsTypewriterCO->clear();
+
+	// With XeTeX, we have access to all system fonts, but not the LaTeX fonts
+	if (fontModule->xetexCB->isChecked()) {
+		fontModule->fontsRomanCO->addItem(qt_("Default"));
+		fontModule->fontsSansCO->addItem(qt_("Default"));
+		fontModule->fontsTypewriterCO->addItem(qt_("Default"));
+	
+		QFontDatabase fontdb;
+		QStringList families(fontdb.families());
+		for (QStringList::Iterator it = families.begin(); it != families.end(); ++it) {
+			fontModule->fontsRomanCO->addItem(*it);
+			fontModule->fontsSansCO->addItem(*it);
+			fontModule->fontsTypewriterCO->addItem(*it);
+		}
+		return;
+	}
+
+	for (int n = 0; tex_fonts_roman[n][0]; ++n) {
+		QString font = qt_(tex_fonts_roman_gui[n]);
+		if (!isFontAvailable(tex_fonts_roman[n]))
+			font += qt_(" (not installed)");
+		fontModule->fontsRomanCO->addItem(font);
+	}
+	for (int n = 0; tex_fonts_sans[n][0]; ++n) {
+		QString font = qt_(tex_fonts_sans_gui[n]);
+		if (!isFontAvailable(tex_fonts_sans[n]))
+			font += qt_(" (not installed)");
+		fontModule->fontsSansCO->addItem(font);
+	}
+	for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
+		QString font = qt_(tex_fonts_monospaced_gui[n]);
+		if (!isFontAvailable(tex_fonts_monospaced[n]))
+			font += qt_(" (not installed)");
+		fontModule->fontsTypewriterCO->addItem(font);
+	}
+}
+
+
 void GuiDocument::romanChanged(int item)
 {
+	if (fontModule->xetexCB->isChecked()) {
+		fontModule->fontScCB->setEnabled(false);
+		return;
+	}
 	string const font = tex_fonts_roman[item];
 	fontModule->fontScCB->setEnabled(providesSC(font));
 	fontModule->fontOsfCB->setEnabled(providesOSF(font));
@@ -1210,6 +1257,10 @@
 
 void GuiDocument::sansChanged(int item)
 {
+	if (fontModule->xetexCB->isChecked()) {
+		fontModule->fontScCB->setEnabled(false);
+		return;
+	}
 	string const font = tex_fonts_sans[item];
 	bool scaleable = providesScale(font);
 	fontModule->scaleSansSB->setEnabled(scaleable);
@@ -1219,6 +1270,10 @@
 
 void GuiDocument::ttChanged(int item)
 {
+	if (fontModule->xetexCB->isChecked()) {
+		fontModule->fontScCB->setEnabled(false);
+		return;
+	}
 	string const font = tex_fonts_monospaced[item];
 	bool scaleable = providesScale(font);
 	fontModule->scaleTypewriterSB->setEnabled(scaleable);
@@ -1709,14 +1764,38 @@
 	params.float_placement = floatModule->get();
 
 	// fonts
-	params.fontsRoman =
-		tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
+	bool const xetex = fontModule->xetexCB->isChecked();
 
-	params.fontsSans =
-		tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
+	params.useXetex = xetex;
 
-	params.fontsTypewriter =
-		tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
+	if (xetex) {
+		if (fontModule->fontsRomanCO->currentIndex() == 0)
+			params.fontsRoman = "default";
+		else
+			params.fontsRoman =
+				fromqstr(fontModule->fontsRomanCO->currentText());
+	
+		if (fontModule->fontsSansCO->currentIndex() == 0)
+			params.fontsSans = "default";
+		else
+			params.fontsSans =
+				fromqstr(fontModule->fontsSansCO->currentText());
+	
+		if (fontModule->fontsTypewriterCO->currentIndex() == 0)
+			params.fontsTypewriter = "default";
+		else
+			params.fontsTypewriter =
+				fromqstr(fontModule->fontsTypewriterCO->currentText());
+	} else {
+		params.fontsRoman =
+			tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
+	
+		params.fontsSans =
+			tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
+	
+		params.fontsTypewriter =
+			tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
+	}
 
 	params.fontsCJK =
 		fromqstr(fontModule->cjkFontLE->text());
@@ -2010,22 +2089,47 @@
 	updateFontsize(documentClass().opt_fontsize(),
 			params.fontsize);
 
-	int n = findToken(tex_fonts_roman, params.fontsRoman);
-	if (n >= 0) {
-		fontModule->fontsRomanCO->setCurrentIndex(n);
-		romanChanged(n);
-	}
+	fontModule->xetexCB->setChecked(params.useXetex);
 
-	n = findToken(tex_fonts_sans, params.fontsSans);
-	if (n >= 0)	{
-		fontModule->fontsSansCO->setCurrentIndex(n);
-		sansChanged(n);
-	}
+	if (params.useXetex) {
+		for (int i = 0; i < fontModule->fontsRomanCO->count(); ++i) {
+			if (fontModule->fontsRomanCO->itemText(i) == toqstr(params.fontsRoman)) {
+				fontModule->fontsRomanCO->setCurrentIndex(i);
+				return;
+			}
+		}
+		
+		for (int i = 0; i < fontModule->fontsSansCO->count(); ++i) {
+			if (fontModule->fontsSansCO->itemText(i) == toqstr(params.fontsSans)) {
+				fontModule->fontsSansCO->setCurrentIndex(i);
+				return;
+			}
+		}
 
-	n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
-	if (n >= 0) {
-		fontModule->fontsTypewriterCO->setCurrentIndex(n);
-		ttChanged(n);
+		for (int i = 0; i < fontModule->fontsTypewriterCO->count(); ++i) {
+			if (fontModule->fontsTypewriterCO->itemText(i) == toqstr(params.fontsTypewriter)) {
+				fontModule->fontsTypewriterCO->setCurrentIndex(i);
+				return;
+			}
+		}
+	} else {
+		int n = findToken(tex_fonts_roman, params.fontsRoman);
+		if (n >= 0) {
+			fontModule->fontsRomanCO->setCurrentIndex(n);
+			romanChanged(n);
+		}
+	
+		n = findToken(tex_fonts_sans, params.fontsSans);
+		if (n >= 0)	{
+			fontModule->fontsSansCO->setCurrentIndex(n);
+			sansChanged(n);
+		}
+	
+		n = findToken(tex_fonts_monospaced, params.fontsTypewriter);
+		if (n >= 0) {
+			fontModule->fontsTypewriterCO->setCurrentIndex(n);
+			ttChanged(n);
+		}
 	}
 
 	if (!params.fontsCJK.empty())
@@ -2038,9 +2142,9 @@
 	fontModule->fontOsfCB->setChecked(params.fontsOSF);
 	fontModule->scaleSansSB->setValue(params.fontsSansScale);
 	fontModule->scaleTypewriterSB->setValue(params.fontsTypewriterScale);
-	n = findToken(GuiDocument::fontfamilies, params.fontsDefaultFamily);
-	if (n >= 0)
-		fontModule->fontsDefaultCO->setCurrentIndex(n);
+	int nn = findToken(GuiDocument::fontfamilies, params.fontsDefaultFamily);
+	if (nn >= 0)
+		fontModule->fontsDefaultCO->setCurrentIndex(nn);
 
 	// paper
 	int const psize = params.papersize;
Index: src/frontends/qt4/GuiSendto.cpp
===================================================================
--- src/frontends/qt4/GuiSendto.cpp	(Revision 26816)
+++ src/frontends/qt4/GuiSendto.cpp	(Arbeitskopie)
@@ -176,6 +176,7 @@
 	if (buffer().isLatex()) {
 		exports.push_back("latex");
 		exports.push_back("pdflatex");
+		exports.push_back("xetex");
 	}
 	else if (buffer().isDocBook())
 		exports.push_back("docbook");
Index: src/frontends/qt4/ui/FontUi.ui
===================================================================
--- src/frontends/qt4/ui/FontUi.ui	(Revision 26816)
+++ src/frontends/qt4/ui/FontUi.ui	(Arbeitskopie)
@@ -5,94 +5,49 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>414</width>
-    <height>268</height>
+    <width>543</width>
+    <height>361</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string>FontUi</string>
   </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
-    <number>9</number>
-   </property>
-   <property name="spacing" >
-    <number>6</number>
-   </property>
-   <item row="8" column="0" colspan="4" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
+  <layout class="QGridLayout" name="gridLayout" >
+   <item row="0" column="0" >
+    <widget class="QCheckBox" name="xetexCB" >
+     <property name="toolTip" >
+      <string>Use the XeTeX processor, which allows access to all system fonts</string>
      </property>
-     <property name="sizeType" >
-      <enum>QSizePolicy::Expanding</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>391</width>
-       <height>16</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="5" column="0" >
-    <widget class="QLabel" name="cjkFontLA" >
      <property name="text" >
-      <string>C&amp;JK:</string>
+      <string>Use &amp;XeTeX</string>
      </property>
-     <property name="buddy" >
-      <cstring>cjkFontLE</cstring>
-     </property>
     </widget>
    </item>
-   <item row="5" column="1" >
-    <widget class="QLineEdit" name="cjkFontLE" >
-     <property name="toolTip" >
-      <string>Input the font to be used for Chinese, Japanese or Korean (CJK) script</string>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="2" colspan="2" >
-    <spacer>
+   <item row="1" column="0" colspan="4" >
+    <widget class="Line" name="line" >
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="sizeHint" >
-      <size>
-       <width>151</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
+    </widget>
    </item>
-   <item row="7" column="1" >
-    <widget class="QCheckBox" name="fontOsfCB" >
-     <property name="toolTip" >
-      <string>Use old style instead of lining figures</string>
-     </property>
+   <item row="2" column="0" >
+    <widget class="QLabel" name="fontsDefaultLA" >
      <property name="text" >
-      <string>Use &amp;Old Style Figures</string>
+      <string>&amp;Default Family:</string>
      </property>
-    </widget>
-   </item>
-   <item row="6" column="1" >
-    <widget class="QCheckBox" name="fontScCB" >
-     <property name="toolTip" >
-      <string>Use a real small caps shape, if the font provides one</string>
+     <property name="buddy" >
+      <cstring>fontsDefaultCO</cstring>
      </property>
-     <property name="text" >
-      <string>Use true S&amp;mall Caps</string>
-     </property>
     </widget>
    </item>
-   <item row="0" column="1" >
+   <item row="2" column="1" >
     <widget class="QComboBox" name="fontsDefaultCO" >
      <property name="toolTip" >
       <string>Select the default family for the document</string>
      </property>
     </widget>
    </item>
-   <item row="0" column="2" >
+   <item row="2" column="2" >
     <widget class="QLabel" name="TextLabel2_2" >
      <property name="text" >
       <string>&amp;Base Size:</string>
@@ -102,37 +57,57 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="3" >
+   <item row="2" column="3" >
     <widget class="QComboBox" name="fontsizeCO" >
      <property name="toolTip" >
       <string/>
      </property>
     </widget>
    </item>
-   <item row="0" column="0" >
-    <widget class="QLabel" name="fontsDefaultLA" >
+   <item row="3" column="1" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>182</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="4" column="0" >
+    <widget class="QLabel" name="fontsRomanLA" >
      <property name="text" >
-      <string>&amp;Default Family:</string>
+      <string>&amp;Roman:</string>
      </property>
      <property name="buddy" >
-      <cstring>fontsDefaultCO</cstring>
+      <cstring>fontsRomanCO</cstring>
      </property>
     </widget>
    </item>
-   <item row="1" column="1" >
+   <item row="4" column="1" >
+    <widget class="QComboBox" name="fontsRomanCO" >
+     <property name="toolTip" >
+      <string>Select the roman (serif) typeface</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="2" colspan="2" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
-       <width>182</width>
-       <height>16</height>
+       <width>131</width>
+       <height>20</height>
       </size>
      </property>
     </spacer>
    </item>
-   <item row="3" column="0" >
+   <item row="5" column="0" >
     <widget class="QLabel" name="fontsSansLA" >
      <property name="text" >
       <string>&amp;Sans Serif:</string>
@@ -142,14 +117,14 @@
      </property>
     </widget>
    </item>
-   <item row="3" column="1" >
+   <item row="5" column="1" >
     <widget class="QComboBox" name="fontsSansCO" >
      <property name="toolTip" >
       <string>Select the Sans Serif (grotesque) typeface</string>
      </property>
     </widget>
    </item>
-   <item row="3" column="2" >
+   <item row="5" column="2" >
     <widget class="QLabel" name="scaleSansLA" >
      <property name="text" >
       <string>S&amp;cale (%):</string>
@@ -159,37 +134,20 @@
      </property>
     </widget>
    </item>
-   <item row="3" column="3" >
+   <item row="5" column="3" >
     <widget class="QSpinBox" name="scaleSansSB" >
      <property name="toolTip" >
       <string>Scale the Sans Serif font to match the base font's dimensions</string>
      </property>
-     <property name="maximum" >
-      <number>200</number>
-     </property>
      <property name="minimum" >
       <number>10</number>
      </property>
-    </widget>
-   </item>
-   <item row="2" column="0" >
-    <widget class="QLabel" name="fontsRomanLA" >
-     <property name="text" >
-      <string>&amp;Roman:</string>
+     <property name="maximum" >
+      <number>200</number>
      </property>
-     <property name="buddy" >
-      <cstring>fontsRomanCO</cstring>
-     </property>
     </widget>
    </item>
-   <item row="2" column="1" >
-    <widget class="QComboBox" name="fontsRomanCO" >
-     <property name="toolTip" >
-      <string>Select the roman (serif) typeface</string>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="0" >
+   <item row="6" column="0" >
     <widget class="QLabel" name="fontsTypewriterLA" >
      <property name="text" >
       <string>&amp;Typewriter:</string>
@@ -199,14 +157,14 @@
      </property>
     </widget>
    </item>
-   <item row="4" column="1" >
+   <item row="6" column="1" >
     <widget class="QComboBox" name="fontsTypewriterCO" >
      <property name="toolTip" >
       <string>Select the typewriter (monospaced) typeface</string>
      </property>
     </widget>
    </item>
-   <item row="4" column="2" >
+   <item row="6" column="2" >
     <widget class="QLabel" name="scaleTypewriterLA" >
      <property name="text" >
       <string>Sc&amp;ale (%):</string>
@@ -216,32 +174,85 @@
      </property>
     </widget>
    </item>
-   <item row="4" column="3" >
+   <item row="6" column="3" >
     <widget class="QSpinBox" name="scaleTypewriterSB" >
      <property name="toolTip" >
       <string>Scale the Typewriter font to match the base font's dimensions</string>
      </property>
+     <property name="minimum" >
+      <number>10</number>
+     </property>
      <property name="maximum" >
       <number>200</number>
      </property>
-     <property name="minimum" >
-      <number>10</number>
+    </widget>
+   </item>
+   <item row="7" column="0" >
+    <widget class="QLabel" name="cjkFontLA" >
+     <property name="text" >
+      <string>C&amp;JK:</string>
      </property>
+     <property name="buddy" >
+      <cstring>cjkFontLE</cstring>
+     </property>
     </widget>
    </item>
-   <item row="2" column="2" colspan="2" >
+   <item row="7" column="1" >
+    <widget class="QLineEdit" name="cjkFontLE" >
+     <property name="toolTip" >
+      <string>Input the font to be used for Chinese, Japanese or Korean (CJK) script</string>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="2" colspan="2" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
-       <width>131</width>
+       <width>151</width>
        <height>20</height>
       </size>
      </property>
     </spacer>
    </item>
+   <item row="8" column="1" >
+    <widget class="QCheckBox" name="fontScCB" >
+     <property name="toolTip" >
+      <string>Use a real small caps shape, if the font provides one</string>
+     </property>
+     <property name="text" >
+      <string>Use true S&amp;mall Caps</string>
+     </property>
+    </widget>
+   </item>
+   <item row="9" column="1" >
+    <widget class="QCheckBox" name="fontOsfCB" >
+     <property name="toolTip" >
+      <string>Use old style instead of lining figures</string>
+     </property>
+     <property name="text" >
+      <string>Use &amp;Old Style Figures</string>
+     </property>
+    </widget>
+   </item>
+   <item row="10" column="0" colspan="4" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>391</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
   </layout>
  </widget>
  <layoutdefault spacing="6" margin="11" />
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(Revision 26816)
+++ src/Buffer.cpp	(Arbeitskopie)
@@ -2500,8 +2500,10 @@
 	if (params().baseClass()->isTeXClassAvailable()) {
 		v.push_back(bufferFormat());
 		// FIXME: Don't hardcode format names here, but use a flag
-		if (v.back() == "latex")
+		if (v.back() == "latex") {
 			v.push_back("pdflatex");
+			v.push_back("xetex");
+		}
 	}
 	v.push_back("text");
 	v.push_back("lyx");
Index: src/BufferParams.cpp
===================================================================
--- src/BufferParams.cpp	(Revision 26816)
+++ src/BufferParams.cpp	(Arbeitskopie)
@@ -92,6 +92,7 @@
 };
 
 
+
 namespace lyx {
 
 // Local translators
@@ -269,7 +270,6 @@
 	return translator;
 }
 
-
 } // anon namespace
 
 
@@ -342,6 +342,7 @@
 	fontsSans = "default";
 	fontsTypewriter = "default";
 	fontsDefaultFamily = "default";
+	useXetex = false;
 	fontsSC = false;
 	fontsOSF = false;
 	fontsSansScale = 100;
@@ -505,13 +506,18 @@
 	} else if (token == "\\graphics") {
 		readGraphicsDriver(lex);
 	} else if (token == "\\font_roman") {
-		lex >> fontsRoman;
+		lex.eatLine();
+		fontsRoman = lex.getString();
 	} else if (token == "\\font_sans") {
-		lex >> fontsSans;
+		lex.eatLine();
+		fontsSans = lex.getString();
 	} else if (token == "\\font_typewriter") {
-		lex >> fontsTypewriter;
+		lex.eatLine();
+		fontsTypewriter = lex.getString();
 	} else if (token == "\\font_default_family") {
 		lex >> fontsDefaultFamily;
+	} else if (token == "\\use_xetex") {
+		lex >> useXetex;
 	} else if (token == "\\font_sc") {
 		lex >> fontsSC;
 	} else if (token == "\\font_osf") {
@@ -734,6 +740,7 @@
 	   << "\n\\font_sans " << fontsSans
 	   << "\n\\font_typewriter " << fontsTypewriter
 	   << "\n\\font_default_family " << fontsDefaultFamily
+	   << "\n\\use_xetex " << convert<string>(useXetex)
 	   << "\n\\font_sc " << convert<string>(fontsSC)
 	   << "\n\\font_osf " << convert<string>(fontsOSF)
 	   << "\n\\font_sf_scale " << fontsSansScale
@@ -929,6 +936,9 @@
 			features.require("color");
 	}
 
+	if (useXetex)
+		features.require("xetex");
+
 	if (language->lang() == "vietnamese")
 		features.require("vietnamese");
 	else if (language->lang() == "japanese")
@@ -1062,11 +1072,20 @@
 	texrow.newline();
 	// end of \documentclass defs
 
+	if (useXetex) {
+		os << "\\usepackage{fontspec}\n";
+		texrow.newline();
+		os << "\\usepackage{xunicode}\n";
+		texrow.newline();
+		os << "\\usepackage{xltxtra}\n";
+		texrow.newline();
+	}
+
 	// font selection must be done before loading fontenc.sty
 	string const fonts =
 		loadFonts(fontsRoman, fontsSans,
 			  fontsTypewriter, fontsSC, fontsOSF,
-			  fontsSansScale, fontsTypewriterScale);
+			  fontsSansScale, fontsTypewriterScale, useXetex);
 	if (!fonts.empty()) {
 		os << from_ascii(fonts);
 		texrow.newline();
@@ -1079,7 +1098,9 @@
 	// this one is not per buffer
 	// for arabic_arabi and farsi we also need to load the LAE and
 	// LFE encoding
-	if (lyxrc.fontenc != "default" && language->lang() != "japanese") {
+	// XeteX works without fontenc
+	if (lyxrc.fontenc != "default" && language->lang() != "japanese"
+	    && !useXetex) {
 		if (language->lang() == "arabic_arabi"
 		    || language->lang() == "farsi") {
 			os << "\\usepackage[" << from_ascii(lyxrc.fontenc)
@@ -1892,6 +1913,8 @@
 void BufferParams::writeEncodingPreamble(odocstream & os,
 		LaTeXFeatures & features, TexRow & texrow) const
 {
+	if (useXetex)
+		return;
 	if (inputenc == "auto") {
 		string const doc_encoding =
 			language->encoding()->latexName();
@@ -1962,10 +1985,22 @@
 }
 
 
+string const BufferParams::parseFontName(string const & name) const
+{
+	string mangled = name;
+	size_t const idx = mangled.find('[');
+	if (idx == string::npos || idx == 0)
+		return mangled;
+	else
+		return mangled.substr(0, idx - 1);
+}
+
+
 string const BufferParams::loadFonts(string const & rm,
 				     string const & sf, string const & tt,
 				     bool const & sc, bool const & osf,
-				     int const & sfscale, int const & ttscale) const
+				     int const & sfscale, int const & ttscale,
+				     bool const & xetex) const
 {
 	/* The LaTeX font world is in a flux. In the PSNFSS font interface,
 	   several packages have been replaced by others, that might not
@@ -1985,6 +2020,37 @@
 
 	ostringstream os;
 
+	if (xetex) {
+		if (rm != "default")
+			os << "\\setmainfont[Mapping=tex-text]{"
+			   << parseFontName(rm) << "}\n";
+		if (sf != "default") {
+			string const sans = parseFontName(sf);
+			if (sfscale != 100)
+				os << "\\setsansfont[Scale=" 
+				   << float(sfscale) / 100 
+				   << ",Mapping=tex-text]{"
+				   << sans << "}\n";
+			else
+				os << "\\setsansfont[Mapping=tex-text]{"
+				   << sans << "}\n";
+		}
+		if (tt != "default") {
+			string const mono = parseFontName(tt);
+			if (ttscale != 100)
+				os << "\\setmonofont[Scale=" 
+				   << float(sfscale) / 100 
+				   << "]{"
+				   << mono << "}\n";
+			else
+				os << "\\setmonofont[Mapping=tex-text]{"
+				   << mono << "}\n";
+		}
+		if (osf)
+			os << "\\defaultfontfeatures{Numbers=OldStyle}\n";
+		return os.str();
+	}
+
 	// ROMAN FONTS
 	// Computer Modern (must be explicitely selectable -- there might be classes
 	// that define a different default font!
@@ -2101,6 +2167,8 @@
 
 Encoding const & BufferParams::encoding() const
 {
+	if (useXetex)
+		return *(encodings.fromLaTeXName("utf8-plain"));
 	if (inputenc == "auto" || inputenc == "default")
 		return *language->encoding();
 	Encoding const * const enc = encodings.fromLaTeXName(inputenc);



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic