Ejemplo n.º 1
0
static int
BitmapOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int flags, 
		  FontEntryPtr entry, char *fileName, 
		  fsBitmapFormat format, fsBitmapFormatMask fmask,
		  FontPtr non_cachable_font) /* We don't do licensing */
{
    FontFilePtr	file;
    FontPtr     pFont;
    int         i;
    int         ret;
    int         bit,
                byte,
                glyph,
                scan,
		image;

    i = BitmapGetRenderIndex(entry->u.bitmap.renderer);
    file = FontFileOpen (fileName);
    if (!file)
	return BadFontName;
    if (!(pFont = CreateFontRec())) {
	fprintf(stderr, "Error: Couldn't allocate pFont (%ld)\n",
		(unsigned long)sizeof(FontRec));
	FontFileClose (file);
	return AllocError;
    }
    /* set up default values */
    FontDefaultFormat(&bit, &byte, &glyph, &scan);
    /* get any changes made from above */
    ret = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);

    /* Fill in font record. Data format filled in by reader. */
    pFont->refcnt = 0;

    ret = (*readers[i].ReadFont) (pFont, file, bit, byte, glyph, scan);

    FontFileClose (file);
    if (ret != Successful) {
	free(pFont);
    } else {
	*ppFont = pFont;
    }
    return ret;
}
Ejemplo n.º 2
0
static int
BuiltinOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int	flags,
		   FontEntryPtr entry, char *fileName, fsBitmapFormat format,
		   fsBitmapFormatMask fmask, FontPtr unused)
{
    FontFilePtr	file;
    FontPtr     pFont;
    int         ret;
    int         bit,
                byte,
                glyph,
                scan,
		image;

    file = BuiltinFileOpen (fileName);
    if (!file)
	return BadFontName;
    pFont = malloc(sizeof(FontRec));
    if (!pFont) {
	BuiltinFileClose (file, 0);
	return AllocError;
    }
    /* set up default values */
    FontDefaultFormat(&bit, &byte, &glyph, &scan);
    /* get any changes made from above */
    ret = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);

    /* Fill in font record. Data format filled in by reader. */
    pFont->refcnt = 0;
    pFont->maxPrivate = -1;
    pFont->devPrivates = (pointer *) 0;

    ret = pcfReadFont (pFont, file, bit, byte, glyph, scan);

    BuiltinFileClose (file, 0);
    if (ret != Successful)
	free(pFont);
    else
	*ppFont = pFont;
    return ret;
}
Ejemplo n.º 3
0
int
main(int argc, char *argv[])
{
    FontRec font = { 0 };

    FontFilePtr input, output;

    char *input_name = NULL, *output_name = NULL;

    char *program_name;

    int bit, byte, glyph, scan;

    FontDefaultFormat(&bit, &byte, &glyph, &scan);
    program_name = argv[0];
    argc--, argv++;
    while (argc-- > 0) {
        if (argv[0][0] == '-') {
            switch (argv[0][1]) {
            case 'p':
                switch (argv[0][2]) {
                case '1':
                case '2':
                case '4':
                case '8':
                    if (argv[0][3] != '\0')
                        goto usage;
                    glyph = argv[0][2] - '0';
                    break;
                default:
                    goto usage;
                }
                break;

            case 'u':
                switch (argv[0][2]) {
                case '1':
                case '2':
                case '4':
                    if (argv[0][3] != '\0')
                        goto usage;
                    scan = argv[0][2] - '0';
                    break;
                default:
                    goto usage;
                }
                break;

            case 'm':
                if (argv[0][2] != '\0')
                    goto usage;
                bit = MSBFirst;
                break;

            case 'l':
                if (argv[0][2] != '\0')
                    goto usage;
                bit = LSBFirst;
                break;

            case 'M':
                if (argv[0][2] != '\0')
                    goto usage;
                byte = MSBFirst;
                break;

            case 'L':
                if (argv[0][2] != '\0')
                    goto usage;
                byte = LSBFirst;
                break;

            case 't':          /* attempt to make terminal fonts if possible */
                if (argv[0][2] != '\0')
                    goto usage;
                break;

            case 'i':          /* inhibit ink metric computation */
                if (argv[0][2] != '\0')
                    goto usage;
                break;
            case 'o':
                if (argv[0][2])
                    output_name = argv[0] + 2;
                else {
                    if (!argv[1])
                        goto usage;
                    argv++;
                    argc--;
                    output_name = argv[0];
                }
                break;

            case 'v':
                printf("%s\n", PACKAGE_STRING);
                exit(0);

            default:
                goto usage;
            }
        }
        else {
            if (input_name) {
 usage:
                fprintf(stderr, "%s: invalid option '%s'\n",
                        program_name, argv[0]);
                fprintf(stderr,
                        "usage: %s [-p#] [-u#] [-m] [-l] [-M] [-L] [-t] [-i] [-o pcf file] [bdf file]\n"
                        "       where # for -p is 1, 2, 4, or 8\n"
                        "       and   # for -u is 1, 2, or 4\n",
                        program_name);
                exit(1);
            }
            input_name = argv[0];
        }
        argv++;
    }
    if (input_name) {
        input = FontFileOpen(input_name);
        if (!input) {
            fprintf(stderr, "%s: can't open bdf source file %s\n",
                    program_name, input_name);
            exit(1);
        }
    }
    else
        input = FontFileOpenFd(STDIN_FILENO);
    if (bdfReadFont(&font, input, bit, byte, glyph, scan) != Successful) {
        fprintf(stderr, "%s: bdf input, %s, corrupt\n",
                program_name, input_name ? input_name : "<stdin>");
        exit(1);
    }
    if (output_name) {
        output = FontFileOpenWrite(output_name);
        if (!output) {
            fprintf(stderr, "%s: can't open pcf sink file %s\n",
                    program_name, output_name);
            exit(1);
        }
    }
    else
        output = FontFileOpenWriteFd(STDOUT_FILENO);
    if (pcfWriteFont(&font, output) != Successful) {
        fprintf(stderr, "%s: can't write pcf file %s\n",
                program_name, output_name ? output_name : "<stdout>");
        if (output_name)
            remove(output_name);
        exit(1);
    }
    else
        FontFileClose(output);
    return (0);
}