components/tft/tft.c

changeset 91
255a75322212
parent 38
537ffe280775
equal deleted inserted replaced
90:1397fb0b3a9d 91:255a75322212
577 struct stat sb; 577 struct stat sb;
578 578
579 // Open the file 579 // Open the file
580 FILE *fhndl = fopen(fontfile, "r"); 580 FILE *fhndl = fopen(fontfile, "r");
581 if (!fhndl) { 581 if (!fhndl) {
582 sprintf(err_msg, "Error opening font file '%s'", fontfile); 582 sprintf(err_msg, "Error open font '%s'", fontfile);
583 err = 1; 583 err = 1;
584 goto exit; 584 goto exit;
585 } 585 }
586 586
587 // Get file size 587 // Get file size
588 if (stat(fontfile, &sb) != 0) { 588 if (stat(fontfile, &sb) != 0) {
589 sprintf(err_msg, "Error getting font file size"); 589 sprintf(err_msg, "stat error");
590 err = 2; 590 err = 2;
591 goto exit; 591 goto exit;
592 } 592 }
593 int fsize = sb.st_size; 593 int fsize = sb.st_size;
594 if (fsize < 30) { 594 if (fsize < 30) {
595 sprintf(err_msg, "Error getting font file size"); 595 sprintf(err_msg, "Error font file size");
596 err = 3; 596 err = 3;
597 goto exit; 597 goto exit;
598 } 598 }
599 599
600 userfont = malloc(fsize+4); 600 userfont = malloc(fsize+4);
601 if (userfont == NULL) { 601 if (userfont == NULL) {
602 sprintf(err_msg, "Font memory allocation error"); 602 sprintf(err_msg, "Font malloc error");
603 fclose(fhndl); 603 fclose(fhndl);
604 err = 4; 604 err = 4;
605 goto exit; 605 goto exit;
606 } 606 }
607 607

mercurial