tedious string copying changes
[blender.git] / source / blender / blenkernel / intern / font.c
index 47627d09b97276f32166624f2ac2491e8a1fb715..5fdb9549179a9e27ca8b6cf5cf6ab3d4707d6e6c 100644 (file)
@@ -305,7 +305,7 @@ static VFontData *vfont_get_data(VFont *vfont)
        if (!vfont->data) {
                PackedFile *pf;
                
-               if (BLI_streq(vfont->name, "<builtin>")) {
+               if (strcmp(vfont->name, FO_BUILTIN_NAME)==0) {
                        pf= get_builtin_packedfile();
                } else {
                        if (vfont->packedfile) {
@@ -342,7 +342,7 @@ static VFontData *vfont_get_data(VFont *vfont)
                        if(!pf) {
                                printf("Font file doesn't exist: %s\n", vfont->name);
 
-                               strcpy(vfont->name, "<builtin>");
+                               strcpy(vfont->name, FO_BUILTIN_NAME);
                                pf= get_builtin_packedfile();
                        }
                }
@@ -367,7 +367,7 @@ VFont *load_vfont(char *name)
        int is_builtin;
        struct TmpFont *tmpfnt;
        
-       if (BLI_streq(name, "<builtin>")) {
+       if (strcmp(name, FO_BUILTIN_NAME)==0) {
                strcpy(filename, name);
                
                pf= get_builtin_packedfile();
@@ -394,7 +394,7 @@ VFont *load_vfont(char *name)
 
                        /* if there's a font name, use it for the ID name */
                        if (strcmp(vfd->name, "")!=0) {
-                               BLI_strncpy(vfont->id.name+2, vfd->name, 21);
+                               BLI_strncpy(vfont->id.name+2, vfd->name, sizeof(vfont->id.name)-2);
                        }
                        BLI_strncpy(vfont->name, name, sizeof(vfont->name));
 
@@ -403,8 +403,8 @@ VFont *load_vfont(char *name)
                                vfont->packedfile = pf;
                        }
                        
-                       // Do not add <builtin> to temporary listbase
-                       if(strcmp(filename, "<builtin>"))
+                       // Do not add FO_BUILTIN_NAME to temporary listbase
+                       if(strcmp(filename, FO_BUILTIN_NAME))
                        {
                                tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
                                tmpfnt->pf= tpf;
@@ -443,10 +443,10 @@ VFont *get_builtin_font(void)
        VFont *vf;
        
        for (vf= G.main->vfont.first; vf; vf= vf->id.next)
-               if (BLI_streq(vf->name, "<builtin>"))
+               if (strcmp(vf->name, FO_BUILTIN_NAME)==0)
                        return vf;
        
-       return load_vfont("<builtin>");
+       return load_vfont(FO_BUILTIN_NAME);
 }
 
 static VChar *find_vfont_char(VFontData *vfd, intptr_t character)
@@ -514,11 +514,12 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
        float *fp, fsize, shear, x, si, co;
        VFontData *vfd = NULL;
        VChar *che = NULL;
-       int i, sel=0;
+       int i;
 
        vfd= vfont_get_data(which_vfont(cu, info));     
        if (!vfd) return;
 
+       /*
        if (cu->selend < cu->selstart) {
                if ((charidx >= (cu->selend)) && (charidx <= (cu->selstart-2)))
                        sel= 1;
@@ -527,6 +528,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
                if ((charidx >= (cu->selstart-1)) && (charidx <= (cu->selend-1)))
                        sel= 1;
        }
+       */
 
        /* make a copy at distance ofsx,ofsy with shear*/
        fsize= cu->fsize;
@@ -779,10 +781,10 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
 
                /*
                 * The character wasn't in the current curve base so load it
-                * But if the font is <builtin> then do not try loading since
+                * But if the font is FO_BUILTIN_NAME then do not try loading since
                 * whole font is in the memory already
                 */
-               if(che == NULL && strcmp(vfont->name, "<builtin>"))     {
+               if(che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) {
                        BLI_vfontchar_from_freetypefont(vfont, ascii);
                }
 
@@ -1148,14 +1150,12 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
 
        if(mode == FO_EDIT) {
                /* make nurbdata */
-               unsigned long cha;
-               
                freeNurblist(&cu->nurb);
                
                ct= chartransdata;
                if (cu->sepchar==0) {
                        for (i= 0; i<slen; i++) {
-                               cha = (uintptr_t) mem[i];
+                               unsigned long cha = (uintptr_t) mem[i];
                                info = &(custrinfo[i]);
                                if (info->mat_nr > (ob->totcol)) {
                                        /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */
@@ -1193,8 +1193,12 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                                ascii = mem[i];
                                info = &(custrinfo[i]);
                                if (cu->sepchar == (i+1)) {
-                                       float vecyo[3]= {ct->xof, ct->yof, 0.0f};
-                                       
+                                       float vecyo[3];
+
+                                       vecyo[0]= ct->xof;
+                                       vecyo[1]= ct->yof;
+                                       vecyo[2]= 0.0f;
+
                                        mem[0] = ascii;
                                        mem[1] = 0;
                                        custrinfo[0]= *info;