X-Git-Url: http://git.tdb.fi/?p=ttf2png.git;a=blobdiff_plain;f=ttf2png.c;h=770f0c633119efc6a3e6219a287bb85de48a193e;hp=0c1c09a490f0dd675c000496b2f7fd3cc6159e5c;hb=HEAD;hpb=0846d7665792d25e673ae51b56b691f58f7d0679 diff --git a/ttf2png.c b/ttf2png.c index 0c1c09a..76c2e0d 100644 --- a/ttf2png.c +++ b/ttf2png.c @@ -1,6 +1,6 @@ /* ttf2png - True Type Font to PNG converter -Copyright (c) 2004-2018 Mikko Rasa, Mikkosoft Productions +Copyright (c) 2004-2021 Mikko Rasa, Mikkosoft Productions This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,7 +73,7 @@ typedef unsigned char bool; void usage(void); int convert_numeric_option(char, int); void convert_code_point_range(char, Range *); -unsigned str_to_code_point(const char *, char **); +int str_to_code_point(const char *, char **); void convert_size(char, unsigned *, unsigned *); void sort_and_compact_ranges(Range *, unsigned *); int range_cmp(const void *, const void *); @@ -289,8 +289,8 @@ int main(int argc, char **argv) void usage(void) { - printf("ttf2png 1.1 - True Type Font to PNG converter\n" - "Copyright (c) 2004-2018 Mikko Rasa, Mikkosoft Productions\n" + printf("ttf2png 2.0 - True Type Font to PNG converter\n" + "Copyright (c) 2004-2021 Mikko Rasa, Mikkosoft Productions\n" "Distributed under the GNU General Public License\n\n"); printf("Usage: ttf2png [options] \n\n"); @@ -344,11 +344,11 @@ void convert_code_point_range(char opt, Range *range) } value = str_to_code_point(optarg, &ptr); - if(value>0 && *ptr==',') + if(value>=0 && *ptr==',') { range->first = value; value = str_to_code_point(ptr+1, &ptr); - if(value>0 && !*ptr) + if(value>=(int)range->first && !*ptr) { range->last = value; return; @@ -359,7 +359,7 @@ void convert_code_point_range(char opt, Range *range) exit(1); } -unsigned str_to_code_point(const char *nptr, char **endptr) +int str_to_code_point(const char *nptr, char **endptr) { if(nptr[0]=='U' && nptr[1]=='+') return strtoul(nptr+2, endptr, 16); @@ -374,9 +374,9 @@ unsigned str_to_code_point(const char *nptr, char **endptr) for(bytes=1; (bytes<4 && (nptr[0]&(0x80>>bytes))); ++bytes) if((nptr[bytes]&0xC0)!=0x80) - return 0; + return -1; if(bytes<2) - return 0; + return -1; code = nptr[0]&(0x3F>>bytes); for(i=1; i