Greg Haerr's new loadable font. No more #ifdef font-style, removed old

propfont and loadable font code. New font file format.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2269 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2002-09-12 13:33:59 +00:00
parent 5ed78ea80c
commit 93b231c693
29 changed files with 5528 additions and 1120 deletions

View File

@ -19,6 +19,7 @@
#include "credits.h"
#include "lcd.h"
#include "font.h"
#include "kernel.h"
#include "button.h"
#include "sprintf.h"
@ -64,6 +65,7 @@ char* credits[] = {
"Chad Lockwood",
"John Pybus",
"Randy Wood",
"Gregory Haerr",
};
#ifdef HAVE_LCD_BITMAP
@ -111,15 +113,15 @@ void roll_credits(void)
int height;
int width;
lcd_getfontsize(0, &width, &height);
lcd_getfontsize(FONT_UI, &width, &height);
while(1) {
lcd_clear_display();
for ( i=0; i <= (64-y)/height; i++ )
lcd_putsxy(0, i*height+y, line+i<numnames?credits[line+i]:"", 0);
lcd_putsxy(0, i*height+y, line+i<numnames?credits[line+i]:"", FONT_UI);
snprintf(buffer, sizeof(buffer), " [Credits] %2d/%2d ",
line+1, numnames);
lcd_putsxy(0, 0, buffer, 0);
lcd_putsxy(0, 0, buffer, FONT_UI);
lcd_update();
if (button_get_w_tmo(HZ/20))

View File

@ -45,9 +45,7 @@
#include "debug_menu.h"
#include "version.h"
#include "sprintf.h"
#ifdef LOADABLE_FONTS
#include "unicode.h"
#endif
#include "font.h"
char appsversion[]=APPSVERSION;
@ -65,10 +63,8 @@ void app_main(void)
void init(void)
{
init_threads();
#ifdef LOADABLE_FONTS
unicode_init();
#endif
lcd_init();
font_init();
show_logo();
settings_reset();
settings_load();
@ -93,6 +89,10 @@ void init(void)
lcd_init();
// FIXME should call font_init before this,
// because may use loadable font in show_logo().
// I didn't call font_init here, since
// disk system isn't up yet.
show_logo();
#ifdef DEBUG
@ -160,10 +160,7 @@ void init(void)
status_init();
usb_start_monitoring();
power_init();
#ifdef LOADABLE_FONTS
unicode_init();
lcd_init_fonts();
#endif
font_init();
}
int main(void)

View File

@ -23,6 +23,7 @@
#include "tree.h"
#include "credits.h"
#include "lcd.h"
#include "font.h"
#include "button.h"
#include "kernel.h"
#include "main_menu.h"
@ -96,9 +97,9 @@ int show_logo( void )
#endif
snprintf(version, sizeof(version), "Ver. %s", appsversion);
lcd_getfontsize(0, &font_w, &font_h);
lcd_getfontsize(FONT_SYSFIXED, &font_w, &font_h);
lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2),
height+10+font_h, version, 0);
LCD_HEIGHT-font_h, version, FONT_SYSFIXED);
lcd_update();
#else

View File

@ -19,6 +19,7 @@
#include <stdbool.h>
#include "lcd.h"
#include "font.h"
#include "backlight.h"
#include "menu.h"
#include "button.h"
@ -34,10 +35,6 @@
#include "widgets.h"
#endif
#ifdef LOADABLE_FONTS
#include "ajf.h"
#endif
struct menu {
int top;
int cursor;
@ -54,8 +51,10 @@ struct menu {
#define LINE_X 0 /* X position the entry-list starts at */
#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */
#define LINE_HEIGTH 8 /* pixels for each text line */
//FIXME remove
#define LINE_HEIGTH 8 /* pixels for each text line */
//FIXME remove
#define MENU_LINES (LCD_HEIGHT / LINE_HEIGTH - LINE_Y)
#define CURSOR_X (global_settings.scrollbar ? 1 : 0)
@ -89,17 +88,12 @@ struct menu {
static struct menu menus[MAX_MENUS];
static bool inuse[MAX_MENUS] = { false };
/* count in letter posistions, NOT pixels */
/* count in letter positions, NOT pixels */
void put_cursorxy(int x, int y, bool on)
{
#ifdef HAVE_LCD_BITMAP
#ifdef LOADABLE_FONTS
int fh;
unsigned char* font = lcd_getcurrentldfont();
fh = ajf_get_fontheight(font);
#else
int fh = 8;
#endif
int fh, fw;
lcd_getfontsize(FONT_UI, &fw, &fh);
#endif
/* place the cursor */
@ -131,11 +125,10 @@ void put_cursorxy(int x, int y, bool on)
static void menu_draw(int m)
{
int i = 0;
#ifdef LOADABLE_FONTS
#if LCD_PROPFONTS
int fw, fh;
int menu_lines;
int fh;
unsigned char* font = lcd_getcurrentldfont();
fh = ajf_get_fontheight(font);
lcd_getfontsize(FONT_UI, &fw, &fh);
if (global_settings.statusbar)
menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh;
else
@ -148,7 +141,7 @@ static void menu_draw(int m)
lcd_clear_display(); /* ...then clean the screen */
#ifdef HAVE_LCD_BITMAP
lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and icon */
lcd_setfont(0);
lcd_setfont(FONT_UI);
#endif
/* correct cursor pos if out of screen */
if (menus[m].cursor - menus[m].top >= menu_lines)
@ -182,18 +175,18 @@ static void menu_draw(int m)
static void put_cursor(int m, int target)
{
bool do_update = true;
#ifdef LOADABLE_FONTS
#if LCD_PROPFONTS
int fw, fh;
int menu_lines;
int fh;
unsigned char* font = lcd_getcurrentldfont();
fh = ajf_get_fontheight(font);
lcd_getfontsize(FONT_UI, &fw, &fh);
if (global_settings.statusbar)
menu_lines = (LCD_HEIGHT-STATUSBAR_HEIGHT)/fh;
menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh;
else
menu_lines = LCD_HEIGHT/fh;
#else
int menu_lines = MENU_LINES;
#endif
put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, false);
menus[m].cursor = target;
menu_draw(m);

View File

@ -136,7 +136,6 @@ static void loopit(void)
lcd_bitmap((char *)char_gen_12x16[rock[i]-0x20],
xtable[xx%71], table[yy&63],
11, 16, false);
lcd_update();
ysanke+= values[NUM_YSANKE].num;

View File

@ -16,8 +16,9 @@
* KIND, either express or implied.
*
****************************************************************************/
#include <lcd.h>
#include <string.h>
#include "lcd.h"
#include "font.h"
#include "kernel.h"
#include "sprintf.h"
#include "rtc.h"
@ -233,15 +234,7 @@ void statusbar_icon_volume(int percent)
/* display volume lever numerical? */
if (TIME_BEFORE(current_tick,switch_tick)) {
snprintf(buffer, sizeof(buffer), "%2d", percent);
#if defined(LCD_PROPFONTS)
lcd_getstringsize(buffer, 0, &width, &height);
#elif defined(LOADABLE_FONTS)
font = lcd_getcurrentldfont();
lcd_getstringsize(buffer, font, &width, &height);
#else
width = 6*strlen(buffer);
height = 8;
#endif
lcd_getstringsize(buffer, FONT_UI, &width, &height);
if (height <= STATUSBAR_HEIGHT)
lcd_putsxy(ICON_VOLUME_X_POS + ICON_VOLUME_WIDTH / 2 -
width/2, STATUSBAR_Y_POS, buffer, 0);
@ -316,15 +309,7 @@ void statusbar_time(int hour, int minute)
strncpy(buffer, "--:--", sizeof buffer);
}
#if defined(LCD_PROPFONTS)
lcd_getstringsize(buffer, 0, &width, &height);
#elif defined(LOADABLE_FONTS)
font = lcd_getcurrentldfont();
lcd_getstringsize(buffer, font, &width, &height);
#else
width = 6*strlen(buffer);
height = 8;
#endif
lcd_getstringsize(buffer, FONT_UI, &width, &height);
if (height <= STATUSBAR_HEIGHT)
lcd_putsxy(TIME_X_END - width, STATUSBAR_Y_POS, buffer, 0);
}

View File

@ -67,11 +67,7 @@
/* size of the field the worm lives in */
#define FIELD_RECT_X 1
#define FIELD_RECT_Y 1
#ifdef LCD_PROPFONTS
#define FIELD_RECT_WIDTH (LCD_WIDTH - 39)
#else
#define FIELD_RECT_WIDTH (LCD_WIDTH - 46)
#endif
#define FIELD_RECT_HEIGHT (LCD_HEIGHT - 2)
/* size of the ring of the worm

View File

@ -40,6 +40,7 @@
#include "atoi.h"
#ifdef HAVE_LCD_BITMAP
#include "icons.h"
#include "font.h"
#endif
struct user_settings global_settings;
@ -772,15 +773,10 @@ void set_time(char* string, int timedate[])
int realyear;
int julianday;
int i;
#if defined(LOADABLE_FONTS) || defined(LCD_PROPFONTS)
unsigned char reffub[5];
unsigned int width, height;
unsigned int separator_width, weekday_width;
unsigned int line_height, prev_line_height;
#if defined(LOADABLE_FONTS)
unsigned char *font = lcd_getcurrentldfont();
#endif
#endif
#ifdef HAVE_LCD_BITMAP
if(global_settings.statusbar)
@ -817,65 +813,35 @@ void set_time(char* string, int timedate[])
timedate[1],
timedate[2]);
lcd_puts(0, 1, buffer);
#if defined(LCD_PROPFONTS)
/* recalculate the positions and offsets */
lcd_getstringsize(string, 0, &width, &prev_line_height);
lcd_getstringsize(buffer, 0, &width, &line_height);
lcd_getstringsize(":", 0, &separator_width, &height);
lcd_getstringsize(string, FONT_UI, &width, &prev_line_height);
lcd_getstringsize(buffer, FONT_UI, &width, &line_height);
lcd_getstringsize(":", FONT_UI, &separator_width, &height);
strncpy(reffub, buffer, 2);
reffub[2] = '\0';
lcd_getstringsize(reffub, 0, &width, &height);
lcd_getstringsize(reffub, FONT_UI, &width, &height);
cursor[0][INDEX_X] = 0;
cursor[0][INDEX_Y] = 1 + prev_line_height + 1;
cursor[0][INDEX_WIDTH] = width;
strncpy(reffub, buffer + 3, 2);
reffub[2] = '\0';
lcd_getstringsize(reffub, 0, &width, &height);
lcd_getstringsize(reffub, FONT_UI, &width, &height);
cursor[1][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width;
cursor[1][INDEX_Y] = 1 + prev_line_height + 1;
cursor[1][INDEX_WIDTH] = width;
strncpy(reffub, buffer + 6, 2);
reffub[2] = '\0';
lcd_getstringsize(reffub, 0, &width, &height);
lcd_getstringsize(reffub, FONT_UI, &width, &height);
cursor[2][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width +
cursor[1][INDEX_WIDTH] + separator_width;
cursor[2][INDEX_Y] = 1 + prev_line_height + 1;
cursor[2][INDEX_WIDTH] = width;
lcd_getstringsize(buffer, 0, &width, &prev_line_height);
#elif defined(LOADABLE_FONTS)
/* recalculate the positions and offsets */
lcd_getstringsize(string, font, &width, &prev_line_height);
lcd_getstringsize(buffer, font, &width, &line_height);
lcd_getstringsize(":", font, &separator_width, &height);
strncpy(reffub, buffer, 2);
reffub[2] = '\0';
lcd_getstringsize(reffub, font, &width, &height);
cursor[0][INDEX_X] = 0;
cursor[0][INDEX_Y] = prev_line_height;
cursor[0][INDEX_WIDTH] = width;
strncpy(reffub, buffer + 3, 2);
reffub[2] = '\0';
lcd_getstringsize(reffub, font, &width, &height);
cursor[1][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width;
cursor[1][INDEX_Y] = prev_line_height;
cursor[1][INDEX_WIDTH] = width;
strncpy(reffub, buffer + 6, 2);
reffub[2] = '\0';
lcd_getstringsize(reffub, font, &width, &height);
cursor[2][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width +
cursor[1][INDEX_WIDTH] + separator_width;
cursor[2][INDEX_Y] = prev_line_height;
cursor[2][INDEX_WIDTH] = width;
lcd_getstringsize(buffer, font, &width, &prev_line_height);
#endif
lcd_getstringsize(buffer, FONT_UI, &width, &prev_line_height);
snprintf(buffer, sizeof(buffer), "%s 20%02d %s %02d ",
dayname[timedate[6]],
@ -883,24 +849,24 @@ void set_time(char* string, int timedate[])
monthname[timedate[4] - 1],
timedate[5]);
lcd_puts(0, 2, buffer);
#if defined(LCD_PROPFONTS)
/* recalculate the positions and offsets */
lcd_getstringsize(buffer, 0, &width, &line_height);
lcd_getstringsize(buffer, FONT_UI, &width, &line_height);
strncpy(reffub, buffer, 3);
reffub[3] = '\0';
lcd_getstringsize(reffub, 0, &weekday_width, &height);
lcd_getstringsize(" ", 0, &separator_width, &height);
lcd_getstringsize(reffub, FONT_UI, &weekday_width, &height);
lcd_getstringsize(" ", FONT_UI, &separator_width, &height);
strncpy(reffub, buffer + 4, 4);
reffub[4] = '\0';
lcd_getstringsize(reffub, 0, &width, &height);
lcd_getstringsize(reffub, FONT_UI, &width, &height);
cursor[3][INDEX_X] = weekday_width + separator_width;
cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height + 1;
cursor[3][INDEX_WIDTH] = width;
strncpy(reffub, buffer + 9, 3);
reffub[3] = '\0';
lcd_getstringsize(reffub, 0, &width, &height);
lcd_getstringsize(reffub, FONT_UI, &width, &height);
cursor[4][INDEX_X] = weekday_width + separator_width +
cursor[3][INDEX_WIDTH] + separator_width;
cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height + 1;
@ -908,7 +874,7 @@ void set_time(char* string, int timedate[])
strncpy(reffub, buffer + 13, 2);
reffub[2] = '\0';
lcd_getstringsize(reffub, 0, &width, &height);
lcd_getstringsize(reffub, FONT_UI, &width, &height);
cursor[5][INDEX_X] = weekday_width + separator_width +
cursor[3][INDEX_WIDTH] + separator_width +
cursor[4][INDEX_WIDTH] + separator_width;
@ -919,48 +885,7 @@ void set_time(char* string, int timedate[])
cursor[cursorpos][INDEX_Y] + lcd_getymargin(),
cursor[cursorpos][INDEX_WIDTH],
line_height);
#elif defined(LOADABLE_FONTS)
/* recalculate the positions and offsets */
lcd_getstringsize(buffer, font, &width, &line_height);
strncpy(reffub, buffer, 3);
reffub[3] = '\0';
lcd_getstringsize(reffub, font, &weekday_width, &height);
lcd_getstringsize(" ", font, &separator_width, &height);
strncpy(reffub, buffer + 4, 4);
reffub[4] = '\0';
lcd_getstringsize(reffub, font, &width, &height);
cursor[3][INDEX_X] = weekday_width + separator_width;
cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
cursor[3][INDEX_WIDTH] = width;
strncpy(reffub, buffer + 9, 3);
reffub[3] = '\0';
lcd_getstringsize(reffub, font, &width, &height);
cursor[4][INDEX_X] = weekday_width + separator_width +
cursor[3][INDEX_WIDTH] + separator_width;
cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
cursor[4][INDEX_WIDTH] = width;
strncpy(reffub, buffer + 13, 2);
reffub[2] = '\0';
lcd_getstringsize(reffub, font, &width, &height);
cursor[5][INDEX_X] = weekday_width + separator_width +
cursor[3][INDEX_WIDTH] + separator_width +
cursor[4][INDEX_WIDTH] + separator_width;
cursor[5][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
cursor[5][INDEX_WIDTH] = width;
lcd_invertrect(cursor[cursorpos][INDEX_X],
cursor[cursorpos][INDEX_Y] + lcd_getymargin(),
cursor[cursorpos][INDEX_WIDTH],
line_height);
#else
lcd_invertrect(cursor[cursorpos][INDEX_X],
cursor[cursorpos][INDEX_Y] + lcd_getymargin(),
cursor[cursorpos][INDEX_WIDTH],
8);
#endif
lcd_puts(0, 4, "ON to set");
lcd_puts(0, 5, "OFF to revert");
#ifdef HAVE_LCD_BITMAP

View File

@ -26,6 +26,7 @@
#include "dir.h"
#include "file.h"
#include "lcd.h"
#include "font.h"
#include "backlight.h"
#include "button.h"
#include "kernel.h"
@ -49,10 +50,6 @@
#include "widgets.h"
#endif
#ifdef LOADABLE_FONTS
#include "ajf.h"
#endif
#define NAME_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH * MAX_FILES_IN_DIR)
char name_buffer[NAME_BUFFER_SIZE];
@ -190,17 +187,16 @@ static int showdir(char *path, int start)
int i;
int tree_max_on_screen;
bool dir_buffer_full;
#ifdef LOADABLE_FONTS
int fh;
unsigned char *font = lcd_getcurrentldfont();
fh = ajf_get_fontheight(font);
#ifdef HAVE_LCD_BITMAP
int fw, fh;
lcd_getfontsize(FONT_UI, &fw, &fh);
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
line_height = fh;
#else
tree_max_on_screen = TREE_MAX_ON_SCREEN;
#endif
/* new dir? cache it */
if (strncmp(path,lastdir,sizeof(lastdir))) {
DIR *dir = opendir(path);
@ -339,7 +335,7 @@ static int showdir(char *path, int start)
lcd_clear_display();
#ifdef HAVE_LCD_BITMAP
lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and icon */
lcd_setfont(0);
lcd_setfont(FONT_UI);
#endif
for ( i=start; i < start+tree_max_on_screen; i++ ) {
@ -573,10 +569,9 @@ bool dirbrowse(char *root)
bool lastfilter = global_settings.mp3filter;
bool lastsortcase = global_settings.sort_case;
bool lastshowhidden = global_settings.show_hidden_files;
#ifdef LOADABLE_FONTS
int fh;
unsigned char *font = lcd_getcurrentldfont();
fh = ajf_get_fontheight(font);
#ifdef HAVE_LCD_BITMAP
int fw, fh;
lcd_getfontsize(FONT_UI, &fw, &fh);
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#else
tree_max_on_screen = TREE_MAX_ON_SCREEN;
@ -743,10 +738,8 @@ bool dirbrowse(char *root)
reload_root = true;
global_settings.resume_index = -1;
}
#ifdef LOADABLE_FONTS
#ifdef HAVE_LCD_BITMAP
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#else
tree_max_on_screen = TREE_MAX_ON_SCREEN;
#endif
}
}
@ -836,10 +829,8 @@ bool dirbrowse(char *root)
lcd_stop_scroll();
if (wps_show() == SYS_USB_CONNECTED)
reload_root = true;
#ifdef LOADABLE_FONTS
#ifdef HAVE_LCD_BITMAP
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#else
tree_max_on_screen = TREE_MAX_ON_SCREEN;
#endif
restore = true;
}
@ -855,10 +846,9 @@ bool dirbrowse(char *root)
case BUTTON_F3:
if (f3_screen())
reload_root = true;
#ifdef LOADABLE_FONTS
#ifdef HAVE_LCD_BITMAP
tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
#else
tree_max_on_screen = TREE_MAX_ON_SCREEN;
#endif
restore = true;
break;

View File

@ -27,6 +27,7 @@
#include <stdlib.h>
#include "lcd.h"
#include "font.h"
#include "mpeg.h"
#include "id3.h"
#include "settings.h"
@ -42,10 +43,6 @@
#include "widgets.h"
#endif
#ifdef LOADABLE_FONTS
#include "ajf.h"
#endif
#define WPS_CONFIG ROCKBOX_DIR "/default.wps"
#ifdef HAVE_LCD_BITMAP
@ -551,11 +548,7 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all)
#else
int w,h;
int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
#ifdef LCD_PROPFONTS
lcd_getstringsize("M",0,&w,&h);
#else
lcd_getfontsize(0,&w,&h);
#endif
lcd_getstringsize("M",FONT_UI,&w,&h);
slidebar(0, i*h + offset + 1, LCD_WIDTH, 6,
(id3->elapsed + ff_rewind_count) * 100 / id3->length,
Grow_Right);
@ -581,15 +574,6 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all)
void wps_display(struct mp3entry* id3)
{
int font_height;
#ifdef LOADABLE_FONTS
unsigned char *font = lcd_getcurrentldfont();
font_height = ajf_get_fontheight(font);
#else
font_height = 8;
#endif
lcd_clear_display();
if (!id3 && !mpeg_is_playing())

View File

@ -22,6 +22,7 @@
#include "file.h"
#include "lcd.h"
#include "font.h"
#include "backlight.h"
#include "button.h"
#include "kernel.h"
@ -40,10 +41,6 @@
#include "icons.h"
#endif
#ifdef LOADABLE_FONTS
#include "ajf.h"
#endif
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
/* 3% of 30min file == 54s step size */
@ -634,21 +631,17 @@ bool f2_screen(void)
char buf[32];
/* Get the font height */
#ifdef LCD_PROPFONTS
lcd_getstringsize("A",0,&w,&h);
#else
lcd_getfontsize(0,&w,&h);
#endif
lcd_getstringsize("A",FONT_UI,&w,&h);
lcd_stop_scroll();
while (!exit) {
lcd_clear_display();
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, "Shuffle", 0);
lcd_putsxy(0, LCD_HEIGHT/2 - h, "mode:", 0);
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, "Shuffle", FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2 - h, "mode:", FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2,
global_settings.playlist_shuffle ? "on" : "off", 0);
global_settings.playlist_shuffle ? "on" : "off", FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
@ -656,13 +649,8 @@ bool f2_screen(void)
global_settings.mp3filter ? "on" : "off");
/* Get the string width and height */
#ifdef LCD_PROPFONTS
lcd_getstringsize(buf,0,&w,&h);
#else
lcd_getfontsize(0,&w,&h);
w *= strlen(buf);
#endif
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf, 0);
lcd_getstringsize(buf,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
@ -717,26 +705,20 @@ bool f3_screen(void)
char* ptr;
ptr = "Status";
#ifdef LCD_PROPFONTS
lcd_getstringsize(ptr,0,&w,&h);
#else
lcd_getfontsize(0,&w,&h);
w *= strlen(ptr);
#endif
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_clear_display();
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, "Scroll", 0);
lcd_putsxy(0, LCD_HEIGHT/2 - h, "bar:", 0);
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, "Scroll", FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2 - h, "bar:", FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2,
global_settings.scrollbar ? "on" : "off", 0);
global_settings.scrollbar ? "on" : "off", FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr, 0);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, "bar:", 0);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr, FONT_UI);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, "bar:", FONT_UI);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2,
global_settings.statusbar ? "on" : "off", 0 );
global_settings.statusbar ? "on" : "off", FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
lcd_update();

View File

@ -1,4 +1,4 @@
Description of the binary AJF font file format
Description of the binary AJF font file format (version 2)
Index Descripton
@ -9,14 +9,27 @@ Index Descripton
23 - 24 "bound width" (high 8 bits, low 8 bits)
25 - 26 "bound height" (high 8 bits, low 8 bits)
26 - 28 first character in the font
29 - 2a 0x00ff (supposed number of characters in the font?)
2b - map offset table starts here. Each offset entry is supposed to be
three bytes: width, offset highbyte, offset lowbyte
The offset is a relative offset, counted in bytes, to where in the
font data this particular char's bitmap image starts.
29 - 2a number of characters in the font (alwasys 0x00ff now)
2b - map offset table starts here. Each offset entry is two bytes:
offset highbyte, offset lowbyte
font data, in Rockbox-internal image-format. That means column-wise
The offset is number of bytes from the start of this file, to where
in the font data this particular char's font data starts.
There is one offset entry for each character in this font, starting
with 'first character' (set above) and ending when all the 'number
of characters' have been stored.
?? - Font data. First four bytes width, height, dispx and dispy and then
the glyph in Rockbox-internal image-format. That means column-wise
left-to-right for the full width, the first 8 pixels of height. Then
follows the next 8 pixels of height left-to-right.
We don't currently support fonts larger than 16 pixels.
We don't currently support fonts larger than 16 pixels. (This font
file format would have no problem with bigger sizes, but the internal
bitmap function has.)
References
The BDF file format
http://partners.adobe.com/asn/developer/pdfs/tn/5005.BDF_Spec.pdf

1967
firmware/X5x8.bdf Normal file

File diff suppressed because it is too large Load Diff

2853
firmware/X5x8.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,100 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Alex Gitelman
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifdef SIMULATOR
#include <fcntl.h>
#endif
#include <file.h>
#include "ajf.h"
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include "debug.h"
static unsigned char font_buf[MAX_FONT_BUFLEN];
unsigned char* ajf_read_font(char* fname)
{
int count;
#ifdef WIN32
int fd = open(fname, O_RDONLY|O_BINARY);
#else
int fd = open(fname, O_RDONLY);
#endif
if (fd<0)
{
#ifdef SIMULATOR
#ifdef WIN32
DEBUGF("Failed opening font file: %d %s. ", _errno(), fname);
#else
DEBUGF("Failed opening font file: %d %s. ", errno, fname);
#endif
#endif
return NULL;
}
count = read(fd, font_buf, MAX_FONT_BUFLEN);
if (count==MAX_FONT_BUFLEN) {
DEBUGF("Font is larger than allocated %d bytes!\n",MAX_FONT_BUFLEN);
return NULL;
}
close(fd);
if (font_buf[0]!=MAGIC1 || font_buf[1]!=MAGIC2) {
DEBUGF("Bad magic word in font");
return NULL;
}
return font_buf;
}
unsigned char* ajf_get_charbuf(unsigned char c, unsigned char* font,
int *w, int *h)
{
int height = READ_SHORT(&font[HEIGHT_OFFSET]);
int size = READ_SHORT(&font[SIZE_OFFSET]);
int chars_offset = LOOKUP_MAP_OFFSET + size*3;
int rows = (height-1)/8 + 1;
int first_char = READ_SHORT(&font[FIRST_CHAR_OFFSET]);
int map_idx = LOOKUP_MAP_OFFSET + (c-first_char)*3;
int byte_count = font[map_idx];
int char_idx;
*h = height;
*w = byte_count/rows;
map_idx++;
char_idx = READ_SHORT(&font[map_idx]);
return &font[chars_offset + char_idx];
}
void ajf_get_charsize(unsigned char c, unsigned char* font,
int *width, int *height)
{
int first_char = READ_SHORT(&font[FIRST_CHAR_OFFSET]);
int map_idx = LOOKUP_MAP_OFFSET + (c-first_char)*3;
int rows = 1;
*height = READ_SHORT(&font[HEIGHT_OFFSET]);
rows = (*height-1)/8 + 1;
*width = font[map_idx]/rows;
}
int ajf_get_fontheight(unsigned char* font)
{
return READ_SHORT(&font[HEIGHT_OFFSET]);
}

View File

@ -1,52 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Alex Gitelman
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef __AJF__
#define __AJF__
/* defined here because they are used by tools/bdf2ajz */
#define MAGIC1 0xBD
#define MAGIC2 0xFC
#define MAX_FONT_BUFLEN 4096
#define CODE_PAGE_OFFSET 2 /* 1 byte TODO: unused now */
#define FONT_NAME_OFFSET 3
#define FONT_NAME_LEN 32
#define MAX_WIDTH_OFFSET (FONT_NAME_OFFSET + FONT_NAME_LEN) /* 2 byte */
#define HEIGHT_OFFSET (MAX_WIDTH_OFFSET + 2) /* 2 byte */
#define ASCENT_OFFSET (HEIGHT_OFFSET+2) /* 2 byte ascent (baseline) height*/
#define FIRST_CHAR_OFFSET (HEIGHT_OFFSET+2) /* 2 bytes first character of font*/
#define SIZE_OFFSET (FIRST_CHAR_OFFSET+2) /* 2 bytes size of font (# encodings)*/
#define LOOKUP_MAP_OFFSET SIZE_OFFSET+2 /* Map to lookup char positions */
#define WRITE_SHORT(s,buf) { (buf)[0] = (s & 0xff00) >> 8 ; \
(buf)[1] = s & 0x00ff; }
#define READ_SHORT(buf) (((buf)[0]<<8) + (buf)[1])
unsigned char* ajf_read_font(char* fname);
unsigned char* ajf_get_charbuf(unsigned char c, unsigned char* font,
int *width, int *height);
void ajf_get_charsize(unsigned char c, unsigned char* font,
int *width, int *height);
int ajf_get_fontheight(unsigned char* font);
extern char _font_error_msg[];
#endif

View File

@ -4,8 +4,7 @@
#include "config.h"
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
#if 0
const unsigned char char_gen_6x8[][5] =
{
{ 0x00,0x00,0x00,0x00,0x00 },
@ -205,7 +204,9 @@ const unsigned char char_gen_8x12[][14] =
{ 0x04,0x00,0x06,0x00,0x02,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x02,0x00 },
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }
};
#endif
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
const unsigned char char_gen_12x16[][22] =
{
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
@ -305,246 +306,5 @@ const unsigned char char_gen_12x16[][22] =
{ 0x10,0x00,0x18,0x00,0x0c,0x00,0x04,0x00,0x0c,0x00,0x18,0x00,0x10,0x00,0x18,0x00,0x0c,0x00,0x04,0x00,0x00,0x00 },
{ 0xff,0x3f,0xff,0x3f,0xff,0x3f,0xff,0x3f,0xff,0x3f,0xff,0x3f,0xff,0x3f,0xff,0x3f,0xff,0x3f,0xff,0x3f,0x00,0x00 }
};
#ifdef LCD_PROPFONTS
unsigned char char_dw_8x8_prop[][9] = {
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x37 } /* */,
{ 0xbe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x17 } /* ! */,
{ 0xe,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x37 } /* " */,
{ 0x28,0x7c,0x28,0x7c,0x28,0x0,0x0,0x0,0x56 } /* # */,
{ 0x48,0x54,0xfe,0x54,0x24,0x0,0x0,0x0,0x57 } /* $ */,
{ 0x88,0x40,0x20,0x10,0x88,0x0,0x0,0x0,0x55 } /* % */,
{ 0x6c,0x92,0x92,0xaa,0x44,0xa0,0x0,0x0,0x67 } /* & */,
{ 0xe,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x17 } /* ' */,
{ 0x7c,0x82,0x0,0x0,0x0,0x0,0x0,0x0,0x27 } /* ( */,
{ 0x82,0x7c,0x0,0x0,0x0,0x0,0x0,0x0,0x27 } /* ) */,
{ 0x54,0x38,0x7c,0x38,0x54,0x0,0x0,0x0,0x56 } /* * */,
{ 0x10,0x10,0x7c,0x10,0x10,0x0,0x0,0x0,0x56 } /* + */,
{ 0x80,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x22 } /* , */,
{ 0x10,0x10,0x10,0x10,0x10,0x0,0x0,0x0,0x45 } /* - */,
{ 0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11 } /* . */,
{ 0x80,0x40,0x20,0x10,0x8,0x4,0x2,0x0,0x77 } /* / */,
{ 0x7c,0x82,0x82,0x7c,0x0,0x0,0x0,0x0,0x47 } /* 0 */,
{ 0x84,0xfe,0x80,0x0,0x0,0x0,0x0,0x0,0x37 } /* 1 */,
{ 0xe4,0x92,0x92,0x8c,0x0,0x0,0x0,0x0,0x47 } /* 2 */,
{ 0x44,0x92,0x92,0x6c,0x0,0x0,0x0,0x0,0x47 } /* 3 */,
{ 0x1e,0x10,0x10,0xfe,0x0,0x0,0x0,0x0,0x47 } /* 4 */,
{ 0x4e,0x92,0x92,0x62,0x0,0x0,0x0,0x0,0x47 } /* 5 */,
{ 0x7c,0x92,0x92,0x60,0x0,0x0,0x0,0x0,0x47 } /* 6 */,
{ 0x2,0x12,0x12,0xfe,0x0,0x0,0x0,0x0,0x47 } /* 7 */,
{ 0x6c,0x92,0x92,0x6c,0x0,0x0,0x0,0x0,0x47 } /* 8 */,
{ 0xc,0x92,0x92,0x7c,0x0,0x0,0x0,0x0,0x47 } /* 9 */,
{ 0x44,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x16 } /* : */,
{ 0x80,0x44,0x0,0x0,0x0,0x0,0x0,0x0,0x26 } /* ; */,
{ 0x10,0x28,0x44,0x0,0x0,0x0,0x0,0x0,0x36 } /* < */,
{ 0x28,0x28,0x28,0x28,0x28,0x0,0x0,0x0,0x55 } /* = */,
{ 0x44,0x28,0x10,0x0,0x0,0x0,0x0,0x0,0x36 } /* > */,
{ 0xb2,0x12,0x12,0xc,0x0,0x0,0x0,0x0,0x47 } /* ? */,
{ 0x60,0x94,0x94,0x94,0xa4,0x48,0x30,0x0,0x76 } /* @ */,
{ 0xfc,0x22,0x22,0xfc,0x0,0x0,0x0,0x0,0x47 } /* A */,
{ 0xfe,0x92,0x92,0x6c,0x0,0x0,0x0,0x0,0x47 } /* B */,
{ 0x7c,0x82,0x82,0x44,0x0,0x0,0x0,0x0,0x47 } /* C */,
{ 0xfe,0x82,0x82,0x7c,0x0,0x0,0x0,0x0,0x47 } /* D */,
{ 0xfe,0x92,0x92,0x82,0x0,0x0,0x0,0x0,0x47 } /* E */,
{ 0xfe,0x12,0x12,0x2,0x0,0x0,0x0,0x0,0x47 } /* F */,
{ 0x7c,0x82,0x92,0xf2,0x0,0x0,0x0,0x0,0x47 } /* G */,
{ 0xfe,0x10,0x10,0xfe,0x0,0x0,0x0,0x0,0x47 } /* H */,
{ 0x82,0xfe,0x82,0x0,0x0,0x0,0x0,0x0,0x37 } /* I */,
{ 0x42,0x82,0x82,0x7e,0x0,0x0,0x0,0x0,0x47 } /* J */,
{ 0xfe,0x10,0x28,0xc6,0x0,0x0,0x0,0x0,0x47 } /* K */,
{ 0xfe,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x47 } /* L */,
{ 0xfe,0x4,0x18,0x4,0xfe,0x0,0x0,0x0,0x57 } /* M */,
{ 0xfe,0x2,0x2,0xfc,0x0,0x0,0x0,0x0,0x47 } /* N */,
{ 0x7c,0x82,0x82,0x7c,0x0,0x0,0x0,0x0,0x47 } /* O */,
{ 0xfe,0x12,0x12,0xc,0x0,0x0,0x0,0x0,0x47 } /* P */,
{ 0x7c,0x82,0xa2,0x7c,0x40,0x80,0x0,0x0,0x67 } /* Q */,
{ 0xfe,0x12,0x12,0xec,0x0,0x0,0x0,0x0,0x47 } /* R */,
{ 0x8c,0x92,0x92,0x62,0x0,0x0,0x0,0x0,0x47 } /* S */,
{ 0x2,0x2,0xfe,0x2,0x2,0x0,0x0,0x0,0x57 } /* T */,
{ 0x7e,0x80,0x80,0x7e,0x0,0x0,0x0,0x0,0x47 } /* U */,
{ 0x3e,0x40,0x80,0x40,0x3e,0x0,0x0,0x0,0x57 } /* V */,
{ 0xfe,0x40,0x30,0x40,0xfe,0x0,0x0,0x0,0x57 } /* W */,
{ 0xc6,0x28,0x10,0x28,0xc6,0x0,0x0,0x0,0x57 } /* X */,
{ 0xe,0x10,0xe0,0x10,0xe,0x0,0x0,0x0,0x57 } /* Y */,
{ 0xe2,0x92,0x92,0x8e,0x0,0x0,0x0,0x0,0x47 } /* Z */,
{ 0xfe,0x82,0x0,0x0,0x0,0x0,0x0,0x0,0x27 } /* [ */,
{ 0x2,0x4,0x8,0x10,0x20,0x40,0x80,0x0,0x77 } /* \ */,
{ 0x82,0xfe,0x0,0x0,0x0,0x0,0x0,0x0,0x27 } /* ] */,
{ 0x8,0x4,0x2,0x4,0x8,0x0,0x0,0x0,0x57 } /* ^ */,
{ 0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x15 } /* _ */,
{ 0x6,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x27 } /* ` */,
{ 0x40,0xa8,0xa8,0xa8,0xf0,0x0,0x0,0x0,0x55 } /* a */,
{ 0xfe,0x90,0x90,0x60,0x0,0x0,0x0,0x0,0x47 } /* b */,
{ 0x70,0x88,0x88,0x88,0x0,0x0,0x0,0x0,0x45 } /* c */,
{ 0x60,0x90,0x90,0xfe,0x0,0x0,0x0,0x0,0x47 } /* d */,
{ 0x70,0xa8,0xa8,0xa8,0x10,0x0,0x0,0x0,0x55 } /* e */,
{ 0x10,0xfc,0x12,0x2,0x0,0x0,0x0,0x0,0x47 } /* f */,
{ 0x10,0xa8,0xa8,0xa8,0x78,0x0,0x0,0x0,0x55 } /* g */,
{ 0xfe,0x10,0x10,0xe0,0x0,0x0,0x0,0x0,0x47 } /* h */,
{ 0x88,0xfa,0x80,0x0,0x0,0x0,0x0,0x0,0x37 } /* i */,
{ 0x40,0x80,0x88,0x7a,0x0,0x0,0x0,0x0,0x47 } /* j */,
{ 0xfe,0x20,0x50,0x88,0x0,0x0,0x0,0x0,0x47 } /* k */,
{ 0x82,0xfe,0x80,0x0,0x0,0x0,0x0,0x0,0x37 } /* l */,
{ 0xf8,0x8,0x70,0x8,0xf8,0x0,0x0,0x0,0x55 } /* m */,
{ 0xf8,0x8,0x8,0xf0,0x0,0x0,0x0,0x0,0x45 } /* n */,
{ 0x70,0x88,0x88,0x70,0x0,0x0,0x0,0x0,0x45 } /* o */,
{ 0xf8,0x28,0x28,0x10,0x0,0x0,0x0,0x0,0x45 } /* p */,
{ 0x10,0x28,0x28,0xf8,0x0,0x0,0x0,0x0,0x45 } /* q */,
{ 0xf8,0x10,0x8,0x8,0x0,0x0,0x0,0x0,0x45 } /* r */,
{ 0x90,0xa8,0xa8,0x48,0x0,0x0,0x0,0x0,0x45 } /* s */,
{ 0x8,0xfe,0x8,0x0,0x0,0x0,0x0,0x0,0x37 } /* t */,
{ 0x78,0x80,0x80,0x78,0x0,0x0,0x0,0x0,0x45 } /* u */,
{ 0x38,0x40,0x80,0x40,0x38,0x0,0x0,0x0,0x55 } /* v */,
{ 0xf8,0x80,0x60,0x80,0xf8,0x0,0x0,0x0,0x55 } /* w */,
{ 0xd8,0x20,0xd8,0x0,0x0,0x0,0x0,0x0,0x35 } /* x */,
{ 0x18,0xa0,0xa0,0x78,0x0,0x0,0x0,0x0,0x45 } /* y */,
{ 0xc8,0xa8,0x98,0x0,0x0,0x0,0x0,0x0,0x35 } /* z 0x7a */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x7b */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x7c */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x7d */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x7e */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x7f */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x80 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x81 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x82 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x83 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x85 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x86 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x87 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x88 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x89 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x8a */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x8b */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x8c */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x8d */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x8e */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x8f */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x90 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x91 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x92 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x93 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x95 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x96 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x97 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x98 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x99 */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x9a */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x9b */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x9c */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x9d */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x9e */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0x9f */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x37 } /* */,
{ 0xfa,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x17 } /* ¡ */,
{ 0x38,0x44,0xfe,0x44,0x28,0x0,0x0,0x0,0x57 } /* ¢ */,
{ 0x90,0x7c,0x92,0x82,0x82,0x44,0x0,0x0,0x67 } /* £ */,
{ 0x44,0x38,0x28,0x38,0x44,0x0,0x0,0x0,0x55 } /* ¤ */,
{ 0x2a,0x2c,0xf8,0x2c,0x2a,0x0,0x0,0x0,0x57 } /* ¥ */,
{ 0xee,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x17 } /* ¦ */,
{ 0x94,0xaa,0xaa,0x52,0x0,0x0,0x0,0x0,0x47 } /* § */,
{ 0x2,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x47 } /* ¨ */,
{ 0x7c,0x82,0xba,0xaa,0xaa,0x82,0x7c,0x0,0x77 } /* © */,
{ 0x0,0x32,0x2a,0x2a,0x3e,0x20,0x0,0x0,0x57 } /* ª */,
{ 0x10,0x28,0x54,0x28,0x44,0x0,0x0,0x0,0x56 } /* « */,
{ 0x2,0x2,0x2,0x2,0x6,0x0,0x0,0x0,0x57 } /* ¬ */,
{ 0x8,0x8,0x8,0x8,0x8,0x0,0x0,0x0,0x55 } /* ­ */,
{ 0x7c,0x82,0xfa,0xaa,0xda,0x82,0x7c,0x0,0x77 } /* ® */,
{ 0x8,0x8,0x8,0x8,0x8,0x8,0x0,0x0,0x65 } /* ­ */,
{ 0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x77 } /* ¯ */,
{ 0x4,0xa,0xa,0x4,0x0,0x0,0x0,0x0,0x47 } /* ° */,
{ 0x24,0x24,0x2e,0x24,0x24,0x0,0x0,0x0,0x57 } /* ± */,
{ 0x1a,0x1a,0x16,0x10,0x0,0x0,0x0,0x0,0x47 } /* ² */,
{ 0x12,0x16,0x1e,0x0,0x0,0x0,0x0,0x0,0x37 } /* ³ */,
{ 0x4,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x27 } /* ´ */,
{ 0x1e,0x8,0x8,0x6,0x0,0x0,0x0,0x0,0x47 } /* µ */,
{ 0xc,0xe,0x1e,0xfe,0x2,0xfe,0x0,0x0,0x67 } /* ¶ */,
{ 0x10,0x38,0x38,0x10,0x0,0x0,0x0,0x0,0x45 } /* · */,
{ 0x0,0x0,0x40,0x80,0x0,0x0,0x0,0x0,0x42 } /* ¸ */,
{ 0xa,0xe,0x8,0x0,0x0,0x0,0x0,0x0,0x17 } /* ¹ */,
{ 0x4,0xa,0xa,0x4,0x0,0x0,0x0,0x0,0x47 } /* º */,
{ 0x44,0x28,0x54,0x28,0x10,0x0,0x0,0x0,0x56 } /* » */,
{ 0x2e,0x10,0x8,0x34,0x22,0x70,0x0,0x0,0x67 } /* ¼ */,
{ 0x2e,0x10,0x8,0xd4,0xd2,0xb0,0x80,0x0,0x77 } /* ½ */,
{ 0x52,0x36,0x1e,0x68,0x44,0xe2,0x0,0x0,0x67 } /* */,
{ 0xb2,0x12,0x12,0xc,0x0,0x0,0x0,0x0,0x47 } /* ? */,
{ 0x60,0x90,0x90,0x9a,0x0,0x0,0x0,0x0,0x47 } /* ¿ */,
{ 0xf9,0x26,0x24,0xf8,0x0,0x0,0x0,0x0,0x48 } /* À */,
{ 0xf8,0x24,0x26,0xf9,0x0,0x0,0x0,0x0,0x48 } /* Á */,
{ 0xfa,0x25,0x25,0xfa,0x0,0x0,0x0,0x0,0x48 } /* Â */,
{ 0xfa,0x25,0x26,0xf9,0x0,0x0,0x0,0x0,0x48 } /* Ã */,
{ 0xf9,0x24,0x24,0xf9,0x0,0x0,0x0,0x0,0x48 } /* Ä */,
{ 0xfa,0x25,0x25,0xfa,0x0,0x0,0x0,0x0,0x48 } /* Å */,
{ 0xfc,0x12,0x12,0xfe,0x92,0x92,0x82,0x0,0x77 } /* Æ */,
{ 0x3c,0x42,0xc2,0x42,0x42,0x24,0x0,0x0,0x67 } /* Ç */,
{ 0xfc,0x95,0x96,0x84,0x0,0x0,0x0,0x0,0x48 } /* È */,
{ 0xfc,0x96,0x95,0x84,0x0,0x0,0x0,0x0,0x48 } /* É */,
{ 0xfe,0x95,0x95,0x86,0x0,0x0,0x0,0x0,0x48 } /* Ê */,
{ 0xfd,0x94,0x94,0x85,0x0,0x0,0x0,0x0,0x48 } /* Ë */,
{ 0x85,0xfe,0x84,0x0,0x0,0x0,0x0,0x0,0x38 } /* Ì */,
{ 0x84,0xfe,0x85,0x0,0x0,0x0,0x0,0x0,0x38 } /* Í */,
{ 0x86,0xfd,0x86,0x0,0x0,0x0,0x0,0x0,0x38 } /* Î */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0xcf */,
{ 0x10,0xfe,0x92,0x82,0x7c,0x0,0x0,0x0,0x57 } /* Ð */,
{ 0xfe,0x5,0x6,0xf9,0x0,0x0,0x0,0x0,0x48 } /* Ñ */,
{ 0x79,0x86,0x84,0x78,0x0,0x0,0x0,0x0,0x48 } /* Ò */,
{ 0x78,0x84,0x86,0x79,0x0,0x0,0x0,0x0,0x48 } /* Ó */,
{ 0x7a,0x85,0x85,0x7a,0x0,0x0,0x0,0x0,0x48 } /* Ô */,
{ 0x7a,0x85,0x86,0x79,0x0,0x0,0x0,0x0,0x48 } /* Õ */,
{ 0x79,0x84,0x84,0x79,0x0,0x0,0x0,0x0,0x48 } /* Ö */,
{ 0x44,0x28,0x10,0x28,0x44,0x0,0x0,0x0,0x56 } /* × */,
{ 0x80,0x78,0x64,0x54,0x4c,0x3c,0x2,0x0,0x77 } /* Ø */,
{ 0x7c,0x81,0x82,0x7c,0x0,0x0,0x0,0x0,0x48 } /* Ù */,
{ 0x7c,0x82,0x81,0x7c,0x0,0x0,0x0,0x0,0x48 } /* Ú */,
{ 0x7a,0x81,0x81,0x7a,0x0,0x0,0x0,0x0,0x48 } /* Û */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0xdc */,
{ 0x4,0x8,0xf2,0x9,0x4,0x0,0x0,0x0,0x58 } /* Ý */,
{ 0xfe,0x14,0x14,0x8,0x0,0x0,0x0,0x0,0x47 } /* Þ */,
{ 0xfc,0x2,0x92,0x92,0x6c,0x0,0x0,0x0,0x57 } /* ß */,
{ 0x40,0xa8,0xa9,0xaa,0xf0,0x0,0x0,0x0,0x58 } /* à */,
{ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x00 } /* 0xe1 */,
{ 0x40,0xaa,0xa9,0xa9,0xf2,0x0,0x0,0x0,0x58 } /* â */,
{ 0x40,0xaa,0xa9,0xaa,0xf1,0x0,0x0,0x0,0x58 } /* ã */,
{ 0x40,0xaa,0xa8,0xa8,0xf2,0x0,0x0,0x0,0x57 } /* ä */,
{ 0x40,0xac,0xaa,0xaa,0xf4,0x0,0x0,0x0,0x57 } /* å */,
{ 0x40,0xa8,0xa8,0xf0,0xa8,0xa8,0xb0,0x0,0x75 } /* æ */,
{ 0x30,0x48,0xc8,0x48,0x48,0x0,0x0,0x0,0x55 } /* ç */,
{ 0x70,0xa9,0xaa,0xa8,0x10,0x0,0x0,0x0,0x58 } /* è */,
{ 0x70,0xa8,0xaa,0xa9,0x10,0x0,0x0,0x0,0x58 } /* é */,
{ 0x72,0xa9,0xa9,0xaa,0x10,0x0,0x0,0x0,0x58 } /* ê */,
{ 0x70,0xaa,0xa8,0xa8,0x12,0x0,0x0,0x0,0x57 } /* ë */,
{ 0x89,0xfa,0x80,0x0,0x0,0x0,0x0,0x0,0x38 } /* ì */,
{ 0x88,0xfa,0x81,0x0,0x0,0x0,0x0,0x0,0x38 } /* í */,
{ 0x8a,0xf9,0x82,0x0,0x0,0x0,0x0,0x0,0x38 } /* î */,
{ 0x8a,0xf8,0x82,0x0,0x0,0x0,0x0,0x0,0x37 } /* ï */,
{ 0x72,0x8b,0x8c,0x70,0x0,0x0,0x0,0x0,0x38 } /* ð */,
{ 0xfa,0x9,0xa,0xf1,0x0,0x0,0x0,0x0,0x48 } /* ñ */,
{ 0x71,0x8a,0x88,0x70,0x0,0x0,0x0,0x0,0x48 } /* ò */,
{ 0x70,0x88,0x8a,0x71,0x0,0x0,0x0,0x0,0x48 } /* ó */,
{ 0x72,0x89,0x89,0x72,0x0,0x0,0x0,0x0,0x48 } /* ô */,
{ 0x72,0x89,0x8a,0x71,0x0,0x0,0x0,0x0,0x48 } /* õ */,
{ 0x72,0x88,0x88,0x72,0x0,0x0,0x0,0x0,0x47 } /* ö */,
{ 0x10,0x10,0x54,0x10,0x10,0x0,0x0,0x0,0x56 } /* ÷ */,
{ 0xb8,0x44,0xa4,0x94,0x88,0x74,0x0,0x0,0x66 } /* ø */,
{ 0x78,0x81,0x82,0x78,0x0,0x0,0x0,0x0,0x48 } /* ù */,
{ 0x78,0x82,0x81,0x78,0x0,0x0,0x0,0x0,0x48 } /* ú */,
{ 0x7a,0x81,0x81,0x7a,0x0,0x0,0x0,0x0,0x48 } /* û */,
{ 0x7a,0x80,0x80,0x7a,0x0,0x0,0x0,0x0,0x47 } /* ü */,
{ 0x18,0xa1,0xa2,0x78,0x0,0x0,0x0,0x0,0x48 } /* ý */,
{ 0xfe,0x28,0x44,0x44,0x44,0x38,0x0,0x0,0x67 } /* þ */,
{ 0x1a,0xa0,0xa0,0x7a,0x0,0x0,0x0,0x0,0x47 } /* ÿ */
};
#endif
#endif /* HAVE_LCD_BITMAP || SIMULATOR */

