From 9667cb383640866f47aea57f059a9d2a5caefc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Mon, 11 Dec 2006 07:42:43 +0000 Subject: [PATCH] * lib/languages: change default for latin1-languages to latin9 (bug 845) * src/paragraph_pimpl.C: add support for the subset of symbols that is only covered by latin1 (not latin9) to make the above switch painless. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16239 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/languages | 66 +++++++++++++++---------------- src/paragraph_pimpl.C | 92 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 106 insertions(+), 52 deletions(-) diff --git a/lib/languages b/lib/languages index 6e68ff25a6..7782fc2a9f 100644 --- a/lib/languages +++ b/lib/languages @@ -1,63 +1,63 @@ # name babel name GUI name RTL? encoding code latex options -afrikaans afrikaans "Afrikaans" false iso8859-1 af_ZA "" -american american "American" false iso8859-1 en_US "" +afrikaans afrikaans "Afrikaans" false iso8859-15 af_ZA "" +american american "American" false iso8859-15 en_US "" arabic arabic "Arabic" true iso8859-6 ar_SA "" -austrian austrian "Austrian" false iso8859-1 de_AT "" -naustrian naustrian "Austrian (new spelling)" false iso8859-1 de_AT "" -bahasa bahasa "Bahasa" false iso8859-1 in_ID "" +austrian austrian "Austrian" false iso8859-15 de_AT "" +naustrian naustrian "Austrian (new spelling)" false iso8859-15 de_AT "" +bahasa bahasa "Bahasa" false iso8859-15 in_ID "" belarusian belarusian "Belarusian" false cp1251 be_BY "" -basque basque "Basque" false iso8859-1 eu_ES "" -brazil brazil "Portuguese (Brazil)" false iso8859-1 pt_BR "" -breton breton "Breton" false iso8859-1 br_FR "" -british british "British" false iso8859-1 en_GB "" +basque basque "Basque" false iso8859-15 eu_ES "" +brazil brazil "Portuguese (Brazil)" false iso8859-15 pt_BR "" +breton breton "Breton" false iso8859-15 br_FR "" +british british "British" false iso8859-15 en_GB "" bulgarian bulgarian "Bulgarian" false cp1251 bg_BG "" -canadian canadian "Canadian" false iso8859-1 en_CA "" -canadien canadien "French Canadian" false iso8859-1 fr_CA "" -catalan catalan "Catalan" false iso8859-1 ca_ES "" +canadian canadian "Canadian" false iso8859-15 en_CA "" +canadien canadien "French Canadian" false iso8859-15 fr_CA "" +catalan catalan "Catalan" false iso8859-15 ca_ES "" croatian croatian "Croatian" false iso8859-2 hr_HR "" czech czech "Czech" false iso8859-2 cs_CZ "" -danish danish "Danish" false iso8859-1 da_DK "" -dutch dutch "Dutch" false iso8859-1 nl_NL "" -english english "English" false iso8859-1 en_US "" +danish danish "Danish" false iso8859-15 da_DK "" +dutch dutch "Dutch" false iso8859-15 nl_NL "" +english english "English" false iso8859-15 en_US "" esperanto esperanto "Esperanto" false iso8859-3 eo "" #and what country code should esperanto have?? (Garst) -estonian estonian "Estonian" false iso8859-1 et_EE "" -finnish finnish "Finnish" false iso8859-1 fi_FI "" +estonian estonian "Estonian" false iso8859-15 et_EE "" +finnish finnish "Finnish" false iso8859-15 fi_FI "" # We redefine \og and \fg (guillemets) for older french language definitions -french french "French" false iso8859-1 fr_FR "\addto\extrasfrench{\providecommand{\og}{\leavevmode\flqq~}\providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}}" -galician galician "Galician" false iso8859-1 gl_ES "" +french french "French" false iso8859-15 fr_FR "\addto\extrasfrench{\providecommand{\og}{\leavevmode\flqq~}\providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}}" +galician galician "Galician" false iso8859-15 gl_ES "" # There are two Galicia's one in Spain one in E.Europe. Because of # the font encoding I am assuming this is the one in Spain. (Garst) -german german "German" false iso8859-1 de_DE "" -ngerman ngerman "German (new spelling)" false iso8859-1 de_DE "" +german german "German" false iso8859-15 de_DE "" +ngerman ngerman "German (new spelling)" false iso8859-15 de_DE "" greek greek "Greek" false iso8859-7 el_GR "" hebrew hebrew "Hebrew" true cp1255 he_IL "" #hungarian hungarian "Hungarian" false iso8859-2 "" "" -irish irish "Irish" false iso8859-1 ga_IE "" -italian italian "Italian" false iso8859-1 it_IT "" +irish irish "Irish" false iso8859-15 ga_IE "" +italian italian "Italian" false iso8859-15 it_IT "" kazakh kazakh "Kazakh" false pt154 kk_KZ "" #lsorbian lsorbian "Lsorbian" false iso8859-2 "" "" # no ISO listing for lsorbian (Garst) lithuanian lithuanian "Lithuanian" false iso8859-13 lt_LT "" latvian latvian "Latvian" false iso8859-13 lv_LV "" -icelandic icelandic "Icelandic" false iso8859-1 "is_IS" "" +icelandic icelandic "Icelandic" false iso8859-15 "is_IS" "" magyar magyar "Magyar" false iso8859-2 hu_HU "" -norsk norsk "Norsk" false iso8859-1 nb_NO "" -nynorsk nynorsk "Nynorsk" false iso8859-1 nn_NO "" +norsk norsk "Norsk" false iso8859-15 nb_NO "" +nynorsk nynorsk "Nynorsk" false iso8859-15 nn_NO "" polish polish "Polish" false iso8859-2 pl_PL "" -portuges portuges "Portugese" false iso8859-1 pt_PT "" +portuges portuges "Portugese" false iso8859-15 pt_PT "" romanian romanian "Romanian" false iso8859-2 ro_RO "" russian russian "Russian" false koi8 ru_RU "" -scottish scottish "Scottish" false iso8859-1 gd_GB "" -serbian croatian "Serbian" false iso8859-5 sr_HR "" -serbocroatian croatian "Serbo-Croatian" false iso8859-2 sh_HR "" -spanish spanish "Spanish" false iso8859-1 es_ES "\deactivatetilden" +scottish scottish "Scottish" false iso8859-15 gd_GB "" +serbian croatian "Serbian" false iso8859-5 sr_HR "" +serbocroatian croatian "Serbo-Croatian" false iso8859-2 sh_HR "" +spanish spanish "Spanish" false iso8859-15 es_ES "\deactivatetilden" slovak slovak "Slovak" false iso8859-2 sk_SK "" slovene slovene "Slovene" false iso8859-2 sl_SI "" -swedish swedish "Swedish" false iso8859-1 sv_SE "" +swedish swedish "Swedish" false iso8859-15 sv_SE "" thai thai "Thai" false tis620-0 th_TH "\usepackage{thswitch}" turkish turkish "Turkish" false iso8859-9 tr_TR "" ukrainian ukrainian "Ukrainian" false koi8-u uk_UA "" #usorbian usorbian "Usorbian" false iso8859-2 "" "" # no ISO listing for usorbian (Garst) -welsh welsh "Welsh" false iso8859-1 cy_GB "" +welsh welsh "Welsh" false iso8859-15 cy_GB "" diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 19d1f1c4e7..1ece42dadb 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -58,6 +58,15 @@ special_phrase const special_phrases[] = { size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase); + +bool isEncoding(BufferParams const & bparams, LyXFont const & font, + string const & encoding) +{ + return (bparams.inputenc == encoding + || (bparams.inputenc == "auto" + && font.language()->encoding()->latexName() == encoding)); +} + } // namespace anon @@ -569,13 +578,8 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf, case 0xb9: // ¹ SUPERSCRIPT ONE case 0xac: // ¬ NOT SIGN case 0xb5: // µ MICRO SIGN - if ((bparams.inputenc == "latin1" || - bparams.inputenc == "latin9") || - (bparams.inputenc == "auto" && - (font.language()->encoding()->latexName() - == "latin1" || - font.language()->encoding()->latexName() - == "latin9"))) { + if (isEncoding(bparams, font, "latin1") + || isEncoding(bparams, font, "latin9")) { os << "\\ensuremath{"; os.put(c); os << '}'; @@ -652,16 +656,9 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf, break; case 0x20ac: // EURO SIGN - if ((bparams.inputenc == "latin9" || - bparams.inputenc == "cp1251"|| - bparams.inputenc == "utf8") || - (bparams.inputenc == "auto" && - (font.language()->encoding()->latexName() - == "latin9" || - font.language()->encoding()->latexName() - == "cp1251"|| - font.language()->encoding()->latexName() - == "utf8"))) { + if (isEncoding(bparams, font, "latin9") + || isEncoding(bparams, font, "cp1251") + || isEncoding(bparams, font, "utf8")) { os.put(c); } else { os << "\\texteuro{}"; @@ -669,6 +666,60 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf, } break; + // These characters are covered by latin1, but not + // by latin9 (a.o.). We have to support them because + // we switched the default of latin1-languages to latin9 + case 0xa4: // CURRENCY SYMBOL + case 0xa6: // BROKEN BAR + case 0xa8: // DIAERESIS + case 0xb4: // ACUTE ACCENT + case 0xb8: // CEDILLA + case 0xbd: // 1/2 FRACTION + case 0xbc: // 1/4 FRACTION + case 0xbe: // 3/4 FRACTION + if (isEncoding(bparams, font, "latin1") + || isEncoding(bparams, font, "latin5") + || isEncoding(bparams, font, "utf8")) { + os.put(c); + break; + } else { + switch (c) { + case 0xa4: + os << "\\textcurrency{}"; + column += 15; + break; + case 0xa6: + os << "\\textbrokenbar{}"; + column += 16; + break; + case 0xa8: + os << "\\textasciidieresis{}"; + column += 20; + break; + case 0xb4: + os << "\\textasciiacute{}"; + column += 17; + break; + case 0xb8: // from latin1.def: + os << "\\c\\ "; + column += 3; + break; + case 0xbd: + os << "\\textonehalf{}"; + column += 14; + break; + case 0xbc: + os << "\\textonequarter{}"; + column += 17; + break; + case 0xbe: + os << "\\textthreequarters{}"; + column += 20; + break; + } + break; + } + case '$': case '&': case '%': case '#': case '{': case '}': case '_': @@ -819,8 +870,11 @@ void Paragraph::Pimpl::validate(LaTeXFeatures & features, break; } } - // the euro sign requires the textcomp package - if (getChar(i) == 0x20ac) + // these glyphs require the textcomp package + if (getChar(i) == 0x20ac || getChar(i) == 0xa4 + || getChar(i) == 0xa6 || getChar(i) == 0xa8 + || getChar(i) == 0xb4 || getChar(i) == 0xbd + || getChar(i) == 0xbc || getChar(i) == 0xbe) features.require("textcomp"); } }