/usr/share/doc/libafterimage-dev/examples/ascheckttf.c is in libafterimage-dev 2.2.11-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | #include "config.h"
#include <string.h>
#include <stdlib.h>
#include <libAfterImage/afterbase.h>
#include <libAfterImage/afterimage.h>
#include "common.h"
/* Usage: ascheckttf [-f font] [-s size] [-t text]|[--glyphs <listof unicodes>]
*/
#define BEVEL_HI_WIDTH 20
#define BEVEL_LO_WIDTH 30
#define BEVEL_ADDON (BEVEL_HI_WIDTH+BEVEL_LO_WIDTH)
void usage()
{
printf( " Usage: ascheckttf [-h] [-f font] [-s size] [-t text]|[--unicode <listof unicodes>]"
"[-S 3D_style] \n");
printf( " Where: font - TrueType font's filename\n");
printf( " size - size in points for TrueType fonts;\n");
printf( " text - text;\n");
printf( " unicode - comma separated list of unicode codes;\n");
printf( " 3D_style - 3D style of text. "
"One of the following:\n");
printf( " 0 - plain 2D tetx, 1 - embossed, 2 - sunken, "
"3 - shade above,\n");
printf( " 4 - shade below, 5 - embossed thick, "
"6 - sunken thick.\n");
printf( " 7 - ouline above, 8 - ouline below, "
"9 - full ouline.\n");
}
int main(int argc, char* argv[])
{
char *font_name = NULL;
int size = 32 ;
char *unicode = NULL;
UNICODE_CHAR* uc_ptr = NULL;
char *text = NULL;
struct ASFontManager *fontman = NULL;
struct ASFont *font = NULL;
int i ;
int text_margin = size/2 ;
char * font_path = NULL;
ASGlyph** glyphs = NULL;
/* see ASView.1 : */
set_application_name( argv[0] );
#if (HAVE_AFTERBASE_FLAG==1)
set_output_threshold(OUTPUT_LEVEL_DEBUG);
#endif
if( argc == 1 )
usage();
else
for (i = 1 ; i < argc ; i++)
{
if (strncmp( argv[i], "-h", 2 ) == 0)
{
usage();
return 0;
}
if (i+1 < argc)
{
if( strncmp( argv[i], "-f", 2 ) == 0 )
font_name = argv[i+1] ;
else if( strncmp( argv[i], "-s", 2 ) == 0 )
{
size = atoi(argv[i+1]);
text_margin = size/2 ;
}else if (strncmp( argv[i], "-t", 2 ) == 0)
text = argv[i+1] ;
else if (strncmp( argv[i], "--unicode", 9 ) == 0)
unicode = argv[i+1] ;
}
}
if (font_name == NULL)
{
show_error( "Font must be specified." );
usage();
return 1;
}
if (text == NULL && unicode == NULL)
{
show_error( "Either text or list of unicode must be specified." );
usage();
return 1;
}
if( getenv("FONT_PATH") != NULL )
{
font_path = safemalloc( strlen(getenv("FONT_PATH"))+1+2+1);
sprintf( font_path, "%s:./", getenv("FONT_PATH") );
}
if( (fontman = create_font_manager( NULL, font_path, NULL )) != NULL )
font = get_asfont( fontman, font_name, 0, size, ASF_Freetype );
if( font == NULL )
{
show_error( "unable to load requested font \"%s\". ", font_name );
return 1;
}
if (text)
{
glyphs = get_text_glyph_list (text, font, ASCT_Char, 0);
}else /* unicode */
{
char *endp = unicode;
i = 0;
uc_ptr = safecalloc (strlen (unicode)+1, sizeof (UNICODE_CHAR));
while ((uc_ptr[i++] = strtol(endp, &endp, 0)) > 0)
if (*endp == ',' || *endp == ';') ++endp;
glyphs = get_text_glyph_list ((char*)uc_ptr, font, ASCT_Unicode, 0);
}
for( i = 0 ; glyphs[i] ; ++i )
{
if (text)
printf ("0x%8.8X ", (unsigned int)text[i]);
else
printf ("0x%8.8X ", (unsigned int)uc_ptr[i]);
if (glyphs[i] == &(font->default_glyph))
printf ("N 0 0\n");
else
printf ("Y %d %d\n", glyphs[i]->width, glyphs[i]->height);
}
release_font( font );
destroy_font_manager( fontman, False );
return 0 ;
}
|