comparison src/pst2dii.cpp.in @ 67:90aa7814ad1f stable-0-6-8

Initial version of pst2dii to convert to Summation dii load file format.
author Carl Byington <carl@five-ten-sg.com>
date Wed, 05 Mar 2008 18:58:40 -0800
parents 2c6040b6e8f8
children 63c02a242ca9
comparison
equal deleted inserted replaced
66:32f771bc9c1c 67:90aa7814ad1f
5 http://www.fsf.org/licenses/gpl.txt 5 http://www.fsf.org/licenses/gpl.txt
6 6
7 Based on readpst.c by David Smith 7 Based on readpst.c by David Smith
8 8
9 */ 9 */
10 #include "gd.h" 10 #include <gd.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <iostream> 12 #include <iostream>
13 #include <unistd.h> 13 #include <unistd.h>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
261 x_position += (brect[2]-brect[6]); 261 x_position += (brect[2]-brect[6]);
262 col_number += len; 262 col_number += len;
263 } 263 }
264 264
265 265
266 static void new_line();
267 static void new_line()
268 {
269 y_position += line_height;
270 line_number += 1;
271 x_position = margin;
272 col_number = 0;
273 }
274
275
266 static void print_pdf_single(char *line, int color); 276 static void print_pdf_single(char *line, int color);
267 static void print_pdf_single(char *line, int color) 277 static void print_pdf_single(char *line, int color)
268 { 278 {
279 while (*line == '\t') {
280 char blanks[5];
281 memset(blanks, ' ', 5);
282 print_pdf_short(blanks, 4, color);
283 line++;
284 if (col_number >= col_max) new_line();
285 }
269 int n = strlen(line); 286 int n = strlen(line);
270 while (n) { 287 while (n) {
271 int m = col_max - col_number; // number of chars that will fit on this line 288 int m = col_max - col_number; // number of chars that will fit on this line
272 m = (n > m) ? m : n; 289 m = (n > m) ? m : n;
273 print_pdf_short(line, m, color); 290 print_pdf_short(line, m, color);
274 line += m; 291 line += m;
275 n -= m; 292 n -= m;
276 if (n) { 293 if (n) new_line();
277 y_position += line_height;
278 line_number += 1;
279 x_position = margin;
280 col_number = 0;
281 }
282 } 294 }
283 } 295 }
284 296
285 297
286 static void print_pdf_only(char *line, int color); 298 static void print_pdf_only(char *line, int color);
290 while (p = strchr(line, '\n')) { 302 while (p = strchr(line, '\n')) {
291 *p = '\0'; 303 *p = '\0';
292 print_pdf_single(line, color); 304 print_pdf_single(line, color);
293 *p = '\n'; 305 *p = '\n';
294 line = p+1; 306 line = p+1;
295 y_position += line_height; 307 new_line();
296 line_number += 1;
297 x_position = margin;
298 col_number = 0;
299 } 308 }
300 print_pdf_single(line, color); 309 print_pdf_single(line, color);
301 } 310 }
302 311
303 312