+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
/* 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
#: 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: "
#: 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:"
#: 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:"
#: 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: "
#: 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:"
#: 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:"
#: 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 : "
#: 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:"
#: 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:"
#: 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:"
#: 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:"
#: 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"
#: 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 "ïÛÉÂËÁ ÚÁËÒÙÔÉÑ ÆÁÊÌÁ "
#: 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:"
#: 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:"
#: 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ý:"
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"
#: 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: "
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 == ' ')
}
+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,
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);
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;
}
{
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;
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;
}
// 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;
}
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;
}
}
} 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);
}
///
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);
///
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];
{
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;
}
{
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;
}
{
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;
}
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
{
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 `"
{
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;
}
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;
}
{
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
{
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
}
+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){
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);
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);
///
int width(char c) const;
+ ///
+ int lbearing(char c) const;
+
+ ///
+ int rbearing(char c) const;
+
///
int textWidth(char const *s, int n) const;
#include "LRegex.h"
using std::count;
+using std::transform;
bool isStrInt(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);
string tostr(unsigned long i)
{
+ // should use string stream
char str[30];
sprintf(str, "%lu", i);
return string(str);
string tostr(double d)
{
+ // should use string stream
char tmp[40];
sprintf(tmp, "%f", d);
return string(tmp);
///
string lowercase(string const &);
+///
+string uppercase(string const &);
+
/// int to string
string tostr(int i);
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);