Add font option to w2l

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@217 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2014-11-15 12:34:00 +00:00
parent 837b6cf220
commit 7fdde6433b
3 changed files with 76 additions and 64 deletions

View file

@ -4,6 +4,7 @@ Changelog for Writer2LaTeX version 1.4 -> 1.6
[w2l] Added new option font to load font packages. It accepts a large number of standard font packages such as [w2l] Added new option font to load font packages. It accepts a large number of standard font packages such as
cmbright or fourier. Only packages with math support are included. Unknown packages defaults to Computer Modern. cmbright or fourier. Only packages with math support are included. Unknown packages defaults to Computer Modern.
The font option is currently not available for the backend xetex.
In the user interface, this option can be found in the export dialog. To make room for this, the BibTeX In the user interface, this option can be found in the export dialog. To make room for this, the BibTeX
settings no longer has a heading in the dialog. settings no longer has a heading in the dialog.

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.6 (2014-11-12) * Version 1.6 (2014-11-14)
* *
*/ */
@ -63,7 +63,7 @@ public class LaTeXOptionsDialog extends OptionsDialogBase {
"charter-mathdesign", "garamond-mathdesign", "utopia-mathdesign", "fourier" }; "charter-mathdesign", "garamond-mathdesign", "utopia-mathdesign", "fourier" };
private static final String[] FONT_NAMES = private static final String[] FONT_NAMES =
{ "Default (Computer Modern)", "CM Bright", "Concrete", "Concrete + Euler Math", { "Default (Computer Modern)", "CM Bright", "Concrete", "Concrete + Euler Math",
"Iwona", "Kurier", "Antykwa Torunska", "Kerkis", "Iwona", "Kurier", "Antykwa Toru\u0144ska", "Kerkis",
"New Century Schoolbook + Millennial Math", "New Century Schoolbook + Fourier Math", "New Century Schoolbook + Millennial Math", "New Century Schoolbook + Fourier Math",
"Palatino + PXfonts Math", "Palatino + Pazo Math", "Palatino + Euler Math", "Palatino + PXfonts Math", "Palatino + Pazo Math", "Palatino + Euler Math",
"Times + TXfonts Math", "Times + Belleek Math", "Times + Symbol", "Times + TXfonts Math", "Times + Belleek Math", "Times + Symbol",
@ -264,6 +264,10 @@ public class LaTeXOptionsDialog extends OptionsDialogBase {
// backend=xetex locks the encoding to utf8 // backend=xetex locks the encoding to utf8
return getListBoxSelectedItem("Backend")==3 || super.isLocked(sOptionName); return getListBoxSelectedItem("Backend")==3 || super.isLocked(sOptionName);
} }
else if ("font".equals(sOptionName)) {
// backend=xetex does not (currently) use the font option
return getListBoxSelectedItem("Backend")==3 || super.isLocked(sOptionName);
}
else if ("greek_math".equals(sOptionName)) { else if ("greek_math".equals(sOptionName)) {
// this option has no effect if backend=xetex // this option has no effect if backend=xetex
return getListBoxSelectedItem("Backend")==3 || super.isLocked(sOptionName); return getListBoxSelectedItem("Backend")==3 || super.isLocked(sOptionName);
@ -301,6 +305,7 @@ public class LaTeXOptionsDialog extends OptionsDialogBase {
setControlEnabled("InputencodingLabel",!isLocked("inputencoding")); setControlEnabled("InputencodingLabel",!isLocked("inputencoding"));
setControlEnabled("Inputencoding",!isLocked("inputencoding")); setControlEnabled("Inputencoding",!isLocked("inputencoding"));
setControlEnabled("Multilingual",!isLocked("multilingual")); setControlEnabled("Multilingual",!isLocked("multilingual"));
setControlEnabled("FontLabel",!isLocked("font"));
setControlEnabled("Font",!isLocked("font")); setControlEnabled("Font",!isLocked("font"));
setControlEnabled("GreekMath",!isLocked("greek_math")); setControlEnabled("GreekMath",!isLocked("greek_math"));
setControlEnabled("AdditionalSymbols",!isLocked("additional_symbols")); setControlEnabled("AdditionalSymbols",!isLocked("additional_symbols"));

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.6 (2014-11-12) * Version 1.6 (2014-11-14)
* *
*/ */
@ -291,24 +291,19 @@ public class ClassicI18n extends I18n {
* @param decl other declarations * @param decl other declarations
*/ */
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) { public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
pack.append("\\usepackage[") useInputenc(pack);
.append(writeInputenc(config.getInputencoding())) useBabel(pack);
.append("]{inputenc}").nl(); useSymbolFonts(pack);
useTextFonts(pack);
// usepackage fontenc }
CSVList fontencs = new CSVList(',');
if (bT2A) { fontencs.addValue("T2A"); } private void useInputenc(LaTeXDocumentPortion ldp) {
if (bGreek) { fontencs.addValue("LGR"); } ldp.append("\\usepackage[")
if (config.useTipa()) { fontencs.addValue("T3"); } .append(writeInputenc(config.getInputencoding()))
fontencs.addValue("T1"); .append("]{inputenc}").nl();
pack.append("\\usepackage[").append(fontencs.toString()) }
.append("]{fontenc}").nl();
private void useBabel(LaTeXDocumentPortion ldp) {
// use font package(s)
useFontPackages(pack);
// usepackage babel
// If the document contains "anonymous" greek letters we need greek in any case // If the document contains "anonymous" greek letters we need greek in any case
// If the document contains "anonymous cyrillic letters we need one of the // If the document contains "anonymous cyrillic letters we need one of the
// languages russian, ukrainian or bulgarian // languages russian, ukrainian or bulgarian
@ -349,54 +344,65 @@ public class ClassicI18n extends I18n {
} }
if (!babelopt.isEmpty()) { if (!babelopt.isEmpty()) {
pack.append("\\usepackage[") ldp.append("\\usepackage[")
.append(babelopt.toString()) .append(babelopt.toString())
.append("]{babel}").nl(); .append("]{babel}").nl();
// For Polish we must undefine \lll which is later defined by ams // For Polish we must undefine \lll which is later defined by ams
if (languages.contains("pl")) { if (languages.contains("pl")) {
pack.append("\\let\\lll\\undefined").nl(); ldp.append("\\let\\lll\\undefined").nl();
} }
} }
// usepackage tipa
if (config.useTipa()) {
pack.append("\\usepackage[noenc]{tipa}").nl()
.append("\\usepackage{tipx}").nl();
}
// usepackage bbding (Has to avoid some nameclashes.)
if (config.useBbding()) {
pack.append("\\usepackage{bbding}").nl()
.append("\\let\\bbCross\\Cross\\let\\Cross\\undefined").nl()
.append("\\let\\bbSquare\\Square\\let\\Square\\undefined").nl()
.append("\\let\\bbTrianbleUp\\TriangleUp\\let\\TriangleUp\\undefined").nl()
.append("\\let\\bbTrianlgeDown\\TriangleDown\\let\\TriangleDown\\undefined").nl();
}
// usepackage ifsym
if (config.useIfsym()) {
pack.append("\\usepackage[geometry,weather,misc,clock]{ifsym}").nl();
}
// usepackage pifont
if (config.usePifont()) { pack.append("\\usepackage{pifont}").nl(); }
// usepackage eurosym
if (config.useEurosym()) { pack.append("\\usepackage{eurosym}").nl(); }
// usepackage amsmath (always!)
pack.append("\\usepackage{amsmath}").nl();
// usepackage wasysym (*must* be loaded between amsmath and amsfonts!)
if (config.useWasysym()) {
pack.append("\\usepackage{wasysym}").nl();
}
// usepackage amssymb, amsfonts, textcomp (always!)
pack.append("\\usepackage{amssymb,amsfonts,textcomp}").nl();
} }
private void useSymbolFonts(LaTeXDocumentPortion ldp) {
if (config.useTipa()) {
ldp.append("\\usepackage[noenc]{tipa}").nl()
.append("\\usepackage{tipx}").nl();
}
// Has to avoid some nameclashes
if (config.useBbding()) {
ldp.append("\\usepackage{bbding}").nl()
.append("\\let\\bbCross\\Cross\\let\\Cross\\undefined").nl()
.append("\\let\\bbSquare\\Square\\let\\Square\\undefined").nl()
.append("\\let\\bbTrianbleUp\\TriangleUp\\let\\TriangleUp\\undefined").nl()
.append("\\let\\bbTrianlgeDown\\TriangleDown\\let\\TriangleDown\\undefined").nl();
}
if (config.useIfsym()) {
ldp.append("\\usepackage[geometry,weather,misc,clock]{ifsym}").nl();
}
if (config.usePifont()) { ldp.append("\\usepackage{pifont}").nl(); }
if (config.useEurosym()) { ldp.append("\\usepackage{eurosym}").nl(); }
// Always use amsmath
ldp.append("\\usepackage{amsmath}").nl();
// wasysym *must* be loaded between amsmath and amsfonts!
if (config.useWasysym()) {
ldp.append("\\usepackage{wasysym}").nl();
}
// Always use amssymb, amsfonts, textcomp (always!)
ldp.append("\\usepackage{amssymb,amsfonts,textcomp}").nl();
}
private void useTextFonts(LaTeXDocumentPortion ldp) {
// usepackage fontenc
CSVList fontencs = new CSVList(',');
if (bT2A) { fontencs.addValue("T2A"); }
if (bGreek) { fontencs.addValue("LGR"); }
if (config.useTipa()) { fontencs.addValue("T3"); }
fontencs.addValue("T1");
ldp.append("\\usepackage[").append(fontencs.toString())
.append("]{fontenc}").nl();
// use font package(s)
useFontPackages(ldp);
}
private void useFontPackages(LaTeXDocumentPortion ldp) { private void useFontPackages(LaTeXDocumentPortion ldp) {
String sFont = config.getFont(); String sFont = config.getFont();
// Sources: // Sources: