Fonts demonstration application
[Applications]

The font application demonstrates use of fonts with the Graphics display system. More...

Collaboration diagram for Fonts demonstration application:

Data Structures

struct  app_fonts
 Application context. More...

Enumerations

enum  app_fonts_button_ids { BUTTON_NEXT_ID, BUTTON_PREV_ID, BUTTON_QUIT_ID }
 

Command event ID.

More...

Functions

static void draw_font_box (gfx_coord_t y, struct font *font, char *fontname)
 Draw a filled box on the screen starting at line y.
static void screen_draw_splash (void)
 Draw the fonts introduction splash page.
static void screen_draw_fonts_info (void)
 Draw the fonts info page.
static void screen_draw_fonts_list (void)
 Draw the fonts list page.
static void screen_draw_language_info (void)
 Draw the language information page.
static void screen_draw_messages (void)
 Draw the messages in different languages page.
static void app_fonts_frame_draw_handler (struct win_window *win, const struct win_clip_region *clip)
 Frame draw handler.
static bool app_fonts_frame_command_handler (struct wtk_basic_frame *frame, win_command_t command_data)
 Frame command handler handling the button events.
static status_t app_fonts_load (void)
 Schedules loading of next non-loaded font.
static void app_fonts_load_worker (struct workqueue_task *task)
 Setup the font objects after loading fonts from the file system.
void app_fonts_launch (struct workqueue_task *task)
 Launches the application.

Variables

static struct app_fontsthe_fonts_app
 Statically allocated context pointer.

Font metadata



static struct font font_ericat
 Erica Type.
static struct font font_fixedrus
 Fixed-width Russian.
static struct font font_larabie
 Larabie.
static struct font font_monofur
 Monofur.

Font definitions and configuration



#define FONT_HEADER_SIZE   16
 Number of bytes in the header for the font files loaded from the TSFS.
#define NUMBER_OF_FONTS   4
 Number of fonts present in the application.

Page configuration



#define PAGE_NUM_BLANK_SCREEN   0
 Page number containing a blank page used while application is loading the font files.
#define PAGE_NUM_MIN   1
 Number of initial page to show, minimum value.
#define PAGE_NUM_MAX   5
 Number of last page to show, maximum value.

Color scheme



#define COLOR_TEXT   GFX_COLOR(255, 255, 255)
 Color on text strings.
#define COLOR_TEXT_SHADED   GFX_COLOR(150, 150, 150)
 Color on shaded text strings.
#define COLOR_BACKGROUND   GFX_COLOR(0, 0, 0)
 Background color.
#define COLOR_FILL   GFX_COLOR(48, 120, 158)
 Color on filled rectangles, progress bar and horizontal lines.
#define COLOR_FILL_BORDER   GFX_COLOR(30, 74, 98)
 Color on filled rectangle borders.

Text appearance



#define TEXT_INDENT   5
 Number of pixels to indent a string.
#define TEXT_PADDING   3
 Number of pixels to add in front of a string.
#define TEXT_PADDING_NEWLINE   2
 Number of pixels for space after newline.

Detailed Description

The font application demonstrates use of fonts with the Graphics display system.

This application will load four fonts from the TSFS file system and use them on various pages drawn to the screen. The first time the application is launched the fonts are loaded into hugemem, and a progress bar of the work is shown on the screen. Consecutive executions will reuse the already loaded fonts.

There are two navigation buttons at the bottom right corner, along with an exit button. The navigation buttons navigates between the different demonstration pages, while the exit button restarts the desktop application.


Define Documentation

#define COLOR_BACKGROUND   GFX_COLOR(0, 0, 0)

Background color.

Definition at line 87 of file app_fonts.c.

#define COLOR_FILL   GFX_COLOR(48, 120, 158)

Color on filled rectangles, progress bar and horizontal lines.

Definition at line 89 of file app_fonts.c.

Referenced by draw_font_box(), screen_draw_fonts_info(), and screen_draw_language_info().

#define COLOR_FILL_BORDER   GFX_COLOR(30, 74, 98)

Color on filled rectangle borders.

Definition at line 91 of file app_fonts.c.

Referenced by draw_font_box().

#define COLOR_TEXT   GFX_COLOR(255, 255, 255)

Color on text strings.

Definition at line 83 of file app_fonts.c.

#define COLOR_TEXT_SHADED   GFX_COLOR(150, 150, 150)

Color on shaded text strings.

Definition at line 85 of file app_fonts.c.

Referenced by screen_draw_splash().

#define FONT_HEADER_SIZE   16

Number of bytes in the header for the font files loaded from the TSFS.

Definition at line 62 of file app_fonts.c.

