From 7fdde6433b20214e8ecbc0d123a961c0663f2765 Mon Sep 17 00:00:00 2001 From: henrikjust Date: Sat, 15 Nov 2014 12:34:00 +0000 Subject: [PATCH] Add font option to w2l git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@217 f0f2a975-2e09-46c8-9428-3b39399b9f3c --- source/distro/changelog.txt | 1 + .../comp/writer2latex/LaTeXOptionsDialog.java | 9 +- .../writer2latex/latex/i18n/ClassicI18n.java | 130 +++++++++--------- 3 files changed, 76 insertions(+), 64 deletions(-) diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt index 0210074..7a0bb93 100644 --- a/source/distro/changelog.txt +++ b/source/distro/changelog.txt @@ -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 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 settings no longer has a heading in the dialog. diff --git a/source/java/org/openoffice/da/comp/writer2latex/LaTeXOptionsDialog.java b/source/java/org/openoffice/da/comp/writer2latex/LaTeXOptionsDialog.java index b465ba4..a0aa131 100644 --- a/source/java/org/openoffice/da/comp/writer2latex/LaTeXOptionsDialog.java +++ b/source/java/org/openoffice/da/comp/writer2latex/LaTeXOptionsDialog.java @@ -20,7 +20,7 @@ * * 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" }; private static final String[] FONT_NAMES = { "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", "Palatino + PXfonts Math", "Palatino + Pazo Math", "Palatino + Euler Math", "Times + TXfonts Math", "Times + Belleek Math", "Times + Symbol", @@ -264,6 +264,10 @@ public class LaTeXOptionsDialog extends OptionsDialogBase { // backend=xetex locks the encoding to utf8 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)) { // this option has no effect if backend=xetex return getListBoxSelectedItem("Backend")==3 || super.isLocked(sOptionName); @@ -301,6 +305,7 @@ public class LaTeXOptionsDialog extends OptionsDialogBase { setControlEnabled("InputencodingLabel",!isLocked("inputencoding")); setControlEnabled("Inputencoding",!isLocked("inputencoding")); setControlEnabled("Multilingual",!isLocked("multilingual")); + setControlEnabled("FontLabel",!isLocked("font")); setControlEnabled("Font",!isLocked("font")); setControlEnabled("GreekMath",!isLocked("greek_math")); setControlEnabled("AdditionalSymbols",!isLocked("additional_symbols")); diff --git a/source/java/writer2latex/latex/i18n/ClassicI18n.java b/source/java/writer2latex/latex/i18n/ClassicI18n.java index 589bc11..94a8bf2 100644 --- a/source/java/writer2latex/latex/i18n/ClassicI18n.java +++ b/source/java/writer2latex/latex/i18n/ClassicI18n.java @@ -20,7 +20,7 @@ * * 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 */ public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) { - pack.append("\\usepackage[") - .append(writeInputenc(config.getInputencoding())) - .append("]{inputenc}").nl(); - - // 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"); - pack.append("\\usepackage[").append(fontencs.toString()) - .append("]{fontenc}").nl(); - - // use font package(s) - useFontPackages(pack); - - // usepackage babel - + useInputenc(pack); + useBabel(pack); + useSymbolFonts(pack); + useTextFonts(pack); + } + + private void useInputenc(LaTeXDocumentPortion ldp) { + ldp.append("\\usepackage[") + .append(writeInputenc(config.getInputencoding())) + .append("]{inputenc}").nl(); + } + + private void useBabel(LaTeXDocumentPortion ldp) { // 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 // languages russian, ukrainian or bulgarian @@ -349,54 +344,65 @@ public class ClassicI18n extends I18n { } if (!babelopt.isEmpty()) { - pack.append("\\usepackage[") - .append(babelopt.toString()) - .append("]{babel}").nl(); + ldp.append("\\usepackage[") + .append(babelopt.toString()) + .append("]{babel}").nl(); // For Polish we must undefine \lll which is later defined by ams 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) { String sFont = config.getFont(); // Sources: