/* * libcucul Unicode canvas library * Copyright (c) 2002-2006 Sam Hocevar * All Rights Reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the Do What The Fuck You Want To * Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ /** \file export.c * \version \$Id$ * \author Sam Hocevar * \author Jean-Yves Lamoureux * \brief Export function * * This file contains export functions for SVG (Scalable Vector Graphics files */ #include "config.h" #if !defined(__KERNEL__) # include # include # include #endif #include "cucul.h" #include "cucul_internals.h" static char const svg_header[] = "\n" "\n" " \n" " \n"); cur += sprintf(cur, " \n"); cur += sprintf(cur, " \n"); /* Background */ for(y = 0; y < qq->height; y++) { uint8_t *lineattr = qq->attr + y * qq->width; for(x = 0; x < qq->width; x++) { cur += sprintf(cur, "\n", *lineattr++, x * 6, y * 10); } } /* Text */ for(y = 0; y < qq->height; y++) { uint8_t *lineattr = qq->attr + y * qq->width; uint32_t *linechar = qq->chars + y * qq->width; for(x = 0; x < qq->width; x++) { uint32_t c = *linechar++; cur += sprintf(cur, "", *lineattr++, x * 6, (y * 10) + 10); if(c < 0x00000020) cur += sprintf(cur, "?"); else if(c < 0x00000080) cur += sprintf(cur, "%c", c); else cur += sprintf(cur, "?"); /* FIXME: SVG supports UTF-8 */ cur += sprintf(cur, "\n"); } } cur += sprintf(cur, " \n"); cur += sprintf(cur, "\n"); /* Crop to really used size */ ex->size = strlen(ex->buffer) + 1; ex->buffer = realloc(ex->buffer, ex->size); }