CHDK_DE Vorschauversion  Trunk Rev. 5234
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
font.h-Dateireferenz
+ Dieser Graph zeigt, welche Datei direkt oder indirekt diese Datei enthält:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define FONT_CP_WIN   0
 
#define FONT_CP_DOS   1
 
#define FONT_CP_WIN_1250   0
 
#define FONT_CP_WIN_1251   1
 
#define FONT_CP_WIN_1252   2
 
#define FONT_CP_WIN_1253   3 /* 1253 (Greek) */
 
#define FONT_CP_WIN_1254   4
 
#define FONT_CP_WIN_1257   5
 

Funktionen

void font_set (int codepage)
 
unsigned char * get_current_font_data (unsigned char ch)
 
int rbf_load_symbol (char *file)
 
void rbf_load_from_file (char *file, int codepage)
 
int rbf_font_height ()
 
int rbf_symbol_height ()
 
int rbf_char_width (int ch)
 
int rbf_symbol_width (int ch)
 
int rbf_str_width (const char *str)
 
void rbf_set_codepage (int codepage)
 
int rbf_draw_char (int x, int y, int ch, twoColors cl)
 
int rbf_draw_symbol (int x, int y, int ch, twoColors cl)
 
int rbf_draw_string (int x, int y, const char *str, twoColors cl)
 
int rbf_draw_clipped_string (int x, int y, const char *str, twoColors cl, int l, int maxlen)
 
int rbf_draw_string_len (int x, int y, int len, const char *str, twoColors cl)
 
int rbf_draw_string_right_len (int x, int y, int len, const char *str, twoColors cl)
 
int rbf_draw_menu_header (int x, int y, int len, char symbol, const char *str, twoColors cl)
 
void rbf_enable_cursor (int s, int e)
 
void rbf_disable_cursor ()
 

Variablen

unsigned char fontdata_lookup []
 

Makro-Dokumentation

#define FONT_CP_DOS   1

Definiert in Zeile 11 der Datei font.h.

#define FONT_CP_WIN   0

Definiert in Zeile 10 der Datei font.h.

#define FONT_CP_WIN_1250   0

Definiert in Zeile 13 der Datei font.h.

#define FONT_CP_WIN_1251   1

Definiert in Zeile 14 der Datei font.h.

#define FONT_CP_WIN_1252   2

Definiert in Zeile 15 der Datei font.h.

#define FONT_CP_WIN_1253   3 /* 1253 (Greek) */

Definiert in Zeile 16 der Datei font.h.

#define FONT_CP_WIN_1254   4

Definiert in Zeile 17 der Datei font.h.

#define FONT_CP_WIN_1257   5

Definiert in Zeile 18 der Datei font.h.

Dokumentation der Funktionen

void font_set ( int  codepage)

Definiert in Zeile 18 der Datei font_8x16.c.

19 {
20  // Save selected codepage
21  current_cp = codepage;
22 }
unsigned char* get_current_font_data ( unsigned char  ch)

Definiert in Zeile 8 der Datei font_8x16.c.

9 {
10  // Test for 'common' char?
11  if (ch < 128)
12  return font_data + cp_common[ch];
13  // If not return value from current codepage
14  return font_data + codepages[current_cp][ch-128];
15 }
int rbf_char_width ( int  ch)

Definiert in Zeile 283 der Datei rbf_font.c.

283  {
284  return rbf_font->wTable[code_page_char(ch)];
285 }
void rbf_disable_cursor ( )

Definiert in Zeile 404 der Datei rbf_font.c.

405 {
406  cursor_on = 0;
407 }
int rbf_draw_char ( int  x,
int  y,
int  ch,
twoColors  cl 
)

Definiert in Zeile 323 der Datei rbf_font.c.

323  {
324  // Convert char for code page
325  ch = code_page_char(ch);
326 
327  // Get char data pointer
328  char* cdata = rbf_font_char(rbf_font, ch);
329 
330  // Draw font character (either loaded font, or from default font)
331  if (rbf_font->usingFont8x16 || !cdata)
332  draw_char(x,y,ch,cl);
333  else
335 
336  return rbf_font->wTable[ch];
337 }
int rbf_draw_clipped_string ( int  x,
int  y,
const char *  str,
twoColors  cl,
int  l,
int  maxlen 
)