Referenced by app_files_load_worker(), and app_fonts_load_worker().

#define NUMBER_OF_FONTS   4

Number of fonts present in the application.

Definition at line 64 of file app_fonts.c.

#define PAGE_NUM_BLANK_SCREEN   0

Page number containing a blank page used while application is loading the font files.

Definition at line 73 of file app_fonts.c.

Referenced by app_fonts_frame_draw_handler().

#define PAGE_NUM_MAX   5

Number of last page to show, maximum value.

Definition at line 77 of file app_fonts.c.

Referenced by app_fonts_frame_command_handler().

#define PAGE_NUM_MIN   1

Number of initial page to show, minimum value.

Definition at line 75 of file app_fonts.c.

Referenced by app_fonts_frame_command_handler(), and app_fonts_load_worker().

#define TEXT_INDENT   5

Number of pixels to indent a string.

Definition at line 97 of file app_fonts.c.

#define TEXT_PADDING   3
#define TEXT_PADDING_NEWLINE   2

Number of pixels for space after newline.

Definition at line 101 of file app_fonts.c.


Enumeration Type Documentation

Command event ID.

Enumerator:
BUTTON_NEXT_ID 

Command event ID for next page-button.

BUTTON_PREV_ID 

Command event ID for previous page-button.

BUTTON_QUIT_ID 

Command event ID for quit-button.

Definition at line 105 of file app_fonts.c.


Function Documentation

static bool app_fonts_frame_command_handler ( struct wtk_basic_frame frame,
win_command_t  command_data 
) [static]

Frame command handler handling the button events.

Handles all command events received by the application frame. This changes the displayed page, or exits the application.

See also:
wtk_basic_frame_command_handler_t
Parameters:
frame Pointer to the basic frame object
command_data Command data provided with the event, holds button ID
Returns:
true when application is exiting, false otherwise

Definition at line 436 of file app_fonts.c.

References app_desktop_restart(), BUTTON_NEXT_ID, BUTTON_PREV_ID, BUTTON_QUIT_ID, app_fonts::frame, membag_free(), memcpy(), PAGE_NUM_MAX, PAGE_NUM_MIN, app_fonts::page_number, app_fonts::prev_sysfont, sysfont, win_redraw(), and wtk_basic_frame_as_child().

static void app_fonts_frame_draw_handler ( struct win_window win,
const struct win_clip_region clip 
) [static]

Frame draw handler.

Handles all draw events received by the application frame. This draws the currently selected page to screen.

See also:
wtk_basic_frame_draw_handler_t
Parameters:
win Pointer to the basic frame's window.
clip Pointer to data for clipping region.

Definition at line 389 of file app_fonts.c.

References PAGE_NUM_BLANK_SCREEN, app_fonts::page_number, screen_draw_fonts_info(), screen_draw_fonts_list(), screen_draw_language_info(), screen_draw_messages(), screen_draw_splash(), and unhandled_case.

void app_fonts_launch ( struct workqueue_task task  ) 

Launches the application.

Allocates and initializes the context, then allocates the basic frame and button widgets that make up the application. Loading of the necessary fonts is then scheduled, unless they have already been loaded.

Parameters:
task Workqueue task to use with application
static status_t app_fonts_load ( void   )  [static]

Schedules loading of next non-loaded font.

This function will schedule loading the next font not already loaded to hugemem. It will also update the progress bar each time a newfont is successfully scheduled to be loaded.

Return values:
ERR_IO_ERROR if font is not present on file system, or other errors
ERR_BUSY when scheduling loading a font
STATUS_OK when all fonts are loaded successfully

Definition at line 548 of file app_fonts.c.

References app_fonts::current_font_loading, ERR_BUSY, ERR_IO_ERROR, font::hugemem, HUGEMEM_NULL, load_file_to_hugemem(), app_fonts::progress_bar, STATUS_OK, app_fonts::task, win_destroy(), wtk_progress_bar_as_child(), and wtk_progress_bar_set_value().

Referenced by app_fonts_load_worker().

static void app_fonts_load_worker ( struct workqueue_task task  )  [static]

Setup the font objects after loading fonts from the file system.

This function is called when a font has been loaded from the file system. It will setup the font object with the data read. Afterwards it will try to load the next font, until done.

When the function is done loading all the fonts, the initial page is shown on the screen.

Parameters:
task Pointer to work queue task

Definition at line 487 of file app_fonts.c.