View File

@ -26,7 +26,8 @@ extern void debugf(char* fmt,...);
/* */
#if defined(DEBUG) || defined(SIMULATOR)
#define DEBUGF(...) debugf(__VA_ARGS__)
//#define DEBUGF(...) debugf(__VA_ARGS__)
#define DEBUGF debugf
#else
#define DEBUGF(...)
#endif

View File

@ -1049,10 +1049,6 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry)
for (j=longs-1; j>=0; j--) {
unsigned char* ptr = dir->cached_buf;
int index = longarray[j];
#ifdef LOADABLE_FONTS
int offset_idx = 0;
unsigned char uni_char[2];
#endif
/* current or cached sector? */
if ( sectoridx >= SECTOR_SIZE ) {
if ( sectoridx >= SECTOR_SIZE*2 ) {
@ -1070,30 +1066,6 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry)
index &= SECTOR_SIZE-1;
}
/* piece together the name subcomponents. */
#ifdef LOADABLE_FONTS
for (k=0; k<5; k++)
{
offset_idx = index + k*2 + 1;
uni_char[0] = ptr[offset_idx+1];
uni_char[1] = ptr[offset_idx];
entry->name[l++] = from_unicode(uni_char);
}
for (k=0; k<6; k++)
{
offset_idx = index + k*2 + 14;
uni_char[0] = ptr[offset_idx+1];
uni_char[1] = ptr[offset_idx];
entry->name[l++] = from_unicode(uni_char);
}
for (k=0; k<2; k++)
{
offset_idx = index + k*2 + 28;
uni_char[0] = ptr[offset_idx+1];
uni_char[1] = ptr[offset_idx];
entry->name[l++] = from_unicode(uni_char);
}
#else
/* names are stored in unicode, but we
only grab the low byte (iso8859-1). */
for (k=0; k<5; k++)
@ -1102,7 +1074,6 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry)
entry->name[l++] = ptr[index + k*2 + 14];
for (k=0; k<2; k++)
entry->name[l++] = ptr[index + k*2 + 28];
#endif
}
entry->name[l]=0;
}

