Commit Graph

99 Commits

Author SHA1 Message Date
Guillaume Munch
a7b993143e Fix compilation with MSVC 2016-12-08 16:28:16 +01:00
Guillaume Munch
c8d1d0d33c GuiSymbols: put ASCII chars first
Having À before A was weird. This only affects GuiSymbols.
2016-12-03 23:35:15 +01:00
Enrico Forestieri
cb70946960 Fix bug #9616 2016-09-10 13:36:45 +02:00
Georg Baum
f35ed0c168 Improve \AA and \aa tex2lyx import
The lib/unicodesymbols part is based on work by Günter Milde:

Both, \r{A} and \AA (rsp. \r{a} and \aa) are equivalent standard LICR macros
for Aring/aring  as well as the deprecated "angstrom sign" character (212B).

However, with \AA for 212B and \r{A} for 00C5, tex2lyx converts \AA to the
deprecated "angstrom sign" which is missing in many fonts including the
Unicode version of Latin Modern.

I added the normalize_c() calls so that tex2lyx prefers the precomposed forms
(these are better editable in LyX) and the deprecated flag.
2016-01-08 21:06:24 +01:00
Jean-Marc Lasgouttes
fd7aa2d62d Do not mix several names for the same variable
This confuses coverity, but is probably harmless.

Fxies coverity issue 23374
2015-02-20 16:37:06 +01:00
Georg Baum
c6b98a504f Make Encoding class thread-safe
Now all const methods may be called without additional locking.
This is assumed by the threaded LaTeX export, which always useses a globally
unique instance for each encoding.
2014-12-08 22:25:40 +01:00
Georg Baum
364e0f72c4 Fix invalid iterator access 2014-12-08 21:29:25 +01:00
Georg Baum
d5aaee1f6b Whitespace 2014-12-07 17:29:12 +01:00
Jean-Marc
41740ea915 Merge remote-tracking branch 'features/str-metrics'
This branch implements string-wise metrics computation. The goal is to
have both good metrics computation (and font with proper kerning and
ligatures) and better performance than what we have with
force_paint_single_char. Moreover there has been some code
factorization in TextMetrics, where the same row-breaking algorithm
was basically implemented 3 times.

Globally, the new code is a bit shorter than the existing one, and it
is much cleaner.  There is still a lot of potential for code removal,
especially in the RowPainter, which should be rewritten to use the new
Row information.

The bugs fixed and caused by this branch are tracked at ticket #9003:
http://www.lyx.org/trac/ticket/9003

What is done:

* Make TextMetrics methods operate on Row objects: breakRow and
  setRowHeight instead of rowBreakPoint and rowHeight.

* Change breakRow operation to operate at strings level to compute
  metrics The list of elements is stored in the row object in visual
  ordering, not logical. This will eventually allow to get rid of the
  Bidi class.

* rename getColumnNearX to getPosNearX (and change code accordingly).
  It does not make sense to return a position relative to the start of
  row, since nobody needs this.

* Re-implement cursorX and getPosNearX using row elements.

* Get rid of lyxrc.force_paint_single_char. This was a workaround that
  is not necessary anymore.

* Implement proper string metrics computation (with cache). Remove
  useless workarounds which disable kerning and ligatures.

* Draw also RtL text string-wise. This speeds-up drawing.

* Do not cut strings at selection boundary in RowPainter. This avoids
  ligature/kerning breaking in latin text, and bad rendering problems
  in Arabic.

* Remove homebrew Arabic and Hebrew support from Encoding.cpp. We now
  rely on Qt to do handle complex scripts.

* Get rid of LyXRC::rtl_support, which does not have a real use case.

* Fix display of [] and {} delimiters in Arabic scripts.
2014-07-25 20:10:55 +02:00
Jean-Marc Lasgouttes
d6337a2488 Remove obsolete code to handle Hebrew and Arabic characters
This is handled by Qt now.

