]> git.lyx.org Git - features.git/commitdiff
fix in lyxfont.C bogus static_cast, some changes in insetlatexaccent
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 15 Dec 1999 06:12:28 +0000 (06:12 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 15 Dec 1999 06:12:28 +0000 (06:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@380 a592a061-630c-0410-9148-cb99ea01b6c8

27 files changed:
ChangeLog
acconfig.h
po/ca.po
po/cs.po
po/da.po
po/de.po
po/es.po
po/fi.po
po/fr.po
po/hu.po
po/it.po
po/nl.po
po/pl.po
po/pt.po
po/ru.po
po/sl.po
po/sv.po
po/tr.po
po/wa.po
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/lyxdraw.C
src/lyxfont.C
src/lyxfont.h
src/support/lstrings.C
src/support/lstrings.h
src/support/lyxstring.C

index 920291d79cb1cb3a8280478d91e2e69d33592dfa..4c32cbb42dd7c04ec038d8f6f8a1abe5b0ae2b82 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+1999-12-15  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * src/insets/insetlatexaccent.C (Lbearing): new function, used to
+       help with placing the manually drawn accents better.
+       (Rbearing): ditto
+       (Draw): x2 and hg changed to float to minimize rounding errors and
+       help place the accents better.
+
+       * src/lyxfont.C (ascent): fixed faulty static_cast, casting from
+       unsigned short to char is just wrong...cast the char to unsigned
+       char instead so that the two values can compare sanely. This
+       should also make the display of insetlatexaccents better and
+       perhaps also some other insets.
+       (descent): ditto
+       (lbearing): new function
+       (rbearing): ditto
+
 1999-12-15  Allan Rae  <rae@lyx.org>
 
        * src/stl_string_fwd.h, src/Makefile.am (lyx_SOURCES):  added new
index f78514cf08941224056b3e3a8aca1fb307236c1e..e39c682e62160a0d369400cbc18246d0516f05e4 100644 (file)
 /* Define as 1 if you have the stpcopy function */
 #undef HAVE_STPCPY
 
-/*
+#if 0
 /* Define if the bool type is known to your compiler */
 #undef HAVE_bool
-*/
+#endif
 
 /* Define to the name of the distribution.  */
 #undef PACKAGE
index 01622a6324ad27dbf15ae3e231b1e6ae5c2e9268..400608e1fd962046aa128c2597a0cb8cc09f7951 100644 (file)
--- a/po/ca.po
+++ b/po/ca.po
@@ -4931,9 +4931,3 @@ msgstr "No es pot tallar la taula."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Un flotant inclouria un flotant!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Error! Impossible tancar el fitxer correctament: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Error! Impossible tancar el fitxer correctament: "
index 839f6f43120ce2e33e55b667f61136e6dcf7630f..eed1088a002e6bf64abc0d24f2c789a11293dfb7 100644 (file)
--- a/po/cs.po
+++ b/po/cs.po
@@ -4924,9 +4924,3 @@ msgstr "Nelze rozd
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Objekt by obsahoval objekt!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Chyba! Nemohu správnì uzavøít soubor: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Chyba! Nemonu strávnì uzavøít soubor:"
index be0b8e83143f74725640f1df4959e07dc0d476ab..86ee2304d3ece877331d830f61070af1066e6bad 100644 (file)
--- a/po/da.po
+++ b/po/da.po
@@ -4970,9 +4970,3 @@ msgstr "Kan ikke klippe tabel."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Flyder ville inkludere flyder!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Fejl! Filen blev ikke lukket korrekt: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Fejl: Filen blev ikke lukket korrekt:"
index b3738c0dfbab52434f3d6ead8ddc4238eba3d26b..98586e7a6eb67cd74b1029d680c73823d9bc663b 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -4952,9 +4952,3 @@ msgstr "Die Tabelle kann nicht ausgeschnitten werden."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Float Objekt würde ein weiteres enthalten!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Fehler! Die Datei konnte nicht ordnungsgemäß geschlossen werden: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Fehler! Die Datei konnte nicht ordnungsgemäß geschlossen werden: "
index fd9a7b86a592f13828caa1ea17e61ed68d9e2e36..f73e4fe85863e6af1e87fe615dff471f0593553d 100644 (file)
--- a/po/es.po
+++ b/po/es.po
@@ -4963,9 +4963,3 @@ msgstr "No se puede cortar tabla."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "¡Flotante incluiría un flotante!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "¡Error! No se pudo cerrar el archivo correctamente: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "¡Error! No se puede cerrar el archivo correctamente:"
index f0d96e153e82d8443a022c0c054e6819b33909ac..58b0f40467553bfcc91bdeeeec0b1ae2e496136d 100644 (file)
--- a/po/fi.po
+++ b/po/fi.po
@@ -4947,9 +4947,3 @@ msgstr "Ei voi jakaa taulukkoa."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Kelluva sisältäisi kelluvan!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Virhe! En saanut tiedosto kunnolla suljetuksi: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Virhe! En saanut tiedosto kunnolla suljetuksi:"
index a6c5c1a51e7086403e56b779aeab53aa9d800f56..fda4ffa245a87819d57ceb3d8cd2da9877b60234 100644 (file)
--- a/po/fr.po
+++ b/po/fr.po
@@ -4978,9 +4978,3 @@ msgstr "Impossible de couper le tableau."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Un flottant inclurait un flottant !"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Erreur ! Impossible de fermer le fichier correctement : "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Erreur ! Impossible de fermer le fichier correctement : "
index 402fd7362c2c70b7397551b4aa2c29ded186dedd..2bd5627ba15f78ed291fe2048eb7e6b3ab18e901 100644 (file)
--- a/po/hu.po
+++ b/po/hu.po
@@ -4940,9 +4940,3 @@ msgstr ""
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr ""
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Hiba! Nem sikerült a fájlt rendesen bezárni: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Hiba! Nem sikerült a fájlt rendesen bezárni:"
index 278630794c2f050c746323f150294643e12ab163..9a4b21d8ff931c7b2f475a165201a702d54a90c2 100644 (file)
--- a/po/it.po
+++ b/po/it.po
@@ -4958,9 +4958,3 @@ msgstr "Non puoi tagliare una tabella."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "L'oggetto flottante ne includerebbe un altro!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Errore! Non riesco a chiudere correttamente il file: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Errore! Non riesco a chiudere correttamente il file:"
index 38a4aedd9f14cde01a50a6909bdbafc2713fdcd7..0d9ae74ffdfb4ebcfeddbd2cf735167531a387ad 100644 (file)
--- a/po/nl.po
+++ b/po/nl.po
@@ -4977,9 +4977,3 @@ msgstr "Kan tabel niet splitsen."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Hier zou een zwever een andere zwever bevatten!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Fout! Kon bestand niet op juiste wijze sluiten: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Fout! Kon bestand niet op juiste wijze sluiten:"
index 010174e55d35860a4af8fc54148058a985264f30..46a969290e1b24b9ee93398126d0ffb5db7d423b 100644 (file)
--- a/po/pl.po
+++ b/po/pl.po
@@ -4924,9 +4924,3 @@ msgstr "Nie mo
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Wstawka móg³aby zawieraæ inn± wstawkê!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "B³±d! Nie mo¿na poprawnie zamkn±æ pliku: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "B³±d! Nie mo¿na poprawnie zamkn±æ pliku:"
index 10458f55f15e42ebe915397c63968d70723f7aac..1be140bcc13c6e670314daa02780e8034b7754cc 100644 (file)
--- a/po/pt.po
+++ b/po/pt.po
@@ -4975,9 +4975,3 @@ msgstr "N
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Flutuante incluiria flutuante!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Erro! Não posso fechar corretamente o arquivo"
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Erro! Não posso fechar corretamente o arquivo"
index 21d7b3ff8f13289d26e73a1408b925d2e94f8a4d..adf9f18e1aae47ab3c5f980107a7c3314581ff6f 100644 (file)
--- a/po/ru.po
+++ b/po/ru.po
@@ -4998,9 +4998,3 @@ msgstr "
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "ëÁÄÒ ÄÏÌÖÅΠ×ËÌÀÞÁÔØ ËÁÄÒ!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "ïÛÉÂËÁ ÚÁËÒÙÔÉÑ ÆÁÊÌÁ "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "ïÛÉÂËÁ ÚÁËÒÙÔÉÑ ÆÁÊÌÁ "
index 3ce8e241ee0f0e65c56e31ee95215467bc2f00b9..292c39fd988ccd166f0659340d73daa21e0d6e97 100644 (file)
--- a/po/sl.po
+++ b/po/sl.po
@@ -4937,9 +4937,3 @@ msgstr "Ne morem razkosati tabele."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Plovka bi vkljuèevala plovko!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Napaka! Ne morem pravilno zapreti datoteke: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Napaka! Ne morem pravilno zapreti datoteke:"
index 84c33aa01cec9efccc76749eead1761726a5e537..fd917c5c834538838cf434883d7a2be6cd58b929 100644 (file)
--- a/po/sv.po
+++ b/po/sv.po
@@ -5062,9 +5062,3 @@ msgstr "Kan inte klippa tabell."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Flytande objekt skulle då innefatta ett annat!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Fel! Kunde inte stänga filen ordentligt: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Fel: Kunde inte stänga filen ordentligt:"
index ae40f7382202da1833bb872e199e43578e7cb8fb..1ccd59009dc390e1ef1d1a16cfb6e86c21bf8828 100644 (file)
--- a/po/tr.po
+++ b/po/tr.po
@@ -4996,9 +4996,3 @@ msgstr "Tabloyu kesemem."
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "Tek-parça, tek-parça içermeli!"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Hata! Dosya düzgün olarak kapatýlamadý: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Hata! Dosya düzgün kapatýlamadý:"
index ab29fe825c1167605a56318acce1fac78975a93f..947df797e8fbab731da2005447e09a07951c381a 100644 (file)
--- a/po/wa.po
+++ b/po/wa.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: LyX 1.0.0\n"
 "POT-Creation-Date: 1999-12-13 23:06+0100\n"
-"PO-Revision-Date: 1999-12-01 00:26+01:00\n"
+"PO-Revision-Date: 1999-12-13 23:40+01:00\n"
 "Last-Translator: Lorint Hendschel <LorintHendschel@skynet.be>\n"
 "Language-Team: walon <linux-wa@chanae.alphanet.ch>\n"
 "MIME-Version: 1.0\n"
@@ -4982,9 +4982,3 @@ msgstr "Dji n' sai c
 #: src/text.C:3927
 msgid "Float would include float!"
 msgstr "I gn åreut on flotant di stitchî dins èn ôte flotant !"
-
-#~ msgid "Error! Could not close file properly: "
-#~ msgstr "Aroke! Dji n' sai cloyu ci fitchî la comufåt: "
-
-#~ msgid "Error! Could not close file properly:"
-#~ msgstr "Aroke! Dji n' sai cloyu ci fitchî ci comufåt: "
index f26d3d8a8bd2b2cabe3f3e6d68cf447c56dc389a..8b018478a1b5bce07392a864c462395ddbd3db15 100644 (file)
@@ -264,6 +264,10 @@ void InsetLatexAccent::checkContents()
 
 int InsetLatexAccent::Ascent(LyXFont const & font) const
 {
+       // This function is a bit too simplistix and is just a
+       // "try to make a fit for all accents" approach, to
+       // make it better we need to know what kind of accent is
+       // used and add to max based on that.
        int max;
        if (candisp) {
                if (ic == ' ')
@@ -303,6 +307,18 @@ int InsetLatexAccent::Width(LyXFont const & font) const
 }
 
 
+int InsetLatexAccent::Lbearing(LyXFont const & font) const
+{
+       return font.lbearing(ic);
+}
+
+
+int InsetLatexAccent::Rbearing(LyXFont const & font) const
+{
+       return font.rbearing(ic);
+}
+
+
 bool InsetLatexAccent::DisplayISO8859_9(LyXFont font,
                            LyXScreen & scr,
                            int baseline, 
@@ -357,73 +373,80 @@ void InsetLatexAccent::Draw(LyXFont font,
                        return;
        
        /* draw it! */ 
-  
+       // All the manually drawn accents in this function could use an
+       // overhaul. Different ways of drawing (what metrics to use)
+       // should also be considered.
+       
        if (candisp) {
                int asc = Ascent(font);
                int desc = Descent(font);
                int wid = Width(font);
-               float x2 = x + float(wid/2);
+               float x2 = x + (Rbearing(font) - Lbearing(font)) / 2.0;
                float hg35;
-               int hg, y;
+               float hg;
+               int y;
                if (plusasc) {
                        // mark at the top
                        hg = font.maxDescent();
                        y = baseline - asc;
 
-                       if (font.shape() == LyXFont::ITALIC_SHAPE) x2 += (4*hg)/5; // italic
+                       if (font.shape() == LyXFont::ITALIC_SHAPE)
+                               x2 += (4.0 * hg) / 5.0; // italic
                } else {
                        // at the bottom
                        hg = desc;
                        y = baseline;
                }
 
-               hg35 = float(hg*3)/5;
+               hg35 = float(hg * 3.0) / 5.0;
 
                // display with proper accent mark
                // first the letter
                scr.drawText(font, &ic, 1, baseline, int(x));
 
-               GC pgc = GetAccentGC(font, (hg+3)/5);
+               GC pgc = GetAccentGC(font, int((hg + 3.0) / 5.0));
 
                if (remdot) {
                        int tmpvar = baseline - font.ascent('i');
                        float tmpx = 0;
-                       if (font.shape() == LyXFont::ITALIC_SHAPE) tmpx += (8*hg)/10; // italic
+                       if (font.shape() == LyXFont::ITALIC_SHAPE)
+                               tmpx += (8.0 * hg) / 10.0; // italic
                        lyxerr.debug() << "Removing dot." << endl;
                        // remove the dot first
                        scr.fillRectangle(gc_clear, int(x + tmpx),
                                          tmpvar, wid,
                                          font.ascent('i') -
-                                         font.ascent('x')-1);
-                       
+                                         font.ascent('x') - 1);
                }
                // now the rest - draw within (x, y, x+wid, y+hg)
                switch (modtype) {
                case ACUTE:     // acute
                {
-                       scr.drawLine(pgc, int(x2), int(y+hg35),
-                                    int(x2+hg35), y);
+                       scr.drawLine(pgc, int(x2), int(y + hg35),
+                                    int(x2 + hg35), y);
                        break;
                }
                case GRAVE:     // grave
                {
-                       scr.drawLine(pgc, int(x2), int(y+hg35),
-                                    int(x2-hg35), y); 
+                       scr.drawLine(pgc, int(x2), int(y + hg35),
+                                    int(x2 - hg35), y); 
                        break;
                }
                case MACRON:     // macron
                {
                        scr.drawLine(pgc,
-                                    int(x2-(3*wid/7)), int(y+(hg/2) + hg35),
-                                    int(x2+(3*wid/7)), int(y+(hg/2) + hg35));
+                                    int(x2 - (3.0 * wid / 7.0)),
+                                    int(y + (hg / 2.0) + hg35),
+                                    int(x2 + (3.0 * wid / 7.0)),
+                                    int(y + (hg / 2.0) + hg35));
                        break;
                }
                case TILDE:     // tilde
                {
-                       if (hg35 > 2) --hg35;
-                       x2 += (hg35/2);
+                       if (hg35 > 2.0) hg35 -= 1.0;
+                       x2 += (hg35 / 2.0);
                        XPoint p[4];
-                       p[0].x = int(x2 - 2*hg35); p[0].y = int(y + hg);
+                       p[0].x = int(x2 - 2.0 * hg35); p[0].y = int(y + hg);
                        p[1].x = int(x2 - hg35);   p[1].y = int(y + hg35);
                        p[2].x = int(x2);          p[2].y = int(y + hg);
                        p[3].x = int(x2 + hg35);   p[3].y = int(y + hg35);
@@ -433,44 +456,48 @@ void InsetLatexAccent::Draw(LyXFont font,
                case UNDERBAR:     // underbar
                {
                        scr.drawLine(pgc,
-                                    int(x2-(3*wid/7)), y+(hg/2),
-                                    int(x2+(3*wid/7)), y+(hg/2));
+                                    int(x2 - (3.0 * wid / 7.0)),
+                                    y + (hg / 2.0),
+                                    int(x2 + (3.0 * wid / 7.0)),
+                                    y + (hg / 2.0));
                        break;
                }
                case CEDILLA:     // cedilla
                {
                        XPoint p[4];
                        p[0].x = int(x2);          p[0].y = y;
-                       p[1].x = int(x2);          p[1].y = y + (hg/3);
-                       p[2].x = int(x2 + (hg/3)); p[2].y = y + (hg/2);
-                       p[3].x = int(x2 - (hg/4)); p[3].y = y + hg;
+                       p[1].x = int(x2);          p[1].y = y + int(hg / 3.0);
+                       p[2].x = int(x2 + (hg / 3.0));
+                       p[2].y = y + int(hg / 2.0);
+                       p[3].x = int(x2 - (hg / 4.0)); p[3].y = y + int(hg);
                        scr.drawLines(pgc, p, 4);
                        break;
                }
                case UNDERDOT:     // underdot
                case DOT:    // dot
                {
-                       scr.drawArc(pgc, int(x2), y+(hg/2),
+                       scr.drawArc(pgc, int(x2), y + (hg / 2.0),
                                    1, 1, 0, 360*64); 
                        break;
                }
                case CIRCLE:     // circle
                {
-                       scr.drawArc(pgc, int(x2-(hg/2)), y, hg, hg, 0,
+                       scr.drawArc(pgc, int(x2 - (hg / 2.0)),
+                                   y + (hg / 2.0), hg, hg, 0,
                                    360*64);
                        break;
                }
                case TIE:     // tie
                {
                        scr.drawArc(pgc,
-                                   int(x2), y+(hg/4),
+                                   int(x2), y + (hg / 4.0),
                                    hg, hg, 0, 11519);
                        break;
                }
                case BREVE:     // breve
                {
                        scr.drawArc(pgc,
-                                   int(x2-(hg/2)), y-(hg/4),
+                                   int(x2 - (hg / 2.0)), y - (hg / 4.0),
                                    hg, hg, 0, -11519);
                        break;
                }
@@ -478,7 +505,7 @@ void InsetLatexAccent::Draw(LyXFont font,
                {
                        XPoint p[3];
                        p[0].x = int(x2 - hg35); p[0].y = y;
-                       p[1].x = int(x2);        p[1].y = int(y+hg35);
+                       p[1].x = int(x2);        p[1].y = int(y + hg35);
                        p[2].x = int(x2 + hg35); p[2].y = y;
                        scr.drawLines(pgc, p, 3);
                        break;
@@ -486,49 +513,60 @@ void InsetLatexAccent::Draw(LyXFont font,
                case SPECIAL_CARON:    // special caron
                {
                        switch (ic) {
-                       case 'L': wid = 4*wid/5; break;
-                       case 't': y -= int(hg35/2); break;
+                       case 'L': wid = int(4.0 * wid / 5.0); break;
+                       case 't': y -= int(hg35 / 2.0); break;
                        }
                        XPoint p[3];
-                       p[0].x = int(x+wid);          p[0].y = int(y+hg35+hg);
-                       p[1].x = int(x+wid+(hg35/2)); p[1].y = int(y+ hg+(hg35/2));
-                       p[2].x = int(x+wid+(hg35/2)); p[2].y = y + hg;
+                       p[0].x = int(x + wid);   p[0].y = int(y + hg35 + hg);
+                       p[1].x = int(x + wid + (hg35 / 2.0));
+                       p[1].y = int(y + hg + (hg35 / 2.0));
+                       p[2].x = int(x + wid + (hg35 / 2.0));
+                       p[2].y = y + int(hg);
                        scr.drawLines(pgc, p, 3);
                        break;
                }
                case HUNGARIAN_UMLAUT:    // hung. umlaut
                {
                        XSegment s[2];
-                       s[0].x1= int(x2-(hg/2));      s[0].y1 = int(y + hg35);
-                       s[0].x2= int(x2+hg35-(hg/2)); s[0].y2 = y;
-                       s[1].x1= int(x2+(hg/2));      s[1].y1 = int(y + hg35);
-                       s[1].x2= int(x2+hg35+(hg/2)); s[1].y2 = y;
+                       s[0].x1= int(x2 - (hg / 2.0));     s[0].y1 = int(y + hg35);
+                       s[0].x2= int(x2 + hg35 - (hg / 2.0)); s[0].y2 = y;
+                       s[1].x1= int(x2 + (hg / 2.0));
+                       s[1].y1 = int(y + hg35);
+                       s[1].x2= int(x2 + hg35 + (hg / 2.0)); s[1].y2 = y;
 
                        scr.drawSegments(pgc, s, 2);
                        break;
                }
                case UMLAUT:    // umlaut
                {
-                       int tmpadd = y;
-                       tmpadd += (remdot) ? ((19*hg)/10) : ((20*hg)/27); // if (remdot) -> i or j
-                       int rad = ((hg*4)/8);
-                       if (rad <= 1) {
-                               scr.drawPoint(pgc, int(x2-((4*hg)/7)), tmpadd);
-                               scr.drawPoint(pgc, int(x2+((4*hg)/7)), tmpadd);
+                       float tmpadd = y;
+                       tmpadd += (remdot) ?
+                               asc/3.0 :
+                               asc/5.0; // if (remdot) -> i or j
+                       float rad = ((hg * 4.0) / 8.0);
+                       if (rad <= 1.0) {
+                               scr.drawPoint(pgc,
+                                             int(x2 - ((4.0 * hg) / 7.0)),
+                                             tmpadd);
+                               scr.drawPoint(pgc,
+                                             int(x2 + ((4.0 * hg) / 7.0)),
+                                             tmpadd);
                        } else {
-                               scr.drawArc(pgc, int(x2-((2*hg)/4)), tmpadd,
-                                           rad-1, rad-1, 0, 360*64);
-                               scr.drawArc(pgc, int(x2+((2*hg)/4)), tmpadd,
-                                           rad-1, rad-1, 0, 360*64);
+                               scr.drawArc(pgc, int(x2 - ((2.0 * hg) / 4.0)),
+                                           tmpadd,
+                                           rad - 1, rad - 1, 0, 360*64);
+                               scr.drawArc(pgc, int(x2 + ((2.0 * hg) / 4.0)),
+                                           tmpadd,
+                                           rad - 1, rad - 1, 0, 360*64);
                        }
                        break;
                }
                case CIRCUMFLEX:    // circumflex
                {
                        XPoint p[3];
-                       p[0].x = int(x2 - hg35); p[0].y = y + hg;
+                       p[0].x = int(x2 - hg35); p[0].y = y + int(hg);
                        p[1].x = int(x2);        p[1].y = int(y + hg35);
-                       p[2].x = int(x2 + hg35); p[2].y = y + hg;
+                       p[2].x = int(x2 + hg35); p[2].y = y + int(hg);
                        scr.drawLines(pgc, p, 3);
                        break;
                }
@@ -538,9 +576,10 @@ void InsetLatexAccent::Draw(LyXFont font,
                        // it should certainly be refined
                        XPoint p[4];
                        p[0].x = int(x2);          p[0].y = y;
-                       p[1].x = int(x2);          p[1].y = y + (hg/3);
-                       p[2].x = int(x2 - (hg/3)); p[2].y = y + (hg/2);
-                       p[3].x = int(x2 + (hg/4)); p[3].y = y + hg;
+                       p[1].x = int(x2);          p[1].y = y + int(hg / 3.0);
+                       p[2].x = int(x2 - (hg / 3.0));
+                       p[2].y = y + int(hg / 2.0);
+                       p[3].x = int(x2 + (hg / 4.0)); p[3].y = y + int(hg);
                        scr.drawLines(pgc, p, 4);
                        break;
                }
@@ -548,8 +587,10 @@ void InsetLatexAccent::Draw(LyXFont font,
                case LSLASH:
                {
                        XPoint p[2];
-                       p[0].x = int(x);                p[0].y = y+3*hg;
-                       p[1].x = int(x+float(wid)*.75); p[1].y = y+hg;
+                       p[0].x = int(x);
+                       p[0].y = y + int(3.0 * hg);
+                       p[1].x = int(x + float(wid) * 0.75);
+                       p[1].y = y + int(hg);
                        scr.drawLines(pgc, p, 2);
                        break;
                }
@@ -562,15 +603,15 @@ void InsetLatexAccent::Draw(LyXFont font,
                }
        } else {
                scr.fillRectangle(gc_lighted,
-                                 int(x+1), baseline - Ascent(font)+1,
-                                 Width(font)-2,
-                                 Ascent(font)+Descent(font)-2);
+                                 int(x + 1), baseline - Ascent(font) + 1,
+                                 Width(font) - 2,
+                                 Ascent(font) + Descent(font) - 2);
                
                scr.drawRectangle(gc_lighted,
                                  int(x), baseline - Ascent(font),
-                                 Width(font)-1,
-                                 Ascent(font)+Descent(font)-1);
-               scr.drawString(font, contents, baseline, int(x+2));
+                                 Width(font) - 1,
+                                 Ascent(font) + Descent(font) - 1);
+               scr.drawString(font, contents, baseline, int(x + 2));
        }
        x +=  Width(font);
 }
index 424a3444f2452c966c0e9e6973420610bb76c6fe..47aa293175ab48c0d5d94ab2b3a7371f5b7505b9 100644 (file)
@@ -42,6 +42,10 @@ public:
        ///
        int Width(LyXFont const & font) const;
        ///
+       int Lbearing(LyXFont const & font) const;
+       ///
+       int Rbearing(LyXFont const & font) const;
+       ///
        bool DisplayISO8859_9(LyXFont font, LyXScreen & scr,
                              int baseline, float & x);
        ///
index cba27858dcb77e66291fb1e27414f6165abf9ea4..9385f7482c2d3dd17236c3be7a42ca2bcf74e7c6 100644 (file)
@@ -432,7 +432,7 @@ GC GetColorGC(LyXFont::FONT_COLOR color)
 
 GC GetAccentGC(LyXFont const &f, int line_width)
 {
-       if (line_width>= 10) line_width = 9;
+       if (line_width >= 10) line_width = 9;
        
        if (accent_gc[line_width]) return accent_gc[line_width];
        
index 2e1055363357550e208a67d0eb63239af237208a..447979c540810a0ac4bf12ce08a99e30bb7b1d4d 100644 (file)
@@ -376,14 +376,14 @@ LyXFont & LyXFont::setLyXFamily(string const & fam)
 {
        string s = lowercase(fam);
 
-       int i= 0;
-       while (s != LyXFamilyNames[i] && LyXFamilyNames[i] != "error") i++;
+       int i = 0;
+       while (s != LyXFamilyNames[i] && LyXFamilyNames[i] != "error") ++i;
        if (s == LyXFamilyNames[i]) {
                setFamily(LyXFont::FONT_FAMILY(i));
        } else
                lyxerr << "LyXFont::setLyXFamily: Unknown family `"
                       << s << '\'' << endl;
-       return (*this);
+       return *this;
 }
 
 
@@ -392,14 +392,14 @@ LyXFont & LyXFont::setLyXSeries(string const & ser)
 {
        string s = lowercase(ser);
 
-       int i= 0;
-       while (s != LyXSeriesNames[i] && LyXSeriesNames[i] != "error") i++;
+       int i = 0;
+       while (s != LyXSeriesNames[i] && LyXSeriesNames[i] != "error") ++i;
        if (s == LyXSeriesNames[i]) {
                setSeries(LyXFont::FONT_SERIES(i));
        } else
                lyxerr << "LyXFont::setLyXSeries: Unknown series `"
                       << s << '\'' << endl;
-       return (*this);
+       return *this;
 }
 
 
@@ -408,14 +408,14 @@ LyXFont & LyXFont::setLyXShape(string const & sha)
 {
        string s = lowercase(sha);
 
-       int i= 0;
-       while (s != LyXShapeNames[i] && LyXShapeNames[i] != "error") i++;
+       int i = 0;
+       while (s != LyXShapeNames[i] && LyXShapeNames[i] != "error") ++i;
        if (s == LyXShapeNames[i]) {
                setShape(LyXFont::FONT_SHAPE(i));
        } else
                lyxerr << "LyXFont::setLyXShape: Unknown shape `"
                       << s << '\'' << endl;
-       return (*this);
+       return *this;
 }
 
 
@@ -423,14 +423,14 @@ LyXFont & LyXFont::setLyXShape(string const & sha)
 LyXFont & LyXFont::setLyXSize(string const & siz)
 {
        string s = lowercase(siz);
-       int i= 0;
-       while (s != LyXSizeNames[i] && LyXSizeNames[i] != "error") i++;
+       int i = 0;
+       while (s != LyXSizeNames[i] && LyXSizeNames[i] != "error") ++i;
        if (s == LyXSizeNames[i]) {
                setSize(LyXFont::FONT_SIZE(i));
        } else
                lyxerr << "LyXFont::setLyXSize: Unknown size `"
                       << s << '\'' << endl;
-       return (*this);
+       return *this;
 }
 
 // Set size according to lyx format string
@@ -438,7 +438,7 @@ LyXFont::FONT_MISC_STATE LyXFont::setLyXMisc(string const & siz)
 {
        string s = lowercase(siz);
        int i= 0;
-       while (s != LyXMiscNames[i] && LyXMiscNames[i] != "error") i++;
+       while (s != LyXMiscNames[i] && LyXMiscNames[i] != "error") ++i;
        if (s == LyXMiscNames[i])
                return FONT_MISC_STATE(i);
        lyxerr << "LyXFont::setLyXMisc: Unknown misc flag `"
@@ -451,13 +451,13 @@ LyXFont & LyXFont::setLyXColor(string const & col)
 {
        string s = lowercase(col);
        int i= 0;
-       while (s != LyXColorNames[i] && LyXColorNames[i] != "error") i++;
+       while (s != LyXColorNames[i] && LyXColorNames[i] != "error") ++i;
        if (s == LyXColorNames[i]) {
                setColor(LyXFont::FONT_COLOR(i));
        } else
                lyxerr << "LyXFont::setLyXColor: Unknown Color `"
                       << s << '\'' << endl;
-       return (*this);
+       return *this;
 }
 
 
@@ -465,16 +465,16 @@ LyXFont & LyXFont::setLyXColor(string const & col)
 LyXFont & LyXFont::setGUISize(string const & siz)
 {
        string s = lowercase(siz);
-       int i= 0;
+       int i = 0;
        while (!lGUISizeNames[i].empty() &&
               s != _(lGUISizeNames[i].c_str()))
-               i++;
+               ++i;
        if (s == _(lGUISizeNames[i].c_str())) {
                setSize(LyXFont::FONT_SIZE(i));
        } else
                lyxerr << "LyXFont::setGUISize: Unknown Size `"
                       << s << '\'' << endl;
-       return (*this);
+       return *this;
 }
 
 
@@ -813,8 +813,8 @@ int LyXFont::ascent(char c) const
 {
        XFontStruct * finfo = getXFontstruct();
        if (finfo->per_char
-           && c >= static_cast<char>(finfo->min_char_or_byte2)
-           && c <= static_cast<char>(finfo->max_char_or_byte2)) {
+           && static_cast<unsigned char>(c) >= finfo->min_char_or_byte2
+           && static_cast<unsigned char>(c) <= finfo->max_char_or_byte2) {
                unsigned int index = c - finfo->min_char_or_byte2;
                return finfo->per_char[index].ascent;
        } else
@@ -826,8 +826,8 @@ int LyXFont::descent(char c) const
 {
        XFontStruct * finfo = getXFontstruct();
        if (finfo->per_char
-           && c >= static_cast<char>(finfo->min_char_or_byte2)
-           && c <= static_cast<char>(finfo->max_char_or_byte2)) {
+           && static_cast<unsigned char>(c) >= finfo->min_char_or_byte2
+           && static_cast<unsigned char>(c) <= finfo->max_char_or_byte2) {
                unsigned int index = c - finfo->min_char_or_byte2;
                return finfo->per_char[index].descent;
        } else
@@ -846,6 +846,32 @@ int LyXFont::width(char c) const
 }
 
 
+int LyXFont::lbearing(char c) const
+{
+       XFontStruct * finfo = getXFontstruct();
+       if (finfo->per_char
+           && static_cast<unsigned char>(c) >= finfo->min_char_or_byte2
+           && static_cast<unsigned char>(c) <= finfo->max_char_or_byte2) {
+               unsigned int index = c - finfo->min_char_or_byte2;
+               return finfo->per_char[index].lbearing;
+       } else
+               return 0;
+}
+
+
+int LyXFont::rbearing(char c) const
+{
+       XFontStruct * finfo = getXFontstruct();
+       if (finfo->per_char
+           && static_cast<unsigned char>(c) >= finfo->min_char_or_byte2
+           && static_cast<unsigned char>(c) <= finfo->max_char_or_byte2) {
+               unsigned int index = c - finfo->min_char_or_byte2;
+               return finfo->per_char[index].rbearing;
+       } else
+               return width(c);
+}
+
+
 int LyXFont::textWidth(char const * s, int n) const
 {
        if (realShape() != LyXFont::SMALLCAPS_SHAPE){
@@ -858,7 +884,7 @@ int LyXFont::textWidth(char const * s, int n) const
                smallfont.decSize();
                smallfont.decSize();
                smallfont.setShape(LyXFont::UP_SHAPE);
-               for (int i= 0; i < n; i++){
+               for (int i = 0; i < n; ++i) {
                        c = s[i];
                        if (islower(c)){
                                c = toupper(c);
@@ -909,7 +935,7 @@ int LyXFont::drawText(char const * s, int n, Pixmap pm,
                smallfont.decSize();
                smallfont.decSize();
                smallfont.setShape(LyXFont::UP_SHAPE);
-               for (int i = 0; i < n; ++i){
+               for (int i = 0; i < n; ++i) {
                        c = s[i];
                        if (islower(c)){
                                c = toupper(c);
index f63d1f5ef811ff5ec9efab0837acc3a1e3ec1a6e..f495367466fed13d61edfdea57c6b7a96a22ebf9 100644 (file)
@@ -330,6 +330,12 @@ public:
        ///
        int width(char c) const;
 
+       ///
+       int lbearing(char c) const;
+
+       ///
+       int rbearing(char c) const;
+       
        ///
        int textWidth(char const *s, int n) const;
 
index 071e0dce00778e092139177ecb9977b2142c778e..ad42eac29f69f219d992c1a0757bbf750ac0b8ce 100644 (file)
@@ -10,6 +10,7 @@
 #include "LRegex.h"
 
 using std::count;
+using std::transform;
 
 bool isStrInt(string const & str)
 {
@@ -44,17 +45,31 @@ int  strToInt(string const & str)
 
 string lowercase(string const & a)
 {
+#if 0
        string tmp;
        string::const_iterator cit = a.begin();
        for(; cit != a.end(); ++cit) {
                tmp += static_cast<char>(tolower(*cit));
        }
        return tmp;
+#endif
+       string tmp(a);
+       transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
+       return tmp;
+}
+
+
+string uppercase(string const & a)
+{
+       string tmp(a);
+       transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
+       return tmp;
 }
 
 
 string tostr(long i)
 {
+       // should use string stream
        char str[30];
        sprintf(str, "%ld", i);
        return string(str);
@@ -63,6 +78,7 @@ string tostr(long i)
 
 string tostr(unsigned long i)
 {
+       // should use string stream
        char str[30];
        sprintf(str, "%lu", i);
        return string(str);
@@ -109,6 +125,7 @@ string tostr(float f)
 
 string tostr(double d)
 {
+       // should use string stream
        char tmp[40];
        sprintf(tmp, "%f", d);
        return string(tmp);
index 790629d23436ad054dc1dc9e385b6691d132a2ae..d29fbe8e38ca3cd53dc8b4d7c22b9d5003412d98 100644 (file)
@@ -99,6 +99,9 @@ int strToInt(string const & str);
 ///
 string lowercase(string const &);
 
+///
+string uppercase(string const &);
+
 /// int to string
 string tostr(int i);
 
index fd22e800c90441102568e9c36f921bbcf0cb1ae7..c3d1af12751ddb0589568a7e868a012c37478826 100644 (file)
@@ -271,7 +271,7 @@ void lyxstring::Srep::reserve(lyxstring::size_type res_arg)
 
 
 void lyxstring::Srep::replace(lyxstring::size_type i, lyxstring::size_type n,
-                           value_type const * p, size_type n2)
+                             value_type const * p, size_type n2)
 {
 // can be called with p= 0 and n2= 0
        n = min(sz - i, n);