Fixed bugs in SVG output again. (dealing with ampersands, and end of beziers)

Fixed text cursor problem in save/load dialogs
This commit is contained in:
Rob Pearce 2009-07-28 02:15:46 +00:00
parent 47dd570d84
commit 96981d8325
2 changed files with 72 additions and 13 deletions

View File

@ -1,14 +1,14 @@
netmapr: netmapr.c constants.h netmapr.h Makefile
gcc -Wall -O2 -g netmapr.c -onetmapr `sdl-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext -lSDL_ttf
gcc -Wall -O2 -g netmapr.c savepng.c -onetmapr `sdl-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lSDL_ttf -lpng
ln -f netmapr netmapr-viewer
install: netmapr
install -C -D -o root -m 755 netmapr /usr/local/bin/netmapr
install -D -o root -m 755 netmapr /usr/local/bin/netmapr
ln -f /usr/local/bin/netmapr /usr/local/bin/netmapr-viewer
install -C -D -o root -m 644 buttons.dat /usr/local/share/netmapr/buttons.dat
install -C -D -o root -m 644 objects.dat /usr/local/share/netmapr/objects.dat
install -C -D -o root -m 644 verdana.ttf /usr/local/share/netmapr/verdana.ttf
install -C -D -o root -m 644 icon.bmp /usr/local/share/netmapr/icon.bmp
install -D -o root -m 644 buttons.dat /usr/local/share/netmapr/buttons.dat
install -D -o root -m 644 objects.dat /usr/local/share/netmapr/objects.dat
install -D -o root -m 644 verdana.ttf /usr/local/share/netmapr/verdana.ttf
install -D -o root -m 644 icon.bmp /usr/local/share/netmapr/icon.bmp
clean: netmapr convert netmapr-viewer
rm -f netmapr convert netmapr-viewer

View File

@ -4960,9 +4960,30 @@ void drawtextat(SDL_Surface *dest, int x, int y, char *text, int size, SDL_Color
drawtext(dest, &temp, FALSE);
}
char *fixforhtml(char *oldtext, char *newtext) {
char *p, *p2;
p2 = newtext;
for (p = oldtext ; *p ; p++) {
if (*p == '&') {
*p2 = '\0';
strcat(p2, "&");
p2 += strlen("&");
} else {
*p2 = *p;
p2++;
}
}
*p2 = '\0';
return newtext;
}
void drawtextSVG(text_t *t) {
int tw,th;
int txoff,tyoff;
char newtext[BUFLEN];
if (strlen(t->text) == 0) {
return;
@ -4990,7 +5011,10 @@ void drawtextSVG(text_t *t) {
sprintf(svgbuf, "<text x=\"%d\" y=\"%d\" font-family=\"Verdana\" font-size=\"%d\" fill=\"rgb(%d,%d,%d)\" >\n",
t->x + txoff, t->y + tyoff + t->h, t->h, t->c.r, t->c.g, t->c.b);
fprintf(svgfile, svgbuf);
sprintf(svgbuf, "%s\n</text>\n",t->text);
fixforhtml(t->text, newtext);
sprintf(svgbuf, "%s\n</text>\n",newtext);
fprintf(svgfile, svgbuf);
@ -5432,9 +5456,6 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove
polycol.unused = 0;
printf("** called drawvector()\n");
for (i = 0; i < vimg->vnum; i++) {
// select colour
if (overridefg == NULL) {
@ -5543,10 +5564,13 @@ printf("** called drawvector()\n");
subobjfill.b = 0;
subobjfill.unused = 0;
}
if (inpoly || inbez) {
if (inpoly) {
sprintf(temp, "\" style=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);stroke-width:1\"/>\n", fillcol.r, fillcol.g, fillcol.b, polycol.r, polycol.g, polycol.b);
strcat(svgbuf, temp);
fprintf(svgfile, svgbuf);
} else if (inbez) {
sprintf(temp, "\" style=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);stroke-width:1\"/>\n", fillcol.r, fillcol.g, fillcol.b, polycol.r, polycol.g, polycol.b);
fprintf(svgfile, temp);
/*} else if (insubobj) {
sprintf(svgbuf, "\" style=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);stroke-width:1\"/>\n", fillcol.r, fillcol.g, fillcol.b, polycol.r, polycol.g, polycol.b);
fprintf(svgfile, svgbuf);
@ -7993,9 +8017,12 @@ int showfiledialog(void) {
Uint32 fillcol;
SDL_Rect area,sarea;
int y;
SDL_Color ccol;
//SDL_Color ccol;
int tw,th;
char t[BUFLEN];
int len;
char tempbuf[BUFLEN];
int sw,sh,cwid,dummy;
/* clear map */
@ -8065,14 +8092,46 @@ int showfiledialog(void) {
bgx = sarea.x;
bgy = sarea.y;
// figure out where to draw cursor
len = textpos - text;
sprintf(tempbuf, text);
tempbuf[len] = '\0';
TTF_SizeText(font[DEFTEXTH*2], tempbuf, &sw, &sh);
// find width of next char
if (*textpos == '\0') {
cwid = CURSORWIDTH;
} else {
tempbuf[0] = *textpos;
tempbuf[1] = '\0';
TTF_SizeText(font[DEFTEXTH*2], tempbuf, &cwid, &dummy);
}
/* draw cursor (a solid block) */
for (y = starty ; y < (starty + sh); y++ ) {
drawline(buffer, startx + sw+1, y,
startx + sw + cwid,y ,blue,1);
}
/* draw text */
drawtextat(buffer, startx , starty , text, DEFTEXTH*2, black);
/*
// draw text
drawtextat(buffer, startx, starty, text, DEFTEXTH*2, black);
/* draw cursor (a solid block) */
// draw cursor (a solid block)
ccol = blue;
for (y = starty ; y < (starty + th); y++ ) {
drawline(buffer, startx + tw, y, startx + tw + CURSORWIDTH,y,ccol,1);
}
*/
/* blit to screen */
SDL_BlitSurface(buffer, 0, screen, 0);