Exemplo n.º 1
0
static void
show_font_header(FontList *list)
{
    const char        *string;
    FSXFontInfoHeader *pfh;

    pfh = list->info;
    if (!pfh) {
	fprintf(stderr,
		"%s:  no font information for font \"%s\".\n",
		program_name, list->name ? list->name : "");
	return;
    }
    if (pfh->draw_direction == LeftToRightDrawDirection)
	string = "-->";
    else
	string = "<--";
    printf("%-4s", string);
    if (pfh->char_range.min_char.high == 0
	    && pfh->char_range.max_char.high == 0) {
	printf(" %3d ", pfh->char_range.min_char.low);
	printf(" %3d ", pfh->char_range.max_char.low);
    } else {
	printf("*%3d ", pfh->char_range.min_char.high);
	printf("*%3d ", pfh->char_range.max_char.high);
    }
    printf("%5s ", (pfh->flags & FontInfoAllCharsExist) ? "all" : "some");
    printf("%4d ", (pfh->default_char.high << 8) + pfh->default_char.low);
    printf("%3d ", pfh->font_ascent);
    printf("%4d ", pfh->font_descent);
    printf("%s\n", list->name);
    if (min_max) {
	char        min[BUFSIZ],
	            max[BUFSIZ];
	char       *pmax = max,
	           *pmin = min;

	strcpy(pmin, "     min(l,r,w,a,d) = (");
	strcpy(pmax, "     max(l,r,w,a,d) = (");
	pmin += strlen(pmin);
	pmax += strlen(pmax);

	copy_number(&pmin, &pmax,
		    pfh->min_bounds.left,
		    pfh->max_bounds.left);
	*pmin++ = *pmax++ = ',';
	copy_number(&pmin, &pmax,
		    pfh->min_bounds.right,
		    pfh->max_bounds.right);
	*pmin++ = *pmax++ = ',';
	copy_number(&pmin, &pmax,
		    pfh->min_bounds.width,
		    pfh->max_bounds.width);
	*pmin++ = *pmax++ = ',';
	copy_number(&pmin, &pmax,
		    pfh->min_bounds.ascent,
		    pfh->max_bounds.ascent);
	*pmin++ = *pmax++ = ',';
	copy_number(&pmin, &pmax,
		    pfh->min_bounds.descent,
		    pfh->max_bounds.descent);
	*pmin++ = *pmax++ = ')';
	*pmin = *pmax = '\0';
	printf("%s\n", min);
	printf("%s\n", max);
    }
}
Exemplo n.º 2
0
static
void show_fonts(void)
{
    int i;

    if (font_cnt == 0)
        return;

    /* first sort the output */
    if (sort_output) qsort(font_list, font_cnt, sizeof(FontList), compare);

    if (long_list > L_MEDIUM) {
        for (i = 0; i < font_cnt; i++) {
            do_query_font (dpy, font_list[i].name);
        }
        return;
    }

    if (long_list == L_MEDIUM) {
        XFontStruct *pfi;
        char        *string;

        printf("DIR  ");
        printf("MIN  ");
        printf("MAX ");
        printf("EXIST ");
        printf("DFLT ");
        printf("PROP ");
        printf("ASC ");
        printf("DESC ");
        printf("NAME");
        printf("\n");
        for (i=0; i<font_cnt; i++) {
            pfi = font_list[i].info;
            if (!pfi) {
                fprintf(stderr, "%s:  no font information for font \"%s\".\n",
                        program_name, 
                        font_list[i].name ? 
                        font_list[i].name : "");
                continue;
            }
            switch(pfi->direction) {
                case FontLeftToRight: string = "-->"; break;
                case FontRightToLeft: string = "<--"; break;
                default:              string = "???"; break;
            }
            printf("%-4s", string);
            if (pfi->min_byte1 == 0 &&
                pfi->max_byte1 == 0) {
                printf(" %3d ", pfi->min_char_or_byte2);
                printf(" %3d ", pfi->max_char_or_byte2);
            } else {
                printf("*%3d ", pfi->min_byte1);
                printf("*%3d ", pfi->max_byte1);
            }
            printf("%5s ", pfi->all_chars_exist ? "all" : "some");
            printf("%4d ", pfi->default_char);
            printf("%4d ", pfi->n_properties);
            printf("%3d ", pfi->ascent);
            printf("%4d ", pfi->descent);
            printf("%s\n", font_list[i].name);
            if (min_max) {
                char  min[ BUFSIZ ],
                      max[ BUFSIZ ];
                char *pmax = max,
                     *pmin = min;

                strcpy(pmin, "     min(l,r,w,a,d) = (");
                strcpy(pmax, "     max(l,r,w,a,d) = (");
                pmin += strlen(pmin);
                pmax += strlen(pmax);

                copy_number(&pmin, &pmax,
                            pfi->min_bounds.lbearing,
                            pfi->max_bounds.lbearing);
                *pmin++ = *pmax++ = ',';
                copy_number(&pmin, &pmax,
                            pfi->min_bounds.rbearing,
                            pfi->max_bounds.rbearing);
                *pmin++ = *pmax++ = ',';
                copy_number(&pmin, &pmax,
                            pfi->min_bounds.width,
                            pfi->max_bounds.width);
                *pmin++ = *pmax++ = ',';
                copy_number(&pmin, &pmax,
                            pfi->min_bounds.ascent,
                            pfi->max_bounds.ascent);
                *pmin++ = *pmax++ = ',';
                copy_number(&pmin, &pmax,
                            pfi->min_bounds.descent,
                            pfi->max_bounds.descent);
                *pmin++ = *pmax++ = ')';
                *pmin = *pmax = '\0';
                printf("%s\n", min);
                printf("%s\n", max);
            }
        }
        return;
    }

    if ((columns == 0 && isatty(1)) || columns > 1) {
        int width,
            max_width = 0,
            lines_per_column,
            j,
            index;

        for (i=0; i<font_cnt; i++) {
            width = strlen(font_list[i].name);
            if (width > max_width)
                max_width = width;
        }
        if (max_width == 0)
            Fatal_Error("all %d fontnames listed are zero length", font_cnt);

        if (columns == 0) {
            if ((max_width * 2) + output_line_padding >
                max_output_line_width) {
                columns = 1;
            } else {
                max_width += output_line_padding;
                columns = ((max_output_line_width +
                            output_line_padding) / max_width);
            }
        } else {
            max_width += output_line_padding;
        }
        if (columns <= 1) goto single_column;

        if (font_cnt < columns)
            columns = font_cnt;
        lines_per_column = (font_cnt + columns - 1) / columns;

        for (i=0; i<lines_per_column; i++) {
            for (j=0; j<columns; j++) {
                index = j * lines_per_column + i;
                if (index >= font_cnt)
                    break;
                if (j+1 == columns)
                    printf("%s", font_list[ index ].name);
                else
                    printf("%-*s",
                           max_width, 
                           font_list[ index ].name);
            }
            printf("\n");
        }
        return;
    }

  single_column:
    for (i=0; i<font_cnt; i++)
        printf("%s\n", font_list[i].name);
}
Exemplo n.º 3
0
token_t akl_lex(struct akl_io_device *dev)
{
    int ch;
    /* We should take care of the '+', '++',
      and etc. style functions. Moreover the
      positive and negative numbers must also work:
      '(++ +5)' should be valid. */
    char op = 0;
    if (!buffer)
        init_buffer();

    assert(dev);
    while ((ch = akl_io_getc(dev))) {
        /* We should avoid the interpretation of the Unix shebang */
        if (dev->iod_char_count == 1 && ch == '#') {
            while ((ch = akl_io_getc(dev)) && ch != '\n') 
                ;
        }
        if (ch == EOF) {
           return tEOF;
        } else if (ch == '\n') {
           dev->iod_line_count++;
           dev->iod_char_count = 0;
        } else if (ch == '+' || ch == '-') {
            if (op != 0) {
                if (op == '+')
                    strcpy(buffer, "++");
                else
                    strcpy(buffer, "--");
                op = 0;
                return tATOM;
            }
            op = ch;
        } else if (isdigit(ch)) {
            akl_io_ungetc(ch, dev);
            copy_number(dev, op);
            op = 0;
            return tNUMBER;
        } else if (ch == ' ' || ch == '\n') {
            dev->iod_column = dev->iod_char_count+1;
            if (op != 0) {
                if (op == '+')
                    strcpy(buffer, "+");
                else
                    strcpy(buffer, "-");
                op = 0;
                return tATOM;
            } else {
                continue;
            }
        } else if (ch == '"') {
            ch = akl_io_getc(dev);
            if (ch == '"')
                return tNIL;
            akl_io_ungetc(ch, dev);
            copy_string(dev); 
            return tSTRING;
        } else if (ch == '(') {
            dev->iod_column = dev->iod_char_count+1;
            ch = akl_io_getc(dev);
            if (ch == ')')
                return tNIL;
            akl_io_ungetc(ch, dev);
            return tLBRACE;
        } else if (ch == ')') {
            return tRBRACE;
        } else if (ch == '\'' || ch == ':') {
            return tQUOTE;
        } else if (ch == ';') {
            while ((ch = akl_io_getc(dev)) != '\n') {
                if (akl_io_eof(dev))
                    return tEOF;
            }
        } else if (isalpha(ch) || ispunct(ch)) {
            akl_io_ungetc(ch, dev);
            copy_atom(dev);
            if ((strcasecmp(buffer, "NIL")) == 0)
                return tNIL;
            else if ((strcasecmp(buffer, "T")) == 0)
                return tTRUE;
            else
                return tATOM;
        } else {
            continue;
        }
    }
    return tEOF;
}