Note that a small optimization (do not draw text that is to the left
of WorkArea) is removed because it cannot be guaranteed to be exact
anymore. It was probably not very useful anyway, and would become
useless once the RowPainter is rewritten to use Row information.

Update 00README_STR_METRICS_BRANCH.
2014-07-08 21:30:06 +02:00
Jean-Marc Lasgouttes
3013ce3716 Implement a better solution for painting of RTL text
Instead of relying on character range (Hebrew or Arabic) or character
direction, use RLO unicode character (Right-to-Left override) to force
painting in the direction indicated by the current font. This should
be as close as we can to the old LyX behavior (and requires less
code).

If this code works as intended, it will be possible to remove a lot of
code from Encodings.cpp.
2014-07-08 21:24:00 +02:00
Jean-Marc Lasgouttes
ea1a5cb80e Draw right-to-left text string-wise using Qt
We rely on Qt built-in unicode support for handling Arabic and Hebrew
compose characters. This allows to avoid to use our homegrown
machinery.

This  should provide a nice speedup at a low cost and
will eventually allow us to get rid of:
 * most of our Arabic/Hebrew machinery in Encodings.cpp,
 * Paragraph::transformChar,
 * and probably more.
2014-07-08 21:24:00 +02:00
Jean-Marc
93a43742a5 Fix a bunch of small performance issues spotted by cppcheck
Most of these are about passing const strings parameters as references.
2014-07-05 19:13:10 +02:00
Peter Kümmel
6b4c3036aa std::min/max are defined in <algorithm>
handle error in msvc12 when linking against msvc10 libs
2014-06-07 08:17:20 +02:00
Richard Heck
6b0a8fbc96 Fix bug #9112: There is a test here that seems intended to catch the
case where there are unbalanced braces, but it comes too late. In that
case, we try to check cmd[docstring::npos] and crash.
2014-05-08 18:19:55 -04:00
Vincent van Ravesteijn
88d0939166 Encodings: Make members of CharInfo private 2013-09-29 15:26:20 +02:00
Stephan Witt
2e23774c6c Encodings: Split off the functions that need Buffer
This is needed to be able to use Encodings in tex2lyx without the need to
compile Buffer as well, or to use a TEX2LYX define.
2013-09-29 15:26:18 +02:00
Vincent van Ravesteijn
01e94f5e03 Encodings: Add CharInfo to Encoding.h 2013-09-29 15:26:17 +02:00
Stephan Witt
b293bd3670 cosmetics: remove unneeded std:: prefix
Amended-by: Vincent van Ravesteijn <vfr@lyx.org>
2013-09-29 15:15:17 +02:00
Georg Baum
97bc443584 Fix regression of f2d2b7c
Thanks Scott for finding the relevant change set!
2013-02-28 22:23:23 +01:00
Georg Baum
f2d2b7cc7d Fix some texl2yx accent bugs
This fixes bug #8554 and some recently introduced busg:
- Encodings::fromLaTeXCommand() can now handle all combining characters,
  not only the one letter ones
- The remainder returned from Encodings::fromLaTeXCommand() must never be
  thrown away in tex2lyx, but output as ERT
- No special case for combining diacritical marks needed anymore in parse_text()
- No special cases for accents and IPA combining diacritical marks needed
  anymore in parse_text()
- special tipa short cuts may only be recognized if the tipa package is loaded
- Use requirements returned by Encodings::fromLaTeXCommand() instead of
  hardcoded registering of tipa and tipax
- Get rid of the name2 variable in parse_text(): We must use name, otherwise
  the extra stuff that might have been put into name vanishes
