Commit Graph

26 Commits

Author SHA1 Message Date
Guillaume Munch
a42c315e79 Amend ad7e2435cf
InsetMathKern is also used for non-mu lengths.

Generalise the fix by moving to Length::inPixels (thanks Jaan-Marc).
2016-11-21 00:08:11 +01:00
Richard Heck
355395174b Mark a number of coverity false positives.
Fixes coverity #23284, 23285, 23286, 23287, 23289.
2016-06-11 23:09:30 -04:00
Georg Baum
c0ce79452f Introduce proper integer rounding function
This fixes a failing unit test with 32bit gcc 4.9.3 and -O2 optimization:
It computed 9953 instead of 9954 for Length::inPixels() of value 2342.
The reason for this is probably different rounding behaviour caused by storing
the unrounded value in a processor register (uses 80bit accuracy) vs. writing
it back to memory (uses 64bit accuracy). The unrounded value is very close to
9953.5 (which is not representable as an exact IEEE floating point value).

Apart from that, having a proper function for rounding makes the code more
readable, and has the nice side effect to make Length::inPB() work for
negative lengths as well.
2016-02-17 21:42:37 +01:00
Georg Baum
79f11f4e7d Fix std::string docstream output error
This was made visible by aab1b145a5, since xhtml export for
lib/doc/Additional.lyx caused an exception. However, the cause for this was
already present earlier: All attempts to output a std::string to an
odocstream resulted in trying to change the encoding of the stream instead,
since there is no operator<<(odocstream &, std::string) defined, and an
implicit conversion to SetEnc happened instead.
This is fixed by making the SetEnc constructor explicit and adjusting all
code parts that did not compile anymore after that. The parts of the code
that did use the wrong output operator were the std::string version of
htmlize() from output_xhtml.cpp and all changed parts in the other .cpp files.
I also removed the std::string versions of html::htmlize() and
html::cleanAttr(), since it was difficult to see which encodings were used
with these. Now we are always explcit when using html::cleanAttr() and
html::htmlize().
2015-10-15 20:52:28 +02:00
Georg Baum
ccbac353ea Fix Length::inBP()
Length::inBP() returned the wrong values for most units. I guess that this was
caused by the default case in the switch statement: It did probably exist
before the other units were added.
inBP() is now correct for all units except the font dependent ones em, ex and
mu and the percent units: For these only approximate values are returned,
since not all needed information is available.
2015-07-12 18:36:19 +02:00
Juergen Spitzmueller
8b86af7298 Fix LaTeX length export of big numbers, part 2 (bug #9416)
LaTeX lengths must not use scientific notation, since the + sign has a
different meaning (glue lengths). This is the GUI part of bug 9416,
on top of part 1 [59e4d16ab/lyxgit].
2015-05-20 09:35:57 +02:00
Georg Baum
59e4d16ab9 Fix LaTeX length export of big numbers (bug 9416)
LaTeX lengths must not use scientific notation, since the + sign has a
different meaning (glue lengths). This is the export part of bug 9416, the GUI
part is still not fixed.
2015-05-14 12:14:47 +02:00
Jean-Marc Lasgouttes
66fa801e74 Improve support for on screen length calculation
The computation of length on screen depend in particular of the computation of the size of an em. Many places of the code used to rely on the width of the M character, which is not really correct:
http://en.wikipedia.org/wiki/Em_%28typography%29

In digital typography, the best value to use is the point size of the font.

* Implement FontMetrics::em(), which returns the value in pixels of the EM unit.
 Convert code to use it.

* Introduce Length::inPixel(MetricsBase const &), which takes the textwidth and em information from the MetricsBase object. Convert code to use it.

* Fix several places where Length::inPixel is used without a proper em value.

* add mathed_font_em() helper function. It should eventually be removed like some other functions in MathSupport.

* Add dummy implementation of FontMetrics to tex2lyx for linking purposes.
2015-03-26 17:10:15 +01:00
Georg Baum
2c39859575 Remove unneeded swap() (thanks Jean-Marc)
std::swap() does exactly the same thing, and avoiding code duplication is
always good.
2014-07-07 21:16:10 +02:00
Jean-Marc Lasgouttes
f04c7711b0 Fix empty width support for Box inset
* InsetBox and GuiBox: Use proper empty length instead of the broken -9.99col% trick
* some slight changes to the logic of GuiBox to make sure that values are set as needed.
* lengthToWidget(): handle properly the empty length case. All the other related Qt helpers did it already, it was probably an oversight. Also set the default_unit parameter as optional (not needed in this patch actually, but I got carried away :)
* allow generating LaTeX code for an empty length, since some broken code does that.
2013-05-24 15:44:59 +02:00
Jean-Marc Lasgouttes
25ff2f8e2b Improve support for empty lengths
Parse empty string as empty length
Output empty length as empty string when it makes sense (not for LaTeX strings, for example).
2013-05-24 15:44:58 +02:00
Vincent van Ravesteijn
5014b38cb7 Add a preference option to specify the default length unit (cm or in).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40030 a592a061-630c-0410-9148-cb99ea01b6c8
2011-10-27 11:52:11 +00:00
Vincent van Ravesteijn
269695aa5f Remove the prefence default_papersize
- This preference was used for specifying the papersize to xdvi, dvipdfm,
  dvips. However, I can't seem to see any effect on the result.

- The papersize should instead be defined in the document settings.

- The global papersize default was misused to also change the tex
  output by specifying the papersize as if it was specified in the
  document settings. This caused the same lyx document to be outputted
  differently on different pcs.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40028 a592a061-630c-0410-9148-cb99ea01b6c8
2011-10-27 11:48:16 +00:00
Uwe Stöhr
306ebdf80b Length.cpp: fix sort order - in all other files we have PTH before PPH
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35012 a592a061-630c-0410-9148-cb99ea01b6c8
2010-07-25 00:17:48 +00:00
Uwe Stöhr
969a8356b8 Length.cpp: take care of percent units also for glue lengths, with this change, #6091 and #6098 can be fixed
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30693 a592a061-630c-0410-9148-cb99ea01b6c8
2009-07-19 20:01:39 +00:00
Richard Heck
bd5cccbb34 Lengths for HTML. Use them for InsetBox.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30074 a592a061-630c-0410-9148-cb99ea01b6c8
2009-06-12 14:42:33 +00:00
Jean-Marc Lasgouttes
26751d83ee Move the half baked code that guesses whether to default on metric or
imperial units in only one place (instead of thousands of slightly different
copies). Functionally equivalent.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28380 a592a061-630c-0410-9148-cb99ea01b6c8
2009-02-06 21:24:13 +00:00
André Pönitz
f1cba8ff64 more latin1..utf8 schanges. all of src/* should be utf8 now
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27425 a592a061-630c-0410-9148-cb99ea01b6c8
2008-11-14 15:58:50 +00:00
Abdelrazak Younes
9383f4c3c6 'using namespace std' instead of 'using std::xxx'
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22097 a592a061-630c-0410-9148-cb99ea01b6c8
2007-12-12 10:16:00 +00:00
Abdelrazak Younes
e61bae3dbb revert rev 21490.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21491 a592a061-630c-0410-9148-cb99ea01b6c8
2007-11-07 16:41:48 +00:00
Abdelrazak Younes
5a8a8b6b0c integrate lengthcommon.cpp into Length.cpp.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21490 a592a061-630c-0410-9148-cb99ea01b6c8
2007-11-07 15:55:59 +00:00
André Pönitz
a5263e0f92 introduce a header to forward declare std::string.
hope there are only conforming implementaions out there ;-}


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21312 a592a061-630c-0410-9148-cb99ea01b6c8
2007-10-31 22:40:34 +00:00
Abdelrazak Younes
5ddc612b73 Splitup Font in saner bits:
* Font::FontBits -> FontInfo
* Font::FONT_XXX -> all enums transfered to FontEnums.h and renamed to FontXxx

I've replaced Font uses with FontInfo were the language() member was not needed, basically all draw() and metrics methods. There's one problematic cases with InsetQuotes which I solved by taking the Buffer main language.




git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21240 a592a061-630c-0410-9148-cb99ea01b6c8
2007-10-28 18:51:54 +00:00
André Pönitz
e7aa8ce683 cosmetics... less than intented
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21190 a592a061-630c-0410-9148-cb99ea01b6c8
2007-10-24 22:55:02 +00:00
André Pönitz
fc6ce7cd08 rename LyXFont to Font except in tex2lyx
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18095 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-29 18:17:15 +00:00
André Pönitz
8c622e4ff0 rename/merge LyXLength related stuff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18067 a592a061-630c-0410-9148-cb99ea01b6c8
2007-04-28 12:58:49 +00:00