References app_desktop_restart(), app_fonts_load(), assert, app_fonts::btn_exit, app_fonts::btn_next, app_fonts::btn_prev, app_fonts::current_font_loading, ERR_BUSY, font::first_char, FONT_HEADER_SIZE, app_fonts::frame, font::height, font::hugemem, hugemem_read_block(), font::last_char, membag_free(), memcpy(), PAGE_NUM_MIN, app_fonts::page_number, app_fonts::prev_sysfont, STATUS_OK, sysfont, font::width, win_destroy(), win_redraw(), win_show(), wtk_basic_frame_as_child(), and wtk_button_as_child().

static void draw_font_box ( gfx_coord_t  y,
struct font font,
char *  fontname 
) [static]

Draw a filled box on the screen starting at line y.

This function draws a filled box containing a demonstration of a given font. It will output the fontname and print the "The Quick Brown Fox Jumps Over the Lazy Dog" string in this font.

Parameters:
y Y coordinate to draw the box at.
font Pointer to font metadata.
fontname Pointer to string with font name.

Definition at line 179 of file app_fonts.c.

References COLOR_FILL, COLOR_FILL_BORDER, COLOR_TEXT, GFX_COLOR_TRANSPARENT, gfx_draw_filled_rect, gfx_draw_rect, gfx_draw_string(), gfx_get_width(), font::height, font::scale, TEXT_INDENT, TEXT_PADDING, and TEXT_PADDING_NEWLINE.

Referenced by screen_draw_fonts_list().

static void screen_draw_fonts_info ( void   )  [static]

Draw the fonts info page.

This function will print generic information about the font system to the screen.

Definition at line 218 of file app_fonts.c.

References COLOR_FILL, COLOR_TEXT, GFX_COLOR_TRANSPARENT, gfx_draw_horizontal_line, gfx_draw_string(), gfx_get_width(), font::height, font::scale, TEXT_INDENT, TEXT_PADDING, and TEXT_PADDING_NEWLINE.

Referenced by app_fonts_frame_draw_handler().

static void screen_draw_fonts_list ( void   )  [static]

Draw the fonts list page.

This function will print the name and a test string of the four fonts loaded in the application to the screen.

Definition at line 276 of file app_fonts.c.

References draw_font_box(), font::height, font::scale, sysfont, TEXT_PADDING, and TEXT_PADDING_NEWLINE.

Referenced by app_fonts_frame_draw_handler().

static void screen_draw_language_info ( void   )  [static]

Draw the language information page.

This function will print information regarding use of multiple fonts and different languages with the Graphics display system.

Definition at line 298 of file app_fonts.c.

References COLOR_FILL, COLOR_TEXT, GFX_COLOR_TRANSPARENT, gfx_draw_horizontal_line, gfx_draw_string(), gfx_get_width(), font::height, font::scale, TEXT_INDENT, TEXT_PADDING, and TEXT_PADDING_NEWLINE.

Referenced by app_fonts_frame_draw_handler().

static void screen_draw_messages ( void   )  [static]

Draw the messages in different languages page.

This function will print some typical strings in different languages to the screen, using different types of fonts. The hardcoded string positions are spread across the display for presentational purposes.

Definition at line 342 of file app_fonts.c.

References COLOR_TEXT, GFX_COLOR_TRANSPARENT, gfx_draw_string(), and sysfont.

Referenced by app_fonts_frame_draw_handler().

static void screen_draw_splash ( void   )  [static]

Draw the fonts introduction splash page.

This function will print two strings to the center of the screen.

Definition at line 203 of file app_fonts.c.

References COLOR_TEXT, COLOR_TEXT_SHADED, GFX_COLOR_TRANSPARENT, and gfx_draw_string().

Referenced by app_fonts_frame_draw_handler().


Variable Documentation

struct font font_ericat [static]
Initial value:
 {
        .type           = FONT_LOC_HUGEMEM,
        .scale          = 1,
}

Erica Type.

Definition at line 141 of file app_fonts.c.

struct font font_fixedrus [static]
Initial value:
 {
        .type           = FONT_LOC_HUGEMEM,
        .scale          = 1,
}

Fixed-width Russian.

Definition at line 147 of file app_fonts.c.

struct font font_larabie [static]
Initial value:
 {
        .type           = FONT_LOC_HUGEMEM,
        .scale          = 1,
}

Larabie.

Definition at line 153 of file app_fonts.c.

struct font font_monofur [static]
Initial value:
 {
        .type           = FONT_LOC_HUGEMEM,
        .scale          = 1,
}

Monofur.

Definition at line 159 of file app_fonts.c.

struct app_fonts* the_fonts_app [static]

Statically allocated context pointer.

Definition at line 166 of file app_fonts.c.

Generated on Thu Apr 29 14:09:59 2010 for display-demo by  doxygen 1.6.3