View File

@ -26,17 +26,12 @@
#include "file.h"
#include "debug.h"
#include "system.h"
#ifdef LOADABLE_FONTS
#include "ajf.h"
#include "panic.h"
#endif
#include "font.h"
#if defined(SIMULATOR)
#include "sim_icons.h"
#endif
/*** definitions ***/
#define LCDR (PBDR_ADDR+1)
@ -513,9 +508,6 @@ void lcd_init (void)
{
create_thread(scroll_thread, scroll_stack,
sizeof(scroll_stack), scroll_name);
#if defined(LOADABLE_FONTS) && defined(SIMULATOR)
lcd_init_fonts();
#endif
}
#endif
@ -568,17 +560,11 @@ static int ymargin=0;
#define ASCII_MIN 0x20 /* First char in table */
#define ASCII_MAX 0x7f /* Last char in table */
extern unsigned char char_gen_6x8[][5];
extern unsigned char char_gen_8x12[][14];
extern unsigned char char_gen_12x16[][22];
/* All zeros and ones bitmaps for area filling */
static unsigned char zeros[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 };
static unsigned char ones[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff };
static char fonts[] = { 6,8,12 };
static char fontheight[] = { 8,12,16 };
#ifndef SIMULATOR
@ -696,175 +682,14 @@ int lcd_getymargin(void)
return ymargin;
}
#ifdef LOADABLE_FONTS
static unsigned char* _font = NULL;
int lcd_init_fonts(void)
{
if (!_font)
_font = ajf_read_font("/system.ajf");
if (!_font)
{
lcd_putsxy(0,0,"No font", 0);
return -1;
}
return 0;
}
void lcd_setldfont(unsigned char* f)
{
_font = f;
}
unsigned char* lcd_getcurrentldfont()
{
if (!_font)
panicf("No font loaded!");
return _font;
}
/*
* Return width and height of a string with a given font.
*/
int lcd_getstringsize(unsigned char *str, unsigned char* font, int *w, int *h)
{
int width=0;
int height=0;
unsigned char ch;
if (!font)
panicf("No font specified");
while((ch = *str++))
{
int dw,dh;
ajf_get_charsize(ch, font, &dw, &dh);
if (dh>height)
height = dh;
width+=dw;
}
*w = width;
*h = height;
return width;
}
/*
* Put a string at specified bit position
*/
void lcd_putsldfxy(int x, int y, unsigned char *str)
{
unsigned char ch;
int nx;
int ny=8;
int lcd_x = x;
int lcd_y = y;
if (!_font)
{
lcd_putsxy(0,0,"No font", 0);
return;
}
ny = (int)_font[2];
while (((ch = *str++) != '\0'))
{
unsigned char *char_buf = ajf_get_charbuf(ch, _font, &nx, &ny);
if (!char_buf)
{
char_buf = ajf_get_charbuf('?', _font, &nx, &ny);
if (!char_buf)
panicf("Bad font");
}
if(lcd_x + nx > LCD_WIDTH)
break;
lcd_bitmap (&char_buf[0], lcd_x, lcd_y, nx, ny, true);
lcd_x += nx;
}
}
#endif
#ifdef LCD_PROPFONTS
extern unsigned char char_dw_8x8_prop[][9];
/*
* Return width and height of a given font.
*/
int lcd_getstringsize(unsigned char *str, unsigned int font, int *w, int *h)
{
int width=0;
unsigned char ch, byte;
(void)font;
while((ch = *str++)) {
/* Limit to char generation table */
if (ch < ASCII_MIN)
/* replace unsupported letters with question marks */
ch = ' '-ASCII_MIN;
else
ch -= ASCII_MIN;
byte = char_dw_8x8_prop[ch][8];
width += (byte>>4) + 1;
}
*w = width;
*h = 8;
return width;
}
/*
* Put a string at specified bit position
*/
void lcd_putspropxy(int x, int y, unsigned char *str, int thisfont)
{
unsigned int ch;
int nx;
int ny=8;
unsigned char *src;
int lcd_x = x;
int lcd_y = y;
(void)thisfont;
while (((ch = *str++) != '\0'))
{
/* Limit to char generation table */
if (ch < ASCII_MIN)
/* replace unsupported letters with question marks */
ch = ' '-ASCII_MIN;
else
ch -= ASCII_MIN;
nx = char_dw_8x8_prop[ch][8] >> 4;
if(lcd_x + nx > LCD_WIDTH)
break;
src = char_dw_8x8_prop[ch];
lcd_clearrect (lcd_x+nx, lcd_y, 1, ny );
lcd_bitmap (src, lcd_x, lcd_y, nx, ny, true);
lcd_x += nx+1;
}
}
#endif
/*
* Put a string at specified character position
*/
//FIXME require font parameter
void lcd_puts(int x, int y, unsigned char *str)
{
int xpos,ypos,w,h;
#if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS)
/* We make the simulator truncate the string if it reaches the right edge,
as otherwise it'll wrap. The real target doesn't wrap. */
@ -882,23 +707,10 @@ void lcd_puts(int x, int y, unsigned char *str)
if(!str || !str[0])
return;
#ifdef LCD_PROPFONTS
lcd_getstringsize(str, font, &w, &h);
xpos = xmargin + x * fonts[font];
ypos = ymargin + y * fontheight[font];
lcd_putspropxy(xpos, ypos, str, font);
#elif LOADABLE_FONTS
lcd_getstringsize(str,_font,&w,&h);
xpos = xmargin + x * w / strlen(str);
ypos = ymargin + y * h;
lcd_putsldfxy(xpos, ypos, str);
#else
xpos = xmargin + x * fonts[font];
ypos = ymargin + y * fontheight[font];
lcd_putsxy(xpos, ypos, str, font);
w = strlen(str) * fonts[font];
h = fontheight[font];
#endif
xpos = xmargin + x*w / strlen(str); //FIXME why strlen?
ypos = ymargin + y*h;
lcd_putsxy( xpos, ypos, str, font);
lcd_clearrect(xpos + w, ypos, LCD_WIDTH - (xpos + w), h);
#if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS)
/* this function is being used when simulating a charcell LCD and
@ -907,58 +719,6 @@ void lcd_puts(int x, int y, unsigned char *str)
#endif
}
/*
* Put a string at specified bit position
*/
void lcd_putsxy(int x, int y, unsigned char *str, int thisfont)
{
#ifdef LCD_PROPFONTS
lcd_putspropxy(x,y,str,thisfont);
#else
int nx = fonts[thisfont];
int ny = fontheight[thisfont];
int ch;
unsigned char *src;
int lcd_x = x;
int lcd_y = y;
#ifdef LOADABLE_FONTS
if ( _font ) {
lcd_putsldfxy(x,y,str);
return;
}
#endif
while (((ch = *str++) != '\0') && (lcd_x + nx <= LCD_WIDTH))
{
if (lcd_y + ny > LCD_HEIGHT)
return;
/* Limit to char generation table */
if ((ch < ASCII_MIN) || (ch > ASCII_MAX))
/* replace unsupported letters with question marks */
ch = '?' - ASCII_MIN;
else
ch -= ASCII_MIN;
if (thisfont == 2)
src = char_gen_12x16[ch];
else if (thisfont == 1)
src = char_gen_8x12[ch];
else
src = char_gen_6x8[ch];
lcd_bitmap (src, lcd_x, lcd_y, nx-1, ny, true);
lcd_bitmap (zeros, lcd_x+nx-1, lcd_y, 1, ny, true);
lcd_x += nx;
}
#endif
}
/*
* Display a bitmap at (x, y), size (nx, ny)
* clear is true to clear destination area first
@ -1265,17 +1025,6 @@ void lcd_invertpixel(int x, int y)
INVERT_PIXEL(x,y);
}
/*
* Return width and height of a given font.
*/
void lcd_getfontsize(unsigned int font, int *width, int *height)
{
if(font < sizeof(fonts)) {
*width = fonts[font];
*height = fontheight[font];
}
}
#else
/* no LCD defined, no code to use */
#endif
@ -1286,47 +1035,31 @@ void lcd_puts_scroll(int x, int y, unsigned char* string )
#ifdef HAVE_LCD_CHARCELLS
s->space = 11 - x;
#else
#if defined(LCD_PROPFONTS) || defined(LOADABLE_FONTS)
unsigned char ch[2];
int w, h;
#endif
int width, height;
lcd_getfontsize(font, &width, &height);
#if defined(LCD_PROPFONTS) || defined(LOADABLE_FONTS)
ch[1] = 0; /* zero terminate */
ch[0] = string[0];
width = 0;
s->space = 0;
while ( ch[0] &&
#ifdef LCD_PROPFONTS
(width + lcd_getstringsize(ch, 0, &w, &h) <
(LCD_WIDTH - x*8))) {
#else
(width + lcd_getstringsize(ch, _font, &w, &h) <
(LCD_WIDTH - x*8))) {
#endif
width += w;
s->space++;
ch[0]=string[s->space];
}
#else
s->space = (LCD_WIDTH - xmargin - x*width) / width;
#endif
#endif
lcd_puts(x,y,string);
s->textlen = strlen(string);
#if defined(LCD_PROPFONTS)
#ifdef HAVE_LCD_BITMAP
s->space += 2;
lcd_getstringsize(string,0,&w,&h);
if ( w > LCD_WIDTH - xmargin ) {
#elif defined(LOADABLE_FONTS)
s->space += 2;
lcd_getstringsize(string,_font,&w,&h);
if ( w > LCD_WIDTH - xmargin ) {
#else
if ( s->textlen > s->space ) {
#endif
@ -1344,32 +1077,24 @@ void lcd_puts_scroll(int x, int y, unsigned char* string )
}
}
void lcd_stop_scroll(void)
{
if ( scroll_count ) {
struct scrollinfo* s = &scroll;
scroll_count = 0;
#ifdef LCD_PROPFONTS
lcd_clearrect(xmargin + s->startx*fonts[font],
ymargin + s->starty*fontheight[font],
LCD_WIDTH - xmargin,
fontheight[font]);
#elif defined(LOADABLE_FONTS)
#ifdef HAVE_LCD_BITMAP
{
int w,h;
lcd_getstringsize( s->text, _font, &w, &h);
/* FIXME no font index */
lcd_getstringsize( s->text, FONT_UI, &w, &h);
lcd_clearrect(xmargin + s->startx*w/s->textlen,
ymargin + s->starty*h,
LCD_WIDTH - xmargin,
h);
}
#endif
/* restore scrolled row */
lcd_puts(s->startx,s->starty,s->text);
lcd_update();
@ -1420,20 +1145,16 @@ static void scroll_thread(void)
s->offset = 0;
}
#ifdef LCD_PROPFONTS
lcd_clearrect(xmargin + s->startx*fonts[font],
ymargin + s->starty*fontheight[font],
LCD_WIDTH - xmargin,
fontheight[font]);
#elif defined(LOADABLE_FONTS)
{
int w,h;
lcd_getstringsize( s->text, _font, &w, &h);
#ifdef HAVE_LCD_BITMAP
{
/* FIXME no font index */
int w, h;
lcd_getstringsize( s->text, FONT_UI, &w, &h);
lcd_clearrect(xmargin + s->startx*w/s->textlen,
ymargin + s->starty*h,
LCD_WIDTH - xmargin,
h);
}
}
#endif
lcd_puts(s->startx,s->starty,s->line);
lcd_update();

View File

@ -101,7 +101,7 @@ extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8];
extern void lcd_putsxy(int x, int y, unsigned char *string, int font);
extern void lcd_setfont(int font);
extern void lcd_getfontsize(unsigned int font, int *width, int *height);
extern void lcd_getfontsize(int font, int *width, int *height);
extern void lcd_setmargins(int xmargin, int ymargin);
extern int lcd_getxmargin(void);
extern int lcd_getymargin(void);
@ -119,19 +119,6 @@ extern void lcd_invertpixel(int x, int y);
#endif /* CHARCELLS / BITMAP */
#ifdef LOADABLE_FONTS
extern int lcd_init_fonts(void);
extern void lcd_putsldfxy(int x, int y, unsigned char *str);
extern int lcd_getstringsize(unsigned char *str,
unsigned char* font,
int *w, int *h);
extern void lcd_setldfont(unsigned char* f);
extern unsigned char* lcd_getcurrentldfont(void);
#endif
#ifdef LCD_PROPFONTS
extern int lcd_getstringsize(unsigned char *str, unsigned int font, int *w, int *h);
#endif
extern int lcd_getstringsize(unsigned char *str, int font, int *w, int *h);
#endif /* __LCD_H__ */

228
firmware/font.c Normal file
View File

@ -0,0 +1,228 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
/*
* Rockbox startup font initialization
* This file specifies which fonts get compiled-in and
* loaded at startup, as well as their mapping into
* the FONT_SYSFIXED, FONT_UI and FONT_MP3 ids.
*/
#include "config.h"
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
#include <stdio.h>
#include <string.h>
#include "lcd.h"
#include "font.h"
#include "debug.h"
#include "panic.h"
/* available compiled-in fonts*/
extern MWCFONT font_X5x8;
/*extern MWCFONT font_X6x9; */
/*extern MWCFONT font_courB08; */
/*extern MWCFONT font_timR08; */
/* structure filled in by rbf_load_font*/
static MWCFONT font_UI;
/* system font table, in order of FONT_xxx definition*/
struct corefont sysfonts[MAXFONTS] = {
{ &font_X5x8, NULL }, /* compiled-in FONT_SYSFIXED*/
{ &font_UI, "/system.fnt" }, /* loaded FONT_UI*/
{ NULL, NULL }, /* no FONT_MP3*/
};
void
font_init(void)
{
struct corefont *cfp;
for (cfp=sysfonts; cfp < &sysfonts[MAXFONTS]; ++cfp) {
if (cfp->pf && cfp->diskname) {
cfp->pf = rbf_load_font(cfp->diskname, cfp->pf);
#if defined(DEBUG) || defined(SIMULATOR)
if (!cfp->pf)
DEBUGF("Font load failed: %s\n", cfp->diskname);
#endif
}
}
}
/*
* Return a pointer to an incore font structure.
* If the requested font isn't loaded/compiled-in,
* decrement the font number and try again.
*/
PMWCFONT
getfont(int font)
{
PMWCFONT pf;
while (1) {
pf = sysfonts[font].pf;
if (pf && pf->height)
return pf;
if (--font < 0)
panicf("No font!");
}
}
/*
* Return width and height of a given font.
*/
void lcd_getfontsize(int font, int *width, int *height)
{
PMWCFONT pf = getfont(font);
*width = pf->maxwidth;
*height = pf->height;
}
/*
* Return width and height of a given font.
*/
//FIXME rename to font_gettextsize, add baseline
int
lcd_getstringsize(unsigned char *str, int font, int *w, int *h)
{
PMWCFONT pf = getfont(font);
int ch;
int width = 0;
while((ch = *str++)) {
/* check input range*/
if (ch < pf->firstchar || ch >= pf->firstchar+pf->size)
ch = pf->defaultchar;
ch -= pf->firstchar;
/* get proportional width and glyph bits*/
width += pf->width? pf->width[ch]: pf->maxwidth;
}
*w = width;
*h = pf->height;
return width;
}
/*
* Take an MWIMAGEBITS bitmap and convert to Rockbox format.
* Used for converting font glyphs for the time being.
* Can use for standard X11 and Win32 images as well.
*
* Doing it this way keeps fonts in standard formats,
* as well as keeping Rockbox hw bitmap format.
*/
static void
rotleft(unsigned char *dst, MWIMAGEBITS *src, unsigned int width,
unsigned int height)
{
unsigned int i,j;
unsigned int dst_col = 0; /* destination column*/
unsigned int dst_shift = 0; /* destination shift amount*/
unsigned int dst_linelen; /* # bytes per output row*/
unsigned int src_words; /* # words of input image*/
/* calc bytes per output row*/
dst_linelen = (height-1)/8+1;
/* calc words of input image*/
src_words = MWIMAGE_WORDS(width) * height;
/* clear background*/
memset(dst, 0, dst_linelen*height);
for (i=0; i < src_words; i++) {
MWIMAGEBITS srcmap; /* current src input bit*/
MWIMAGEBITS dstmap; /* current dst output bit*/
/* calc src input bit*/
srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1);
/* calc dst output bit*/
if (i>0 && (i%8==0)) {
++dst_col;
dst_shift = 0;
}
dstmap = 1 << dst_shift++;
/* for each input column...*/
for(j=0; j < width; j++) {
/* calc input bitmask*/
MWIMAGEBITS bit = srcmap >> j;
if (bit==0) {
srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1);
bit = srcmap >> (j % 16);
}
/* if set in input, set in rotated output*/
if (bit & src[i]) {
/* input column j becomes output row*/
dst[j*dst_linelen + dst_col] |= dstmap;
}
//printf((bit & src[i])? "*": ".");
}
//printf("\n");
}
}
/*
* Put a string at specified bit position
*/
//FIXME rename font_putsxy?
void
lcd_putsxy(int x, int y, unsigned char *str, int font)
{
int ch;
unsigned char *src;
PMWCFONT pf = getfont(font);
while (((ch = *str++) != '\0')) {
MWIMAGEBITS *bits;
int width;
unsigned char outbuf[256];
/* check input range*/
if (ch < pf->firstchar || ch >= pf->firstchar+pf->size)
ch = pf->defaultchar;
ch -= pf->firstchar;
/* get proportional width and glyph bits*/
width = pf->width? pf->width[ch]: pf->maxwidth;
if(x + width > LCD_WIDTH)
break;
bits = pf->bits + (pf->offset? pf->offset[ch]: (pf->height * ch));
/* rotate left for lcd_bitmap function input*/
rotleft(outbuf, bits, width, pf->height);
src = outbuf;
lcd_bitmap (src, x, y, width, pf->height, true);
x += width;
}
}
#endif /* HAVE_LCD_BITMAP */
/* -----------------------------------------------------------------
* local variables:
* eval: (load-file "rockbox-mode.el")
* end:
*/

