>>>>> "Bennett" == Bennett Helm <[EMAIL PROTECTED]> writes:
>> Bennett, can you try the attached patch (against 1.4.0cvs)? Bennett> It does work. :) I am happy :) It turns out that the patch is a little bit more complicated than that (and the 1.3.x version is worse, but that's OK). As far as I can see, it does not change behavior in linux. I attach a test file that allows to see what happens on 1.4.x and 1.3.x. Bennett, could you try the file accents.lyx with the patches applied? The output is a bit less nice as it used to be, because 1.4.x has less nice code (the price to pay for code factorization, I guess). Lars, would you be OK with the 1.4.x version of the patch? JMarc
Index: src/insets/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.552.2.29 diff -u -p -r1.552.2.29 ChangeLog --- src/insets/ChangeLog 14 Jul 2005 11:10:43 -0000 1.552.2.29 +++ src/insets/ChangeLog 1 Aug 2005 21:26:09 -0000 @@ -1,3 +1,10 @@ +2005-08-01 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * insetlatexaccent.C (drawAccent): new method, backported from + HEAD. This contains in particular a fix for badly placed accents + in LyX/Mac. + (draw): use drawAccent. + 2005-07-14 Angus Leeming <[EMAIL PROTECTED]> * insetbib.C (InsetBibtex::latex): when processing the LaTeX file in Index: src/insets/insetlatexaccent.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.C,v retrieving revision 1.58.2.1 diff -u -p -r1.58.2.1 insetlatexaccent.C --- src/insets/insetlatexaccent.C 7 Dec 2004 10:49:35 -0000 1.58.2.1 +++ src/insets/insetlatexaccent.C 1 Aug 2005 21:26:09 -0000 @@ -358,6 +358,28 @@ bool InsetLatexAccent::displayISO8859_9( } +void InsetLatexAccent::drawAccent(Painter & pain, LyXFont const & font, + int baseline, float x, char accent, + bool fakeaccent) const +{ + x -= (font_metrics::rbearing(accent, font) + - font_metrics::lbearing(accent, font)) / 2; + // Usually, accent characters have a small height and live + // above the normal characters. This is why their descent is + // negative and the correction below is needed. However, in + // some fonts, accents are regular characters and we skip the + // correction (seen in Qt/Mac currently, but this may happen + // elsewhere). (JMarc) + if (fakeaccent || font_metrics::descent(accent, font) < 0) { + baseline -= font_metrics::ascent(ic, font); + baseline -= font_metrics::descent(accent, font); + baseline -= (font_metrics::ascent(accent, font) + + font_metrics::descent(accent, font)); + } + pain.text(int(x), baseline, accent, font); +} + + void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0, int baseline, float & x, bool) const { @@ -427,30 +449,22 @@ void InsetLatexAccent::draw(BufferView * switch (modtype) { case ACUTE: // acute 0xB4 { - pain.text(int(x2 - (font_metrics::rbearing(0xB4, font) - font_metrics::lbearing(0xB4, font)) / 2), - baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB4, font) - (font_metrics::ascent(0xB4, font) + font_metrics::descent(0xB4, font)) / 2, - char(0xB4), font); + drawAccent(pain, font, baseline, x2, 0xB4, false); break; } case GRAVE: // grave 0x60 { - pain.text(int(x2 - (font_metrics::rbearing(0x60, font) - font_metrics::lbearing(0x60, font)) / 2), - int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x60, font) - (font_metrics::ascent(0x60, font) + font_metrics::descent(0x60, font)) / 2.0), - char(0x60), font); + drawAccent(pain, font, baseline, x2, '`', true); break; } - case MACRON: // macron + case MACRON: // macron 0xAF { - pain.text(int(x2 - (font_metrics::rbearing(0xAF, font) - font_metrics::lbearing(0xAF, font)) / 2), - baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xAF, font) - (font_metrics::ascent(0xAF, font) + font_metrics::descent(0xAF, font)), - char(0xAF), font); + drawAccent(pain, font, baseline, x2, 0xAF, false); break; } - case TILDE: // tilde + case TILDE: // tilde { - pain.text(int(x2 - (font_metrics::rbearing('~', font) - font_metrics::lbearing('~', font)) / 2), - baseline - font_metrics::ascent(ic, font) - font_metrics::descent('~', font) - (font_metrics::ascent('~', font) + font_metrics::descent('~', font)) / 2, - '~', font); + drawAccent(pain, font, baseline, x2, '~', true); break; } case UNDERBAR: // underbar 0x5F @@ -476,19 +490,13 @@ void InsetLatexAccent::draw(BufferView * case DOT: // dot { - pain.text(int(x2 - (font_metrics::rbearing('.', font) - font_metrics::lbearing('.', font)) / 2.0), - baseline - font_metrics::ascent(ic, font) - font_metrics::descent('.', font) - (font_metrics::ascent('.', font) + font_metrics::descent('.', font)) / 2, - '.', font); + drawAccent(pain, font, baseline, x2, '.', true); break; } case CIRCLE: // circle { - LyXFont tmpf(font); - tmpf.decSize().decSize(); - pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0), - int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0), - char(0xB0), tmpf); + drawAccent(pain, font, baseline, x2, 0xB0, false); break; } case TIE: // tie @@ -534,28 +542,22 @@ void InsetLatexAccent::draw(BufferView * } case HUNGARIAN_UMLAUT: // hung. umlaut { - pain.text(int(x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font))), - baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2, - '´', font); - pain.text(int(x2), - baseline - font_metrics::ascent(ic, font) - font_metrics::descent('´', font) - (font_metrics::ascent('´', font) + font_metrics::descent('´', font)) / 2, - '´', font); + drawAccent(pain, font, baseline, + x2 - (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font)) / 2, + '´', false); + drawAccent(pain, font, baseline, + x2 + (font_metrics::rbearing('´', font) - font_metrics::lbearing('´', font)) / 2, + '´', false); break; } case UMLAUT: // umlaut { - pain.text(int(x2 - (font_metrics::rbearing('¨', font) - font_metrics::lbearing('¨', font)) / 2), - baseline - font_metrics::ascent(ic, font) - font_metrics::descent('¨', font) - (font_metrics::ascent('¨', font) + font_metrics::descent('¨', font)) / 2, - '¨', font); + drawAccent(pain, font, baseline, x2, '¨', false); break; } case CIRCUMFLEX: // circumflex { - LyXFont tmpf(font); - tmpf.decSize().decSize().decSize(); - pain.text(int(x2 - (font_metrics::rbearing(0x5E, tmpf) - font_metrics::lbearing(0x5E, tmpf)) / 2), - int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0x5E, tmpf) - (font_metrics::ascent(0x5E, tmpf) + font_metrics::descent(0x5E, tmpf)) / 3.0), - char(0x5E), tmpf); + drawAccent(pain, font, baseline, x2, 0x5E, true); break; } case OGONEK: // ogonek Index: src/insets/insetlatexaccent.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.h,v retrieving revision 1.40.2.2 diff -u -p -r1.40.2.2 insetlatexaccent.h --- src/insets/insetlatexaccent.h 7 Dec 2004 10:49:36 -0000 1.40.2.2 +++ src/insets/insetlatexaccent.h 1 Aug 2005 21:26:09 -0000 @@ -124,6 +124,8 @@ private: friend std::ostream & operator<<(std::ostream &, ACCENT_TYPES); /// Check if we know the modifier and can display it ok on screen. void checkContents(); + /// draw an accent + void drawAccent(Painter &, LyXFont const &, int, float, char, bool) const; /// string contents; /// can display as proper char
Index: src/insets/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.1177 diff -u -p -r1.1177 ChangeLog --- src/insets/ChangeLog 28 Jul 2005 09:45:43 -0000 1.1177 +++ src/insets/ChangeLog 1 Aug 2005 21:27:01 -0000 @@ -1,3 +1,10 @@ +2005-08-01 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * insetlatexaccent.C (drawAccent): add new argument fakeaccent for + accents built from real characters; fix case where real accents + have positive descent (like in Qt/Mac). + (draw): adapt to drawAccent change. + 2005-07-28 Jürgen Spitzmüller <[EMAIL PROTECTED]> * insettabular.C (getStatus): disable line and paragraph breaks Index: src/insets/insetlatexaccent.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.C,v retrieving revision 1.96 diff -u -p -r1.96 insetlatexaccent.C --- src/insets/insetlatexaccent.C 17 May 2005 11:11:45 -0000 1.96 +++ src/insets/insetlatexaccent.C 1 Aug 2005 21:27:01 -0000 @@ -330,15 +330,23 @@ bool InsetLatexAccent::displayISO8859_9( return true; } - +// realaccent is true when the character may have a small height void InsetLatexAccent::drawAccent(PainterInfo const & pi, int x, int y, - char accent) const + char accent, bool fakeaccent) const { LyXFont const & font = pi.base.font; x -= font_metrics::center(accent, font); - y -= font_metrics::ascent(ic, font); - y -= font_metrics::descent(accent, font); - y -= font_metrics::height(accent, font) / 2; + // Usually, accent characters have a small height and live + // above the normal characters. Their descent is then negative + // and the correction below is needed (as well as for fake + // accents like ~). However, in some fonts, accents are + // regular characters and we skip the correction (seen in + // Qt/Mac currently, but this may happen elsewhere). (JMarc) + if (fakeaccent || font_metrics::descent(accent, font) < 0) { + y -= font_metrics::ascent(ic, font); + y -= font_metrics::descent(accent, font); + y -= font_metrics::height(accent, font) / 2; + } pi.pain.text(x, y, accent, font); } @@ -407,19 +415,19 @@ void InsetLatexAccent::draw(PainterInfo // now the rest - draw within (x, y, x + wid, y + hg) switch (modtype) { case ACUTE: - drawAccent(pi, x2, baseline, '\xB4'); + drawAccent(pi, x2, baseline, '\xB4', false); break; case GRAVE: - drawAccent(pi, x2, baseline, '\x60'); + drawAccent(pi, x2, baseline, '\x60', true); break; case MACRON: - drawAccent(pi, x2, baseline, '\xAF'); + drawAccent(pi, x2, baseline, '\xAF', false); break; case TILDE: - drawAccent(pi, x2, baseline, '~'); + drawAccent(pi, x2, baseline, '~', true); break; case UNDERBAR: { @@ -443,11 +451,11 @@ void InsetLatexAccent::draw(PainterInfo break; case DOT: - drawAccent(pi, x2, baseline, '.'); + drawAccent(pi, x2, baseline, '.', true); break; case CIRCLE: - drawAccent(pi, x2, baseline, '\xB0'); + drawAccent(pi, x2, baseline, '\xB0', false); break; case TIE: @@ -489,16 +497,16 @@ void InsetLatexAccent::draw(PainterInfo } case HUNGARIAN_UMLAUT: - drawAccent(pi, x2 - font_metrics::center('´', font), baseline, '´'); - drawAccent(pi, x2 + font_metrics::center('´', font), baseline, '´'); + drawAccent(pi, x2 - font_metrics::center('´', font), baseline, '´', false); + drawAccent(pi, x2 + font_metrics::center('´', font), baseline, '´', false); break; case UMLAUT: - drawAccent(pi, x2, baseline, '"'); + drawAccent(pi, x2, baseline, '"', true); break; case CIRCUMFLEX: - drawAccent(pi, x2, baseline, '\x5E'); + drawAccent(pi, x2, baseline, '\x5E', false); break; case OGONEK: { Index: src/insets/insetlatexaccent.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetlatexaccent.h,v retrieving revision 1.69 diff -u -p -r1.69 insetlatexaccent.h --- src/insets/insetlatexaccent.h 17 May 2005 11:11:45 -0000 1.69 +++ src/insets/insetlatexaccent.h 1 Aug 2005 21:27:01 -0000 @@ -122,7 +122,8 @@ private: /// Check if we know the modifier and can display it ok on screen. void checkContents(); /// - void drawAccent(PainterInfo const & pi, int x, int y, char accent) const; + void drawAccent(PainterInfo const & pi, int x, int y, + char accent, bool fakeaccent) const; /// std::string contents; /// can display as proper char
#LyX 1.3 created this file. For more info see http://www.lyx.org/ \lyxformat 221 \textclass article \language english \inputencoding latin1 \fontscheme default \graphics default \paperfontsize default \papersize Default \paperpackage a4 \use_geometry 0 \use_amsmath 0 \use_natbib 0 \use_numerical_citations 0 \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \quotes_times 2 \papercolumns 1 \papersides 1 \paperpagestyle default \layout Standard \i \'{a} \i \`{a} \i \~{a} \i \^{a} \i \c{a} \i \"{a} \i \={a} \i \b{a} \i \t{a} b\i \d{a} \i \u{a} \i \v{a} \i \H{a} \i \.{a} \i \k{a} \the_end