-----------------------
-2018-04-24 Jürgen Spitzmüller <spitz@lyx.org>
+2018-04-22 Jürgen Spitzmüller <spitz@lyx.org>
+ * format incremented to 550: rename \fontencoding global to \fontencoding auto.
+ Semantic change: this is now automatically set depending on the document fonts.
+
+2018-04-21 Jürgen Spitzmüller <spitz@lyx.org>
* format incremented to 549: change \textcyr to \textcyrillic.
Dummy format change for now (in case it turns out we need to do something).
!!!The following pref variables are obsoleted in 2.4:
+* \font_encoding
+ The font encoding is now automatically set depending on the document
+ fonts and languages.
+
* \use_qimage
This is no longer necessary due to the rewrite of the painter.
if rmcopy:
removeFiles( [ 'chkconfig.ltx' ] )
#
- # currently, values in chkconfig are only used to set
- # \font_encoding
- values = {}
- for line in open('chkconfig.vars').readlines():
- key, val = re.sub('-', '_', line).split('=')
- val = val.strip()
- values[key] = val.strip("'")
- # chk_fontenc may not exist
- try:
- addToRC(r'\font_encoding "%s"' % values["chk_fontenc"])
- except:
- pass
+ # values in chkconfig were only used to set
+ # \font_encoding, which is obsolete
+# values = {}
+# for line in open('chkconfig.vars').readlines():
+# key, val = re.sub('-', '_', line).split('=')
+# val = val.strip()
+# values[key] = val.strip("'")
# if configure successed, move textclass.lst.tmp to textclass.lst
# and packages.lst.tmp to packages.lst
if (os.path.isfile('textclass.lst.tmp')
lyx_check_config = True
lyx_kpsewhich = True
outfile = 'lyxrc.defaults'
- lyxrc_fileformat = 25
+ lyxrc_fileformat = 26
rc_entries = ''
lyx_keep_temps = False
version_suffix = ''
\papercolumns 1
\papersides 2
\paperpagestyle default
-\tracking_changes false
+\tracking_changes true
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict true
+\author -712698321 "Jürgen Spitzmüller"
\end_header
\begin_body
\end_layout
\begin_layout Verbatim
+
This is Verbatim.
\end_layout
\begin_layout Verbatim
\noindent
\align block
+
The following 2 lines are empty:
\end_layout
\end_layout
\begin_layout Verbatim
+
Almost everything is allowed in Verbatim:"%&$§#~'`
\backslash
}][{|
\end_layout
\begin_layout Verbatim*
+
This is Verbatim*.
\end_layout
Default,
\family default
the font that is preset by the current document class is used.
- With LyX's default font encoding, this is a look-alike of the standard
- \SpecialChar TeX
+ With LyX's
+\change_deleted -712698321 1524413696
+default
+\change_inserted -712698321 1524413700
+automatic
+\change_unchanged
+ font encoding, this is
+\change_inserted -712698321 1524413733
+, depending on the document language,
+\change_unchanged
+
+\change_inserted -712698321 1524413747
+either the the standard \SpecialChar TeX
+ font
+\begin_inset Quotes eld
+\end_inset
+
+
+\family typewriter
+Computer
+\begin_inset space ~
+\end_inset
+
+Modern
+\family default
+
+\begin_inset Quotes erd
+\end_inset
+
+ (
+\family typewriter
+cm
+\family default
+) or
+\change_unchanged
+a look-alike of
+\change_deleted -712698321 1524413754
+ the standard \SpecialChar TeX
font
\begin_inset Quotes eld
\end_inset
\family typewriter
cm
\family default
-): either
+)
+\change_inserted -712698321 1524413756
+ this font
+\change_unchanged
+: either
\begin_inset Quotes eld
\end_inset
\end_inset
+
+\change_deleted -712698321 1524413571
(see also section
\begin_inset space ~
\end_inset
\end_inset
-).
+)
+\change_unchanged
+.
Normally, you do not need to change (or even understand) this.
Unless you have specific reasons, use
+\change_deleted -712698321 1524413471
+
\family sans
Default
+\change_inserted -712698321 1524413474
+Automatic
+\change_unchanged
+
\family default
.
\end_layout
\end_layout
\begin_layout Description
+
+\change_deleted -712698321 1524413534
Use
\begin_inset space ~
\end_inset
\SpecialChar LyX
sets up in the background.
So there is no need to change the default encoding.
+\change_unchanged
+
\end_layout
\begin_layout Description
# BabelName <babelname>
# PolyglossiaName <polyglossianame>
# PolyglossiaOpts "<language-specific options>"
-# Encoding <encoding>
-# FontEncoding <font encoding>
# QuoteStyle <british|danish|english|french|frenchin|
# german|polish|russian|swedish|swedishg|swiss|plain>
+# Encoding <encoding>
+# FontEncoding <font encoding|font encoding|...]>
# InternalEncoding <true|false>
# RTL <true|false>
# AsBabelOptions <true|false>
# is set to "Language Default" and "use non-TeX fonts" is FALSE.
# Encoding "inherit" means: keep encoding of the context (used by
# latex_language).
+# * FontEncoding is a bar-separated list of font encodings.
+# The first value is the required font encoding for correct hyphenation with
+# 8-bit TeX (http://www.hyphenation.org). Eventually following values may be
+# used if the selected font is unavailable in FontEncoding. They provide all
+# letters used in the language, but some only as "surrogate pairs" with
+# possible problems for hyphenation and drag-and-drop from the generated
+# documents.
+# If not given, all standard text encodings (T<n>) as well as OT1 work.
+# * "FontEncoding none" tells LyX that fontenc should not be loaded with this
+# language.
+# * "FontEncoding ASCII" means: "works with any standard text encoding
+# as well as OT1".
# * InternalEncoding is used to tell LyX that babel internally sets a
# non-standard font encoding (such as hebrew to LHE or greek to LGR).
-# If True, LyX cares for characters/macros that do not exist in
+# If True, LyX takes care for characters/macros that do not exist in
# some font encodings ("<", ">", "|" and straight quote).
# It is not required for standard encodings like T2A. See bug #5091.
-# * "FontEncoding none" tells LyX that fontenc should not be loaded with this
-# language.
# * AsBabelOptions advices LyX to pass the languages locally to babel, not
# globally to the class. Some languages (basically those not directly
# supported by babel) need this.
BabelName afrikaans
QuoteStyle polish
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode af_ZA
End
+# FontEncoding: no hyphenation, but uses Ç/ç und Ë/ë
Language albanian
GuiName "Albanian"
BabelName albanian
PolyglossiaName albanian
QuoteStyle swiss
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode sq_AL
End
PolyglossiaOpts "variant=american"
QuoteStyle english
Encoding iso8859-15
+ FontEncoding ASCII
LangCode en_US
End
LangCode ast_ES
End
+
Language australian
GuiName "English (Australia)"
BabelName australian
PolyglossiaName english
PolyglossiaOpts "variant=australian"
Encoding iso8859-15
+ FontEncoding ASCII
QuoteStyle english
LangCode en_AU
End
PolyglossiaOpts "variant=austrian,spelling=old,babelshorthands=true"
QuoteStyle german
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode de_AT
End
PolyglossiaOpts "variant=austrian,spelling=new,babelshorthands=true"
QuoteStyle german
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode de_AT
End
PolyglossiaName bahasai
QuoteStyle english
Encoding iso8859-15
+ FontEncoding ASCII
LangCode id_ID
End
PolyglossiaName basque
QuoteStyle swiss
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode eu_ES
PostBabelPreamble
\addto\extrasbasque{\bbl@deactivate{~}}
BabelName belarusian
QuoteStyle french
Encoding cp1251
+ FontEncoding T2A
LangCode be_BY
AsBabelOptions true
End
BabelName bosnian
QuoteStyle polish
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode bs_BA
End
PolyglossiaName brazil
QuoteStyle english
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode pt_BR
End
+# FontEncoding: # ? no hyphenation, but uses ñ
Language breton
GuiName "Breton"
BabelName breton
PolyglossiaName breton
QuoteStyle french
Encoding iso8859-15
+ #FontEncoding T1
LangCode br_FR
End
PolyglossiaOpts "variant=british"
QuoteStyle british
Encoding iso8859-15
+ FontEncoding ASCII
LangCode en_GB
End
# PolyglossiaOpts "variant=canadian"
QuoteStyle english
Encoding iso8859-15
+ FontEncoding ASCII
LangCode en_CA
End
# PolyglossiaOpts "variant=canadien"
QuoteStyle french
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode fr_CA
End
PolyglossiaOpts "babelshorthands=true"
QuoteStyle french
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode ca_ES
End
PolyglossiaName croatian
QuoteStyle polish
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode hr_HR
End
PolyglossiaName czech
QuoteStyle german
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode cs_CZ
End
PolyglossiaName danish
QuoteStyle danish
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode da_DK
End
PolyglossiaOpts "babelshorthands=true"
QuoteStyle polish
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode nl_NL
End
PolyglossiaOpts "variant=american"
QuoteStyle english
Encoding iso8859-15
+ FontEncoding ASCII
LangCode en_US
End
PolyglossiaName esperanto
QuoteStyle english
Encoding iso8859-3
+ FontEncoding IL3|T1|OT1
LangCode eo_EO
End
PolyglossiaName estonian
QuoteStyle german
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode et_EE
PostBabelPreamble
\addto\extrasestonian{\bbl@deactivate{~}}
PolyglossiaName finnish
QuoteStyle swedish
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode fi_FI
End
PolyglossiaName french
QuoteStyle french
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode fr_FR
PostBabelPreamble
\addto\extrasfrench{%
PolyglossiaName friulan
QuoteStyle french
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode fur_IT
End
PolyglossiaName galician
QuoteStyle french
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode gl_ES
PostBabelPreamble
\addto\shorthandsgalician{\galiciandeactivate{~}}
PolyglossiaOpts "variant=german,spelling=old,babelshorthands=true"
QuoteStyle german
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode de
LangVariety alt
End
PolyglossiaOpts "variant=german,spelling=new,babelshorthands=true"
QuoteStyle german
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode de_DE
End
PolyglossiaOpts "variant=swiss,spelling=new,babelshorthands=true"
QuoteStyle swiss
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode de_CH
End
PolyglossiaOpts "variant=swiss,spelling=old,babelshorthands=true"
QuoteStyle swiss
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode de_CH
End
# QuoteStyle polish
#End
+# FontEncoding: OT1 misses ð and Þ
Language icelandic
GuiName "Icelandic"
BabelName icelandic
PolyglossiaName icelandic
QuoteStyle german
Encoding iso8859-15
+ FontEncoding T1
LangCode is_IS
End
BabelName interlingua
PolyglossiaName interlingua
Encoding iso8859-15
+ FontEncoding ASCII
LangCode ia_IA
QuoteStyle english
End
PolyglossiaName irish
QuoteStyle english
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode ga_IE
End
PolyglossiaName italian
QuoteStyle french
Encoding iso8859-15
+ FontEncoding ASCII
LangCode it_IT
End
# not yet supported by polyglossia
# not supported by babel
Language kazakh
- GuiName "Kazakh"
- Encoding ascii
- LangCode kk_KZ
+ GuiName "Kazakh"
+ Encoding ascii
+ FontEncoding T2A
+ LangCode kk_KZ
PostBabelPreamble
\input{t2aenc.def}
\AtBeginDocument{\fontencoding{T2A}\selectfont}
GuiName "Kurmanji"
BabelName kurmanji
Encoding utf8
+ FontEncoding T1|OT1
LangCode kmr
AsBabelOptions true
End
BabelName latin
PolyglossiaName latin
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode la_LA
End
# latvian must be loaded locally with babel options,
# not globally via class options
+# FontEncoding: L7x required for hyphenation but not set by Babel
Language latvian
GuiName "Latvian"
BabelName latvian
PolyglossiaName latvian
QuoteStyle german
Encoding iso8859-4
-# FontEncoding L7x # (required for hyphenation but not set by babel)
+ FontEncoding L7x|T1|OT1
LangCode lv_LV
AsBabelOptions true
End
# lithuanian must be loaded locally with babel options,
# not globally via class options
+# FontEncoding: L7x set by Babel
Language lithuanian
GuiName "Lithuanian"
BabelName lithuanian
PolyglossiaName lsorbian
QuoteStyle german
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode dsb_DE
End
PolyglossiaName magyar
QuoteStyle polish
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode hu_HU
End
PolyglossiaOpts "variant=newzealand"
QuoteStyle english
Encoding iso8859-15
+ FontEncoding ASCII
LangCode en_NZ
End
PolyglossiaName norsk
QuoteStyle swiss
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode nb_NO
End
PolyglossiaName nynorsk
QuoteStyle swiss
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode nn_NO
End
PolyglossiaName piedmontese
QuoteStyle french
Encoding iso8859-15
+ FontEncoding ASCII
LangCode pms_IT
End
+# FontEncoding: QX required for hyphenation but not set by babel
Language polish
GuiName "Polish"
HasGuiSupport true
PolyglossiaName polish
QuoteStyle polish
Encoding iso8859-2
-# FontEncoding QX # (required for hyphenation but not set by babel)
+ FontEncoding QX|T1|OT1
LangCode pl_PL
End
PolyglossiaName portuges
QuoteStyle french
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode pt_PT
End
PolyglossiaName romanian
QuoteStyle polish
Encoding iso8859-16
+ FontEncoding T1|OT1
LangCode ro_RO
End
PolyglossiaName romansh
QuoteStyle german
Encoding iso8859-15
+ FontEncoding ASCII
LangCode rm_CH
End
Provides textcyrillic
End
+# FontEncoding: no hyphenation, but diacritics
Language samin
GuiName "North Sami"
BabelName samin
PolyglossiaName samin
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode se_NO
End
LangCode sa_IN
End
+# Gaidhlig (Scottish Gaelic)
+# FontEncoding: no hyphenation, grave accent (à, è, ì, ò, ù)
Language scottish
GuiName "Scottish"
BabelName scottish
PolyglossiaName scottish
QuoteStyle english
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode gd_GB
End
PolyglossiaOpts "script=Latin"
QuoteStyle polish
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode sr_RS-Latin
End
PolyglossiaName slovak
QuoteStyle german
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode sk_SK
End
PolyglossiaName slovenian
QuoteStyle german
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode sl_SI
End
PolyglossiaName spanish
QuoteStyle french
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode es_ES
PostBabelPreamble
\addto\shorthandsspanish{\spanishdeactivate{~<>}}
PolyglossiaName spanish
QuoteStyle french
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode es_MX
PostBabelPreamble
\addto\shorthandsspanish{\spanishdeactivate{~<>.}}
PolyglossiaName swedish
QuoteStyle swedish
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode sv_SE
End
PolyglossiaName thai
QuoteStyle english
Encoding tis620-0
-# FontEncoding LTH
+ FontEncoding LTH
LangCode th_TH
PostBabelPreamble
\usepackage{thswitch}
PolyglossiaName turkish
QuoteStyle english
Encoding iso8859-9
+ FontEncoding T1|OT1
LangCode tr_TR
PostBabelPreamble
\usepackage{xkeyval}
PolyglossiaName turkmen
QuoteStyle swiss
Encoding utf8
+ FontEncoding T1|OT1
LangCode tk_TM
AsBabelOptions true
End
PolyglossiaName usorbian
QuoteStyle german
Encoding iso8859-2
+ FontEncoding T1|OT1
LangCode hsb_DE
End
PolyglossiaName vietnamese
QuoteStyle english
Encoding utf8
+ FontEncoding T5
LangCode vi_VN
End
PolyglossiaName welsh
QuoteStyle british
Encoding iso8859-15
+ FontEncoding T1|OT1
LangCode cy_GB
End
# Font <name>
# GuiName "<Gui Name>"
# Family <rm|sf|tt|math>
+# FontEncoding <font encoding>
# SwitchDefault <0|1>
# Package <LaTeX package to be loaded>
# Requires <LaTeX package to test for>
# * Adding a new font results in a FILE FORMAT CHANGE. So if a new font
# is added for the LyX distribution, the according changes need to be
# done.
+# * If FontEncoding is not specified, T1 is assumed.
# * "SwitchDefault 1" makes the font to be loaded by switching the default
# family to <name> (e.g., \renewcommand{\rmdefault}{cmr}), whereas
# Package <package> loads it via \usepackage{package}. Only one of these
Font cmr
GuiName "Computer Modern Roman"
Family rm
+ FontEncoding OT1
SwitchDefault 1
OsfFont eco
EndFont
Font cmss
GuiName "Computer Modern Sans"
Family sf
+ FontEncoding OT1
SwitchDefault 1
EndFont
Font cmtt
GuiName "Computer Modern Typewriter"
Family tt
+ FontEncoding OT1
SwitchDefault 1
EndFont
# no need to reset i
+def convert_fontenc(document):
+ " Convert default fontenc setting "
+
+ i = find_token(document.header, "\\fontencoding global", 0)
+ if i == -1:
+ return
+
+ document.header[i] = document.header[i].replace("global", "auto")
+
+
+def revert_fontenc(document):
+ " Revert default fontenc setting "
+
+ i = find_token(document.header, "\\fontencoding auto", 0)
+ if i == -1:
+ return
+
+ document.header[i] = document.header[i].replace("auto", "global")
+
+
##
# Conversion hub
#
[546, []],
[547, []],
[548, []],
- [549, []]
+ [549, []],
+ [550, [convert_fontenc]]
]
revert = [
+ [549, [revert_fontenc]],
[548, []],# dummy format change
[547, [revert_lscape]],
[546, [revert_xcharter]],
# Incremented to format 25, by lasgouttes
# Remove use_qimage preference
+# Incremented to format 26, by spitz
+# Rename font_encoding preference
+
# NOTE: The format should also be updated in LYXRC.cpp and
# in configure.py.
return no_match
return (True, "")
+def remove_font_encoding(line):
+ if not line.lower().startswith("\\font_encoding "):
+ return no_match
+ return (True, "")
+
# End conversions for LyX 2.3 to 2.4
####################################
[ 22, []],
[ 23, []],
[ 24, [rename_collapsible]],
- [ 25, [remove_use_qimage]]
+ [ 25, [remove_use_qimage]],
+ [ 26, [remove_font_encoding]]
]
secnumdepth = 3;
tocdepth = 3;
language = default_language;
- fontenc = "global";
+ fontenc = "auto";
fonts_roman[0] = "default";
fonts_roman[1] = "default";
fonts_sans[0] = "default";
vector<string> const BufferParams::font_encodings() const
{
- string doc_fontenc = (fontenc == "global") ? lyxrc.fontenc : fontenc;
+ string doc_fontenc = (fontenc == "auto") ? string() : fontenc;
vector<string> fontencs;
// "default" means "no explicit font encoding"
if (doc_fontenc != "default") {
- fontencs = getVectorFromString(doc_fontenc);
- if (!language->fontenc().empty()
- && ascii_lowercase(language->fontenc()) != "none") {
- vector<string> fencs = getVectorFromString(language->fontenc());
- vector<string>::const_iterator fit = fencs.begin();
- for (; fit != fencs.end(); ++fit) {
- if (find(fontencs.begin(), fontencs.end(), *fit) == fontencs.end())
- fontencs.push_back(*fit);
+ if (!doc_fontenc.empty())
+ // If we have a custom setting, we use only that!
+ return getVectorFromString(doc_fontenc);
+ if (!language->fontenc(*this).empty()
+ && ascii_lowercase(language->fontenc(*this)) != "none") {
+ vector<string> fencs = getVectorFromString(language->fontenc(*this));
+ for (auto & fe : fencs) {
+ if (find(fontencs.begin(), fontencs.end(), fe) == fontencs.end())
+ fontencs.push_back(fe);
}
}
}
}
for (auto const & lang : UsedLanguages_)
- if (!lang->fontenc().empty()
- && ascii_lowercase(lang->fontenc()) != "none") {
- vector<string> extraencs = getVectorFromString(lang->fontenc());
+ if (!lang->fontencs().empty()) {
+ vector<string> extraencs = lang->fontencs();
for (auto const & extra : extraencs) {
- if (find(encs.begin(), encs.end(), extra) == encs.end())
+ if (extra != "none" && find(encs.begin(), encs.end(), extra) == encs.end())
encs.insert(encs.begin(), extra);
}
}
}
+bool LaTeXFont::hasFontenc(string const & name) const
+{
+ for (auto const & fe : fontenc_) {
+ if (fe == name)
+ return true;
+ }
+ return false;
+}
+
+
bool LaTeXFont::readFont(Lexer & lex)
{
enum LaTeXFontTags {
LF_COMPLETE_FONT,
LF_END,
LF_FAMILY,
+ LF_FONTENC,
LF_GUINAME,
LF_NOMATHFONT,
LF_OSFDEFAULT,
{ "completefont", LF_COMPLETE_FONT },
{ "endfont", LF_END },
{ "family", LF_FAMILY },
+ { "fontencoding", LF_FONTENC },
{ "guiname", LF_GUINAME },
{ "nomathfont", LF_NOMATHFONT },
{ "osfdefault", LF_OSFDEFAULT },
case LF_GUINAME:
lex >> guiname_;
break;
+ case LF_FONTENC: {
+ lex.eatLine();
+ string fe = lex.getString();
+ fontenc_ = getVectorFromString(fe);
+ break;
+ }
case LF_NOMATHFONT:
lex >> nomathfont_;
break;
return false;
}
+ if (fontenc_.empty())
+ fontenc_.push_back("T1");
+
return true;
}
docstring const & family() { return family_; }
/// The package that provides this font
docstring const & package() { return package_; }
+ /// Does this provide a specific font encoding?
+ bool hasFontenc(std::string const &) const;
+ /// The font encoding(s)
+ std::vector<std::string> const & fontencs() const { return fontenc_; }
/// Alternative font if package() is not available
std::vector<docstring> const & altfonts() { return altfonts_; }
/// A font that provides all families
///
docstring package_;
///
+ std::vector<std::string> fontenc_;
+ ///
std::vector<docstring> altfonts_;
///
docstring completefont_;
#include "Language.h"
#include "Encoding.h"
+#include "LaTeXFonts.h"
#include "Lexer.h"
#include "LyXRC.h"
}
+vector<string> Language::fontencs() const
+{
+ return fontenc_;
+}
+
+
+string Language::fontenc(BufferParams const & params) const
+{
+ // Determine optimal font encoding
+ // We check whether the used rm font supports an encoding our language supports
+ for (auto & fe : fontenc_) {
+ LaTeXFont const & lf = theLaTeXFonts().getLaTeXFont(from_ascii(params.fontsRoman()));
+ // ASCII means: support all T* encodings plus OT1
+ if (fe == "ASCII") {
+ vector<string> const lfe = lf.fontencs();
+ for (auto & afe : lfe) {
+ if (afe == "OT1" || prefixIs(afe, "T"))
+ // we found a suitable one; return that.
+ return afe;
+ }
+ }
+ // For other encodings, just check whether the font supports it
+ if (lf.hasFontenc(fe))
+ return fe;
+ }
+ // We did not find a suitable one; just take the first in the list,
+ // the priorized one (which is "T1" for ASCII).
+ return fontencs().front() == "ASCII" ? "T1" : fontencs().front();
+}
+
+
bool Language::readLanguage(Lexer & lex)
{
enum LanguageTags {
case LA_ENCODING:
lex >> encodingStr_;
break;
- case LA_FONTENC:
- lex >> fontenc_;
+ case LA_FONTENC: {
+ lex.eatLine();
+ vector<string> const fe =
+ getVectorFromString(lex.getString(true), "|");
+ fontenc_.insert(fontenc_.end(), fe.begin(), fe.end());
break;
+ }
case LA_GUINAME:
lex >> display_;
break;
encoding_ = encodings.fromLyXName("iso8859-1");
LYXERR0("Unknown encoding " << encodingStr_);
}
+ if (fontenc_.empty())
+ fontenc_.push_back("ASCII");
return true;
}
#ifndef LANGUAGE_H
#define LANGUAGE_H
+#include "BufferParams.h"
+
#include "support/docstring.h"
#include "support/trivstring.h"
#include <map>
+#include <vector>
namespace lyx {
/// This language internally sets a font encoding
bool internalFontEncoding() const { return internal_enc_; }
/// fontenc encoding(s)
- std::string const fontenc() const { return fontenc_; }
+ std::string fontenc(BufferParams const &) const;
+ /// fontenc encoding(s)
+ std::vector<std::string> fontencs() const;
/// This language needs to be passed to babel itself (not the class)
bool asBabelOptions() const { return as_babel_options_; }
/// This language corresponds to a translation of the GUI
///
trivdocstring babel_presettings_;
///
- trivstring fontenc_;
+ std::vector<std::string> fontenc_;
///
bool internal_enc_;
///
// The format should also be updated in configure.py, and conversion code
// should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 25; // lasgouttes: remove qimage
+static unsigned int const LYXRC_FILEFORMAT = 26; // spitz: remove font_encoding
// when adding something to this array keep it sorted!
LexerKeyword lyxrcTags[] = {
{ "\\escape_chars", LyXRC::RC_ESC_CHARS },
{ "\\example_path", LyXRC::RC_EXAMPLEPATH },
{ "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE },
- { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
{ "\\format", LyXRC::RC_FILEFORMAT },
{ "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
{ "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF },
default_platex_view_format = "pdf3";
chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
bibtex_command = "automatic";
- fontenc = "default";
index_command = "makeindex -c -q";
nomencl_command = "makeindex -s nomencl.ist";
pygmentize_command = string();
}
break;
- case RC_FONT_ENCODING:
- lexrc >> fontenc;
- break;
-
case RC_PRINTLANDSCAPEFLAG:
lexrc >> print_landscape_flag;
break;
if (tag != RC_LAST)
break;
// fall through
- case RC_FONT_ENCODING:
- if (ignore_system_lyxrc ||
- fontenc != system_lyxrc.fontenc) {
- os << "\\font_encoding \"" << fontenc << "\"\n";
- }
- if (tag != RC_LAST)
- break;
-
os << "\n#\n"
<< "# FILE SECTION ######################################\n"
<< "#\n\n";
-
// fall through
case RC_DOCUMENTPATH:
if (ignore_system_lyxrc ||
case LyXRC::RC_EDITOR_ALTERNATIVES:
case LyXRC::RC_ESC_CHARS:
case LyXRC::RC_EXAMPLEPATH:
- case LyXRC::RC_FONT_ENCODING:
case LyXRC::RC_FILEFORMAT:
case LyXRC::RC_GROUP_LAYOUTS:
case LyXRC::RC_HUNSPELLDIR_PATH:
str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
break;
- case RC_FONT_ENCODING:
- str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
- break;
-
case RC_FILEFORMAT:
break;
RC_ESC_CHARS,
RC_EXAMPLEPATH,
RC_EXPORT_OVERWRITE,
- RC_FONT_ENCODING,
RC_FILEFORMAT,
RC_FORWARD_SEARCH_DVI,
RC_FORWARD_SEARCH_PDF,
/// DPI of monitor
unsigned int dpi;
///
- std::string fontenc;
- ///
std::string roman_font_name;
///
std::string sans_font_name;
/// Output the surrogate pair formed by \p c and \p next to \p os.
/// \return the number of characters written.
- int latexSurrogatePair(otexstream & os, char_type c, char_type next,
+ int latexSurrogatePair(BufferParams const &, otexstream & os,
+ char_type c, char_type next,
OutputParams const &);
/// Output a space in appropriate formatting (or a surrogate pair
/// if the next character is a combining character).
/// \return whether a surrogate pair was output.
- bool simpleTeXBlanks(OutputParams const &,
+ bool simpleTeXBlanks(BufferParams const &,
+ OutputParams const &,
otexstream &,
pos_type i,
unsigned int & column,
/// Output consecutive unicode chars, belonging to the same script as
/// specified by the latex macro \p ltx, to \p os starting from \p i.
/// \return the number of characters written.
- int writeScriptChars(OutputParams const &, otexstream & os,
+ int writeScriptChars(BufferParams const &, OutputParams const &,
+ otexstream & os,
docstring const & ltx,
Change const &, Encoding const &,
std::string const, pos_type & i);
}
-int Paragraph::Private::latexSurrogatePair(otexstream & os, char_type c,
- char_type next, OutputParams const & runparams)
+int Paragraph::Private::latexSurrogatePair(BufferParams const & bparams,
+ otexstream & os, char_type c, char_type next,
+ OutputParams const & runparams)
{
// Writing next here may circumvent a possible font change between
// c and next. Since next is only output if it forms a surrogate pair
int length = brace2;
string fontenc;
if (runparams.local_font)
- fontenc = runparams.local_font->language()->fontenc();
+ fontenc = runparams.local_font->language()->fontenc(bparams);
else
fontenc = runparams.main_fontenc;
docstring scriptmacro;
}
-bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
+bool Paragraph::Private::simpleTeXBlanks(BufferParams const & bparams,
+ OutputParams const & runparams,
otexstream & os,
pos_type i,
unsigned int & column,
char_type next = text_[i + 1];
if (Encodings::isCombiningChar(next)) {
// This space has an accent, so we must always output it.
- column += latexSurrogatePair(os, ' ', next, runparams) - 1;
+ column += latexSurrogatePair(bparams, os, ' ', next, runparams) - 1;
return true;
}
}
}
-int Paragraph::Private::writeScriptChars(OutputParams const & runparams,
+int Paragraph::Private::writeScriptChars(BufferParams const & bparams,
+ OutputParams const & runparams,
otexstream & os,
docstring const & ltx,
Change const & runningChange,
if (i + 2 < size) {
next_next = text_[i + 2];
if (Encodings::isCombiningChar(next_next)) {
- length += latexSurrogatePair(os, next, next_next, runparams) - 1;
+ length += latexSurrogatePair(bparams, os, next, next_next, runparams) - 1;
i += 2;
continue;
}
if (i + 1 < int(text_.size())) {
next = text_[i + 1];
if (Encodings::isCombiningChar(next)) {
- column += latexSurrogatePair(os, c, next, runparams) - 1;
+ column += latexSurrogatePair(bparams, os, c, next, runparams) - 1;
++i;
break;
}
if (running_font.language()->lang() == bparams.language->lang())
fontenc = runparams.main_fontenc;
else
- fontenc = running_font.language()->fontenc();
+ fontenc = running_font.language()->fontenc(bparams);
// "Script chars" need to embraced in \textcyrillic and \textgreek notwithstanding
// whether they are encodable or not (it only depends on the font encoding)
if (!runparams.isFullUnicode() && Encodings::isKnownScriptChar(c, script)) {
docstring ltx = latex.first;
if (!prefixIs(ltx, wrapper))
ltx = wrapper + latex.first + from_ascii("}");
- column += writeScriptChars(runparams, os, ltx, running_change,
+ column += writeScriptChars(bparams, runparams, os, ltx, running_change,
encoding, fontenc, i) - 1;
} else if (latex.second
&& ((!prefixIs(nextlatex, '\\')
|| ((&owner_->getFontSettings(bp, i))->language()->internalFontEncoding()))
features.require("textquotedbl");
} else if (Encodings::isKnownScriptChar(c, bscript)){
- string fontenc = (&owner_->getFontSettings(bp, i))->language()->fontenc();
+ string fontenc = (&owner_->getFontSettings(bp, i))->language()->fontenc(bp);
if (fontenc.empty())
fontenc = features.runparams().main_fontenc;
if (Encodings::needsScriptWrapper("textbaltic", fontenc))
// latexSpecialChar ignores spaces if
// style.pass_thru is false.
if (i != body_pos - 1) {
- if (d->simpleTeXBlanks(runparams, os,
+ if (d->simpleTeXBlanks(bparams, runparams, os,
i, column, current_font, style)) {
// A surrogate pair was output. We
// must not call latexSpecialChar
connect(outputModule->saveTransientPropertiesCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+
+ // language & quote
+ // this must preceed font, since fonts depend on this
+ langModule = new UiWidget<Ui::LanguageUi>(this);
+ connect(langModule->languageCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(langModule->languageCO, SIGNAL(activated(int)),
+ this, SLOT(languageChanged(int)));
+ connect(langModule->defaultencodingRB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(langModule->otherencodingRB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(langModule->encodingCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(langModule->languagePackageCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(langModule->languagePackageLE, SIGNAL(textChanged(QString)),
+ this, SLOT(change_adaptor()));
+ connect(langModule->languagePackageCO, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(languagePackageChanged(int)));
+ connect(langModule->dynamicQuotesCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+
+ langModule->languagePackageLE->setValidator(new NoNewLineValidator(
+ langModule->languagePackageLE));
+
+ QAbstractItemModel * language_model = guiApp->languageModel();
+ // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
+ language_model->sort(0);
+ langModule->languageCO->setModel(language_model);
+ langModule->languageCO->setModelColumn(0);
+
+ // Always put the default encoding in the first position.
+ langModule->encodingCO->addItem(qt_("Language Default (no inputenc)"));
+ QStringList encodinglist;
+ for (auto const & encvar : encodings) {
+ if (!encvar.unsafe() && !encvar.guiName().empty())
+ encodinglist.append(qt_(encvar.guiName()));
+ }
+ encodinglist.sort();
+ langModule->encodingCO->addItems(encodinglist);
+
+ langModule->languagePackageCO->addItem(
+ qt_("Default"), toqstr("default"));
+ langModule->languagePackageCO->addItem(
+ qt_("Automatic"), toqstr("auto"));
+ langModule->languagePackageCO->addItem(
+ qt_("Always Babel"), toqstr("babel"));
+ langModule->languagePackageCO->addItem(
+ qt_("Custom"), toqstr("custom"));
+ langModule->languagePackageCO->addItem(
+ qt_("None[[language package]]"), toqstr("none"));
+
+
// fonts
fontModule = new FontModule(this);
connect(fontModule->osFontsCB, SIGNAL(clicked()),
fontModule->fontsizeCO->addItem(qt_("11"));
fontModule->fontsizeCO->addItem(qt_("12"));
- fontModule->fontencCO->addItem(qt_("Default"), QString("global"));
+ fontModule->fontencCO->addItem(qt_("Automatic"), QString("auto"));
+ fontModule->fontencCO->addItem(qt_("Class default"), QString("default"));
fontModule->fontencCO->addItem(qt_("Custom"), QString("custom"));
- fontModule->fontencCO->addItem(qt_("None (no fontenc)"), QString("default"));
for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
fontModule->fontsDefaultCO->addItem(
marginsModule->columnsepL);
- // language & quote
- langModule = new UiWidget<Ui::LanguageUi>(this);
- connect(langModule->languageCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(langModule->languageCO, SIGNAL(activated(int)),
- this, SLOT(languageChanged(int)));
- connect(langModule->defaultencodingRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(langModule->otherencodingRB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
- connect(langModule->encodingCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(langModule->quoteStyleCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(langModule->languagePackageCO, SIGNAL(activated(int)),
- this, SLOT(change_adaptor()));
- connect(langModule->languagePackageLE, SIGNAL(textChanged(QString)),
- this, SLOT(change_adaptor()));
- connect(langModule->languagePackageCO, SIGNAL(currentIndexChanged(int)),
- this, SLOT(languagePackageChanged(int)));
- connect(langModule->dynamicQuotesCB, SIGNAL(clicked()),
- this, SLOT(change_adaptor()));
-
- langModule->languagePackageLE->setValidator(new NoNewLineValidator(
- langModule->languagePackageLE));
-
- QAbstractItemModel * language_model = guiApp->languageModel();
- // FIXME: it would be nice if sorting was enabled/disabled via a checkbox.
- language_model->sort(0);
- langModule->languageCO->setModel(language_model);
- langModule->languageCO->setModelColumn(0);
-
- // Always put the default encoding in the first position.
- langModule->encodingCO->addItem(qt_("Language Default (no inputenc)"));
- QStringList encodinglist;
- for (auto const & encvar : encodings) {
- if (!encvar.unsafe() && !encvar.guiName().empty())
- encodinglist.append(qt_(encvar.guiName()));
- }
- encodinglist.sort();
- langModule->encodingCO->addItems(encodinglist);
-
- langModule->languagePackageCO->addItem(
- qt_("Default"), toqstr("default"));
- langModule->languagePackageCO->addItem(
- qt_("Automatic"), toqstr("auto"));
- langModule->languagePackageCO->addItem(
- qt_("Always Babel"), toqstr("babel"));
- langModule->languagePackageCO->addItem(
- qt_("Custom"), toqstr("custom"));
- langModule->languagePackageCO->addItem(
- qt_("None[[language package]]"), toqstr("none"));
-
-
// color
colorModule = new UiWidget<Ui::ColorUi>(this);
connect(colorModule->fontColorPB, SIGNAL(clicked()),
{
QString const fontenc =
fontModule->fontencCO->itemData(fontModule->fontencCO->currentIndex()).toString();
+ int const i = langModule->languageCO->currentIndex();
+ if (i == -1)
+ return false;
+ QString const langname = langModule->languageCO->itemData(i).toString();
+ Language const * newlang = lyx::languages.getLanguage(fromqstr(langname));
return (fontenc == "default"
- || (fontenc == "global" && (lyxrc.fontenc == "default" || lyxrc.fontenc == "OT1"))
+ || (fontenc == "auto" && newlang->fontenc(buffer().params()) == "OT1")
|| (fontenc == "custom" && fontModule->fontencLE->text() == "OT1"));
}
if (nn >= 0)
fontModule->fontsDefaultCO->setCurrentIndex(nn);
- if (bp_.fontenc == "global" || bp_.fontenc == "default") {
+ if (bp_.fontenc == "auto" || bp_.fontenc == "default") {
fontModule->fontencCO->setCurrentIndex(
fontModule->fontencCO->findData(toqstr(bp_.fontenc)));
fontModule->fontencLE->setEnabled(false);
} else {
- fontModule->fontencCO->setCurrentIndex(1);
+ fontModule->fontencCO->setCurrentIndex(
+ fontModule->fontencCO->findData("custom"));
fontModule->fontencLE->setText(toqstr(bp_.fontenc));
}
{
setupUi(this);
- latexEncodingED->setValidator(new NoNewLineValidator(latexEncodingED));
latexDviPaperED->setValidator(new NoNewLineValidator(latexDviPaperED));
latexBibtexED->setValidator(new NoNewLineValidator(latexBibtexED));
latexJBibtexED->setValidator(new NoNewLineValidator(latexJBibtexED));
latexNomenclED->setValidator(new NoNewLineValidator(latexNomenclED));
latexChecktexED->setValidator(new NoNewLineValidator(latexChecktexED));
- connect(latexEncodingCB, SIGNAL(clicked()),
- this, SIGNAL(changed()));
- connect(latexEncodingED, SIGNAL(textChanged(QString)),
- this, SIGNAL(changed()));
connect(latexChecktexED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
connect(latexBibtexCO, SIGNAL(activated(int)),
}
-void PrefLatex::on_latexEncodingCB_stateChanged(int state)
-{
- latexEncodingED->setEnabled(state == Qt::Checked);
-}
-
-
void PrefLatex::on_latexBibtexCO_activated(int n)
{
QString const bibtex = latexBibtexCO->itemData(n).toString();
else
rc.index_command = fromqstr(index) + " " + fromqstr(idxopt);
- if (latexEncodingCB->isChecked())
- rc.fontenc = fromqstr(latexEncodingED->text());
- else
- rc.fontenc = "default";
rc.chktex_command = fromqstr(latexChecktexED->text());
rc.jindex_command = fromqstr(latexJIndexED->text());
rc.nomencl_command = fromqstr(latexNomenclED->text());
latexIndexOptionsLA->setText(qt_("Co&mmand:"));
}
- if (rc.fontenc == "default") {
- latexEncodingCB->setChecked(false);
- latexEncodingED->setEnabled(false);
- } else {
- latexEncodingCB->setChecked(true);
- latexEncodingED->setEnabled(true);
- latexEncodingED->setText(toqstr(rc.fontenc));
- }
latexChecktexED->setText(toqstr(rc.chktex_command));
latexJIndexED->setText(toqstr(rc.jindex_command));
latexNomenclED->setText(toqstr(rc.nomencl_command));
virtual void updateRC(LyXRC const & rc);
private Q_SLOTS:
- void on_latexEncodingCB_stateChanged(int state);
void on_latexBibtexCO_activated(int n);
void on_latexJBibtexCO_activated(int n);
void on_latexIndexCO_activated(int n);
<x>0</x>
<y>0</y>
<width>425</width>
- <height>620</height>
+ <height>582</height>
</rect>
</property>
<property name="windowTitle">
<number>0</number>
</property>
<item row="0" column="0">
- <widget class="QCheckBox" name="latexEncodingCB">
- <property name="toolTip">
- <string>Enable if a specific font encoding (such as T1) should be used (via fontenc)</string>
- </property>
- <property name="text">
- <string>Use LaTe&X font encoding:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="latexEncodingED">
- <property name="toolTip">
- <string>Specify the font encoding (e.g., T1).</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
<widget class="QLabel" name="latexDviPaperLA">
<property name="text">
<string>&DVI viewer paper size options:</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="0" column="1">
<widget class="QLineEdit" name="latexDviPaperED">
<property name="toolTip">
<string>Optional paper size flag (-paper) for some DVI viewers</string>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>1</height>
+ <height>0</height>
</size>
</property>
</spacer>
fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
} else {
global_style_ = InsetQuotesParams::EnglishQuotes;
- fontenc_ = lyxrc.fontenc;
+ fontenc_ = "OT1";
fontspec_ = false;
}
if (style.empty())
else if (name == "fontenc") {
h_fontencoding = getStringFromVector(options, ",");
- /* We could do the following for better round trip support,
- * but this makes the document less portable, so I skip it:
- if (h_fontencoding == lyxrc.fontenc)
- h_fontencoding = "global";
- */
options.clear();
}
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 549 // spitz: \textcyr -> \textcyrillic
-#define LYX_FORMAT_TEX2LYX 549
+#define LYX_FORMAT_LYX 550 // spitz: \fontenc auto
+#define LYX_FORMAT_TEX2LYX 550
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER