224 |
|
|
225 |
if ( FT_NEW_ARRAY( ht->table, ht->size ) ) |
if ( FT_NEW_ARRAY( ht->table, ht->size ) ) |
226 |
goto Exit; |
goto Exit; |
|
FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * ht->size ); |
|
227 |
|
|
228 |
for ( i = 0, bp = obp; i < sz; i++, bp++ ) |
for ( i = 0, bp = obp; i < sz; i++, bp++ ) |
229 |
{ |
{ |
254 |
|
|
255 |
if ( FT_NEW_ARRAY( ht->table, sz ) ) |
if ( FT_NEW_ARRAY( ht->table, sz ) ) |
256 |
goto Exit; |
goto Exit; |
|
FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * sz ); |
|
257 |
|
|
258 |
Exit: |
Exit: |
259 |
return error; |
return error; |
349 |
char** field; |
char** field; |
350 |
unsigned long size; |
unsigned long size; |
351 |
unsigned long used; |
unsigned long used; |
352 |
|
FT_Memory memory; |
353 |
|
|
354 |
} _bdf_list_t; |
} _bdf_list_t; |
355 |
|
|
388 |
#define sbitset( m, cc ) ( m[(cc) >> 3] & ( 1 << ( (cc) & 7 ) ) ) |
#define sbitset( m, cc ) ( m[(cc) >> 3] & ( 1 << ( (cc) & 7 ) ) ) |
389 |
|
|
390 |
|
|
391 |
|
static void |
392 |
|
_bdf_list_init( _bdf_list_t* list, |
393 |
|
FT_Memory memory ) |
394 |
|
{ |
395 |
|
FT_ZERO(list); |
396 |
|
list->memory = memory; |
397 |
|
} |
398 |
|
|
399 |
|
static void |
400 |
|
_bdf_list_done( _bdf_list_t* list ) |
401 |
|
{ |
402 |
|
FT_Memory memory = list->memory; |
403 |
|
|
404 |
|
if ( memory ) |
405 |
|
{ |
406 |
|
FT_FREE( list->field ); |
407 |
|
FT_ZERO(list); |
408 |
|
} |
409 |
|
} |
410 |
|
|
411 |
|
|
412 |
|
static FT_Error |
413 |
|
_bdf_list_ensure( _bdf_list_t* list, |
414 |
|
int num_items ) |
415 |
|
{ |
416 |
|
FT_Error error = 0; |
417 |
|
|
418 |
|
if ( num_items > list->size ) |
419 |
|
{ |
420 |
|
int oldsize = list->size; |
421 |
|
int newsize = oldsize + (oldsize >> 1) + 4; |
422 |
|
int bigsize = FT_INT_MAX / sizeof(char*); |
423 |
|
FT_Memory memory = list->memory; |
424 |
|
|
425 |
|
if ( oldsize == bigsize ) |
426 |
|
{ |
427 |
|
error = FT_Err_Out_Of_Memory; |
428 |
|
goto Exit; |
429 |
|
} |
430 |
|
else if ( newsize < oldsize || newsize > bigsize ) |
431 |
|
newsize = bigsize; |
432 |
|
|
433 |
|
if ( FT_RENEW_ARRAY( list->field, oldsize, newsize ) ) |
434 |
|
goto Exit; |
435 |
|
|
436 |
|
list->size = newsize; |
437 |
|
} |
438 |
|
Exit: |
439 |
|
return error; |
440 |
|
} |
441 |
|
|
442 |
|
|
443 |
|
static void |
444 |
|
_bdf_list_shift( _bdf_list_t* list, |
445 |
|
unsigned long n ) |
446 |
|
{ |
447 |
|
unsigned long i, u; |
448 |
|
|
449 |
|
|
450 |
|
if ( list == 0 || list->used == 0 || n == 0 ) |
451 |
|
return; |
452 |
|
|
453 |
|
if ( n >= list->used ) |
454 |
|
{ |
455 |
|
list->used = 0; |
456 |
|
return; |
457 |
|
} |
458 |
|
|
459 |
|
for ( u = n, i = 0; u < list->used; i++, u++ ) |
460 |
|
list->field[i] = list->field[u]; |
461 |
|
list->used -= n; |
462 |
|
} |
463 |
|
|
464 |
|
|
465 |
|
static char * |
466 |
|
_bdf_list_join( _bdf_list_t* list, |
467 |
|
int c, |
468 |
|
unsigned long *alen ) |
469 |
|
{ |
470 |
|
unsigned long i, j; |
471 |
|
char *fp, *dp; |
472 |
|
|
473 |
|
|
474 |
|
*alen = 0; |
475 |
|
|
476 |
|
if ( list == 0 || list->used == 0 ) |
477 |
|
return 0; |
478 |
|
|
479 |
|
dp = list->field[0]; |
480 |
|
for ( i = j = 0; i < list->used; i++ ) |
481 |
|
{ |
482 |
|
fp = list->field[i]; |
483 |
|
while ( *fp ) |
484 |
|
dp[j++] = *fp++; |
485 |
|
|
486 |
|
if ( i + 1 < list->used ) |
487 |
|
dp[j++] = (char)c; |
488 |
|
} |
489 |
|
dp[j] = 0; |
490 |
|
|
491 |
|
*alen = j; |
492 |
|
return dp; |
493 |
|
} |
494 |
|
|
495 |
|
|
496 |
|
|
497 |
/* An empty string for empty fields. */ |
/* An empty string for empty fields. */ |
498 |
|
|
499 |
static const char empty[1] = { 0 }; /* XXX eliminate this */ |
static const char empty[1] = { 0 }; /* XXX eliminate this */ |
500 |
|
|
501 |
|
|
|
/* Assume the line is NULL-terminated and that the `list' parameter */ |
|
|
/* was initialized the first time it was used. */ |
|
502 |
|
|
503 |
static FT_Error |
static FT_Error |
504 |
_bdf_split( char* separators, |
_bdf_list_split( _bdf_list_t* list, |
505 |
char* line, |
char* separators, |
506 |
unsigned long linelen, |
char* line, |
507 |
_bdf_list_t* list, |
unsigned long linelen ) |
|
FT_Memory memory ) |
|
508 |
{ |
{ |
509 |
int mult, final_empty; |
int mult, final_empty; |
510 |
char *sp, *ep, *end; |
char *sp, *ep, *end; |
553 |
/* Resize the list if necessary. */ |
/* Resize the list if necessary. */ |
554 |
if ( list->used == list->size ) |
if ( list->used == list->size ) |
555 |
{ |
{ |
556 |
if ( list->size == 0 ) |
error = _bdf_list_ensure( list, list->used+1 ); |
557 |
{ |
if ( error ) |
558 |
if ( FT_NEW_ARRAY( list->field, 5 ) ) |
goto Exit; |
|
goto Exit; |
|
|
} |
|
|
else |
|
|
{ |
|
|
if ( FT_RENEW_ARRAY ( list->field , |
|
|
list->size, |
|
|
list->size + 5 ) ) |
|
|
goto Exit; |
|
|
} |
|
|
|
|
|
list->size += 5; |
|
559 |
} |
} |
560 |
|
|
561 |
/* Assign the field appropriately. */ |
/* Assign the field appropriately. */ |
580 |
} |
} |
581 |
|
|
582 |
/* Finally, NULL-terminate the list. */ |
/* Finally, NULL-terminate the list. */ |
583 |
if ( list->used + final_empty + 1 >= list->size ) |
if ( list->used + final_empty >= list->size ) |
584 |
{ |
{ |
585 |
if ( list->used == list->size ) |
error = _bdf_list_ensure( list, list->used+final_empty+1 ); |
586 |
{ |
if ( error ) |
587 |
if ( list->size == 0 ) |
goto Exit; |
|
{ |
|
|
if ( FT_NEW_ARRAY( list->field, 5 ) ) |
|
|
goto Exit; |
|
|
} |
|
|
else |
|
|
{ |
|
|
if ( FT_RENEW_ARRAY( list->field, |
|
|
list->size, |
|
|
list->size + 5 ) ) |
|
|
goto Exit; |
|
|
} |
|
|
|
|
|
list->size += 5; |
|
|
} |
|
588 |
} |
} |
589 |
|
|
590 |
if ( final_empty ) |
if ( final_empty ) |
591 |
list->field[list->used++] = (char*)empty; |
list->field[list->used++] = (char*)empty; |
592 |
|
|
|
if ( list->used == list->size ) |
|
|
{ |
|
|
if ( list->size == 0 ) |
|
|
{ |
|
|
if ( FT_NEW_ARRAY( list->field, 5 ) ) |
|
|
goto Exit; |
|
|
} |
|
|
else |
|
|
{ |
|
|
if ( FT_RENEW_ARRAY( list->field, |
|
|
list->size, |
|
|
list->size + 5 ) ) |
|
|
goto Exit; |
|
|
} |
|
|
|
|
|
list->size += 5; |
|
|
} |
|
|
|
|
593 |
list->field[list->used] = 0; |
list->field[list->used] = 0; |
594 |
|
|
595 |
Exit: |
Exit: |
597 |
} |
} |
598 |
|
|
599 |
|
|
|
static void |
|
|
_bdf_shift( unsigned long n, |
|
|
_bdf_list_t* list ) |
|
|
{ |
|
|
unsigned long i, u; |
|
|
|
|
|
|
|
|
if ( list == 0 || list->used == 0 || n == 0 ) |
|
|
return; |
|
|
|
|
|
if ( n >= list->used ) |
|
|
{ |
|
|
list->used = 0; |
|
|
return; |
|
|
} |
|
|
|
|
|
for ( u = n, i = 0; u < list->used; i++, u++ ) |
|
|
list->field[i] = list->field[u]; |
|
|
list->used -= n; |
|
|
} |
|
|
|
|
|
|
|
|
static char * |
|
|
_bdf_join( int c, |
|
|
unsigned long* len, |
|
|
_bdf_list_t* list ) |
|
|
{ |
|
|
unsigned long i, j; |
|
|
char *fp, *dp; |
|
|
|
|
|
|
|
|
if ( list == 0 || list->used == 0 ) |
|
|
return 0; |
|
|
|
|
|
*len = 0; |
|
|
|
|
|
dp = list->field[0]; |
|
|
for ( i = j = 0; i < list->used; i++ ) |
|
|
{ |
|
|
fp = list->field[i]; |
|
|
while ( *fp ) |
|
|
dp[j++] = *fp++; |
|
|
|
|
|
if ( i + 1 < list->used ) |
|
|
dp[j++] = (char)c; |
|
|
} |
|
|
dp[j] = 0; |
|
|
|
|
|
*len = j; |
|
|
return dp; |
|
|
} |
|
|
|
|
|
|
|
|
/* High speed file reader that passes each line to a callback. */ |
|
|
static FT_Error |
|
|
bdf_internal_readstream( FT_Stream stream, |
|
|
char* buffer, |
|
|
int count, |
|
|
int *read_bytes ) |
|
|
{ |
|
|
int rbytes; |
|
|
unsigned long pos = stream->pos; |
|
|
FT_Error error = BDF_Err_Ok; |
|
|
|
|
|
|
|
|
if ( pos > stream->size ) |
|
|
{ |
|
|
FT_ERROR(( "bdf_internal_readstream:" )); |
|
|
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n", |
|
|
pos, stream->size )); |
|
|
error = BDF_Err_Invalid_Stream_Operation; |
|
|
goto Exit; |
|
|
} |
|
|
|
|
|
if ( stream->read ) |
|
|
rbytes = stream->read( stream, pos, |
|
|
(unsigned char *)buffer, count ); |
|
|
else |
|
|
{ |
|
|
rbytes = stream->size - pos; |
|
|
if ( rbytes > count ) |
|
|
rbytes = count; |
|
|
|
|
|
FT_MEM_COPY( buffer, stream->base + pos, rbytes ); |
|
|
} |
|
|
|
|
|
stream->pos = pos + rbytes; |
|
|
|
|
|
*read_bytes = rbytes; |
|
|
|
|
|
Exit: |
|
|
return error; |
|
|
} |
|
600 |
|
|
601 |
|
#define NO_SKIP 256 /* this value cannot be stored in a 'char' */ |
602 |
|
|
603 |
static FT_Error |
static FT_Error |
604 |
_bdf_readstream( FT_Stream stream, |
_bdf_readstream( FT_Stream stream, |
607 |
unsigned long *lno ) |
unsigned long *lno ) |
608 |
{ |
{ |
609 |
_bdf_line_func_t cb; |
_bdf_line_func_t cb; |
610 |
unsigned long lineno; |
unsigned long lineno, buf_size; |
611 |
int n, done, refill, bytes, hold; |
int refill, bytes, hold, to_skip; |
612 |
char *ls, *le, *pp, *pe, *hp; |
int start, end, cursor, avail; |
613 |
char *buf = 0; |
char* buf = 0; |
614 |
FT_Memory memory = stream->memory; |
FT_Memory memory = stream->memory; |
615 |
FT_Error error = BDF_Err_Ok; |
FT_Error error = BDF_Err_Ok; |
616 |
|
|
621 |
goto Exit; |
goto Exit; |
622 |
} |
} |
623 |
|
|
624 |
if ( FT_NEW_ARRAY( buf, 65536L ) ) |
/* initial size and allocation of the input buffer |
625 |
goto Exit; |
*/ |
626 |
|
buf_size = 1024; |
627 |
|
|
628 |
cb = callback; |
if ( FT_NEW_ARRAY( buf, buf_size ) ) |
629 |
lineno = 1; |
goto Exit; |
|
buf[0] = 0; |
|
|
|
|
|
done = 0; |
|
|
pp = ls = le = buf; |
|
630 |
|
|
631 |
bytes = 65536L; |
cb = callback; |
632 |
|
lineno = 1; |
633 |
|
buf[0] = 0; |
634 |
|
start = 0; |
635 |
|
end = 0; |
636 |
|
avail = 0; |
637 |
|
cursor = 0; |
638 |
|
refill = 1; |
639 |
|
to_skip = NO_SKIP; |
640 |
|
|
641 |
while ( !done ) |
for (;;) |
642 |
{ |
{ |
643 |
error = bdf_internal_readstream( stream, pp, bytes, &n ); |
if ( refill ) |
644 |
if ( error ) |
{ |
645 |
goto Exit; |
bytes = (int) FT_Stream_TryRead( stream, buf + cursor, |
646 |
|
(FT_ULong)(buf_size - cursor) ); |
647 |
|
avail = cursor + bytes; |
648 |
|
cursor = 0; |
649 |
|
refill = 0; |
650 |
|
} |
651 |
|
|
652 |
if ( n == 0 ) |
end = start; |
|
break; |
|
653 |
|
|
654 |
/* Determine the new end of the buffer pages. */ |
/* should we skip an optional character like \n or \r ? */ |
655 |
pe = pp + n; |
if ( start < avail && buf[start] == to_skip ) |
656 |
|
{ |
657 |
|
start += 1; |
658 |
|
to_skip = NO_SKIP; |
659 |
|
continue; |
660 |
|
} |
661 |
|
|
662 |
for ( refill = 0; done == 0 && refill == 0; ) |
/* try to find the end of the line */ |
663 |
|
while ( end < avail && buf[end] != '\n' && buf[end] != '\r' ) |
664 |
|
end++; |
665 |
|
|
666 |
|
/* if we hit the end of the buffer, try shifting its content |
667 |
|
* or even resizing it |
668 |
|
*/ |
669 |
|
if ( end >= avail ) |
670 |
{ |
{ |
671 |
while ( le < pe && *le != '\n' && *le != '\r' ) |
if ( bytes == 0 ) /* last line in file doesn't end in \r or \n */ |
672 |
le++; |
break; /* ignore it then exit */ |
673 |
|
|
674 |
if ( le == pe ) |
if ( start == 0 ) |
675 |
{ |
{ |
676 |
/* Hit the end of the last page in the buffer. Need to find */ |
/* this line is definitely too long, try resizing the input buffer |
677 |
/* out how many pages to shift and how many pages need to be */ |
* a bit to handle it. |
678 |
/* read in. Adjust the line start and end pointers down to */ |
*/ |
679 |
/* point to the right places in the pages. */ |
FT_ULong new_size; |
680 |
|
|
681 |
pp = buf + ( ( ( ls - buf ) >> 13 ) << 13 ); |
if ( buf_size >= 65536UL ) /* limit ourselves to 64 Kb */ |
682 |
n = pp - buf; |
{ |
683 |
ls -= n; |
error = BDF_Err_Invalid_Argument; |
684 |
le -= n; |
goto Exit; |
685 |
n = pe - pp; |
} |
686 |
|
|
687 |
FT_MEM_MOVE( buf, pp, n ); |
new_size = buf_size*2; |
688 |
|
if ( FT_RENEW_ARRAY( buf, buf_size, new_size ) ) |
689 |
pp = buf + n; |
goto Exit; |
690 |
bytes = 65536L - n; |
|
691 |
refill = 1; |
cursor = buf_size; |
692 |
|
buf_size = new_size; |
693 |
} |
} |
694 |
else |
else |
695 |
{ |
{ |
696 |
/* Temporarily NULL-terminate the line. */ |
bytes = avail - start; |
|
hp = le; |
|
|
hold = *le; |
|
|
*le = 0; |
|
|
|
|
|
/* XXX: Use encoding independent value for 0x1a */ |
|
|
if ( *ls != '#' && *ls != 0x1a && |
|
|
le > ls && |
|
|
( error = (*cb)( ls, le - ls, lineno, (void *)&cb, |
|
|
client_data ) ) != BDF_Err_Ok ) |
|
|
done = 1; |
|
|
else |
|
|
{ |
|
|
ls = ++le; |
|
|
/* Handle the case of DOS crlf sequences. */ |
|
|
if ( le < pe && hold == '\n' && *le =='\r' ) |
|
|
ls = ++le; |
|
|
} |
|
697 |
|
|
698 |
/* Increment the line number. */ |
FT_MEM_COPY( buf, buf+start, bytes ); |
|
lineno++; |
|
699 |
|
|
700 |
/* Restore the character at the end of the line. */ |
cursor = bytes; |
701 |
*hp = (char)hold; |
avail -= bytes; |
702 |
|
start = 0; |
703 |
} |
} |
704 |
|
refill = 1; |
705 |
|
continue; |
706 |
|
} |
707 |
|
|
708 |
|
/* Temporarily NUL-terminate the line. */ |
709 |
|
hold = buf[end]; |
710 |
|
buf[end] = 0; |
711 |
|
|
712 |
|
/* XXX: Use encoding independent value for 0x1a */ |
713 |
|
if ( buf[start] != '#' && buf[start] != 0x1a && end > start ) |
714 |
|
{ |
715 |
|
error = (*cb)( buf+start, end-start, lineno, (void*)&cb, client_data ); |
716 |
|
if ( error ) |
717 |
|
break; |
718 |
} |
} |
719 |
|
|
720 |
|
lineno += 1; |
721 |
|
buf[end] = (char)hold; |
722 |
|
start = end+1; |
723 |
|
|
724 |
|
if ( hold == '\n' ) |
725 |
|
to_skip = '\r'; |
726 |
|
else if ( hold == '\r' ) |
727 |
|
to_skip = '\n'; |
728 |
|
else |
729 |
|
to_skip = NO_SKIP; |
730 |
} |
} |
731 |
|
|
732 |
*lno = lineno; |
*lno = lineno; |
733 |
|
|
734 |
Exit: |
Exit: |
735 |
FT_FREE( buf ); |
FT_FREE( buf ); |
952 |
|
|
953 |
if ( c1->encoding < c2->encoding ) |
if ( c1->encoding < c2->encoding ) |
954 |
return -1; |
return -1; |
955 |
else if ( c1->encoding > c2->encoding ) |
|
956 |
|
if ( c1->encoding > c2->encoding ) |
957 |
return 1; |
return 1; |
958 |
|
|
959 |
return 0; |
return 0; |
977 |
if ( hash_lookup( name, &(font->proptbl) ) ) |
if ( hash_lookup( name, &(font->proptbl) ) ) |
978 |
goto Exit; |
goto Exit; |
979 |
|
|
980 |
if ( font->nuser_props == 0 ) |
if ( FT_RENEW_ARRAY( font->user_props, |
981 |
{ |
font->nuser_props, |
982 |
if ( FT_NEW_ARRAY( font->user_props, 1 ) ) |
font->nuser_props + 1 ) ) |
983 |
goto Exit; |
goto Exit; |
|
} |
|
|
else |
|
|
{ |
|
|
if ( FT_RENEW_ARRAY( font->user_props, |
|
|
font->nuser_props, |
|
|
font->nuser_props + 1 ) ) |
|
|
goto Exit; |
|
|
} |
|
984 |
|
|
985 |
p = font->user_props + font->nuser_props; |
p = font->user_props + font->nuser_props; |
986 |
FT_MEM_ZERO( p, sizeof ( bdf_property_t ) ); |
FT_ZERO( p ); |
987 |
|
|
988 |
n = (unsigned long)( ft_strlen( name ) + 1 ); |
n = (unsigned long)( ft_strlen( name ) + 1 ); |
989 |
|
|
990 |
if ( FT_NEW_ARRAY( p->name, n ) ) |
if ( FT_NEW_ARRAY( p->name, n ) ) |
991 |
goto Exit; |
goto Exit; |
992 |
|
|
1101 |
FT_Error error = BDF_Err_Ok; |
FT_Error error = BDF_Err_Ok; |
1102 |
|
|
1103 |
|
|
1104 |
if ( font->comments_len == 0 ) |
if ( FT_RENEW_ARRAY( font->comments, |
1105 |
{ |
font->comments_len, |
1106 |
if ( FT_NEW_ARRAY( font->comments, len + 1 ) ) |
font->comments_len + len + 1 ) ) |
1107 |
goto Exit; |
goto Exit; |
|
} |
|
|
else |
|
|
{ |
|
|
if ( FT_RENEW_ARRAY( font->comments, |
|
|
font->comments_len, |
|
|
font->comments_len + len + 1 ) ) |
|
|
goto Exit; |
|
|
} |
|
1108 |
|
|
1109 |
cp = font->comments + font->comments_len; |
cp = font->comments + font->comments_len; |
1110 |
|
|
1111 |
FT_MEM_COPY( cp, comment, len ); |
FT_MEM_COPY( cp, comment, len ); |
1112 |
cp += len; |
cp[len] = '\n'; |
1113 |
*cp++ = '\n'; |
|
1114 |
font->comments_len += len + 1; |
font->comments_len += len + 1; |
1115 |
|
|
1116 |
Exit: |
Exit: |
1139 |
|
|
1140 |
memory = font->memory; |
memory = font->memory; |
1141 |
|
|
1142 |
|
_bdf_list_init( &list, memory ); |
1143 |
|
|
1144 |
font->spacing = opts->font_spacing; |
font->spacing = opts->font_spacing; |
1145 |
|
|
1146 |
len = (unsigned long)( ft_strlen( font->name ) + 1 ); |
len = (unsigned long)( ft_strlen( font->name ) + 1 ); |
1147 |
FT_MEM_COPY( name, font->name, len ); |
FT_MEM_COPY( name, font->name, len ); |
1148 |
|
|
1149 |
list.size = list.used = 0; |
error = _bdf_list_split( &list, (char *)"-", name, len ); |
|
|
|
|
error = _bdf_split( (char *)"-", name, len, &list, memory ); |
|
1150 |
if ( error ) |
if ( error ) |
1151 |
goto Exit; |
goto Fail; |
1152 |
|
|
1153 |
if ( list.used == 15 ) |
if ( list.used == 15 ) |
1154 |
{ |
{ |
1169 |
} |
} |
1170 |
} |
} |
1171 |
|
|
1172 |
FT_FREE( list.field ); |
Fail: |
1173 |
|
_bdf_list_done( &list ); |
1174 |
|
|
1175 |
Exit: |
Exit: |
1176 |
return error; |
return error; |
1469 |
goto Exit; |
goto Exit; |
1470 |
} |
} |
1471 |
|
|
1472 |
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
1473 |
if ( error ) |
if ( error ) |
1474 |
goto Exit; |
goto Exit; |
1475 |
p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1], 0, 10 ); |
p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1], 0, 10 ); |
1523 |
/* encoding can be checked for an unencoded character. */ |
/* encoding can be checked for an unencoded character. */ |
1524 |
FT_FREE( p->glyph_name ); |
FT_FREE( p->glyph_name ); |
1525 |
|
|
1526 |
error = _bdf_split( (char *)" +", line, linelen, &p->list,memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
1527 |
if ( error ) |
if ( error ) |
1528 |
goto Exit; |
goto Exit; |
|
_bdf_shift( 1, &p->list ); |
|
1529 |
|
|
1530 |
s = _bdf_join( ' ', &slen, &p->list ); |
_bdf_list_shift( &p->list, 1 ); |
1531 |
|
|
1532 |
|
s = _bdf_list_join( &p->list, ' ', &slen ); |
1533 |
|
|
1534 |
if ( FT_NEW_ARRAY( p->glyph_name, slen + 1 ) ) |
if ( FT_NEW_ARRAY( p->glyph_name, slen + 1 ) ) |
1535 |
goto Exit; |
goto Exit; |
1536 |
|
|
1537 |
FT_MEM_COPY( p->glyph_name, s, slen + 1 ); |
FT_MEM_COPY( p->glyph_name, s, slen + 1 ); |
1538 |
|
|
1539 |
p->flags |= _BDF_GLYPH; |
p->flags |= _BDF_GLYPH; |
1552 |
goto Exit; |
goto Exit; |
1553 |
} |
} |
1554 |
|
|
1555 |
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
1556 |
if ( error ) |
if ( error ) |
1557 |
goto Exit; |
goto Exit; |
1558 |
|
|
1559 |
p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 ); |
p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 ); |
1560 |
|
|
1561 |
/* Check to see whether this encoding has already been encountered. */ |
/* Check to see whether this encoding has already been encountered. */ |
1586 |
font->glyphs_size, |
font->glyphs_size, |
1587 |
font->glyphs_size + 64 ) ) |
font->glyphs_size + 64 ) ) |
1588 |
goto Exit; |
goto Exit; |
1589 |
FT_MEM_ZERO( font->glyphs + font->glyphs_size, |
|
|
sizeof ( bdf_glyph_t ) * 64 ); /* FZ inutile */ |
|
1590 |
font->glyphs_size += 64; |
font->glyphs_size += 64; |
1591 |
} |
} |
1592 |
|
|
1606 |
/* Allocate the next unencoded glyph. */ |
/* Allocate the next unencoded glyph. */ |
1607 |
if ( font->unencoded_used == font->unencoded_size ) |
if ( font->unencoded_used == font->unencoded_size ) |
1608 |
{ |
{ |
1609 |
if ( font->unencoded_size == 0 ) |
if ( FT_RENEW_ARRAY( font->unencoded , |
1610 |
{ |
font->unencoded_size, |
1611 |
if ( FT_NEW_ARRAY( font->unencoded, 4 ) ) |
font->unencoded_size + 4 ) ) |
1612 |
goto Exit; |
goto Exit; |
1613 |
} |
|
|
else |
|
|
{ |
|
|
if ( FT_RENEW_ARRAY( font->unencoded , |
|
|
font->unencoded_size, |
|
|
font->unencoded_size + 4 ) ) |
|
|
goto Exit; |
|
|
} |
|
1614 |
font->unencoded_size += 4; |
font->unencoded_size += 4; |
1615 |
} |
} |
1616 |
|
|
1699 |
goto Exit; |
goto Exit; |
1700 |
} |
} |
1701 |
|
|
1702 |
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
1703 |
if ( error ) |
if ( error ) |
1704 |
goto Exit; |
goto Exit; |
1705 |
|
|
1706 |
glyph->swidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 ); |
glyph->swidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 ); |
1707 |
p->flags |= _BDF_SWIDTH; |
p->flags |= _BDF_SWIDTH; |
1708 |
|
|
1712 |
/* Expect the DWIDTH (scalable width) field next. */ |
/* Expect the DWIDTH (scalable width) field next. */ |
1713 |
if ( ft_memcmp( line, "DWIDTH", 6 ) == 0 ) |
if ( ft_memcmp( line, "DWIDTH", 6 ) == 0 ) |
1714 |
{ |
{ |
1715 |
error = _bdf_split( (char *)" +", line, linelen, &p->list,memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
1716 |
if ( error ) |
if ( error ) |
1717 |
goto Exit; |
goto Exit; |
1718 |
|
|
1719 |
glyph->dwidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 ); |
glyph->dwidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 ); |
1720 |
|
|
1721 |
if ( !( p->flags & _BDF_SWIDTH ) ) |
if ( !( p->flags & _BDF_SWIDTH ) ) |
1737 |
/* Expect the BBX field next. */ |
/* Expect the BBX field next. */ |
1738 |
if ( ft_memcmp( line, "BBX", 3 ) == 0 ) |
if ( ft_memcmp( line, "BBX", 3 ) == 0 ) |
1739 |
{ |
{ |
1740 |
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
1741 |
if ( error ) |
if ( error ) |
1742 |
goto Exit; |
goto Exit; |
1743 |
|
|
1918 |
} |
} |
1919 |
else |
else |
1920 |
{ |
{ |
1921 |
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
1922 |
if ( error ) |
if ( error ) |
1923 |
goto Exit; |
goto Exit; |
1924 |
name = p->list.field[0]; |
name = p->list.field[0]; |
1925 |
|
|
1926 |
_bdf_shift( 1, &p->list ); |
_bdf_list_shift( &p->list, 1 ); |
1927 |
value = _bdf_join( ' ', &vlen, &p->list ); |
value = _bdf_list_join( &p->list, ' ', &vlen ); |
1928 |
|
|
1929 |
error = _bdf_add_property( p->font, name, value ); |
error = _bdf_add_property( p->font, name, value ); |
1930 |
if ( error ) |
if ( error ) |
2039 |
/* Check for the start of the properties. */ |
/* Check for the start of the properties. */ |
2040 |
if ( ft_memcmp( line, "STARTPROPERTIES", 15 ) == 0 ) |
if ( ft_memcmp( line, "STARTPROPERTIES", 15 ) == 0 ) |
2041 |
{ |
{ |
2042 |
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
2043 |
if ( error ) |
if ( error ) |
2044 |
goto Exit; |
goto Exit; |
2045 |
p->cnt = p->font->props_size = _bdf_atoul( p->list.field[1], 0, 10 ); |
p->cnt = p->font->props_size = _bdf_atoul( p->list.field[1], 0, 10 ); |
2064 |
goto Exit; |
goto Exit; |
2065 |
} |
} |
2066 |
|
|
2067 |
error = _bdf_split( (char *)" +", line, linelen, &p->list , memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
2068 |
if ( error ) |
if ( error ) |
2069 |
goto Exit; |
goto Exit; |
2070 |
|
|
2087 |
/* The next thing to check for is the FONT field. */ |
/* The next thing to check for is the FONT field. */ |
2088 |
if ( ft_memcmp( line, "FONT", 4 ) == 0 ) |
if ( ft_memcmp( line, "FONT", 4 ) == 0 ) |
2089 |
{ |
{ |
2090 |
error = _bdf_split( (char *)" +", line, linelen, &p->list , memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
2091 |
if ( error ) |
if ( error ) |
2092 |
goto Exit; |
goto Exit; |
2093 |
_bdf_shift( 1, &p->list ); |
_bdf_list_shift( &p->list, 1 ); |
2094 |
|
|
2095 |
s = _bdf_join( ' ', &slen, &p->list ); |
s = _bdf_list_join( &p->list, ' ', &slen ); |
2096 |
if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) ) |
if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) ) |
2097 |
goto Exit; |
goto Exit; |
2098 |
FT_MEM_COPY( p->font->name, s, slen + 1 ); |
FT_MEM_COPY( p->font->name, s, slen + 1 ); |
2119 |
goto Exit; |
goto Exit; |
2120 |
} |
} |
2121 |
|
|
2122 |
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory ); |
error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); |
2123 |
if ( error ) |
if ( error ) |
2124 |
goto Exit; |
goto Exit; |
2125 |
|
|
2189 |
FT_Error error = BDF_Err_Ok; |
FT_Error error = BDF_Err_Ok; |
2190 |
|
|
2191 |
|
|
2192 |
if ( FT_ALLOC( p, sizeof ( _bdf_parse_t ) ) ) |
if ( FT_NEW( p ) ) |
2193 |
goto Exit; |
goto Exit; |
2194 |
|
|
2195 |
memory = NULL; |
memory = NULL; |
2197 |
p->minlb = 32767; |
p->minlb = 32767; |
2198 |
p->memory = extmemory; /* only during font creation */ |
p->memory = extmemory; /* only during font creation */ |
2199 |
|
|
2200 |
|
_bdf_list_init( &p->list, extmemory ); |
2201 |
|
|
2202 |
error = _bdf_readstream( stream, _bdf_parse_start, |
error = _bdf_readstream( stream, _bdf_parse_start, |
2203 |
(void *)p, &lineno ); |
(void *)p, &lineno ); |
2204 |
if ( error ) |
if ( error ) |
2285 |
} |
} |
2286 |
} |
} |
2287 |
|
|
|
/* Free up the list used during the parsing. */ |
|
|
if ( memory != NULL ) |
|
|
FT_FREE( p->list.field ); |
|
|
|
|
2288 |
if ( p->font != 0 ) |
if ( p->font != 0 ) |
2289 |
{ |
{ |
2290 |
/* Make sure the comments are NULL terminated if they exist. */ |
/* Make sure the comments are NULL terminated if they exist. */ |
2307 |
Exit: |
Exit: |
2308 |
if ( p ) |
if ( p ) |
2309 |
{ |
{ |
2310 |
|
_bdf_list_done( &p->list ); |
2311 |
|
|
2312 |
memory = extmemory; |
memory = extmemory; |
2313 |
|
|
2314 |
FT_FREE( p ); |
FT_FREE( p ); |
2315 |
} |
} |
2316 |
|
|