126
firmware/font.h Normal file
View File

@ -0,0 +1,126 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
/*
* Incore font and image definitions
*/
#include "config.h"
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
/* max static loadable fonts buffer*/
#ifndef MAX_FONT_SIZE
#define MAX_FONT_SIZE 9000 /* max total fontsize allocation*/
#endif
/*
* Fonts are specified by number, and used for display
* of menu information as well as mp3 filename data.
* At system startup, up to MAXFONTS fonts are initialized,
* either by being compiled-in, or loaded from disk.
* If the font asked for does not exist, then the
* system uses the next lower font number. Font 0
* must be available at system startup.
* Fonts are specified in firmware/font.c.
*/
#define FONT_SYSFIXED 0 /* system fixed pitch font*/
#define FONT_UI 1 /* system porportional font*/
#define FONT_MP3 2 /* font used for mp3 info*/
#define MAXFONTS 3 /* max # fonts*/
/*
* .fnt (.rbf) loadable font file format definition
*
* format len description
* ------------------------- ---- ------------------------------
* UCHAR version[4] 4 magic number and version bytes
* UCHAR name[64] 64 font name, space padded
* UCHAR copyright[256] 256 copyright info, space padded
* USHORT maxwidth 2 font max width in pixels
* USHORT height 2 font height in pixels
* USHORT ascent 2 font ascent (baseline) in pixels
* ULONG firstchar 4 first character code in font
* ULONG defaultchar 4 default character code in font
* ULONG size 4 # characters in font
* ULONG nbits 4 # words imagebits data in file
* ULONG noffset 4 # longs offset data in file
* ULONG nwidth 4 # bytes width data in file
* MWIMAGEBITS bits nbits*2 image bits variable data
* ULONG offset noffset*4 offset variable data
* UCHAR width nwidth*1 width variable data
*/
/* loadable font magic and version #*/
#define VERSION "RB10"
/* MWIMAGEBITS helper macros*/
#define MWIMAGE_WORDS(x) (((x)+15)/16) /* image size in words*/
#define MWIMAGE_BYTES(x) (((x)+7)/8) /* image size in bytes*/
#define MWIMAGE_BITSPERIMAGE (sizeof(MWIMAGEBITS) * 8)
#define MWIMAGE_BITVALUE(n) ((MWIMAGEBITS) (((MWIMAGEBITS) 1) << (n)))
#define MWIMAGE_FIRSTBIT (MWIMAGE_BITVALUE(MWIMAGE_BITSPERIMAGE - 1))
#define MWIMAGE_TESTBIT(m) ((m) & MWIMAGE_FIRSTBIT)
#define MWIMAGE_SHIFTBIT(m) ((MWIMAGEBITS) ((m) << 1))
typedef unsigned short MWIMAGEBITS; /* bitmap image unit size*/
/* builtin C-based proportional/fixed font structure */
/* based on The Microwindows Project http://microwindows.org */
typedef struct {
char * name; /* font name*/
int maxwidth; /* max width in pixels*/
unsigned int height; /* height in pixels*/
int ascent; /* ascent (baseline) height*/
int firstchar; /* first character in bitmap*/
int size; /* font size in glyphs*/
MWIMAGEBITS *bits; /* 16-bit right-padded bitmap data*/
unsigned long *offset; /* offsets into bitmap data*/
unsigned char *width; /* character widths or NULL if fixed*/
int defaultchar; /* default char (not glyph index)*/
long bits_size; /* # words of MWIMAGEBITS bits*/
#if 0
char * facename; /* facename of font*/
char * copyright; /* copyright info for loadable fonts*/
#endif
} MWCFONT, *PMWCFONT;
/* structure for rockbox startup font selection*/
struct corefont {
PMWCFONT pf; /* compiled-in or loaded font*/
char *diskname; /* diskname if not compiled-in*/
};
extern struct corefont sysfonts[MAXFONTS];
/* font routines*/
PMWCFONT getfont(int font);
PMWCFONT rbf_load_font(char *path, PMWCFONT pf);
void font_init(void);
#else /* HAVE_LCD_BITMAP */
#define font_init()
#endif
/* -----------------------------------------------------------------
* local variables:
* eval: (load-file "rockbox-mode.el")
* end:
*/

