eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_font.c
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #include "d4d.h"
49 
50 #if (D4D_EXTSRC_FILE_ENABLE != D4D_FALSE) && (D4D_FNT_EXTSRC_SUPPORT != D4D_FALSE)
51  static D4D_CHAR* pFntWorkPath = D4D_FNT_WORK_PATH_DEFAULT;
52  static D4D_FONT_TYPE * d4d_FontTableRam = NULL;
53  static Byte D4D_GetFontTableEntries(D4D_FONT_TYPE* fontTable);
54 #endif
55 
56  typedef struct
57  {
58  LWord row;
59  LWord clm;
60  LWord char_width;
61  D4D_FONT_DATA* pFntData;
62  D4D_FONT_DESCRIPTOR* pFontDescriptor;
63  }CHAR_PXL_DESC;
64 
65  typedef struct
66  {
67  D4D_FONT_DESCRIPTOR * pFontDescriptor;
68  D4D_FONT_IX index;
69  }FNT_CHAR_PLACE;
70 
71 
72 static FNT_CHAR_PLACE D4D_LCD_GetCharPlace(const D4D_FONT_DESCRIPTOR * pFontDescriptorStart, D4D_TCHAR ch);
73 
75 static D4D_FONT_DATA* D4D_GetCharData(FNT_CHAR_PLACE* char_place);
76 
77 #if (D4D_FONT_TABLE_DISABLED == D4D_FALSE)
79 #endif
80 
81 #if (D4D_EXTSRC_FILE_ENABLE != D4D_FALSE) && (D4D_FNT_EXTSRC_SUPPORT != D4D_FALSE)
82 
83  /**************************************************************/
88  static Byte D4D_GetFontTableEntries(D4D_FONT_TYPE* fontTable)
89  {
90  Byte i = 0;
91 
92  if(fontTable != NULL)
93 
94 
95  while(fontTable[i].pFontDescriptor || fontTable[i].fileName)
96  i++;
97 
98  return i;
99  }
100 
101  /**************************************************************/
106  D4D_BOOL D4D_ExtFntInit(void)
107  {
108  LWord i,j;
109 
110  // Free possible previous font table
111  if(d4d_FontTableRam)
112  {
113  i = 0;
114  while(d4d_pFontTable[i].pFontDescriptor || d4d_pFontTable[i].fileName)
115  {
116  // Standard local memory based font?
117  if(d4d_pFontTable[i].fileName != NULL)
118  {
119  // external file that should be loaded into RAM to be able to use it
120 
121  // 1. clear possible previous allocated RAM
122  if(d4d_FontTableRam[i].pFontDescriptor)
123  D4D_MemFree((void*)d4d_FontTableRam[i].pFontDescriptor);
124  }
125  i++;
126  }
127 
128  D4D_MemFree(d4d_FontTableRam);
129  }
130  j = (sizeof(D4D_FONT_TYPE) * (D4D_GetFontTableEntries(d4d_pFontTable) + 1));
131 
132  // Allocate the new place for the font table
133  d4d_FontTableRam = D4D_MemAlloc(j);
134 
135  if(d4d_FontTableRam == NULL)
136  return D4D_FALSE;
137 
138  //Clear up the d4d_FontTableRam structure
139  for(i = 0; i < j; i++)
140  ((Byte*)d4d_FontTableRam)[i] = 0;
141 
142  // Load to RAM the font tables
143  D4D_ExtFntSetWorkPath(pFntWorkPath);
144 
145  d4d_pFontTable = d4d_FontTableRam;
146 
147  return D4D_TRUE;
148  }
149 
150  /**************************************************************/
155  void D4D_ExtFntSetWorkPath(D4D_CHAR* pPath)
156  {
157  Byte i=0;
158  D4D_FILEPTR pFile;
159  LWord fileSize;
160  D4D_FONT_DESCRIPTOR* pFntDesc;
161  if(pPath)
162  pFntWorkPath = pPath;
163 
164  // create the new font table from template and also copy the new fonts to the RAM
165 
166  while(d4d_pFontTable[i].pFontDescriptor || d4d_pFontTable[i].fileName)
167  {
168  // Standard local memory based font?
169  if(d4d_pFontTable[i].fileName == NULL)
170  {
171  // just copy to RAM version of font table
172  d4d_FontTableRam[i] = d4d_pFontTable[i];
173  }else
174  {
175  // external file that should be loaded into RAM to be able to use it
176 
177  // 1. clear possible previous allocated RAM
178  if(d4d_FontTableRam[i].pFontDescriptor)
179  D4D_MemFree((void*)d4d_FontTableRam[i].pFontDescriptor);
180 
181  // 2. just copy to RAM version of font table
182  d4d_FontTableRam[i] = d4d_pFontTable[i];
183 
184  // 3. try to open the font file
185  pFile = D4D_OpenFntFile((void*)d4d_pFontTable[i].fileName);
186 
187  // 4. if the file can't be opened, just go to next font
188  if(pFile == NULL)
189  {
190  i++;
191  continue;
192  }
193  // 5. Get the size of file
194  if(D4D_FileSeek(pFile, 0, D4D_SEEK_END) != 0)
195  {
196  D4D_FileClose(pFile);
197  i++;
198  continue;
199  }
200 
201  fileSize = D4D_FileTell(pFile);
202 
203  // Return the file location to start
204  if(D4D_FileSeek(pFile, 0, D4D_SEEK_SET) != 0)
205  {
206  D4D_FileClose(pFile);
207  i++;
208  continue;
209  }
210 
211  // 6. Alloc the memory on heap for the data
212  d4d_FontTableRam[i].pFontDescriptor = D4D_MemAlloc(fileSize + 16);
213 
214  if(d4d_FontTableRam[i].pFontDescriptor == NULL)
215  {
216  D4D_FileClose(pFile);
217  i++;
218  continue;
219  }
220 
221  // 7. Copy the content of file to RAM
222  if(D4D_FileRead(pFile, d4d_FontTableRam[i].pFontDescriptor, fileSize) != fileSize)
223  {
224  D4D_MemFree(d4d_FontTableRam[i].pFontDescriptor);
225  d4d_FontTableRam[i].pFontDescriptor = NULL;
226  D4D_FileClose(pFile);
227  i++;
228  continue;
229  }
230 
231  // 8. Adjust the used pointers in all loaded structures
232  pFntDesc = d4d_FontTableRam[i].pFontDescriptor;
233 #ifdef D4D_UNICODE
234  while((pFntDesc != NULL) && ((pFntDesc - d4d_FontTableRam[i].pFontDescriptor) <= fileSize))
235  {
236 #endif
237  if(pFntDesc->pIxTable)
238  *(LWord*)&(pFntDesc->pIxTable) += (LWord)pFntDesc;
239 
240  if(pFntDesc->pOffTable)
241  *(LWord*)&(pFntDesc->pOffTable) += (LWord)pFntDesc;
242 
243  if(pFntDesc->pSizeTable)
244  *(LWord*)&(pFntDesc->pSizeTable) += (LWord)pFntDesc;
245 
246  if(pFntDesc->pFontData)
247  *(LWord*)&(pFntDesc->pFontData) += (LWord)pFntDesc;
248 #ifdef D4D_UNICODE
249  if(pFntDesc->pNext)
250  {
251  *(LWord*)&(pFntDesc->pNext) += (LWord)pFntDesc;
252  pFntDesc = (D4D_FONT_DESCRIPTOR*)pFntDesc->pNext;
253  }
254  else
255  pFntDesc = NULL;
256  }
257 #endif
258  }
259  i++;
260  }
261  }
262 
263  /**************************************************************/
268  void D4D_ExtFntSetDfltWorkPath(void)
269  {
270  D4D_ExtFntSetWorkPath(D4D_FNT_WORK_PATH_DEFAULT);
271  }
272  /**************************************************************/
277  D4D_CHAR* D4D_ExtFntGetWorkPath(void)
278  {
279  return pFntWorkPath;
280  }
281 
282  /**************************************************************/
287  D4D_FILEPTR D4D_OpenFntFile(D4D_CHAR* pFileName)
288  {
289  // create the file name (if needed)
290  if(D4D_FileIsAbsolutePath(pFileName))
291  {
292  // the input path is absolute and can't be changed
293  return D4D_FileOpen(pFileName,"r");
294  }
295  else
296  {
297  // the input path is relative and must be updated with preselected image work paths
298  if(D4D_StrLen(pFntWorkPath) + D4D_StrLen(pFileName) >= D4D_EXTSRC_BUFF_SIZE)
299  return NULL;
300 
301  D4D_StrCopy((D4D_CHAR*)d4d_extsrcBuffer, pFntWorkPath);
302  D4D_StrCat((D4D_CHAR*)d4d_extsrcBuffer, pFileName);
303  return D4D_FileOpen((D4D_CHAR*)d4d_extsrcBuffer,"r");
304  }
305 
306  }
307 #endif
308 
309 /**************************************************************/
315 {
316  if(pFontTable == d4d_pFontTable)
317  return;
318 
319  if(pFontTable == NULL)
320  d4d_pFontTable = (D4D_FONT_TYPE*)&d4d_FontTable;
321  else
322  d4d_pFontTable = pFontTable;
323 
324 #if (D4D_EXTSRC_FILE_ENABLE != D4D_FALSE) && (D4D_FNT_EXTSRC_SUPPORT != D4D_FALSE)
325  D4D_ExtFntInit();
326 #endif
327 
328 }
329 
331 {
332  return d4d_pFontTable;
333 }
334 /**************************************************************/
341 {
342 
343 #if (D4D_FONT_TABLE_DISABLED == D4D_TRUE)
344  D4D_UNUSED(ix);
345  return NULL;
346 #else
347  Byte i=0;
348 
349  while(d4d_pFontTable[i].pFontDescriptor != NULL)
350  {
351  if(d4d_pFontTable[i].ix_font == ix)
352  return (D4D_FONT_TYPE*) &(d4d_pFontTable[i]);
353  i++;
354  }
355  return NULL;
356 #endif
357 }
358 
359 /**************************************************************/
366 {
367  D4D_FONT_SIZES tmpFontSize;
368 
369  tmpFontSize.height = D4D_GetFontHeight(ix);
370  tmpFontSize.width = D4D_GetFontWidth(ix);
371  return tmpFontSize;
372 }
373 
374 
375 /**************************************************************/
382 {
383  D4D_FONT_TYPE* pFontType = D4D_GetFont(ix);
384  D4D_FONT_DESCRIPTOR* pFontDescriptor = (D4D_FONT_DESCRIPTOR*)(pFontType->pFontDescriptor);
385 
386  if(pFontType != NULL)
387  return (D4D_FONT_SIZE)((pFontType->scale.height * pFontDescriptor->charFullSize.height) + pFontType->charSpacing.height);
388 
389  return (D4D_FONT_SIZE) 0;
390 }
391 
392 /**************************************************************/
399 {
400  D4D_FONT_TYPE* pFontType = D4D_GetFont(ix);
401  D4D_FONT_DESCRIPTOR* pFontDescriptor = (D4D_FONT_DESCRIPTOR*)(pFontType->pFontDescriptor);
402 
403  if(pFontType != NULL)
404  return (D4D_FONT_SIZE)((pFontType->scale.width * pFontDescriptor->charFullSize.width) + pFontType->charSpacing.width);
405 
406  return (D4D_FONT_SIZE) 0;
407 }
408 
409 /**************************************************************/
416 {
417  D4D_FONT_TYPE* pFontType = D4D_GetFont(ix);
418  D4D_FONT_SIZE tmp_width = 0;
419  FNT_CHAR_PLACE char_place;
420  if(NULL == pFontType)
421  return 0;
422 
423  if(ch < ' ')
424  return 0;
425 
426  if(pFontType->pFontDescriptor == NULL)
427  return 0;
428 
429  char_place = D4D_LCD_GetCharPlace(pFontType->pFontDescriptor, ch);
430 
431  if(char_place.pFontDescriptor == NULL)
432  return 0;
433 
434  if(char_place.pFontDescriptor->flags & D4D_FONT_FLAGS_FNT_WIDTH_PROPORTIONAL)
435  {
436  // Get the raw width of char
437  tmp_width = char_place.pFontDescriptor->pSizeTable[char_place.index];
438  }else
439  tmp_width = char_place.pFontDescriptor->charFullSize.width;
440 
441  // Apply the scale for the char width
442  tmp_width *= pFontType->scale.width;
443  // Add the char spacing
444  tmp_width += pFontType->charSpacing.width;
445 
446  // return the char width
447  return tmp_width;
448 }
449 
450 
451 
452 /**************************************************************/
459 {
460  D4D_FONT_IX char_ix = (D4D_FONT_IX)(ch - pFontDescriptor->startChar);
461 
462  // is the indes table linear or nonlinear?
463  if(pFontDescriptor->flags & D4D_FONT_FLAGS_IX_STYLE_NONLINEAR)
464  {
465  // Index table is used?
466  if(pFontDescriptor->pIxTable != NULL)
467  {
468  if(pFontDescriptor->flags & D4D_FONT_FLAGS_IX_TYPE_MAP)
469  {
470  // Map style of Index Table
471  D4D_FONT_IX i;
472  // Look for the used char in index map table
473  for(i = 0; i < pFontDescriptor->charCnt; i++)
474  {
475  if(ch == pFontDescriptor->pIxTable[i])
476  return i;
477  }
478  }else
479  {
480  // check if the char is set into range of used font
481  if(char_ix < pFontDescriptor->charCnt)
482  // Look up style of Index Table
483  return pFontDescriptor->pIxTable[char_ix];
484  }
485  }
486  }else
487  {
488  // check if the char is set into range of used font
489  if(char_ix < pFontDescriptor->charCnt)
490  return char_ix;
491  }
492 
493  // return the "real table index" of used car
494  return -1;
495 }
496 
497 /**************************************************************/
502  static FNT_CHAR_PLACE D4D_LCD_GetCharPlace(const D4D_FONT_DESCRIPTOR * pFontDescriptorStart, D4D_TCHAR ch)
503  {
504  FNT_CHAR_PLACE result = { NULL, 0};
505  D4D_FONT_DESCRIPTOR * pFontDescriptor = (D4D_FONT_DESCRIPTOR *)pFontDescriptorStart;
506  D4D_INDEX_DELTA char_ix;
507 
508  if(!pFontDescriptor)
509  return result;
510 
511  do{
512  #ifdef D4D_UNICODE
513  while (pFontDescriptor)
514  {
515  if((ch & 0xff00) == (pFontDescriptor->startChar & 0xff00))
516  break;
517 
518  pFontDescriptor = (D4D_FONT_DESCRIPTOR *)pFontDescriptor->pNext;
519  }
520  #endif
521 
522  if(pFontDescriptor && ((char_ix = D4D_GetCharIndex((D4D_FONT_DESCRIPTOR*)pFontDescriptor, ch)) >= 0 ))
523  {
524  // The char was found , so everything is perfect
525  result.pFontDescriptor = pFontDescriptor;
526  result.index = (D4D_FONT_IX)char_ix;
527  break;
528  }else
529  {
530  // The char is not part of this page
531 
532  // check if the the char what we are looking for isn't default one
533  // if yes and we not able to find it go out
534  if(ch == pFontDescriptorStart->charDefault)
535  break;
536 
537  // we have to look for default char
538  ch = pFontDescriptorStart->charDefault;
539  pFontDescriptor = (D4D_FONT_DESCRIPTOR *)pFontDescriptorStart;
540  }
541 
542  }while(1);
543 
544  return result;
545  }
546 
547 
548 /**************************************************************/
554 D4D_FONT_DATA* D4D_GetCharData(FNT_CHAR_PLACE* char_place) {
555 
556  if(!char_place)
557  return NULL;
558 
559  if(!char_place->pFontDescriptor)
560  return NULL;
561 
562  // check the style of font monospace / proportional
563  if(char_place->pFontDescriptor->flags & D4D_FONT_FLAGS_FNT_WIDTH_PROPORTIONAL) {
564  // Proportinal font is used
565 
566  // Check if Offset table exist
567  if(char_place->pFontDescriptor->pOffTable == NULL)
568  return NULL;
569 
570  return (D4D_FONT_DATA*)(char_place->pFontDescriptor->pFontData + char_place->pFontDescriptor->pOffTable[char_place->index]);
571  }
572 
573  // Monospace font is used
574  return (D4D_FONT_DATA*)(char_place->pFontDescriptor->pFontData + char_place->index * char_place->pFontDescriptor->charBmpSize);
575 }
576 
577 /**************************************************************/
585 static D4D_BOOL D4D_LCD_GetFntBit(CHAR_PXL_DESC * pPxlDesc) {
586 
587  LWord bit_cnt;
588  Byte data;
589 
590  // This is decoder only for fonts that are row scan based and preffered !!!
591  if(pPxlDesc->pFontDescriptor->pack & D4D_FONT_PACK_SCANPREFERRED_COLUMN)
592  return 0;
593 
594  if(pPxlDesc->pFontDescriptor->pack & D4D_FONT_PACK_SCANBASED_COLUMN)
595  return 0;
596 
597 
598  if(pPxlDesc->pFontDescriptor->pack & D4D_FONT_PACK_COMPRESSED_ON) {
599  // data are packed in bit stream
600  bit_cnt = (Word)(pPxlDesc->char_width * pPxlDesc->row + pPxlDesc->clm);
601  data = pPxlDesc->pFntData[bit_cnt / 8];
602  }else
603  {
604  // data aren't packed
605  LWord byte_cnt;
606  byte_cnt = (Word)((((pPxlDesc->char_width - 1) / 8) + 1) * pPxlDesc->row); // get the start of row index of data
607  byte_cnt += (pPxlDesc->clm / 8); // add the collumn index move
608  data = pPxlDesc->pFntData[byte_cnt]; // get the data byte
609  bit_cnt = (Byte)(pPxlDesc->clm % 8); // get position of bit in byte for this pixel
610  }
611 
612  if(pPxlDesc->pFontDescriptor->pack & D4D_FONT_PACK_BITORDER_LITTLEEND)
613  return (D4D_BOOL)((data >> (bit_cnt % 8)) & 0x01); // little endian decoding
614  else
615  return (D4D_BOOL)((data << (bit_cnt % 8)) & 0x80); // big endian decoding
616 }
617 
619 {
620  D4D_INDEX ix = 0;
621 
622  if(pTab == NULL)
623  return 0;
624 
625  if(pTab->pTabTable == NULL)
626  return 0;
627 
628  while(pTab->pTabTable[ix])
629  {
630  if((pos + pTab->tabOffset) < pTab->pTabTable[ix])
631  return (D4D_COOR)(pTab->pTabTable[ix] /*- pTab->tabOffset*/);
632 
633  ix++;
634  }
635 
636  return 0;
637 
638 }
639 
640 /**************************************************************/
646 {
647  D4D_FONT_SIZE xScale, yScale;
648  LWord row_cnt;
649  LWord bit_cnt;
650  LWord px_cnt;
651  LWord yScale_cnt;
652  D4D_COLOR clr;
653  D4D_FONT_TYPE* pFontType = (D4D_FONT_TYPE*)p_CharDes->pFontType;
654  CHAR_PXL_DESC pxlDesc;
655  FNT_CHAR_PLACE char_place;
656 
657  if(pFontType == NULL)
658  return 0;
659 
660  pxlDesc.pFontDescriptor = (D4D_FONT_DESCRIPTOR*)(pFontType->pFontDescriptor);
661 
662  if(!pxlDesc.pFontDescriptor)
663  return 0;
664 
665  if(ch < ' ')
666  {
667  if((ch == '\t') && (p_CharDes->pTab != NULL))
668  {
669  D4D_COOR nextTab;
670  // print tabulator
671  nextTab = D4D_GetNextTab(p_CharDes->pTab, p_CharDes->x);
672 
673  if(nextTab)
674  {
675  D4D_LCD_Box(p_CharDes->x, p_CharDes->y, nextTab,\
676  (D4D_COOR)(p_CharDes->y + D4D_GetFontHeight(p_CharDes->pFontType->ix_font) - 1),\
677  p_CharDes->colorBack);
678  return (D4D_COOR)(nextTab - p_CharDes->x);
679  }
680  }else
681  return 0; // none printable char
682  }
683  xScale = p_CharDes->pFontType->scale.width;
684  yScale = p_CharDes->pFontType->scale.height;
685 
686  char_place = D4D_LCD_GetCharPlace(pxlDesc.pFontDescriptor, ch);
687 
688  if(!char_place.pFontDescriptor)
689  return 0;
690 
691  pxlDesc.pFontDescriptor = char_place.pFontDescriptor;
692 
693 
694  pxlDesc.pFntData = D4D_GetCharData(&char_place); // Get pointer to char bmp data
695 
696  if(pxlDesc.pFontDescriptor->flags & D4D_FONT_FLAGS_FNT_WIDTH_PROPORTIONAL)
697  pxlDesc.char_width = pxlDesc.pFontDescriptor->pSizeTable[char_place.index];
698  else
699  pxlDesc.char_width = pxlDesc.pFontDescriptor->charFullSize.width;
700 
701 
702 
703 #ifndef D4D_COLOR_TRANSPARENT
704 
706  {
707  for (pxlDesc.row=0; pxlDesc.row<pxlDesc.pFontDescriptor->charFullSize.height; ++pxlDesc.row) // For each vertical row of this character
708  {
709  for(pxlDesc.clm = 0; pxlDesc.clm < pxlDesc.char_width; pxlDesc.clm++)
710  {
711  if(D4D_LCD_GetFntBit(&pxlDesc))
712  {
713  D4D_LCD_Box((D4D_COOR)(p_CharDes->x + pFontType->charSpacing.width + pxlDesc.clm * xScale),\
714  (D4D_COOR)(p_CharDes->y + pFontType->charSpacing.height + (pxlDesc.row * yScale)),\
715  (D4D_COOR)(p_CharDes->x + pFontType->charSpacing.width + pxlDesc.clm * xScale + xScale - 1),\
716  (D4D_COOR)(p_CharDes->y + pFontType->charSpacing.height + (pxlDesc.row * yScale) + yScale - 1),\
717  p_CharDes->colorText);
718  }
719  }
720  }
721  }
722  else // if(Transparent)
723 #else
725  p_CharDes->colorBack = D4D_COLOR_TRANSPARENT;
726 
727 #endif
728  {
729  (void)D4D_LLD_LCD.D4DLCD_SetWindow(p_CharDes->x, p_CharDes->y,
730  (D4D_COOR)(p_CharDes->x + D4D_GetCharWidth(p_CharDes->pFontType->ix_font, ch) - 1),
731  (D4D_COOR)(p_CharDes->y + D4D_GetFontHeight(p_CharDes->pFontType->ix_font) - 1)); // Set character window
732 
733  // add on background box on bottom of character to provide line spacing
734  for(row_cnt=0; row_cnt < pFontType->charSpacing.height; ++row_cnt)
735  {
736  for(bit_cnt = 0; bit_cnt < (D4D_COOR)(pxlDesc.char_width * xScale + pFontType->charSpacing.width); ++bit_cnt)
738  }
739 
740 
741  for (pxlDesc.row=0; pxlDesc.row < pxlDesc.pFontDescriptor->charFullSize.height; ++pxlDesc.row) // For each vertical row of this character
742  {
743  for (yScale_cnt=1; yScale_cnt<=yScale; ++yScale_cnt) // As often as needed by the Y-scale factor (e.g. draws complete line twice if double height font is requested)
744  {
745  for (pxlDesc.clm=1; pxlDesc.clm<=pFontType->charSpacing.width; ++pxlDesc.clm)
746  {
747  // empty column = always background color
748  D4D_LLD_LCD.D4DLCD_Send_PixelColor(p_CharDes->colorBack); // draw pixel
749  }
750 
751  for(pxlDesc.clm = 0; pxlDesc.clm < pxlDesc.char_width; ++pxlDesc.clm)
752  {
753  if(D4D_LCD_GetFntBit(&pxlDesc))
754  clr = p_CharDes->colorText;
755  else
756  clr = p_CharDes->colorBack;
757 
758  for (px_cnt=1; px_cnt<=xScale; ++px_cnt) // as often as needed by the horizotal scale factor (e.g. draws pixel twice if double wide font is requested)
759  D4D_LLD_LCD.D4DLCD_Send_PixelColor(clr); // draw pixel
760  }
761  } // draw this line again if needed for scaling
762  }
763  }// next row of this character
764 
765  return (D4D_COOR)(pxlDesc.char_width * xScale + pFontType->charSpacing.width);
766 }
767 
768 
769 
Byte D4D_FONT_SIZE
Definition: d4d_font.h:174
D4D_WCHAR D4D_TCHAR
Type definition of eGUI character (it depends on UNICODE setting if this is D4D_CHAR or D4D_WCHAR)...
Definition: d4d_types.h:284
Byte D4D_FONT
Definition: d4d_font.h:171
D4D_FONT_TYPE * pFontType
Definition: d4d_font.h:220
D4D_FONT_SIZE height
Definition: d4d_font.h:183
D4D_FONT_TYPE * D4D_GetFont(D4D_FONT ix)
Definition: d4d_font.c:340
D4D_CHAR * D4D_StrCopy(register D4D_CHAR *sd, register const D4D_CHAR *ss)
The function copy string one string to other one (terminated by zero)
Definition: d4d_extsrc.c:154
static D4D_BOOL D4D_LCD_GetFntBit(CHAR_PXL_DESC *pPxlDesc)
Definition: d4d_font.c:585
#define D4D_MemAlloc(size)
Mem Alloc eGUI definition. If not defined by user config any special user function, it used standard system function.
Definition: d4d_extsrc.h:320
Byte D4D_FONT_IX
Definition: d4d_font.h:165
D4D_COOR D4D_LCD_PrintChr(D4D_TCHAR ch, D4D_PRINT_DESC *p_CharDes)
Definition: d4d_font.c:645
D4D_COOR * pTabTable
Pointer to tabulator table.
Definition: d4d_types.h:255
Byte D4D_FONT_DATA
Definition: d4d_font.h:170
#define D4D_FALSE
This is definition of boolean operation value in eGUI - FALSE.
Definition: d4d_types.h:104
D4D_COOR tabOffset
Start offset of tabulator.
Definition: d4d_types.h:256
const D4D_FONT_TYPE d4d_FontTable[]
D4D_FONT_SIZES charSpacing
Definition: d4d_font.h:212
D4D_COLOR colorText
Definition: d4d_font.h:222
static D4D_FONT_DATA * D4D_GetCharData(FNT_CHAR_PLACE *char_place)
Definition: d4d_font.c:554
D4D_COOR y
Definition: d4d_font.h:218
D4D_FONT_PROPERTIES properties
Definition: d4d_font.h:224
void D4D_LCD_Box(D4D_COOR x1, D4D_COOR y1, D4D_COOR x2, D4D_COOR y2, D4D_COLOR color)
Definition: d4d_low.c:212
const D4D_FONT_IX * pIxTable
Definition: d4d_font.h:198
#define D4D_TRUE
This is definition of boolean operation value in eGUI - TRUE.
Definition: d4d_types.h:106
const D4D_FONT_OFFSET * pOffTable
Definition: d4d_font.h:199
D4D_FONT_TYPE * D4D_GetFontTable(void)
Definition: d4d_font.c:330
D4D Driver main header file.
void D4D_SetFontTable(D4D_FONT_TYPE *pFontTable)
Definition: d4d_font.c:314
struct D4D_FONT_DESCRIPTOR_S * pNext
Definition: d4d_font.h:202
#define D4D_FNT_WORK_PATH_DEFAULT
D4D_FNT_WORK_PATH_DEFAULT constant default declaration (&quot;a:\\&quot;)
Definition: d4d_extsrc.h:72
#define D4D_FileOpen
Macro used as short cut to used File Open function defined by D4D_DECLARE_FILE_FUNCTIONS.
Definition: d4d_extsrc.h:303
D4D Driver private header file.
D4D_FONT ix_font
Definition: d4d_font.h:209
#define D4D_FONT_PACK_SCANPREFERRED_COLUMN
Definition: d4d_font.h:133
#define D4D_FONT_FLAGS_IX_TYPE_MAP
Definition: d4d_font.h:150
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
D4D_FONT_FLAGS flags
Definition: d4d_font.h:189
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
D4D_FONT_DESCRIPTOR * pFontDescriptor
Definition: d4d_font.h:210
#define D4D_EXTSRC_BUFF_SIZE
This macro is used to specify size of buffer that is using when external file support is enabled...
Definition: d4d_base.h:167
#define NULL
Type definition of null pointer.
Definition: d4d_types.h:184
#define D4D_FONT_FLAGS_FNT_WIDTH_PROPORTIONAL
Definition: d4d_font.h:154
#define D4D_MemFree(pMem)
Mem Free eGUI definition. If not defined by user config any special user function, it used standard system function.
Definition: d4d_extsrc.h:329
unsigned long LWord
Type definition of LWord (unsigned 32-bit).
Definition: d4d_types.h:167
D4D_COOR x
Definition: d4d_font.h:217
D4D_FONT_IX charCnt
Definition: d4d_font.h:191
const D4D_FONT_DATA * pFontData
Definition: d4d_font.h:201
#define D4D_FNT_PRTY_TRANSPARENT_MASK
Definition: d4d_font.h:112
D4D_COLOR colorBack
Definition: d4d_font.h:223
D4D_FONT_SIZES charFullSize
Definition: d4d_font.h:196
Type definition of eGUI tabulation structure.
Definition: d4d_types.h:253
LWord D4D_INDEX
Type definition of eGUI general index variables.
Definition: d4d_types.h:206
#define D4D_FONT_FLAGS_IX_STYLE_NONLINEAR
Definition: d4d_font.h:146
#define D4D_SEEK_SET
D4D_SEEK_SET eGUI Origin constant for begin of file (1)
Definition: d4d_extsrc.h:139
static FNT_CHAR_PLACE D4D_LCD_GetCharPlace(const D4D_FONT_DESCRIPTOR *pFontDescriptorStart, D4D_TCHAR ch)
Definition: d4d_font.c:502
#define D4D_FONT_PACK_COMPRESSED_ON
Definition: d4d_font.h:137
D4D_FONT_SIZES scale
Definition: d4d_font.h:211
D4D_CHAR * D4D_StrCat(register D4D_CHAR *sd, register const D4D_CHAR *ss)
The function concatenate strings (terminated by zero)
Definition: d4d_extsrc.c:211
#define D4D_FileClose
Macro used as short cut to used File Close function defined by D4D_DECLARE_FILE_FUNCTIONS.
Definition: d4d_extsrc.h:305
#define D4D_FileTell
Macro used as short cut to used File Tell function defined by D4D_DECLARE_FILE_FUNCTIONS.
Definition: d4d_extsrc.h:313
D4D_FONT_IX charDefault
Definition: d4d_font.h:192
const D4DLCD_FUNCTIONS D4D_LLD_LCD
LWord D4D_BOOL
Type definition of eGUI boolean.
Definition: d4d_types.h:204
#define D4D_UNUSED(x)
Macro used just for notify compiler that the input parameter is not used.
Definition: d4d_base.h:504
char D4D_CHAR
Type definition of eGUI ASCII character.
Definition: d4d_types.h:280
D4D_FONT_SIZE D4D_GetFontWidth(D4D_FONT ix)
Definition: d4d_font.c:398
sLWord D4D_INDEX_DELTA
Type definition of eGUI general index variables for signed offsets.
Definition: d4d_types.h:208
D4D_FONT_SIZE D4D_GetCharWidth(D4D_FONT ix, D4D_TCHAR ch)
Definition: d4d_font.c:415
D4D_FONT_SIZE width
Definition: d4d_font.h:182
#define D4D_FileSeek
Macro used as short cut to used File Seek function defined by D4D_DECLARE_FILE_FUNCTIONS.
Definition: d4d_extsrc.h:311
D4D_TAB * pTab
Definition: d4d_font.h:221
D4D_FONT_SIZES D4D_GetFontSize(D4D_FONT ix)
Definition: d4d_font.c:365
#define D4D_SEEK_END
D4D_SEEK_END eGUI Origin constant for end of file (3)
Definition: d4d_extsrc.h:143
static D4D_INDEX_DELTA D4D_GetCharIndex(D4D_FONT_DESCRIPTOR *pFontDescriptor, D4D_TCHAR ch)
Definition: d4d_font.c:458
Byte d4d_extsrcBuffer[D4D_EXTSRC_BUFF_SIZE]
D4D driver - resistive touch screen driver function header file.
D4D_COOR D4D_GetNextTab(D4D_TAB *pTab, D4D_COOR pos)
Definition: d4d_font.c:618
void(* D4DLCD_Send_PixelColor)(D4D_COLOR value)
The LCD driver send pixel function. The pixels will be draw on position (automaticaly incremented) se...
Definition: d4d_lldapi.h:152
LWord D4D_COLOR
Type definition of eGUI color variables.
Definition: d4d_types.h:262
#define D4D_FONT_PACK_BITORDER_LITTLEEND
Definition: d4d_font.h:125
D4D_FONT_SIZE D4D_GetFontHeight(D4D_FONT ix)
Definition: d4d_font.c:381
#define D4D_FONT_PACK_SCANBASED_COLUMN
Definition: d4d_font.h:129
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159
D4D_FONT_IX startChar
Definition: d4d_font.h:190
static D4D_FONT_TYPE * d4d_pFontTable
Definition: d4d_font.c:78
D4D_BOOL D4D_FileIsAbsolutePath(D4D_CHAR *pFileName)
void * D4D_FILEPTR
Type definition of eGUI file pointer.
Definition: d4d_types.h:298
const D4D_FONT_SIZE * pSizeTable
Definition: d4d_font.h:200
int D4D_StrLen(register const D4D_CHAR *s)
The function returns length of string terminated by zero.
Definition: d4d_extsrc.c:128
#define D4D_FileRead
Macro used as short cut to used File Read function defined by D4D_DECLARE_FILE_FUNCTIONS.
Definition: d4d_extsrc.h:307
unsigned char(* D4DLCD_SetWindow)(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2)
The LCD driver Set logic window function. Into this logic window will be draw pixels.
Definition: d4d_lldapi.h:150