| 593 | } |
| 594 | |
| 595 | int msLoadFontSet(fontSetObj *fontset, mapObj *map) |
| 596 | { |
| 597 | #ifdef USE_GD_FT |
| 598 | FILE *stream; |
| 599 | char buffer[MS_BUFFER_LENGTH]; |
| 600 | char alias[64], file1[MS_PATH_LENGTH], file2[MS_PATH_LENGTH]; |
| 601 | char *path; |
| 602 | char szPath[MS_MAXPATHLEN]; |
| 603 | int i; |
| 604 | int bFullPath = 0; |
| 605 | |
| 606 | if(fontset->numfonts != 0) /* already initialized */ |
| 607 | return(0); |
| 608 | |
| 609 | if(!fontset->filename) |
| 610 | return(0); |
| 611 | |
| 612 | fontset->map = (mapObj *)map; |
| 613 | |
| 614 | path = msGetPath(fontset->filename); |
| 615 | |
| 616 | /* fontset->fonts = msCreateHashTable(); // create font hash */ |
| 617 | /* if(!fontset->fonts) { */ |
| 618 | /* msSetError(MS_HASHERR, "Error initializing font hash.", "msLoadFontSet()"); */ |
| 619 | /* return(-1); */ |
| 620 | /* } */ |
| 621 | |
| 622 | stream = fopen( msBuildPath(szPath, fontset->map->mappath, fontset->filename), "r"); |
| 623 | if(!stream) { |
| 624 | msSetError(MS_IOERR, "Error opening fontset %s.", "msLoadFontset()", |
| 625 | fontset->filename); |
| 626 | return(-1); |
| 627 | } |
| 628 | |
| 629 | i = 0; |
| 630 | while(fgets(buffer, MS_BUFFER_LENGTH, stream)) { /* while there's something to load */ |
| 631 | |
| 632 | if(buffer[0] == '#' || buffer[0] == '\n' || buffer[0] == '\r' || buffer[0] == ' ') |
| 633 | continue; /* skip comments and blank lines */ |
| 634 | |
| 635 | sscanf(buffer,"%s %s", alias, file1); |
| 636 | |
| 637 | if (!(*file1) || !(*alias) || (strlen(file1) <= 0)) |
| 638 | continue; |
| 639 | |
| 640 | bFullPath = 0; |
| 641 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 642 | if (file1[0] == '\\' || (strlen(file1) > 1 && (file1[1] == ':'))) |
| 643 | bFullPath = 1; |
| 644 | #else |
| 645 | if(file1[0] == '/') |
| 646 | bFullPath = 1; |
| 647 | #endif |
| 648 | |
| 649 | if(bFullPath) { /* already full path */ |
| 650 | msInsertHashTable(&(fontset->fonts), alias, file1); |
| 651 | } else { |
| 652 | snprintf(file2, sizeof(file2), "%s%s", path, file1); |
no test coverage detected