2013-02-24 15:44:16 +01:00
Georg Baum
9f93983b61 Extend unicodesymbols force flag
As suggested by Günter Milde.
2013-02-19 22:19:10 +01:00
Georg Baum
c0395333b2 Fix force flag for multiple encodings
A comma cannot be used as delimiter, since it is already the flag delimiter.
2013-02-17 10:19:58 +01:00
Pavel Sanda
718eeba60f Another attempt at Encoding::any (we don't compile at linux now). 2013-01-25 21:19:10 -08:00
Uwe Stöhr
9e29dc2338 Encoding.cpp: make it compilable again after [2eea1590/lyxgit] 2013-01-25 23:24:26 +01:00
Julien Rioux
2eea1590b1 Separation of the various names for encodings.
Provide functions for translating to the LyX name
of an encoding from either a LaTeX name or an Iconv
name, with the possibility to specify the package.
This is in anticipation of changing to use the LyX
name of the encoding in the .lyx file format and
allowing multiple lib/encodings entries to have
the same LaTeX name (but different packages!).

The tex2lyx parser needs to worry about the iconv
name of the input encoding, so store that instead
of the latex name.
2013-01-22 23:43:18 +01:00
Georg Baum
7c6a6a05a2 Fix bug #5087 as suggested by Jürgen
Now it is possible to force certain commands only for some encodings.
2013-01-13 21:36:41 +01:00
Georg Baum
ee3ce572a0 Fix import of shift-jis and big5 CJK texts.
These encodings were not defined, since they must not be used as document
encodings (the characters {, } and \ may appear in high bytes, and latex
would be confused). However, they are supported by CJK.sty (which uses a
preprocessor to circumvent the limitations of the latex executable). These
encodings are now defined, but used for import in tex2lyx only.
The test case CJK.tex contained fake tests for shift-jis and big5 (the
japanese and chinese characters were entered using the utf8 encoding), and
therefore the wrong interpretation of these encoding looked as if it worked.
The comments about missing iconv support of shift-jis and big5 were wrong as
well (otherwise shift-jis-plain would not work either).
2012-12-30 20:52:50 +01:00
Lars Gullik Bjønnes
6b2232a29c src/*.cpp: reformatting to increase consistency 2012-10-28 17:42:07 +01:00
Juergen Spitzmueller
398b1a450a properly validate unicode-math 2012-09-24 13:56:37 +02:00
Juergen Spitzmueller
8bf5d4b461 Very basic support for unicode-math
With non-TeX fonts, you can select a 'Non-TeX Font Default' math font, which simply loads unicode-math without actually selecting a math font, this then uses the default math otf font, currently Latin Modern. Other fonts still need to be set manually in the preamble, via \setmathfont.

The implementation suppresses unneeded package requests from unicodesymbols, but the output still uses macros instead of full unicode (both is possible with unicode-math).

The whole thing is a proof of concept, and it needs to be tested. I have tested it with the math manual, which compiles and seems to display correctly if I remove some hardcoded package loadings. OTOH I have not much experience with math.

This addresses #7449 partly.
2012-09-24 13:19:25 +02:00
Juergen Spitzmueller
51d591d168 Factor out method to get a properly encoded latex string 2012-06-30 13:30:48 +02:00
Georg Baum
1a6c599917 Extend the notermination flag to math as well.
Math commands need it as well as text commands. At the same time, this
further unifies the checking for termination and fixes cases of wrong
output (e.g. for 0x2005).
2012-03-25 15:57:38 +02:00
Jürgen Spitzmüller
2cf5de28a9 Add "notermination" flag to unicodesymbols. This tells us not to try any termination of the command (such as '{}' or ' ' ).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40905 a592a061-630c-0410-9148-cb99ea01b6c8
2012-03-10 13:34:42 +00:00
Jürgen Spitzmüller
84971fb27e * implement possibility to use IPA shortcut notation (the actual shortcuts will follow)
* do not terminate macros by {} if not necessary (prevent kerning violation)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40891 a592a061-630c-0410-9148-cb99ea01b6c8
2012-03-09 09:05:13 +00:00
Jürgen Spitzmüller
163bc119e6 Do not load font packages with encoding "utf8-plain" (bug #7766, #7782).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40633 a592a061-630c-0410-9148-cb99ea01b6c8
2012-01-20 06:07:12 +00:00
Georg Baum
bb0432d74a Beautify output of \usepckage statements (each statement is on its own line
now) and move more packages to the new exclude mechanism.
The remaining ones are not so easy.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40442 a592a061-630c-0410-9148-cb99ea01b6c8
2011-12-08 20:05:51 +00:00
Georg Baum
6954c542fb Generalize the esintoramsmath requirement:
Now you can also require a|b|c, and if any of the features is already used,
no other one will be loaded. The first feature wins if none is already used.
This is required for a part of bug #7811.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39884 a592a061-630c-0410-9148-cb99ea01b6c8
2011-10-18 19:32:02 +00:00
Richard Heck
d89d60c5a7 Fix bug #7682. Problem was that we were finding the children using the
BufferList, which knows nothing about clones.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39327 a592a061-630c-0410-9148-cb99ea01b6c8
2011-07-16 13:30:17 +00:00
Stephan Witt
c7e6a677c4 fix compiler warnings in pedantic mode: remove trailing comma after last enum member
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36923 a592a061-630c-0410-9148-cb99ea01b6c8
2010-12-17 19:56:51 +00:00
Enrico Forestieri
f5cc73f583 Avoid unnecessary exceptions.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33516 a592a061-630c-0410-9148-cb99ea01b6c8
2010-02-19 16:31:15 +00:00
Jean-Marc Lasgouttes
18b808e67c add "ansinew" as a synonym of LaTeX encoding "cp1252" (second part of #6142)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31439 a592a061-630c-0410-9148-cb99ea01b6c8
2009-09-22 13:05:43 +00:00
Enrico Forestieri
411b7a1dec Fix display of BibTeX entries in the info field of the citation
dialog by only converting text mode latex macros to unicode points.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30070 a592a061-630c-0410-9148-cb99ea01b6c8
2009-06-12 14:03:57 +00:00
Enrico Forestieri
3175a28893 Fix bug 5836 (http://bugzilla.lyx.org/show_bug.cgi?id=5836)
Cyrillic formatted text in mathmode

If some other letters from some script need to be typeset in italic,
it will suffice adding the flag "mathalpha" to the unicodesymbols file.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28731 a592a061-630c-0410-9148-cb99ea01b6c8
2009-03-09 06:34:00 +00:00
Jean-Marc Lasgouttes
29117ed909 compilation warning: unused parameter
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28509 a592a061-630c-0410-9148-cb99ea01b6c8
2009-02-16 10:05:40 +00:00
Enrico Forestieri
7728b5cbb9 Fix bug 5665
http://bugzilla.lyx.org/show_bug.cgi?id=5665


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28058 a592a061-630c-0410-9148-cb99ea01b6c8
2009-01-09 16:09:41 +00:00
Richard Heck
a05cc2c93e Fix minor problem with fromLaTeXCommand(): We were missing things like
\"{U}ber, since \"{U} was followed by a letter.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27987 a592a061-630c-0410-9148-cb99ea01b6c8
2009-01-04 23:26:04 +00:00
Enrico Forestieri
ef65f0e1af Add clarifying comment.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27969 a592a061-630c-0410-9148-cb99ea01b6c8
2008-12-23 12:49:42 +00:00
Enrico Forestieri
98114f5a82 Take into account that '\' is always part of a LaTeX command and also
that entries in the unicodesymbols file may not start with '\'.
Maybe the method should be renamed as fromLaTeXCode?


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27957 a592a061-630c-0410-9148-cb99ea01b6c8
2008-12-23 02:03:53 +00:00
Jean-Marc Lasgouttes
df8bb4edcd * Encoding.cpp (fromLaTeXCommand): fix bug when the string passed
to the method does not match any of the known unicode symbols.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27953 a592a061-630c-0410-9148-cb99ea01b6c8
2008-12-22 15:23:05 +00:00