In fact having an extra parameter "bool cond" is no longer useful because it can
now always be emulated with a ternary operator:
Changers dummy = cond ? do_change() : Changer();
* Factor code for easier maintainance.
* Avoid computing metrics several times. This duplication explained the
exponential blowup during the metrics phase for nested fractions (see
b2b87330). This happened in particular when using lyxproofs which heavily uses
nested \dfracs for on-screen drawing.
* Call MetricsBase::changeScript instead of MetricsBase::changeFrac for
\nicefrac and \unitfrac.
Move math style to FontInfo and compute the font sizes for scriptstyle and
scriptscriptstyle according to standard proportions: 0.73 and 0.55.
This is simpler and more accurate. It also fixes the font size of
${\scriptscriptstyle {\textstyle A}}A$ which exposed the limitations of the
previous approach.
The purpose of this branch is to improve the spacing in math equations
* do not use hardcoded pixel values, but math units that depend on
zoom and dpi. This should be good for HiDPI systems.
* implement as much as possible the math typesetting algorithm
described in Appendix G of the TeXbook.
One typical example of the spacing algorithm is that ``-a'' has no
spacing, contrary to ``a + b''. This reflects the unitary/binary
minus that will indeed happen in typeset output.
Together with the better character substitution that has already been
implemented by Guillaume, we get a nice improvement of mathed looks.
What makes this code complicated is that it handles macros properly:
the spacing inside the macro will depend on the values of the
arguments and the elements that are before and after the macro.
As a result, many definitions in lib/symbols are now just copy/pasted
from the relevant sty file. In particular, it is now possible to make
use of \mathrel, \mathbin, etc. macros to specify spacing.
This merge is a starting point. Remaining work includes
* proper handling of sub/superscript nucleus and of font-changing
insets (as is done in the TeX algorithm).
* proper typesetting of fractions
Thanks to Guillaume for extensive testing.
Try as far as possible to use the same definitions as in the LaTeX files.
An example of that is the definition and subsequent use of \joinrel,
\relbar and \Relbar.
This is mostly Guillaume's work.
There is no reason to reserve pixel space in macros replacement text,
which is not editable. This makes macros more compact and eases the
writing of lib/symbols.
* introduce new InsetMath::drawMarkers and friends that do nothing
when nested inside a macro. This required to move macro_nesting
inside MetricsBase, and to pass MetricsInfo & to metricsMarkers.
* keep track of nesting when drawing rows or macros.
Empty insets should use a minimal amount of space, especially when
they are part of a built-in macro in lib/symbols.
With this change, blue rectangles signal actually editable places.
Empty macros in editable data are shown as grey boxes, but they do not
appear when further nested.
This is done by adding a new type BOX of MathRow::Element object and a
MetricsInfo::macro_nesting that keeps track of macros (and is reset to
0 in editable macro arguments).
* new MathRow class which contains the description of a MathData
object in terms of math class and spacing
+ macros and their arguments used in the MathData object are
linearized (replaced with their contents) so that all math insets
are typeset as a string together. To this end, we introduce a
method addToMathRow to InsetMath and MathData. This method allows
to linearize recursively a MathData object.
+ It is then necessary to set manually the dimension and position of
the macros and arguments.
+ the class class and spacing are computed using the MathClass helpers.
The MathRow data is cached in the MathData object in a bufferview-dependent
way (different dpi for different screens).
* delegate most of the work MathData::metrics/draw to MathRow metrics/draw.
The case of draw is trickier, since many draw() methods rely on their
metrics without any spacing added.
This implements the relevant math typography rules described in the
Appendix G of the TeXbook. More precisely, for each atom
+ the class is computed by implementing rules 5 and 6 of Appendix G
+ the spacing is computed according to the table p. 170
This code is not used at this point.
This done according to the TeXbook. This class replaces the individual
isMathXXX() methods. The mathClass() method (currently unused) is
provided for the following insets:
* InsetMathChar (with a revised list of affected characters)
* InsetMathSymbol: the class is given by the `extra' field
Operators defined in lib/symbols (e.g. \log) are MC_OP
* InsetMathFrac is MC_INNER (except nicefrac and units)
* InsetDelimiters is MC_INNER
* InsetStackrel is MC_REL
* The class of InsetScript is the class of the last element of its
nucleus (yes, it is a hack, but doing it right is more work).
Remove the explicit spacing that was done in the different insets. The spacing
will be reintroduced properly in a forthcoming commit.
Test unicodesymbols for most supported input encodings with Kornel's addition to ctests.
Add required "forces" to unicodesymbols:
* utf8x does not support all characters supported by LyX
* several 8-bit encodings map characters to math-mode commands - force replacement in text-mode so that LyX can wrap them in \\ensuremath.
Fix a misalignment (wrong replacements) in the Cyrillic Unicode block.
Use \\mathscr for Mathematical Script characters in Mathematical Alphanumeric Characters (in line with the characters in other unicode blocks.
Rename the directory for test samples "export/latex/Unicode-characters" to "export/latex/unicodesymbols". This matches the purpose to test the lib/unicodesymbols file.
* set up a replacement of *, -, and : by the adequate symbols (#9893)
* fix the wrong character selection and operator spacing in \text mode
* hide some internal symbols from the auto-completion.
* Fix spacing in lib/symbols after recent commits about math spacing, as well as
older spacing issues (e.g. \Join).
* InsetMathKern now uses the same em value as other math length commands.
What is nice is that the kerning amount now matches the ones found in the
packages definition (modulo 10mu that lyx currently adds between relations).
Testcase: $\CheckedBox\LEFTcircle\RIGHTcircle\photon\gluon\vcentcolon\dblcolon\Coloneqq\eqcolon\models\hookrightarrow\bowtie\hookleftarrow\Join\APLinv\neq$
First run of Kornels patch for tests with all input encodings in lib/encodings.
Remove redundant sample files - keep only one sample and change the input encoding in the test script.
Put remaining failing test in "unreliableTests" for later sorting...
This is a long wanted feature, although it does not go all the way to
fix#6604 (private-cut/private-paste).
Additionally, it fixes a crash that can happen when using undefined
branches. This is done by making the action when pasting unknown
branches configurable.
Fixes bug #6570.
An overlong word containing a hyphen could be broken anywhere, instead of after
the hyphen.
Example: compare the line breaking of
aaaaa-aaaaa-aaaaa-aaaaa
with
aaa aaaaa-aaaaa-aaaaa-aaaaa
(with a very narrow window)
This also improves Chinese text in some situations (#10299)
1) Distinguish expanding characters from separators, to fit with Qt's notion of
expanding character which comes from the Unicode std. CountExpanders() is moved
to FontMetrics to fix a discrepancy with the duplicate implementation from
598f7e4a.
2) Make these expanders stretch on-screen proportionally to the em of the font.
If a row mixes large and small text, LyX let us see which spaces are set in the
bigger font.
3) Now that the stretch is defined in ems, add a limit such that an expander
never stretches more than 1.5em to avoid weird and hard to read justified lines.
4) Add a return boolean to setSeparatorExtraWidth for future use.
When \multicolumn{ncol}{align}{content} is parsed and the ncol
parameter is not a numeric value, this parameter is swallowed
and replaced with '1'. Hence, if the file is subsequently saved
a dataloss would occur. With this commit, \multicolumn is not
interpreted when ncol is not a numeric value and is left as is.
See also #10466
It turns out that Cursor::getFont() does not return a fully realized
font in some cases. This patch uses real_current_font instead, which
seems better anyway.
I suspect that all uses of getFont() should be removed, but this is
not code that I know well.
Fixes bug #10478.
This means that, when a string contains high-plane Unicode characters,
the length of a docstring and the corresponding QString will be
different: Qt will encode these characters using several 16bit
characters.
We have additionally to take into account QTBUG-25536, which implies
that sometimes qstring_to_ucs4(toqstr(s)) !=s. It is not clear whether
this bug can be a problem in other places.
Fixes bug #10443.