awips2/pythonPackages/matplotlib/ttconv/ttutil.cpp
root 57877615f5 Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: 2b462d8665 [formerly 133dc97f67] [formerly a02aeb236c] [formerly a02aeb236c [formerly 9f19e3f712]] [formerly 2b462d8665 [formerly 133dc97f67] [formerly a02aeb236c] [formerly a02aeb236c [formerly 9f19e3f712]] [formerly 06a8b51d6d [formerly a02aeb236c [formerly 9f19e3f712] [formerly 06a8b51d6d [formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]]]]
Former-commit-id: 06a8b51d6d
Former-commit-id: 2c3569dd39 [formerly 9bb8decbcf] [formerly 8e80217e59] [formerly e2ecdcfe33 [formerly 377dcd10b9] [formerly 8e80217e59 [formerly 3360eb6c5f]]]
Former-commit-id: e2ecdcfe33 [formerly 377dcd10b9]
Former-commit-id: e2ecdcfe33
Former-commit-id: 7dbd17a5aa
2012-01-06 08:55:05 -06:00

81 lines
1.5 KiB
C++
Executable file

/*
* Modified for use within matplotlib
* 5 July 2007
* Michael Droettboom
*/
/* Very simple interface to the ppr TT routines */
/* (c) Frank Siegert 1996 */
#include "global_defines.h"
#include <cstdio>
#include <cstdarg>
#include <cstdlib>
#include "pprdrv.h"
#if DEBUG_TRUETYPE
void debug(const char *format, ... )
{
va_list arg_list;
va_start(arg_list, format);
printf(format, arg_list);
va_end(arg_list);
}
#endif
#define PRINTF_BUFFER_SIZE 512
void TTStreamWriter::printf(const char* format, ...)
{
va_list arg_list;
va_start(arg_list, format);
char buffer[PRINTF_BUFFER_SIZE];
#if defined(WIN32) || defined(_MSC_VER)
int size = _vsnprintf(buffer, PRINTF_BUFFER_SIZE, format, arg_list);
#else
int size = vsnprintf(buffer, PRINTF_BUFFER_SIZE, format, arg_list);
#endif
if (size >= PRINTF_BUFFER_SIZE) {
char* buffer2 = (char*)malloc(size);
#if defined(WIN32) || defined(_MSC_VER)
_vsnprintf(buffer2, size, format, arg_list);
#else
vsnprintf(buffer2, size, format, arg_list);
#endif
free(buffer2);
} else {
this->write(buffer);
}
va_end(arg_list);
}
void TTStreamWriter::put_char(int val)
{
char c[2];
c[0] = (char)val;
c[1] = 0;
this->write(c);
}
void TTStreamWriter::puts(const char *a)
{
this->write(a);
}
void TTStreamWriter::putline(const char *a)
{
this->write(a);
this->write("\n");
}
void replace_newlines_with_spaces(char *a) {
char* i = a;
while (*i != 0) {
if (*i == '\n')
*i = ' ';
i++;
}
}