Beispiel #1
0
int DoChar(int sx, int sy, int c){
	int x=0;

	/* how many bytes is it high? */
	char height=(font->u8Height-1)/8+1;

	const uint8_t * data;

	/* "real" coordinates. Our physical display is upside down */
	int rx=RESX-sx-1;
	int ry=RESY-sy-font->u8Height;

	/* Does this font provide this character? */
	if(c<font->u8FirstChar)
		c=font->u8FirstChar+1; // error
	if(c>font->u8LastChar && font->charExtra == NULL)
		c=font->u8FirstChar+1; // error

	if(c>font->u8LastChar && font->charExtra != NULL){
		int cc=0;
		while( font->charExtra[cc] < c)
			cc++;
		if(font->charExtra[cc] > c)
			c=font->u8FirstChar+1; // error
		else
			c=font->u8LastChar+cc+1;
	};

	/* starting offset into character source data */
	int toff=0,width,preblank=0,blank=0; 

	if(font->u8Width==0){
		for(int y=0;y<c-font->u8FirstChar;y++)
			toff+=font->charInfo[y].widthBits;
		width=font->charInfo[c-font->u8FirstChar].widthBits;

		toff*=height;
		data=&font->au8FontTable[toff];
		blank=1;
	}else if(font->u8Width==1){ // NEW CODE
		// Find offset and length for our character
		for(int y=0;y<c-font->u8FirstChar;y++)
			toff+=font->charInfo[y].widthBits;
		width=font->charInfo[c-font->u8FirstChar].widthBits;

		if(font->au8FontTable[toff]>>4 == 15){ // It's a raw character!
			preblank = font->au8FontTable[toff+1];
			blank= font->au8FontTable[toff+2];
			data=&font->au8FontTable[toff+3];
			width=(width/height)-1;
		}else{
			data=pk_decode(&font->au8FontTable[toff],&width);
		}
	}else{
Beispiel #2
0
int DoChar(int sx, int sy, int c){

    if(font==NULL){
	font=&Font_7x8;
    };

	/* how many bytes is it high? */
    char height=(font->u8Height-1)/8+1;
    char hoff=(8-(font->u8Height%8))%8;


	const uint8_t * data;
    int width,preblank=0,postblank=0;
    do { /* Get Character data */
        /* Get intex into character list */
        c=_getIndex(c);

        /* starting offset into character source data */
        int toff=0;

        if(font->u8Width==0){
            if(efont.type == FONT_EXTERNAL){
                _getFontData(SEEK_WIDTH,0);
                for(int y=0;y<c;y++)
                    toff+=_getFontData(GET_WIDTH,0);
                width=_getFontData(GET_WIDTH,0);

                _getFontData(SEEK_DATA,toff);
                UINT res;
                UINT readbytes;
                UINT size = width * height;
                if(size > MAXCHR) size = MAXCHR;
                res = f_read(&file, charBuf, size, &readbytes);
                if(res != FR_OK || readbytes<width*height)
                    return sx;
                data=charBuf;
            }else{
                for(int y=0;y<c;y++)
                    toff+=font->charInfo[y].widthBits;
                width=font->charInfo[c].widthBits;

                toff*=height;
                data=&font->au8FontTable[toff];
            };
            postblank=1;
        }else if(font->u8Width==1){ // NEW CODE
            if(efont.type == FONT_EXTERNAL){
                _getFontData(SEEK_WIDTH,0);
                for(int y=0;y<c;y++)
                    toff+=_getFontData(GET_WIDTH,0);
                width=_getFontData(GET_WIDTH,0);
                _getFontData(SEEK_DATA,toff);
                UINT res;
                UINT readbytes;
                uint8_t testbyte;
                testbyte = read_byte ();
                if(testbyte>>4 ==15){
                    preblank = read_byte ();
                    postblank = read_byte ();
                    width-=3;
                    width/=height;
                    UINT size = width * height;
                    if(size > MAXCHR) size = MAXCHR;
                    res = f_read(&file, charBuf, size, &readbytes);
                    if(res != FR_OK || readbytes<width*height)
                        return sx;
                    data=charBuf;
                }else{
                    _getFontData(SEEK_DATA,toff);
                    data=pk_decode(NULL,&width); // Hackety-hack
                };
            }else{
                // Find offset and length for our character
                for(int y=0;y<c;y++)
                    toff+=font->charInfo[y].widthBits;
                width=font->charInfo[c].widthBits;
                if(font->au8FontTable[toff]>>4 == 15){ // It's a raw character!
                    preblank = font->au8FontTable[toff+1];
                    postblank= font->au8FontTable[toff+2];
                    data=&font->au8FontTable[toff+3];
                    width=(width-3/height);
                }else{
                    data=pk_decode(&font->au8FontTable[toff],&width);
                }
            };