84
if(code=='`') new= 224;
85
else if(code==39) new= 225;
86
else if(code=='^') new= 226;
87
else if(code=='~') new= 227;
88
else if(code=='"') new= 228;
89
else if(code=='o') new= 229;
90
else if(code=='e') new= 230;
91
else if(code=='-') new= 170;
94
if(code==',') new= 231;
95
if(code=='|') new= 162;
98
if(code=='`') new= 232;
99
else if(code==39) new= 233;
100
else if(code=='^') new= 234;
101
else if(code=='"') new= 235;
103
else if(char1=='i') {
104
if(code=='`') new= 236;
105
else if(code==39) new= 237;
106
else if(code=='^') new= 238;
107
else if(code=='"') new= 239;
109
else if(char1=='n') {
110
if(code=='~') new= 241;
112
else if(char1=='o') {
113
if(code=='`') new= 242;
114
else if(code==39) new= 243;
115
else if(code=='^') new= 244;
116
else if(code=='~') new= 245;
117
else if(code=='"') new= 246;
118
else if(code=='/') new= 248;
119
else if(code=='-') new= 186;
120
else if(code=='e') new= 143;
122
else if(char1=='s') {
123
if(code=='s') new= 167;
125
else if(char1=='u') {
126
if(code=='`') new= 249;
127
else if(code==39) new= 250;
128
else if(code=='^') new= 251;
129
else if(code=='"') new= 252;
131
else if(char1=='y') {
132
if(code==39) new= 253;
133
else if(code=='"') new= 255;
135
else if(char1=='A') {
136
if(code=='`') new= 192;
137
else if(code==39) new= 193;
138
else if(code=='^') new= 194;
139
else if(code=='~') new= 195;
140
else if(code=='"') new= 196;
141
else if(code=='o') new= 197;
142
else if(code=='e') new= 198;
144
else if(char1=='C') {
145
if(code==',') new= 199;
147
else if(char1=='E') {
148
if(code=='`') new= 200;
149
else if(code==39) new= 201;
150
else if(code=='^') new= 202;
151
else if(code=='"') new= 203;
153
else if(char1=='I') {
154
if(code=='`') new= 204;
155
else if(code==39) new= 205;
156
else if(code=='^') new= 206;
157
else if(code=='"') new= 207;
159
else if(char1=='N') {
160
if(code=='~') new= 209;
162
else if(char1=='O') {
163
if(code=='`') new= 210;
164
else if(code==39) new= 211;
165
else if(code=='^') new= 212;
166
else if(code=='~') new= 213;
167
else if(code=='"') new= 214;
168
else if(code=='/') new= 216;
169
else if(code=='e') new= 141;
171
else if(char1=='U') {
172
if(code=='`') new= 217;
173
else if(code==39) new= 218;
174
else if(code=='^') new= 219;
175
else if(code=='"') new= 220;
177
else if(char1=='Y') {
178
if(code==39) new= 221;
180
else if(char1=='1') {
181
if(code=='4') new= 188;
182
if(code=='2') new= 189;
184
else if(char1=='3') {
185
if(code=='4') new= 190;
187
else if(char1==':') {
188
if(code=='-') new= 247;
190
else if(char1=='-') {
191
if(code==':') new= 247;
192
if(code=='|') new= 135;
193
if(code=='+') new= 177;
195
else if(char1=='|') {
196
if(code=='-') new= 135;
197
if(code=='=') new= 136;
199
else if(char1=='=') {
200
if(code=='|') new= 136;
202
else if(char1=='+') {
203
if(code=='-') new= 177;
86
if (code=='`') new= 224;
87
else if (code==39) new= 225;
88
else if (code=='^') new= 226;
89
else if (code=='~') new= 227;
90
else if (code=='"') new= 228;
91
else if (code=='o') new= 229;
92
else if (code=='e') new= 230;
93
else if (code=='-') new= 170;
95
else if (char1=='c') {
96
if (code==',') new= 231;
97
if (code=='|') new= 162;
99
else if (char1=='e') {
100
if (code=='`') new= 232;
101
else if (code==39) new= 233;
102
else if (code=='^') new= 234;
103
else if (code=='"') new= 235;
105
else if (char1=='i') {
106
if (code=='`') new= 236;
107
else if (code==39) new= 237;
108
else if (code=='^') new= 238;
109
else if (code=='"') new= 239;
111
else if (char1=='n') {
112
if (code=='~') new= 241;
114
else if (char1=='o') {
115
if (code=='`') new= 242;
116
else if (code==39) new= 243;
117
else if (code=='^') new= 244;
118
else if (code=='~') new= 245;
119
else if (code=='"') new= 246;
120
else if (code=='/') new= 248;
121
else if (code=='-') new= 186;
122
else if (code=='e') new= 143;
124
else if (char1=='s') {
125
if (code=='s') new= 167;
127
else if (char1=='u') {
128
if (code=='`') new= 249;
129
else if (code==39) new= 250;
130
else if (code=='^') new= 251;
131
else if (code=='"') new= 252;
133
else if (char1=='y') {
134
if (code==39) new= 253;
135
else if (code=='"') new= 255;
137
else if (char1=='A') {
138
if (code=='`') new= 192;
139
else if (code==39) new= 193;
140
else if (code=='^') new= 194;
141
else if (code=='~') new= 195;
142
else if (code=='"') new= 196;
143
else if (code=='o') new= 197;
144
else if (code=='e') new= 198;
146
else if (char1=='C') {
147
if (code==',') new= 199;
149
else if (char1=='E') {
150
if (code=='`') new= 200;
151
else if (code==39) new= 201;
152
else if (code=='^') new= 202;
153
else if (code=='"') new= 203;
155
else if (char1=='I') {
156
if (code=='`') new= 204;
157
else if (code==39) new= 205;
158
else if (code=='^') new= 206;
159
else if (code=='"') new= 207;
161
else if (char1=='N') {
162
if (code=='~') new= 209;
164
else if (char1=='O') {
165
if (code=='`') new= 210;
166
else if (code==39) new= 211;
167
else if (code=='^') new= 212;
168
else if (code=='~') new= 213;
169
else if (code=='"') new= 214;
170
else if (code=='/') new= 216;
171
else if (code=='e') new= 141;
173
else if (char1=='U') {
174
if (code=='`') new= 217;
175
else if (code==39) new= 218;
176
else if (code=='^') new= 219;
177
else if (code=='"') new= 220;
179
else if (char1=='Y') {
180
if (code==39) new= 221;
182
else if (char1=='1') {
183
if (code=='4') new= 188;
184
if (code=='2') new= 189;
186
else if (char1=='3') {
187
if (code=='4') new= 190;
189
else if (char1==':') {
190
if (code=='-') new= 247;
192
else if (char1=='-') {
193
if (code==':') new= 247;
194
if (code=='|') new= 135;
195
if (code=='+') new= 177;
197
else if (char1=='|') {
198
if (code=='-') new= 135;
199
if (code=='=') new= 136;
201
else if (char1=='=') {
202
if (code=='|') new= 136;
204
else if (char1=='+') {
205
if (code=='-') new= 177;
207
209
else return char1;
211
void update_string(Curve *cu)
213
static void update_string(Curve *cu)
213
215
EditFont *ef= cu->editfont;
217
219
MEM_freeN(cu->str);
219
221
// Calculate the actual string length in UTF-8 variable characters
220
len = wcsleninu8(ef->textbuf);
222
len = BLI_wstrlen_utf8(ef->textbuf);
222
224
// Alloc memory for UTF-8 variable char length string
223
225
cu->str = MEM_callocN(len + sizeof(wchar_t), "str");
225
227
// Copy the wchar to UTF-8
226
wcs2utf8s(cu->str, ef->textbuf);
228
BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, len + 1);
229
231
static int insert_into_textbuf(Object *obedit, uintptr_t c)
231
233
Curve *cu= obedit->data;
233
if(cu->len<MAXTEXT-1) {
235
if (cu->len<MAXTEXT-1) {
234
236
EditFont *ef= cu->editfont;
237
for(x= cu->len; x>cu->pos; x--) ef->textbuf[x]= ef->textbuf[x-1];
238
for(x= cu->len; x>cu->pos; x--) ef->textbufinfo[x]= ef->textbufinfo[x-1];
239
for (x= cu->len; x>cu->pos; x--) ef->textbuf[x]= ef->textbuf[x-1];
240
for (x= cu->len; x>cu->pos; x--) ef->textbufinfo[x]= ef->textbufinfo[x-1];
239
241
ef->textbuf[cu->pos]= c;
240
242
ef->textbufinfo[cu->pos] = cu->curinfo;
241
243
ef->textbufinfo[cu->pos].kern = 0;
243
ef->textbufinfo[cu->pos].mat_nr = obedit->actcol;
245
ef->textbufinfo[cu->pos].mat_nr = 0;
244
ef->textbufinfo[cu->pos].mat_nr = obedit->actcol;
259
258
static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int recalc, int mode)
260
struct Main *bmain= CTX_data_main(C);
261
261
Curve *cu= obedit->data;
262
262
EditFont *ef= cu->editfont;
265
cu->curinfo = ef->textbufinfo[cu->pos-1];
267
cu->curinfo = ef->textbufinfo[0];
263
cu->curinfo = ef->textbufinfo[cu->pos?cu->pos-1:0];
270
obedit->actcol= ef->textbufinfo[cu->pos-1].mat_nr;
273
BKE_text_to_curve(scene, obedit, mode);
276
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
265
if (obedit->totcol > 0) {
266
obedit->actcol= ef->textbufinfo[cu->pos?cu->pos-1:0].mat_nr;
268
/* since this array is calloc'd, it can be 0 even though we try ensure
269
* (mat_nr > 0) almost everywhere */
270
if (obedit->actcol < 1) {
278
BKE_text_to_curve(bmain, scene, obedit, mode);
281
DAG_id_tag_update(obedit->data, 0);
277
282
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
280
285
/********************** insert lorem operator *********************/
282
static int insert_lorem_exec(bContext *C, wmOperator *op)
287
static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op))
284
289
Object *obedit= CTX_data_edit_object(C);
287
static char *lastlorem;
292
static const char *lastlorem;
294
299
i= rand()/(RAND_MAX/6)+4;
296
for(p2=p; *p2 && i; p2++) {
301
for (p2=p; *p2 && i; p2++) {
297
302
insert_into_textbuf(obedit, *p2);
303
308
lastlorem = p2+1;
304
if(strlen(lastlorem)<5)
309
if (strlen(lastlorem)<5)
305
310
lastlorem = ED_lorem;
307
312
insert_into_textbuf(obedit, '\n');
308
313
insert_into_textbuf(obedit, '\n');
310
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
315
DAG_id_tag_update(obedit->data, 0);
311
316
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
313
318
return OPERATOR_FINISHED;
404
409
void FONT_OT_file_paste(wmOperatorType *ot)
406
411
/* identifiers */
407
ot->name= "Paste File";
408
ot->description= "Paste contents from file";
409
ot->idname= "FONT_OT_file_paste";
412
ot->name = "Paste File";
413
ot->description = "Paste contents from file";
414
ot->idname = "FONT_OT_file_paste";
411
416
/* api callbacks */
412
ot->exec= paste_file_exec;
413
ot->invoke= paste_file_invoke;
414
ot->poll= ED_operator_editfont;
417
ot->exec = paste_file_exec;
418
ot->invoke = paste_file_invoke;
419
ot->poll = ED_operator_editfont;
417
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
422
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
420
WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
423
/******************* paste buffer operator ********************/
425
static int paste_buffer_exec(bContext *C, wmOperator *op)
430
filename= "C:\\windows\\temp\\cutbuf.txt";
432
// The following is more likely to work on all Win32 installations.
433
// suggested by Douglas Toltzman. Needs windows include files...
435
char tempFileName[MAX_PATH];
437
static const char cutbufname[]="cutbuf.txt";
439
if((pathlen=GetTempPath(sizeof(tempFileName),tempFileName)) > 0 &&
440
pathlen + sizeof(cutbufname) <= sizeof(tempFileName))
442
strcat(tempFileName,cutbufname);
443
filename= tempFilename;
447
filename= "/tmp/.cutbuffer";
450
return paste_file(C, NULL, filename);
453
void FONT_OT_buffer_paste(wmOperatorType *ot)
456
ot->name= "Paste Buffer";
457
ot->description= "Paste text from OS buffer";
458
ot->idname= "FONT_OT_buffer_paste";
461
ot->exec= paste_buffer_exec;
462
ot->poll= ED_operator_editfont;
465
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
425
WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
468
428
/******************* text to object operator ********************/
564
524
static short next_word(Curve *cu)
567
for(s=cu->pos; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
527
for (s=cu->pos; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
568
528
(cu->str[s]!=1) && (cu->str[s]!='\r'); s++);
569
if(cu->str[s]) return(s+1); else return(s);
529
if (cu->str[s]) return(s+1); else return(s);
572
532
static short prev_word(Curve *cu)
576
if(cu->pos==0) return(0);
577
for(s=cu->pos-2; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
536
if (cu->pos==0) return(0);
537
for (s=cu->pos-2; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
578
538
(cu->str[s]!=1) && (cu->str[s]!='\r'); s--);
579
if(cu->str[s]) return(s+1); else return(s);
539
if (cu->str[s]) return(s+1); else return(s);
582
542
static int kill_selection(Object *obedit, int ins) /* 1 == new character */
617
577
{CU_CHINFO_SMALLCAPS, "SMALL_CAPS", 0, "Small Caps", ""},
618
578
{0, NULL, 0, NULL, NULL}};
620
static int set_style(bContext *C, int style, int clear)
580
static int set_style(bContext *C, const int style, const int clear)
622
582
Object *obedit= CTX_data_edit_object(C);
623
583
Curve *cu= obedit->data;
624
584
EditFont *ef= cu->editfont;
625
585
int i, selstart, selend;
627
if(!BKE_font_getselection(obedit, &selstart, &selend))
587
if (!BKE_font_getselection(obedit, &selstart, &selend))
628
588
return OPERATOR_CANCELLED;
630
for(i=selstart; i<=selend; i++) {
590
for (i=selstart; i<=selend; i++) {
632
592
ef->textbufinfo[i].flag &= ~style;
634
594
ef->textbufinfo[i].flag |= style;
637
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
597
DAG_id_tag_update(obedit->data, 0);
638
598
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
640
600
return OPERATOR_FINISHED;
653
611
void FONT_OT_style_set(wmOperatorType *ot)
655
613
/* identifiers */
656
ot->name= "Set Style";
657
ot->description= "Set font style";
658
ot->idname= "FONT_OT_style_set";
614
ot->name = "Set Style";
615
ot->description = "Set font style";
616
ot->idname = "FONT_OT_style_set";
660
618
/* api callbacks */
661
ot->exec= set_style_exec;
662
ot->poll= ED_operator_editfont;
619
ot->exec = set_style_exec;
620
ot->poll = ED_operator_editfont;
665
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
623
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
668
RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to.");
669
RNA_def_boolean(ot->srna, "clear", 0, "Clear", "Clear style rather than setting it.");
626
RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to");
627
RNA_def_boolean(ot->srna, "clear", 0, "Clear", "Clear style rather than setting it");
672
630
/******************* toggle style operator ********************/
691
649
void FONT_OT_style_toggle(wmOperatorType *ot)
693
651
/* identifiers */
694
ot->name= "Toggle Style";
695
ot->description= "Toggle font style";
696
ot->idname= "FONT_OT_style_toggle";
652
ot->name = "Toggle Style";
653
ot->description = "Toggle font style";
654
ot->idname = "FONT_OT_style_toggle";
698
656
/* api callbacks */
699
ot->exec= toggle_style_exec;
700
ot->poll= ED_operator_editfont;
657
ot->exec = toggle_style_exec;
658
ot->poll = ED_operator_editfont;
703
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
661
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
706
RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to.");
664
RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to");
709
667
/******************* copy text operator ********************/
734
692
void FONT_OT_text_copy(wmOperatorType *ot)
736
694
/* identifiers */
737
ot->name= "Copy Text";
738
ot->description= "Copy selected text to clipboard";
739
ot->idname= "FONT_OT_text_copy";
695
ot->name = "Copy Text";
696
ot->description = "Copy selected text to clipboard";
697
ot->idname = "FONT_OT_text_copy";
741
699
/* api callbacks */
742
ot->exec= copy_text_exec;
743
ot->poll= ED_operator_editfont;
700
ot->exec = copy_text_exec;
701
ot->poll = ED_operator_editfont;
746
704
/******************* cut text operator ********************/
748
static int cut_text_exec(bContext *C, wmOperator *op)
706
static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
750
708
Scene *scene= CTX_data_scene(C);
751
709
Object *obedit= CTX_data_edit_object(C);
752
710
int selstart, selend;
754
if(!BKE_font_getselection(obedit, &selstart, &selend))
712
if (!BKE_font_getselection(obedit, &selstart, &selend))
755
713
return OPERATOR_CANCELLED;
757
715
copy_selection(obedit);
758
716
kill_selection(obedit, 0);
760
text_update_edited(C, scene, obedit, 1, 0);
718
text_update_edited(C, scene, obedit, 1, FO_EDIT);
762
720
return OPERATOR_FINISHED;
856
814
Object *obedit= CTX_data_edit_object(C);
857
815
Curve *cu= obedit->data;
858
816
EditFont *ef= cu->editfont;
863
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
865
if(ef->textbuf[cu->pos-1]=='\n') break;
866
if(ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break;
821
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
823
if (ef->textbuf[cu->pos-1]=='\n') break;
824
if (ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break;
869
827
cursmove=FO_CURS;
873
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
874
while(cu->pos<cu->len) {
875
if(ef->textbuf[cu->pos]==0) break;
876
if(ef->textbuf[cu->pos]=='\n') break;
877
if(ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break;
831
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
832
while (cu->pos<cu->len) {
833
if (ef->textbuf[cu->pos]==0) break;
834
if (ef->textbuf[cu->pos]=='\n') break;
835
if (ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break;
880
838
cursmove=FO_CURS;
884
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
842
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
885
843
cu->pos= prev_word(cu);
886
844
cursmove= FO_CURS;
890
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
848
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
891
849
cu->pos= next_word(cu);
892
850
cursmove= FO_CURS;
896
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
854
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
898
856
cursmove=FO_CURS;
902
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
860
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
904
862
cursmove= FO_CURS;
909
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
867
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
910
868
cursmove=FO_CURSUP;
914
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
872
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
915
873
cursmove= FO_CURSDOWN;
919
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
877
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
920
878
cursmove=FO_PAGEUP;
924
if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
882
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
925
883
cursmove=FO_PAGEDOWN;
930
888
return OPERATOR_CANCELLED;
892
struct Main *bmain= CTX_data_main(C);
934
893
cu->selstart = cu->selend = 0;
935
894
update_string(cu);
936
BKE_text_to_curve(scene, obedit, FO_SELCHANGE);
895
BKE_text_to_curve(bmain, scene, obedit, FO_SELCHANGE);
940
if(cu->pos>cu->len) cu->pos= cu->len;
941
else if(cu->pos>=MAXTEXT) cu->pos= MAXTEXT;
942
else if(cu->pos<0) cu->pos= 0;
899
if (cu->pos>cu->len) cu->pos= cu->len;
900
else if (cu->pos>=MAXTEXT) cu->pos= MAXTEXT;
901
else if (cu->pos<0) cu->pos= 0;
944
903
text_update_edited(C, scene, obedit, select, cursmove);
947
906
cu->selend = cu->pos;
949
908
return OPERATOR_FINISHED;
959
918
void FONT_OT_move(wmOperatorType *ot)
961
920
/* identifiers */
962
ot->name= "Move Cursor";
963
ot->description= "Move cursor to position type";
964
ot->idname= "FONT_OT_move";
921
ot->name = "Move Cursor";
922
ot->description = "Move cursor to position type";
923
ot->idname = "FONT_OT_move";
966
925
/* api callbacks */
968
ot->poll= ED_operator_editfont;
926
ot->exec = move_exec;
927
ot->poll = ED_operator_editfont;
971
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
930
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
974
RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to.");
933
RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to");
977
936
/******************* move select operator ********************/
986
945
void FONT_OT_move_select(wmOperatorType *ot)
988
947
/* identifiers */
989
ot->name= "Move Select";
990
ot->description= "Make selection from current cursor position to new cursor position type";
991
ot->idname= "FONT_OT_move_select";
948
ot->name = "Move Select";
949
ot->description = "Make selection from current cursor position to new cursor position type";
950
ot->idname = "FONT_OT_move_select";
993
952
/* api callbacks */
994
ot->exec= move_select_exec;
995
ot->poll= ED_operator_editfont;
953
ot->exec = move_select_exec;
954
ot->poll = ED_operator_editfont;
998
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
957
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1000
959
/* properties */
1001
RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to, to make a selection.");
960
RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to, to make a selection");
1004
963
/************************* change spacing **********************/
1028
987
void FONT_OT_change_spacing(wmOperatorType *ot)
1030
989
/* identifiers */
1031
ot->name= "Change Spacing";
1032
ot->description= "Change font spacing";
1033
ot->idname= "FONT_OT_change_spacing";
990
ot->name = "Change Spacing";
991
ot->description = "Change font spacing";
992
ot->idname = "FONT_OT_change_spacing";
1035
994
/* api callbacks */
1036
ot->exec= change_spacing_exec;
1037
ot->poll= ED_operator_editfont;
995
ot->exec = change_spacing_exec;
996
ot->poll = ED_operator_editfont;
1040
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
999
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1042
1001
/* properties */
1043
RNA_def_int(ot->srna, "delta", 1, -20, 20, "Delta", "Amount to decrease or increasing character spacing with.", -20, 20);
1002
RNA_def_int(ot->srna, "delta", 1, -20, 20, "Delta", "Amount to decrease or increase character spacing with", -20, 20);
1046
1005
/************************* change character **********************/
1053
1012
EditFont *ef= cu->editfont;
1054
1013
int character, delta= RNA_int_get(op->ptr, "delta");
1057
1016
return OPERATOR_CANCELLED;
1059
1018
character= ef->textbuf[cu->pos - 1];
1060
1019
character += delta;
1061
1020
CLAMP(character, 0, 255);
1063
if(character == ef->textbuf[cu->pos - 1])
1022
if (character == ef->textbuf[cu->pos - 1])
1064
1023
return OPERATOR_CANCELLED;
1066
1025
ef->textbuf[cu->pos - 1]= character;
1068
text_update_edited(C, scene, obedit, 1, 0);
1027
text_update_edited(C, scene, obedit, 1, FO_EDIT);
1070
1029
return OPERATOR_FINISHED;
1073
1032
void FONT_OT_change_character(wmOperatorType *ot)
1075
1034
/* identifiers */
1076
ot->name= "Change Character";
1077
ot->description= "Change font character code";
1078
ot->idname= "FONT_OT_change_character";
1035
ot->name = "Change Character";
1036
ot->description = "Change font character code";
1037
ot->idname = "FONT_OT_change_character";
1080
1039
/* api callbacks */
1081
ot->exec= change_character_exec;
1082
ot->poll= ED_operator_editfont;
1040
ot->exec = change_character_exec;
1041
ot->poll = ED_operator_editfont;
1085
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
1044
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1087
1046
/* properties */
1088
RNA_def_int(ot->srna, "delta", 1, -255, 255, "Delta", "Number to increase or decrease character code with.", -255, 255);
1047
RNA_def_int(ot->srna, "delta", 1, -255, 255, "Delta", "Number to increase or decrease character code with", -255, 255);
1091
1050
/******************* line break operator ********************/
1150
1109
EditFont *ef= cu->editfont;
1151
1110
int x, selstart, selend, type= RNA_enum_get(op->ptr, "type");
1154
1113
return OPERATOR_CANCELLED;
1156
if(BKE_font_getselection(obedit, &selstart, &selend)) {
1157
if(type == DEL_NEXT_SEL) type= DEL_SELECTION;
1158
else if(type == DEL_PREV_SEL) type= DEL_SELECTION;
1115
if (BKE_font_getselection(obedit, &selstart, &selend)) {
1116
if (type == DEL_NEXT_SEL) type= DEL_SELECTION;
1117
else if (type == DEL_PREV_SEL) type= DEL_SELECTION;
1161
if(type == DEL_NEXT_SEL) type= DEL_NEXT_CHAR;
1162
else if(type == DEL_PREV_SEL) type= DEL_PREV_CHAR;
1120
if (type == DEL_NEXT_SEL) type= DEL_NEXT_CHAR;
1121
else if (type == DEL_PREV_SEL) type= DEL_PREV_CHAR;
1168
1127
ef->textbuf[0]= 0;
1170
1129
case DEL_SELECTION:
1171
if(!kill_selection(obedit, 0))
1130
if (!kill_selection(obedit, 0))
1172
1131
return OPERATOR_CANCELLED;
1174
1133
case DEL_PREV_CHAR:
1176
1135
return OPERATOR_CANCELLED;
1178
for(x=cu->pos;x<=cu->len;x++)
1137
for (x=cu->pos;x<=cu->len;x++)
1179
1138
ef->textbuf[x-1]= ef->textbuf[x];
1180
for(x=cu->pos;x<=cu->len;x++)
1139
for (x=cu->pos;x<=cu->len;x++)
1181
1140
ef->textbufinfo[x-1]= ef->textbufinfo[x];
1184
1143
ef->textbuf[--cu->len]='\0';
1186
1145
case DEL_NEXT_CHAR:
1187
if(cu->pos>=cu->len)
1146
if (cu->pos>=cu->len)
1188
1147
return OPERATOR_CANCELLED;
1190
for(x=cu->pos;x<cu->len;x++)
1149
for (x=cu->pos;x<cu->len;x++)
1191
1150
ef->textbuf[x]= ef->textbuf[x+1];
1192
for(x=cu->pos;x<cu->len;x++)
1151
for (x=cu->pos;x<cu->len;x++)
1193
1152
ef->textbufinfo[x]= ef->textbufinfo[x+1];
1195
1154
ef->textbuf[--cu->len]='\0';
1206
1165
void FONT_OT_delete(wmOperatorType *ot)
1208
1167
/* identifiers */
1210
ot->description= "Delete text by cursor position";
1211
ot->idname= "FONT_OT_delete";
1168
ot->name = "Delete";
1169
ot->description = "Delete text by cursor position";
1170
ot->idname = "FONT_OT_delete";
1213
1172
/* api callbacks */
1214
ot->exec= delete_exec;
1215
ot->poll= ED_operator_editfont;
1173
ot->exec = delete_exec;
1174
ot->poll = ED_operator_editfont;
1218
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
1177
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1220
1179
/* properties */
1221
RNA_def_enum(ot->srna, "type", delete_type_items, DEL_ALL, "Type", "Which part of the text to delete.");
1180
RNA_def_enum(ot->srna, "type", delete_type_items, DEL_ALL, "Type", "Which part of the text to delete");
1224
1183
/*********************** insert text operator *************************/
1228
1187
Scene *scene= CTX_data_scene(C);
1229
1188
Object *obedit= CTX_data_edit_object(C);
1230
1189
char *inserted_utf8;
1231
wchar_t *inserted_text, first;
1190
wchar_t *inserted_text;
1234
if(!RNA_property_is_set(op->ptr, "text"))
1193
if (!RNA_struct_property_is_set(op->ptr, "text"))
1235
1194
return OPERATOR_CANCELLED;
1237
1196
inserted_utf8= RNA_string_get_alloc(op->ptr, "text", NULL, 0);
1238
len= strlen(inserted_utf8);
1197
len= BLI_strlen_utf8(inserted_utf8);
1240
1199
inserted_text= MEM_callocN(sizeof(wchar_t)*(len+1), "FONT_insert_text");
1241
utf8towchar(inserted_text, inserted_utf8);
1242
first= inserted_text[0];
1200
BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len+1);
1244
for(a=0; a<len; a++)
1202
for (a=0; a<len; a++)
1245
1203
insert_into_textbuf(obedit, inserted_text[a]);
1247
1205
MEM_freeN(inserted_text);
1248
1206
MEM_freeN(inserted_utf8);
1250
1208
kill_selection(obedit, 1);
1251
text_update_edited(C, scene, obedit, 1, 0);
1209
text_update_edited(C, scene, obedit, 1, FO_EDIT);
1253
1211
return OPERATOR_FINISHED;
1265
1223
int event= evt->type, val= evt->val;
1266
1224
wchar_t inserted_text[2]= {0};
1268
if(RNA_property_is_set(op->ptr, "text"))
1226
if (RNA_struct_property_is_set(op->ptr, "text"))
1269
1227
return insert_text_exec(C, op);
1229
if (RNA_struct_property_is_set(op->ptr, "accent")) {
1230
if (cu->len!=0 && cu->pos>0)
1232
return OPERATOR_FINISHED;
1271
1235
/* tab should exit editmode, but we allow it to be typed using modifier keys */
1273
if((alt||ctrl||shift) == 0)
1236
if (event==TABKEY) {
1237
if ((alt||ctrl||shift) == 0)
1274
1238
return OPERATOR_PASS_THROUGH;
1278
else if(event==BACKSPACEKEY)
1242
else if (event==BACKSPACEKEY)
1245
if (val && (ascii || evt->utf8_buf[0])) {
1282
1246
/* handle case like TAB (== 9) */
1283
if((ascii > 31 && ascii < 254 && ascii != 127) || (ascii==13) || (ascii==10) || (ascii==8)) {
1247
if ( (ascii > 31 && ascii < 254 && ascii != 127) ||
1254
if (evt->utf8_buf[0]) {
1255
BLI_strncpy_wchar_from_utf8(inserted_text, evt->utf8_buf, 1);
1256
ascii= inserted_text[0];
1257
insert_into_textbuf(obedit, ascii);
1260
else if (accentcode) {
1286
1262
inserted_text[0]= findaccent(ef->textbuf[cu->pos-1], ascii);
1287
1263
ef->textbuf[cu->pos-1]= inserted_text[0];
1291
else if(cu->len<MAXTEXT-1) {
1267
else if (cu->len<MAXTEXT-1) {
1293
1269
/* might become obsolete, apple has default values for this, other OS's too? */
1294
if(ascii=='t') ascii= 137;
1295
else if(ascii=='c') ascii= 169;
1296
else if(ascii=='f') ascii= 164;
1297
else if(ascii=='g') ascii= 176;
1298
else if(ascii=='l') ascii= 163;
1299
else if(ascii=='r') ascii= 174;
1300
else if(ascii=='s') ascii= 223;
1301
else if(ascii=='y') ascii= 165;
1302
else if(ascii=='.') ascii= 138;
1303
else if(ascii=='1') ascii= 185;
1304
else if(ascii=='2') ascii= 178;
1305
else if(ascii=='3') ascii= 179;
1306
else if(ascii=='%') ascii= 139;
1307
else if(ascii=='?') ascii= 191;
1308
else if(ascii=='!') ascii= 161;
1309
else if(ascii=='x') ascii= 215;
1310
else if(ascii=='>') ascii= 187;
1311
else if(ascii=='<') ascii= 171;
1270
if (ascii=='t') ascii= 137;
1271
else if (ascii=='c') ascii= 169;
1272
else if (ascii=='f') ascii= 164;
1273
else if (ascii=='g') ascii= 176;
1274
else if (ascii=='l') ascii= 163;
1275
else if (ascii=='r') ascii= 174;
1276
else if (ascii=='s') ascii= 223;
1277
else if (ascii=='y') ascii= 165;
1278
else if (ascii=='.') ascii= 138;
1279
else if (ascii=='1') ascii= 185;
1280
else if (ascii=='2') ascii= 178;
1281
else if (ascii=='3') ascii= 179;
1282
else if (ascii=='%') ascii= 139;
1283
else if (ascii=='?') ascii= 191;
1284
else if (ascii=='!') ascii= 161;
1285
else if (ascii=='x') ascii= 215;
1286
else if (ascii=='>') ascii= 187;
1287
else if (ascii=='<') ascii= 171;
1314
1290
inserted_text[0]= ascii;
1318
1294
kill_selection(obedit, 1);
1319
text_update_edited(C, scene, obedit, 1, 0);
1295
text_update_edited(C, scene, obedit, 1, FO_EDIT);
1322
1298
inserted_text[0]= ascii;
1323
1299
insert_into_textbuf(obedit, ascii);
1324
text_update_edited(C, scene, obedit, 1, 0);
1300
text_update_edited(C, scene, obedit, 1, FO_EDIT);
1327
else if(val && event == BACKSPACEKEY) {
1328
if(alt && cu->len!=0 && cu->pos>0)
1303
else if (val && event == BACKSPACEKEY) {
1304
if (alt && cu->len!=0 && cu->pos>0)
1331
1307
return OPERATOR_PASS_THROUGH;
1334
1310
return OPERATOR_PASS_THROUGH;
1336
if(inserted_text[0]) {
1312
if (inserted_text[0]) {
1337
1313
/* store as utf8 in RNA string */
1338
1314
char inserted_utf8[8] = {0};
1340
wcs2utf8s(inserted_utf8, inserted_text);
1316
BLI_strncpy_wchar_as_utf8(inserted_utf8, inserted_text, sizeof(inserted_utf8));
1341
1317
RNA_string_set(op->ptr, "text", inserted_utf8);
1320
/* reset property? */
1344
1323
return OPERATOR_FINISHED;
1347
1326
void FONT_OT_text_insert(wmOperatorType *ot)
1349
1328
/* identifiers */
1350
ot->name= "Insert Text";
1351
ot->description= "Insert text at cursor position";
1352
ot->idname= "FONT_OT_text_insert";
1329
ot->name = "Insert Text";
1330
ot->description = "Insert text at cursor position";
1331
ot->idname = "FONT_OT_text_insert";
1354
1333
/* api callbacks */
1355
ot->exec= insert_text_exec;
1356
ot->invoke= insert_text_invoke;
1357
ot->poll= ED_operator_editfont;
1334
ot->exec = insert_text_exec;
1335
ot->invoke = insert_text_invoke;
1336
ot->poll = ED_operator_editfont;
1360
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
1339
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1362
1341
/* properties */
1363
RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position.");
1342
RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position");
1343
RNA_def_boolean(ot->srna, "accent", 0, "Accent mode", "Next typed character will strike through previous, for special character input");
1367
1347
/*********************** textbox add operator *************************/
1368
static int textbox_poll(bContext *C)
1370
Object *ob = CTX_data_active_object(C);
1372
if (!ED_operator_object_active_editable(C) ) return 0;
1373
if (ob->type != OB_FONT) return 0;
1378
static int textbox_add_exec(bContext *C, wmOperator *op)
1348
static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
1380
1350
Object *obedit= CTX_data_active_object(C);
1381
1351
Curve *cu= obedit->data;
1438
1408
void FONT_OT_textbox_remove(wmOperatorType *ot)
1440
1410
/* identifiers */
1441
ot->name= "Remove Textbox";
1442
ot->description= "Remove the textbox";
1443
ot->idname= "FONT_OT_textbox_remove";
1411
ot->name = "Remove Textbox";
1412
ot->description = "Remove the textbox";
1413
ot->idname = "FONT_OT_textbox_remove";
1445
1415
/* api callbacks */
1446
ot->exec= textbox_remove_exec;
1447
ot->poll= textbox_poll;
1416
ot->exec = textbox_remove_exec;
1417
ot->poll = ED_operator_object_active_editable_font;
1450
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
1452
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box.", 0, INT_MAX);
1420
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1422
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box", 0, INT_MAX);
1576
1544
void FONT_OT_case_set(wmOperatorType *ot)
1578
1546
/* identifiers */
1579
ot->name= "Set Case";
1580
ot->description= "Set font case";
1581
ot->idname= "FONT_OT_case_set";
1547
ot->name = "Set Case";
1548
ot->description = "Set font case";
1549
ot->idname = "FONT_OT_case_set";
1583
1551
/* api callbacks */
1584
ot->exec= set_case_exec;
1585
ot->poll= ED_operator_editfont;
1552
ot->exec = set_case_exec;
1553
ot->poll = ED_operator_editfont;
1588
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
1556
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1590
1558
/* properties */
1591
RNA_def_enum(ot->srna, "case", case_items, CASE_LOWER, "Case", "Lower or upper case.");
1559
RNA_def_enum(ot->srna, "case", case_items, CASE_LOWER, "Case", "Lower or upper case");
1594
1562
/********************** toggle case operator *********************/
1596
static int toggle_case_exec(bContext *C, wmOperator *op)
1564
static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
1598
1566
Object *obedit= CTX_data_edit_object(C);
1599
1567
Curve *cu= obedit->data;
1619
1587
void FONT_OT_case_toggle(wmOperatorType *ot)
1621
1589
/* identifiers */
1622
ot->name= "Toggle Case";
1623
ot->description= "Toggle font case";
1624
ot->idname= "FONT_OT_case_toggle";
1590
ot->name = "Toggle Case";
1591
ot->description = "Toggle font case";
1592
ot->idname = "FONT_OT_case_toggle";
1626
1594
/* api callbacks */
1627
ot->exec= toggle_case_exec;
1628
ot->poll= ED_operator_editfont;
1595
ot->exec = toggle_case_exec;
1596
ot->poll = ED_operator_editfont;
1631
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
1599
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1634
1602
/* **************** Open Font ************** */
1636
static void open_init(bContext *C, wmOperator *op)
1604
static void font_ui_template_init(bContext *C, wmOperator *op)
1638
1606
PropertyPointerRNA *pprop;
1641
1609
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
1644
static int open_cancel(bContext *C, wmOperator *op)
1612
static int font_open_cancel(bContext *UNUSED(C), wmOperator *op)
1646
1614
MEM_freeN(op->customdata);
1647
1615
op->customdata= NULL;
1648
1616
return OPERATOR_CANCELLED;
1651
static int open_exec(bContext *C, wmOperator *op)
1619
static int font_open_exec(bContext *C, wmOperator *op)
1653
Object *ob = CTX_data_active_object(C);
1621
struct Main *bmain= CTX_data_main(C);
1656
1623
PropertyPointerRNA *pprop;
1657
1624
PointerRNA idptr;
1660
RNA_string_get(op->ptr, "filepath", str);
1662
font = load_vfont(str);
1665
if(op->customdata) MEM_freeN(op->customdata);
1625
char filepath[FILE_MAX];
1626
RNA_string_get(op->ptr, "filepath", filepath);
1628
font= load_vfont(bmain, filepath);
1631
if (op->customdata) MEM_freeN(op->customdata);
1666
1632
return OPERATOR_CANCELLED;
1635
if (!op->customdata)
1636
font_ui_template_init(C, op);
1672
1638
/* hook into UI */
1673
1639
pprop= op->customdata;
1676
1642
/* when creating new ID blocks, use is already 1, but RNA
1677
1643
* pointer se also increases user, so this compensates it */
1680
1646
RNA_id_pointer_create(&font->id, &idptr);
1681
1647
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
1682
1648
RNA_property_update(C, &pprop->ptr, pprop->prop);
1683
} else if(ob && ob->type == OB_FONT) {
1685
id_us_min(&cu->vfont->id);
1689
DAG_id_flush_update(ob->data, OB_RECALC_DATA);
1690
WM_event_add_notifier(C, NC_GEOM|ND_DATA|NA_EDITED, ob->data);
1692
1651
MEM_freeN(op->customdata);
1694
1653
return OPERATOR_FINISHED;
1697
static int open_invoke(bContext *C, wmOperator *op, wmEvent *event)
1656
static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
1699
Object *ob = CTX_data_active_object(C);
1701
1658
VFont *font=NULL;
1703
if (ob && ob->type == OB_FONT) {
1662
PropertyPointerRNA *pprop;
1664
font_ui_template_init(C, op);
1667
pprop= op->customdata;
1670
idptr= RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop);
1671
font= idptr.id.data;
1707
path = (font && font->name)? font->name: U.fontdir;
1709
if(RNA_property_is_set(op->ptr, "filepath"))
1710
return open_exec(C, op);
1674
path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir;
1676
if (RNA_struct_property_is_set(op->ptr, "filepath"))
1677
return font_open_exec(C, op);
1714
1679
RNA_string_set(op->ptr, "filepath", path);
1715
1680
WM_event_add_fileselect(C, op);
1720
1685
void FONT_OT_open(wmOperatorType *ot)
1722
1687
/* identifiers */
1724
ot->idname= "FONT_OT_open";
1688
ot->name = "Open Font";
1689
ot->idname = "FONT_OT_open";
1726
1691
/* api callbacks */
1727
ot->exec= open_exec;
1728
ot->invoke= open_invoke;
1729
ot->cancel= open_cancel;
1692
ot->exec = font_open_exec;
1693
ot->invoke = open_invoke;
1694
ot->cancel = font_open_cancel;
1732
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
1697
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1734
1699
/* properties */
1735
WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
1700
WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
1738
1703
/******************* delete operator *********************/
1739
static int font_unlink_poll(bContext *C)
1741
Object *ob = CTX_data_active_object(C);
1744
if (!ED_operator_object_active_editable(C) ) return 0;
1745
if (ob->type != OB_FONT) return 0;
1748
if (cu && strcmp(cu->vfont->name, "<builtin>")==0) return 0;
1752
1705
static int font_unlink_exec(bContext *C, wmOperator *op)
1754
Object *ob = CTX_data_active_object(C);
1756
VFont *font, *builtin_font;
1707
VFont *builtin_font;
1710
PropertyPointerRNA pprop;
1712
uiIDContextProperty(C, &pprop.ptr, &pprop.prop);
1762
BKE_report(op->reports, RPT_ERROR, "No font datablock available to unlink.");
1714
if (pprop.prop==NULL) {
1715
BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink");
1763
1716
return OPERATOR_CANCELLED;
1766
if (strcmp(font->name, "<builtin>")==0) {
1767
BKE_report(op->reports, RPT_WARNING, "Can't unlink the default builtin font.");
1768
return OPERATOR_FINISHED;
1771
/* revert back to builtin font */
1772
1719
builtin_font = get_builtin_font();
1774
cu->vfont = builtin_font;
1775
id_us_plus(&cu->vfont->id);
1776
id_us_min(&font->id);
1778
DAG_id_flush_update(ob->data, OB_RECALC_DATA);
1779
WM_event_add_notifier(C, NC_GEOM|ND_DATA|NA_EDITED, ob->data);
1721
RNA_id_pointer_create(&builtin_font->id, &idptr);
1722
RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr);
1723
RNA_property_update(C, &pprop.ptr, pprop.prop);
1781
1725
return OPERATOR_FINISHED;
1784
1728
void FONT_OT_unlink(wmOperatorType *ot)
1786
1730
/* identifiers */
1788
ot->idname= "FONT_OT_unlink";
1789
ot->description= "Unlink active font data block";
1731
ot->name = "Unlink";
1732
ot->idname = "FONT_OT_unlink";
1733
ot->description = "Unlink active font data block";
1791
1735
/* api callbacks */
1792
ot->exec= font_unlink_exec;
1793
ot->poll= font_unlink_poll;
1736
ot->exec = font_unlink_exec;
1797
1740
/* **************** undo for font object ************** */
1799
static void undoFont_to_editFont(void *strv, void *ecu)
1742
static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata))
1801
1744
Curve *cu= (Curve *)ecu;
1802
1745
EditFont *ef= cu->editfont;