Definiert in Zeile 409 der Datei rbf_font.c.

410 {
411  int i = 0;
412  twoColors inv_cl = MAKE_COLOR(FG_COLOR(cl), BG_COLOR(cl));
413 
414  // Draw chars from string up to max pixel length
415  while (*str && l+rbf_char_width(*str)<=maxlen)
416  {
417  if (cursor_on && (cursor_start <= i) && (i <= cursor_end))
418  l+=rbf_draw_char(x+l, y, *str++, inv_cl);
419  else
420  l+=rbf_draw_char(x+l, y, *str++, cl);
421  i++;
422  }
423 
424  return l;
425 }
int rbf_draw_menu_header ( int  x,
int  y,
int  len,
char  symbol,
const char *  str,
twoColors  cl 
)

Definiert in Zeile 455 der Datei rbf_font.c.

455  {
456  int l=0, i, ll, lr;
457 
458  // If symbol to be added to string determing the width of the symbol + space
459  if (symbol!=0x0 && conf.menu_symbol_enable && rbf_font_height()>=rbf_symbol_height()) {
460  l += rbf_symbol_width(symbol);
461  l += rbf_char_width(' ');
462  }
463 
464  // Add the length of the string (possibly clipped to fit)
465  l = rbf_str_clipped_width(str, l, len);
466 
467  // Calculate padding required on left and right side
468  ll = 8;
469  lr = len-l-ll;
470 
471  int right = x+len-1, bottom = y+rbf_font_height()-1;
472 
473  // Fill left & right sides of string area with a rectangle that has rounded top corners
474  for (i=0; i<=l && i<3; i++) {
475  if (i < 2) {
476  // First and second columns make rounded top corners
477  draw_line(x+i, y+2-i, x+i, bottom, BG_COLOR(cl)); // left side
478  draw_line(right-i, y+2-i, right-i, bottom, BG_COLOR(cl)); // right side
479  }
480  else {
481  // Rest of empty space is just filled with rectangles
482  draw_rectangle(x+i, y, x+ll-1, bottom, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl)), RECT_BORDER0|DRAW_FILLED); // left side
483  draw_rectangle(right-lr, y, right-i, bottom, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl)), RECT_BORDER0|DRAW_FILLED); // right side
484  }
485  }
486 
487  // Draw symbol and space if required
488  if (symbol!=0x0 && conf.menu_symbol_enable && rbf_font_height()>=rbf_symbol_height()) {
489  ll += rbf_draw_symbol(x+ll, y, symbol, cl);
490  ll += rbf_draw_char(x+ll, y, ' ', cl);
491  }
492 
493  // Draw chars
494  ll = rbf_draw_clipped_string(x, y, str, cl, ll, len);
495 
496  return ll;
497 }
int rbf_draw_string ( int  x,
int  y,
const char *  str,
twoColors  cl 
)

Definiert in Zeile 388 der Datei rbf_font.c.

388  {
389  return rbf_draw_string_c(x, y, str, cl, -1, MAKE_COLOR(0,0));
390 }
int rbf_draw_string_len ( int  x,
int  y,
int  len,
const char *  str,
twoColors  cl 
)

Definiert in Zeile 428 der Datei rbf_font.c.

428  {
429  // Draw string characters
430  int l = rbf_draw_clipped_string(x, y, str, cl, 0, len);
431 
432  // Fill any remaining space on right with background color
433  if (l < len)
435 
436  return len;
437 }
int rbf_draw_string_right_len ( int  x,
int  y,
int  len,
const char *  str,
twoColors  cl 
)

Definiert in Zeile 440 der Datei rbf_font.c.

