handle font=0 in drawchar (dummy character passing)
authorkramm <kramm>
Thu, 28 Jun 2007 11:25:36 +0000 (11:25 +0000)
committerkramm <kramm>
Thu, 28 Jun 2007 11:25:36 +0000 (11:25 +0000)
lib/devices/arts.c
lib/devices/bbox.c
lib/devices/opengl.c
lib/devices/record.c
lib/devices/render.c
lib/devices/swf.c
lib/devices/text.c

index 78986ec..e3aef2b 100644 (file)
@@ -218,6 +218,8 @@ void arts_addfont(struct _gfxdevice*dev, gfxfont_t*font)
 void arts_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
 {
     dbg("arts_drawchar");
+    if(!font)
+       return;
     internal_t*i = (internal_t*)dev->internal;
     gfxline_t*glyph = gfxline_clone(font->glyphs[glyphnr].line);
     gfxline_transform(glyph, matrix);
index 5a13d51..05df67f 100644 (file)
@@ -112,6 +112,8 @@ void bbox_addfont(gfxdevice_t*dev, gfxfont_t*font)
 void bbox_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
 {
     internal_t*i = (internal_t*)dev->internal;
+    if(!font)
+       return;
 
     if(i->do_text) {
        gfxglyph_t*glyph = &font->glyphs[glyphnr];
index 36ffcc7..366f249 100644 (file)
@@ -476,6 +476,8 @@ void opengl_addfont(gfxdevice_t*dev, gfxfont_t*font)
 void opengl_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
 {
     internal_t*i = (internal_t*)dev->internal;
+    if(!font)
+       return;
 
     if(i->font && i->font->id && !strcmp(font->id, i->font->id)) {
        // current font is correct
index 617b427..ae5bedf 100644 (file)
@@ -334,11 +334,14 @@ static void record_addfont(struct _gfxdevice*dev, gfxfont_t*font)
 static void record_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
 {
     internal_t*i = (internal_t*)dev->internal;
-    if(!gfxfontlist_hasfont(i->fontlist, font))
+    if(font && !gfxfontlist_hasfont(i->fontlist, font))
        record_addfont(dev, font);
 
     writer_writeU8(&i->w, OP_DRAWCHAR);
-    writer_writeString(&i->w, font->id);
+    if(font) 
+       writer_writeString(&i->w, font->id);
+    else
+       writer_writeString(&i->w, "*NULL*");
     writer_writeU32(&i->w, glyphnr);
     dumpColor(&i->w, color);
     dumpMatrix(&i->w, matrix);
@@ -463,7 +466,7 @@ void gfxresult_record_replay(gfxresult_t*result, gfxdevice_t*device)
            }
            case OP_DRAWCHAR: {
                char* id = reader_readString(r);
-               gfxfont_t*font = gfxfontlist_findfont(fontlist, id);
+               gfxfont_t*font = id?gfxfontlist_findfont(fontlist, id):0;
                U32 glyph = reader_readU32(r);
                gfxcolor_t color = readColor(r);
                gfxmatrix_t matrix = readMatrix(r);
index 5a9504b..bb71bed 100644 (file)
@@ -648,6 +648,8 @@ void render_addfont(struct _gfxdevice*dev, gfxfont_t*font)
 void render_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
 {
     internal_t*i = (internal_t*)dev->internal;
+    if(!font)
+       return;
 
     /* align characters to whole pixels */
     matrix->tx = (int)(matrix->tx * i->antialize) / i->antialize;
index 67c6ac4..0bd3160 100644 (file)
@@ -2482,6 +2482,8 @@ static void swf_switchfont(gfxdevice_t*dev, char*fontid)
 static void swf_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyph, gfxcolor_t*color, gfxmatrix_t*matrix)
 {
     swfoutput_internal*i = (swfoutput_internal*)dev->internal;
+    if(!font)
+       return;
        
     if(!i->swffont || !i->swffont->name || strcmp((char*)i->swffont->name,font->id)) // not equal to current font
     {
index 87b786c..d5b4bbc 100644 (file)
@@ -120,9 +120,13 @@ void text_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*colo
     } else if(xshift > i->lastadvance*1.3 || xshift<0) {
         addchar(dev, 32);
     }
-    i->lastadvance = font->glyphs[glyphnr].advance*matrix->m00;
-
-    int u = font->glyphs[glyphnr].unicode;
+    if(font) {
+       i->lastadvance = font->glyphs[glyphnr].advance*matrix->m00;
+       int u = font->glyphs[glyphnr].unicode;
+    } else {
+       u = glyphnr;
+       i->currentx = 0;i->currenty = 0;
+    }
     if(u>13) {
         addchar(dev, u);
     }