~ubuntu-branches/ubuntu/wily/xfonts-utils/wily-proposed

« back to all changes in this revision

Viewing changes to mkfontscale/mkfontscale.c

  • Committer: Package Import Robot
  • Author(s): Julien Cristau
  • Date: 2013-12-25 17:43:35 UTC
  • Revision ID: package-import@ubuntu.com-20131225174335-muv4wm0afyg36dcd
Tags: 1:7.7+1
* bdftopcf 1.0.4
* mkfontscale 1.1.1
* Bump debhelper compat level to 7.
* Switch to dh with the autotools-dev addon; should give us updated
  config.{guess,sub} (closes: #717842).
* Disable silent build rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
  THE SOFTWARE.
21
21
*/
22
22
 
 
23
#include "config.h"
 
24
 
23
25
#include <stdio.h>
24
26
#include <stdlib.h>
25
27
#include <string.h>
26
28
 
27
29
#include <sys/types.h>
 
30
#include <sys/stat.h>
28
31
#include <dirent.h>
29
32
#include <unistd.h>
30
33
#include <errno.h>
826
829
    while((entry = readdir(dirp)) != NULL) {
827
830
        int have_face = 0;
828
831
        char *xlfd_name = NULL;
 
832
        struct stat f_stat;
 
833
        int tprio = 1;
 
834
 
829
835
        xlfd = NULL;
830
836
 
831
837
        if (xl) {
836
842
 
837
843
        filename = dsprintf("%s%s", dirname, entry->d_name);
838
844
 
 
845
#define PRIO(x) ((x << 1) + tprio)
 
846
#ifdef DT_LNK
 
847
        if (entry->d_type != DT_UNKNOWN) {
 
848
            if (entry->d_type == DT_LNK)
 
849
                tprio = 0;
 
850
        } else
 
851
#endif
 
852
#ifdef S_ISLNK
 
853
        {
 
854
            if (lstat(filename, &f_stat))
 
855
                goto done;
 
856
            if (S_ISLNK(f_stat.st_mode))
 
857
                tprio = 0;
 
858
        }
 
859
#else
 
860
        ;
 
861
#endif
839
862
        if(doBitmaps)
840
863
            rc = bitmapIdentify(filename, &xlfd_name);
841
864
        else
875
898
                BDF_PropertyRec prop;
876
899
                rc = FT_Get_BDF_Property(face, "FONT", &prop);
877
900
                if(rc == 0 && prop.type == BDF_PROPERTY_TYPE_ATOM) {
878
 
                    xlfd_name = malloc(strlen(prop.u.atom) + 1);
 
901
                    xlfd_name = strdup(prop.u.atom);
879
902
                    if(xlfd_name == NULL)
880
903
                        goto done;
881
 
                    strcpy(xlfd_name, prop.u.atom);
882
904
                }
883
905
            }
884
906
        }
896
918
                xlfd = listCons(s, xlfd);
897
919
            } else {
898
920
                /* Not a reencodable font -- skip all the rest of the loop body */
899
 
                putHash(entries, xlfd_name, entry->d_name, filePrio(entry->d_name));
 
921
                putHash(entries, xlfd_name, entry->d_name, PRIO(filePrio(entry->d_name)));
900
922
                goto done;
901
923
            }
902
924
        }
930
952
                    found = 1;
931
953
                    snprintf(buf, MAXFONTNAMELEN, "%s-%s",
932
954
                            lp->value, encoding->value);
933
 
                    putHash(entries, buf, entry->d_name, filePrio(entry->d_name));
 
955
                    putHash(entries, buf, entry->d_name, PRIO(filePrio(entry->d_name)));
934
956
                }
935
957
            }
936
958
            for(encoding = extra_encodings; encoding;
939
961
                    /* Do not set found! */
940
962
                    snprintf(buf, MAXFONTNAMELEN, "%s-%s",
941
963
                            lp->value, encoding->value);
942
 
                    putHash(entries, buf, entry->d_name, filePrio(entry->d_name));
 
964
                    putHash(entries, buf, entry->d_name, PRIO(filePrio(entry->d_name)));
943
965
                }
944
966
            }
945
967
        }
949
971
        deepDestroyList(xlfd);
950
972
        xlfd = NULL;
951
973
        free(filename);
 
974
#undef PRIO
952
975
    }
953
976
 
954
977
    closedir(dirp);