440  {
441  // Calulate amount of padding needed on the left
442  int l = len - rbf_str_clipped_width(str, 0, len);
443 
444  // Fill padding with background color
445  if (l > 0)
447 
448  // Draw chars
449  l = rbf_draw_clipped_string(x, y, str, cl, l, len);
450 
451  return l;
452 }
int rbf_draw_symbol ( int  x,
int  y,
int  ch,
twoColors  cl 
)

Definiert in Zeile 340 der Datei rbf_font.c.

340  {
341  int space=0, pixel_width, sym_height, txt_height;
342 
343  // Skip if symbol font height taller than text font height (or invalid char value)
344  if (rbf_font->hdr.height<rbf_symbol_font->hdr.height || ch==0x0) return 0;
345 
346  // get width of symbol in pixels
347  pixel_width = rbf_symbol_width(ch);
348  // get height of symbol font
349  sym_height = rbf_symbol_font->hdr.height;
350  // get height of text font
351  txt_height = rbf_font->hdr.height;
352 
353  // Get char data pointer
354  char* cdata = rbf_font_char(rbf_symbol_font, ch);
355 
356  if (cdata) {
357  // if symbol font shorter than text font center symbol vertically and fill empty space above
358  if (txt_height > sym_height) {
359  space = (txt_height - sym_height)/2;
361  y+=space;
362  }
363 
364  // Draw font character
365  font_draw_char(x, y, cdata, rbf_symbol_font->width, sym_height, pixel_width, cl);
366 
367  // Fill space below symbol if shorter than text font
368  if (txt_height > sym_height)
369  draw_rectangle(x, y+sym_height, x+pixel_width, y-space+txt_height-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl)), RECT_BORDER0|DRAW_FILLED);
370  }
371 
372  return pixel_width;
373 }
void rbf_enable_cursor ( int  s,
int  e 
)

Definiert in Zeile 397 der Datei rbf_font.c.

398 {
399  cursor_on = 1;
400  cursor_start = s;
401  cursor_end = e;
402 }
int rbf_font_height ( )

Definiert in Zeile 274 der Datei rbf_font.c.

274  {
275  return rbf_font->hdr.height;
276 }
void rbf_load_from_file ( char *  file,
int  codepage 
)

Definiert in Zeile 243 der Datei rbf_font.c.

244 {
245  // Allocate font if needed
246  init_fonts();
247  // Load font, load default on failure
248  if (!rbf_font_load(file, rbf_font, 0))
249  {
250  // Reset back to built in font, file load failed
254  rbf_font->hdr.charFirst = 0;
255  rbf_font->hdr.charLast = 255;
256 
257  // This is only ever called to copy the 'current_font' data into the rbf_font
258  // Instead of doing this set the rbf_font flag so we call 'draw_char' directly (which uses current_font)
259  // This avoids allocating memory for a copy of something we already have
260  rbf_font->usingFont8x16 = 1;
261 
263  }
264  // Set codepage
265  rbf_set_codepage(codepage);
266 }
int rbf_load_symbol ( char *  file)

Definiert in Zeile 234 der Datei rbf_font.c.

234  {
235  // Allocate font if needed
236  init_fonts();
237  // Load font
238  return rbf_font_load(file, rbf_symbol_font, maxSymbols+32);
239 }
void rbf_set_codepage ( int  codepage)

Definiert in Zeile 269 der Datei rbf_font.c.

269  {
270  rbf_codepage = codepage;
271 }
int rbf_str_width ( const char *  str)

Definiert in Zeile 293 der Datei rbf_font.c.

293  {
294  int l=0;
295 
296  // Calculate how long the string is in pixels
297  while (*str)
298  l+=rbf_char_width(*str++);
299 
300  return l;
301 }
int rbf_symbol_height ( )

Definiert in Zeile 278 der Datei rbf_font.c.

278  {
279  return rbf_symbol_font->hdr.height;
280 }
int rbf_symbol_width ( int  ch)

Definiert in Zeile 288 der Datei rbf_font.c.

288  {
289  return rbf_symbol_font->wTable[ch];
290 }

Variablen-Dokumentation

unsigned char fontdata_lookup[]

Definiert in Zeile 21 der Datei font_8x16_pack.c.