Fix handling of Thai tis620-0 input encoding.

The Thai tis620-0 input encoding is supported via the inputenc "plug in"
(data) file tis620.def from https://ctan.org/pkg/babel-thai.

We can handle it like the other contributed input encodings, e.g.,
Greek (ISO 8859-7) and the several Cyrillic encodings from
http://www.ctan.org/pkg/latex-cyrillic.

Under TeXLive 2018, the input encoding defaults to utf8, if there is no call to
inputenc. The added test file fails without the patch but compiles fine, if the
file "tis620.def" is present in the TEXPATH.
This commit is contained in:
Günter Milde 2019-01-08 10:52:20 +01:00
parent 9982651fd6
commit 41055bab88
3 changed files with 139 additions and 9 deletions

View File

@ -0,0 +1,128 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 566
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\begin_preamble
\usepackage{textalpha}
\end_preamble
\use_default_options false
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding tis620-0
\fontencoding auto
\font_roman "lmodern" "default"
\font_sans "lmss" "default"
\font_typewriter "lmtt" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format pdf2
\output_sync 0
\bibtex_command default
\index_command default
\float_placement class
\float_alignment class
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\use_minted 0
\branch na
\selected 0
\filename_suffix 0
\color #faf0e6
\end_branch
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip medskip
\is_math_indent 0
\math_numbering_side default
\quotes_style english
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Standard
The packages
\begin_inset Flex URL
status open
\begin_layout Plain Layout
https://ctan.org/pkg/babel-thai
\end_layout
\end_inset
and
\begin_inset Flex URL
status open
\begin_layout Plain Layout
https://ctan.org/pkg/thailatex
\end_layout
\end_inset
provide a definition file for the Thai input encoding tis620.
\end_layout
\begin_layout Standard
Textcomp supports the Thai currency symbol ฿ (
\backslash
textbaht).
\end_layout
\begin_layout Standard
All other Thai characters require fonts in the local LTH encoding or Xe/LuaTeX
with Unicode fonts.
\end_layout
\end_body
\end_document

View File

@ -166,6 +166,11 @@ End
Encoding pt154 pt154 "Cyrillic (pt 154)" PT154 fixed inputenc
End
# from https://ctan.org/pkg/babel-thai
Encoding tis620-0 tis620 "Thai (TIS 620-0)" TIS620-0 fixed inputenc
End
# encodings used by CJK.sty
# The following encodings that are supported by the CJK package are not
@ -231,15 +236,9 @@ End
Encoding utf8-platex utf8 "Japanese (pLaTeX) (UTF8)" UTF-8 variable japanese
End
# This one needs hardcoded support, since the inputenc package does not know
# tis620-0, and thailatex sets up babel directly to use tis620-0, so the
# LaTeX name is never output to .tex files (but needed for the hardcoded
# tis620-0 support).
Encoding tis620-0 tis620-0 "Thai (TIS 620-0)" TIS620-0 fixed none
End
# A plain utf8 encoding that does not use the inputenc package.
# Such an encoding is required for XeTeX.
# A plain utf8 encoding that does not use the inputenc package
# nor the LyX-added conversions in lib/unicodesymbols.
# Such an encoding is required for XeTeX and LuaTeX.
Encoding utf8-plain utf8-plain "Unicode (XeTeX) (utf8)" UTF-8 variable none
End

View File

@ -1621,6 +1621,9 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
// This does of course only work in special cases (e.g. switch from
// tis620-0 to latin1, but the text in latin1 contains ASCII only),
// but it is the best we can do
//
// 2019-01-08 Possibly no longer required since tis620-0 is supported
// by inputenc (but check special encodings "utf8-plain" and "default").
if (oldEnc.package() == Encoding::none
|| newEnc.package() == Encoding::none)
return make_pair(false, 0);