git.cweiske.de
/
enigma2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
output pid if timeoutet section table
[enigma2.git]
/
lib
/
gdi
/
font.cpp
diff --git
a/lib/gdi/font.cpp
b/lib/gdi/font.cpp
index f7c1bca5ed59f075bc5b2acb334555ea68e59dd1..ce1b3c4bd77dc5dbc4e54d990d804baf0f0ee6ce 100644
(file)
--- a/
lib/gdi/font.cpp
+++ b/
lib/gdi/font.cpp
@@
-235,6
+235,13
@@
int fontRenderClass::getFont(ePtr<Font> &font, const std::string &face, int size
return 0;
}
return 0;
}
+void addFont(const char *filename, const char *alias, int scale_factor, int is_replacement)
+{
+ fontRenderClass::getInstance()->AddFont(filename, alias, scale_factor);
+ if (is_replacement)
+ eTextPara::setReplacementFont(alias);
+}
+
DEFINE_REF(Font);
Font::Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tw): tabwidth(tw)
DEFINE_REF(Font);
Font::Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tw): tabwidth(tw)
@@
-270,7
+277,7
@@
int eTextPara::appendGlyph(Font *current_font, FT_Face current_face, FT_UInt gly
int nx=cursor.x();
nx+=glyph->xadvance;
int nx=cursor.x();
nx+=glyph->xadvance;
-
+
if (
(rflags&RS_WRAP) &&
(nx >= area.right())
if (
(rflags&RS_WRAP) &&
(nx >= area.right())
@@
-278,33
+285,43
@@
int eTextPara::appendGlyph(Font *current_font, FT_Face current_face, FT_UInt gly
{
int cnt = 0;
glyphString::reverse_iterator i(glyphs.rbegin());
{
int cnt = 0;
glyphString::reverse_iterator i(glyphs.rbegin());
+ /* find first possibility (from end to begin) to break */
while (i != glyphs.rend())
{
while (i != glyphs.rend())
{
- if (i->flags&(GS_
ISSPACE|GS_ISFIRST))
+ if (i->flags&(GS_
CANBREAK|GS_ISFIRST)) /* stop on either space/hyphen/shy or start of line (giving up) */
break;
cnt++;
++i;
break;
cnt++;
++i;
- }
- if (i != glyphs.rend()
- && ((i->flags&(GS_ISSPACE|GS_ISFIRST))==GS_ISSPACE)
- && cnt )
+ }
+
+ /* if ... */
+ if (i != glyphs.rend() /* ... we found anything */
+ && (i->flags&GS_CANBREAK) /* ...and this is a space/hyphen/soft-hyphen */
+ && (!(i->flags & GS_ISFIRST)) /* ...and this is not an start of line (line with just a single space/hyphen) */
+ && cnt ) /* ... and there are actual non-space characters after this */
{
{
- --i;
+ /* if we have a soft-hyphen, and used that for breaking, turn it into a real hyphen */
+ if (i->flags & GS_SOFTHYPHEN)
+ {
+ i->flags &= ~GS_SOFTHYPHEN;
+ i->flags |= GS_HYPHEN;
+ }
+ --i; /* skip the space/hypen/softhyphen */
int linelength=cursor.x()-i->x;
int linelength=cursor.x()-i->x;
- i->flags|=GS_ISFIRST;
+ i->flags|=GS_ISFIRST;
/* make this a line start */
ePoint offset=ePoint(i->x, i->y);
newLine(rflags);
offset-=cursor;
ePoint offset=ePoint(i->x, i->y);
newLine(rflags);
offset-=cursor;
+
+ /* and move everything to the end into the next line. */
do
{
i->x-=offset.x();
i->y-=offset.y();
i->bbox.moveBy(-offset.x(), -offset.y());
do
{
i->x-=offset.x();
i->y-=offset.y();
i->bbox.moveBy(-offset.x(), -offset.y());
- }
- while (i-- != glyphs.rbegin()); // rearrange them into the next line
+ } while (i-- != glyphs.rbegin()); // rearrange them into the next line
cursor+=ePoint(linelength, 0); // put the cursor after that line
cursor+=ePoint(linelength, 0); // put the cursor after that line
- }
- else
+ } else
{
if (cnt)
{
{
if (cnt)
{
@@
-315,7
+332,7
@@
int eTextPara::appendGlyph(Font *current_font, FT_Face current_face, FT_UInt gly
}
int xadvance=glyph->xadvance, kern=0;
}
int xadvance=glyph->xadvance, kern=0;
-
+
if (previous && use_kerning)
{
FT_Vector delta;
if (previous && use_kerning)
{
FT_Vector delta;
@@
-340,7
+357,9
@@
int eTextPara::appendGlyph(Font *current_font, FT_Face current_face, FT_UInt gly
ng.flags = flags;
glyphs.push_back(ng);
ng.flags = flags;
glyphs.push_back(ng);
- cursor += ePoint(xadvance, 0);
+ /* when we have a SHY, don't xadvance. It will either be the last in the line (when used for breaking), or not displayed. */
+ if (!(flags & GS_SOFTHYPHEN))
+ cursor += ePoint(xadvance, 0);
previous = glyphIndex;
return 0;
}
previous = glyphIndex;
return 0;
}
@@
-363,7
+382,7
@@
void eTextPara::calc_bbox()
for (; i != glyphs.end(); ++i)
{
for (; i != glyphs.end(); ++i)
{
- if (
i->flags & GS_ISSPACE
)
+ if (
i->flags & (GS_ISSPACE|GS_SOFTHYPHEN)
)
continue;
if ( i->bbox.left() < boundBox.left() )
boundBox.setLeft( i->bbox.left() );
continue;
if ( i->bbox.left() < boundBox.left() )
boundBox.setLeft( i->bbox.left() );
@@
-470,9
+489,9
@@
int eTextPara::renderString(const char *string, int rflags)
if (string)
uc_string.reserve(strlen(string));
if (string)
uc_string.reserve(strlen(string));
- const char *p = string;
+ const char *p = string
? string : ""
;
- while
(
p)
+ while
(*
p)
{
unsigned int unicode=(unsigned char)*p++;
{
unsigned int unicode=(unsigned char)*p++;
@@
-482,28
+501,28
@@
int eTextPara::renderString(const char *string, int rflags)
{
unicode&=0x1F;
unicode<<=6;
{
unicode&=0x1F;
unicode<<=6;
- if (p)
+ if (
*
p)
unicode|=(*p++)&0x3F;
} else if ((unicode & 0xF0)==0xE0) // three bytes
{
unicode&=0x0F;
unicode<<=6;
unicode|=(*p++)&0x3F;
} else if ((unicode & 0xF0)==0xE0) // three bytes
{
unicode&=0x0F;
unicode<<=6;
- if (p)
+ if (
*
p)
unicode|=(*p++)&0x3F;
unicode<<=6;
unicode|=(*p++)&0x3F;
unicode<<=6;
- if (p)
+ if (
*
p)
unicode|=(*p++)&0x3F;
} else if ((unicode & 0xF8)==0xF0) // four bytes
{
unicode&=0x07;
unicode<<=6;
unicode|=(*p++)&0x3F;
} else if ((unicode & 0xF8)==0xF0) // four bytes
{
unicode&=0x07;
unicode<<=6;
- if (p)
+ if (
*
p)
unicode|=(*p++)&0x3F;
unicode<<=6;
unicode|=(*p++)&0x3F;
unicode<<=6;
- if (p)
+ if (
*
p)
unicode|=(*p++)&0x3F;
unicode<<=6;
unicode|=(*p++)&0x3F;
unicode<<=6;
- if (p)
+ if (
*
p)
unicode|=(*p++)&0x3F;
}
}
unicode|=(*p++)&0x3F;
}
}
@@
-541,9
+560,11
@@
int eTextPara::renderString(const char *string, int rflags)
int isprintable=1;
int flags = nextflags;
nextflags = 0;
int isprintable=1;
int flags = nextflags;
nextflags = 0;
+ unsigned long chr = *i;
+
if (!(rflags&RS_DIRECT))
{
if (!(rflags&RS_DIRECT))
{
- switch (
*i
)
+ switch (
chr
)
{
case '\\':
{
{
case '\\':
{
@@
-581,6
+602,14
@@
newline:isprintable=0;
case 0x87: case 0xE087:
nprint: isprintable=0;
break;
case 0x87: case 0xE087:
nprint: isprintable=0;
break;
+ case 0xAD: // soft-hyphen
+ flags |= GS_SOFTHYPHEN;
+ chr = 0x2010; /* hyphen */
+ break;
+ case 0x2010:
+ case '-':
+ flags |= GS_HYPHEN;
+ break;
case ' ':
flags|=GS_ISSPACE;
default:
case ' ':
flags|=GS_ISSPACE;
default:
@@
-590,17
+619,21
@@
nprint: isprintable=0;
if (isprintable)
{
FT_UInt index = 0;
if (isprintable)
{
FT_UInt index = 0;
-
- if (forced_replaces.find(*i) == forced_replaces.end())
- index=(rflags&RS_DIRECT)? *i : FT_Get_Char_Index(current_face, *i);
+
+ /* FIXME: our font doesn't seem to have a hyphen, so use hyphen-minus for it. */
+ if (chr == 0x2010)
+ chr = '-';
+
+ if (forced_replaces.find(chr) == forced_replaces.end())
+ index=(rflags&RS_DIRECT)? chr : FT_Get_Char_Index(current_face, chr);
if (!index)
{
if (replacement_face)
if (!index)
{
if (replacement_face)
- index=(rflags&RS_DIRECT)?
*i : FT_Get_Char_Index(replacement_face, *i
);
+ index=(rflags&RS_DIRECT)?
chr : FT_Get_Char_Index(replacement_face, chr
);
if (!index)
if (!index)
- eDebug("unicode
%d ('%c') not present", *i, *i
);
+ eDebug("unicode
U+%4lx not present", chr
);
else
appendGlyph(replacement_font, replacement_face, index, flags, rflags);
} else
else
appendGlyph(replacement_font, replacement_face, index, flags, rflags);
} else
@@
-690,6
+723,9
@@
void eTextPara::blit(gDC &dc, const ePoint &offset, const gRGB &background, cons
{
for (glyphString::iterator i(glyphs.begin()); i != glyphs.end(); ++i)
{
{
for (glyphString::iterator i(glyphs.begin()); i != glyphs.end(); ++i)
{
+ if (i->flags & GS_SOFTHYPHEN)
+ continue;
+
if (!(i->flags & GS_INVERT))
{
lookup8 = lookup8_normal;
if (!(i->flags & GS_INVERT))
{
lookup8 = lookup8_normal;
@@
-807,9
+843,6
@@
void eTextPara::realign(int dir) // der code hier ist ein wenig merkwuerdig.
num++;
}
num++;
}
- if (!num) // line mit nur einem space
- continue;
-
switch (dir)
{
case dirRight:
switch (dir)
{
case dirRight: