Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions lib/gdi/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ int eTextPara::renderString(const char *string, int rflags, int border)

unsigned long newcolor = 0;
bool activate_newcolor = false;
bool activate_colorreset = false;
int nextflags = 0;

for (std::vector<unsigned long>::const_iterator i(uc_visual.begin());
Expand Down Expand Up @@ -812,22 +813,34 @@ int eTextPara::renderString(const char *string, int rflags, int border)
goto nprint;
case 'c':
{
char color[8];
char color[9];
int codeidx;
for (codeidx = 0; codeidx < 8; codeidx++)
{
if ((i + 2 + codeidx) == uc_visual.end()) break;
color[codeidx] = (char)((*(i + 2 + codeidx)) & 0xff);
if (!isxdigit((unsigned char)color[codeidx]))
break;
}
if (codeidx == 8)
{
color[8] = '\0';
newcolor = gRGB(color).argb();
activate_newcolor = true;
isprintable = 0;
i += 1 + codeidx;
}
else
{
isprintable = 1;
}
break;
}
case 'C':
isprintable = 0;
activate_colorreset = true;
i++;
break;
default:
;
}
Expand Down Expand Up @@ -867,6 +880,9 @@ nprint: isprintable=0;
}
if (isprintable)
{
if (activate_colorreset)
flags |= GS_COLORRESET;

FT_UInt index = 0;

/* FIXME: our font doesn't seem to have a hyphen, so use hyphen-minus for it. */
Expand Down Expand Up @@ -896,6 +912,7 @@ nprint: isprintable=0;
appendGlyph(current_font, current_face, index, flags, rflags, border, i == uc_visual.end() - 1, activate_newcolor, newcolor);

activate_newcolor = false;
activate_colorreset = false;
}
}
bboxValid=false;
Expand Down Expand Up @@ -971,10 +988,15 @@ void eTextPara::blit(gDC &dc, const ePoint &offset, const gRGB &cbackground, con
line_offs = *(line_offs_it++);
line_chars = *(line_chars_it++);
}
if (i->flags & GS_COLORCHANGE)
/* don't do colorchanges in borders */
if (!border)
{
/* don't do colorchanges in borders */
if (!border)
if (i->flags & GS_COLORRESET)
{
currentforeground = foreground;
setcolor = true;
}
else if (i->flags & GS_COLORCHANGE)
{
currentforeground = i->newcolor;
setcolor = true;
Expand Down
1 change: 1 addition & 0 deletions lib/gdi/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class fontRenderClass
#define GS_HYPHEN 32
#define GS_COLORCHANGE 64
#define GS_LF 128
#define GS_COLORRESET 256
#define GS_CANBREAK (GS_ISSPACE|GS_SOFTHYPHEN|GS_HYPHEN)

struct pGlyph
Expand Down
Loading