202
firmware/loadfont.c Normal file
View File

@ -0,0 +1,202 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
/*
* Load an rbf font, store in incore format.
*/
#include "config.h"
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
#include <stdio.h>
#include <string.h>
#include "font.h"
#include "file.h"
#ifndef DEBUGF
#include "debug.h"
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
/* static buffer allocation structures*/
static unsigned char mbuf[MAX_FONT_SIZE];
static unsigned char *freeptr = mbuf;
typedef unsigned char CFILE;
static CFILE *fileptr;
static CFILE *eofptr;
static int
READSHORT(unsigned short *sp)
{
unsigned short s;
s = *fileptr++ & 0xff;
*sp = (*fileptr++ << 8) | s;
return (fileptr <= eofptr);
}
static int
READLONG(unsigned long *lp)
{
unsigned long l;
l = *fileptr++ & 0xff;
l |= *fileptr++ << 8;
l |= *fileptr++ << 16;
*lp = (*fileptr++ << 24) | l;
return (fileptr <= eofptr);
}
/* read count bytes*/
static int
READSTR(char *buf, int count)
{
int n = count;
while (--n >= 0)
*buf++ = *fileptr++;
return (fileptr <= eofptr)? count: 0;
}
/* read totlen bytes, return NUL terminated string*/
/* may write 1 past buf[totlen]; removes blank pad*/
static int
READSTRPAD(char *buf, int totlen)
{
char *p = buf;
int n = totlen;
while (--n >= 0)
*p++ = *fileptr++;
if (fileptr > eofptr)
return 0;
p = &buf[totlen];
*p-- = 0;
while (*p == ' ' && p >= buf)
*p-- = '\0';
return totlen;
}
/* read and load font into incore font structure*/
PMWCFONT
rbf_load_font(char *path, PMWCFONT pf)
{
int fd, filesize;
unsigned short maxwidth, height, ascent;
unsigned long firstchar, defaultchar, size;
unsigned long nbits, noffset, nwidth;
char version[4+1];
char copyright[256+1];
memset(pf, 0, sizeof(MWCFONT));
/* open and read entire font file*/
fd = open(path, O_RDONLY|O_BINARY);
if (fd < 0) {
DEBUGF("Can't open font: %s\n", path);
return NULL;
}
fileptr = freeptr;
filesize = read(fd, fileptr, MAX_FONT_SIZE);
freeptr += filesize;
eofptr = fileptr + filesize;
close(fd);
if (filesize == MAX_FONT_SIZE) {
DEBUGF("Font %s too large: %d\n", path, filesize);
return NULL;
}
/* read magic and version #*/
memset(version, 0, sizeof(version));
if (READSTR(version, 4) != 4)
return NULL;
if (strcmp(version, VERSION) != 0)
return NULL;
/* internal font name*/
pf->name = fileptr;
if (READSTRPAD(pf->name, 64) != 64)
return NULL;
/* copyright, not currently stored*/
if (READSTRPAD(copyright, 256) != 256)
return NULL;
/* font info*/
if (!READSHORT(&maxwidth))
return NULL;
pf->maxwidth = maxwidth;
if (!READSHORT(&height))
return NULL;
pf->height = height;
if (!READSHORT(&ascent))
return NULL;
pf->ascent = ascent;
if (!READLONG(&firstchar))
return NULL;
pf->firstchar = firstchar;
if (!READLONG(&defaultchar))
return NULL;
pf->defaultchar = defaultchar;
if (!READLONG(&size))
return NULL;
pf->size = size;
/* get variable font data sizes*/
/* # words of MWIMAGEBITS*/
if (!READLONG(&nbits))
return NULL;
pf->bits_size = nbits;
/* # longs of offset*/
if (!READLONG(&noffset))
return NULL;
/* # bytes of width*/
if (!READLONG(&nwidth))
return NULL;
/* variable font data*/
pf->bits = (MWIMAGEBITS *)fileptr;
fileptr += nbits*sizeof(MWIMAGEBITS);
if (noffset) {
pf->offset = (unsigned long *)fileptr;
fileptr += noffset*sizeof(unsigned long);
} else pf->offset = NULL;
if (nwidth) {
pf->width = (unsigned char *)fileptr;
fileptr += noffset*sizeof(unsigned char);
} else pf->width = NULL;
if (fileptr > eofptr)
return NULL;
return pf; /* success!*/
}
#endif /* HAVE_LCD_BITMAP */
/* -----------------------------------------------------------------
* local variables:
* eval: (load-file "rockbox-mode.el")
* end:
*/

View File

@ -21,6 +21,7 @@
#include <stdarg.h>
#include "panic.h"
#include "lcd.h"
#include "font.h"
#include "debug.h"
static char panic_buf[128];
@ -48,7 +49,9 @@ void panicf( char *fmt, ...)
lcd_puts(0,0,panic_buf);
#elif defined(HAVE_LCD_BITMAP)
lcd_clear_display();
lcd_putsxy(0,0,panic_buf,0);
//FIXME putsxy may call panic...
lcd_putsxy(0,0,panic_buf,FONT_SYSFIXED);
lcd_update();
#else

View File

@ -1,101 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Alex Gitelman
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "unicode.h"
#include "string.h"
#define MAX_TYPE 3
unsigned char *conversion_table[255];
unsigned char *reverse_conversion_table[255];
static unsigned char page_04[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
};
void install_unicode_tables(void)
{
install_conversion_table(0x04, page_04);
}
void unicode_init(void)
{
memset(conversion_table, 0, sizeof(conversion_table));
memset(reverse_conversion_table, 0, sizeof(reverse_conversion_table));
install_unicode_tables();
}
/**
Convertion table defines how chars in ing given page map to ascii
*/
void install_conversion_table(unsigned char page, unsigned char* conv_table)
{
if (conv_table!=0)
conversion_table[page] = conv_table;
else
conversion_table[page] = 0;
}
void install_reverse_conversion_table(unsigned char page,
unsigned char* rev_conv_table)
{
if (rev_conv_table!=0)
reverse_conversion_table[page] = rev_conv_table;
else
reverse_conversion_table[page] = 0;
}
unsigned char from_unicode(const unsigned char *uni_char)
{
/*
Here we should get proper code page conversions.
For now hack for Cyrrilic->Unicode
*/
unsigned char *table = conversion_table[uni_char[0]];
if (table!=0)
return table[uni_char[1]];
/* If page is not present -> no conversion */
return uni_char[1];
}
void to_unicode(unsigned char c, unsigned char page, unsigned char *uni_char)
{
unsigned char *table = reverse_conversion_table[page];
if (table!=0)
uni_char[1] = table[c];
else
uni_char[1] = c;
uni_char[0] = page;
}

View File

@ -1,36 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Alex Gitelman
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef __UNICODE__
#define __UNICODE__
unsigned char from_unicode(const unsigned char *uni_char);
void to_unicode(unsigned char c, unsigned char page, unsigned char *uni_char);
/* Unicode -> ASCII */
void install_conversion_table(unsigned char page, unsigned char* conv_table);
/* ASCII -> Unicode */
void install_reverse_conversion_table(unsigned char page,
unsigned char* rev_conv_table);
void unicode_init(void);
/* Unicode main init point. Here we must read conversion
tables and install them */
void install_unicode_tables(void);
#endif

View File

@ -76,13 +76,8 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) -W -Wall
APPCFLAGS = $(DEBUG) $(DEFINES) -DAPPSVERSION=\"$(VERSION)\" $(APPINCLUDES) -W -Wall
FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c usb.c mpeg.c power.c powermgmt.c
ifeq (LOADABLE_FONTS,$(findstring LOADABLE_FONTS, $(DEFINES)))
FIRMSRCS += unicode.c ajf.c panic.c
EXTRA_TARGETS = $(OBJDIR)/archos/system.ajf
SYSTEM_FONT = $(FIRMWAREDIR)/fonts/alt6x10.bdf
endif
FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c usb.c mpeg.c power.c\
powermgmt.c font.c X5x8.c loadfont.c panic.c
APPS = main.c tree.c menu.c credits.c main_menu.c\
playlist.c showtext.c wps.c wps-display.c settings.c status.c icons.c
@ -110,9 +105,6 @@ clean:
$(RM) $(OBJS) *~ core $(TARGET) $(CLIENTS)
$(RM) -r $(DEPS)
$(OBJDIR)/archos/system.ajf: $(TOOLSDIR)/bdf2ajf $(SYSTEM_FONT)
$(TOOLSDIR)/bdf2ajf -f $(SYSTEM_FONT) -o $(OBJDIR)/archos/system.ajf
distclean: clean
$(RM) config.cache
@ -227,6 +219,24 @@ $(OBJDIR)/lcd.o: $(DRIVERS)/lcd.c
$(OBJDIR)/chartables.o: $(FIRMWAREDIR)/chartables.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/X5x8.o: $(FIRMWAREDIR)/X5x8.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/X6x9.o: $(FIRMWAREDIR)/X6x9.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/timR08.o: $(FIRMWAREDIR)/timR08.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/courB08.o: $(FIRMWAREDIR)/courB08.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/font.o: $(FIRMWAREDIR)/font.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/loadfont.o: $(FIRMWAREDIR)/loadfont.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/settings.o: $(APPDIR)/settings.c
$(CC) $(APPCFLAGS) -c $< -o $@

View File

@ -198,6 +198,7 @@ screenhack (Display *the_dpy, Window the_window)
screen_redraw();
#ifdef HAVE_LCD_CHARCELLS
// FIXME??
lcd_setfont(2);
#endif