2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* font.c
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version. The Blender
|
|
|
|
|
* Foundation also sells licenses for use in proprietary software under
|
|
|
|
|
* the Blender License. See http://www.blender.org/BL/ for information
|
|
|
|
|
* about this.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
2002-11-25 12:02:15 +00:00
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_vfontdata.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_packedFile_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
#include "DNA_vfont_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
#include "BKE_bad_level_calls.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_packedFile.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_font.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
#include "BKE_anim.h"
|
|
|
|
|
#include "BKE_curve.h"
|
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
|
|
|
|
|
|
|
|
|
|
struct SelBox *selboxes= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
struct chartrans {
|
|
|
|
|
float xof, yof;
|
|
|
|
|
float rot;
|
|
|
|
|
short linenr,charnr;
|
2005-06-17 21:04:27 +00:00
|
|
|
char dobreak;
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void free_vfont(struct VFont *vf)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (vf == 0) return;
|
|
|
|
|
|
|
|
|
|
if (vf->data) {
|
|
|
|
|
for (i = 0; i < MAX_VF_CHARS; i++){
|
|
|
|
|
while (vf->data->nurbsbase[i].first) {
|
|
|
|
|
Nurb *nu = vf->data->nurbsbase[i].first;
|
|
|
|
|
if (nu->bezt) MEM_freeN(nu->bezt);
|
|
|
|
|
BLI_freelinkN(&vf->data->nurbsbase[i], nu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(vf->data);
|
|
|
|
|
vf->data = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vf->packedfile) {
|
|
|
|
|
freePackedFile(vf->packedfile);
|
|
|
|
|
vf->packedfile = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void *builtin_font_data= NULL;
|
|
|
|
|
static int builtin_font_size= 0;
|
|
|
|
|
|
|
|
|
|
void BKE_font_register_builtin(void *mem, int size)
|
|
|
|
|
{
|
|
|
|
|
builtin_font_data= mem;
|
|
|
|
|
builtin_font_size= size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PackedFile *get_builtin_packedfile(void)
|
|
|
|
|
{
|
|
|
|
|
if (!builtin_font_data) {
|
2003-11-23 23:51:18 +00:00
|
|
|
printf("Internal error, builtin font not loaded\n");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
} else {
|
|
|
|
|
void *mem= MEM_mallocN(builtin_font_size, "vfd_builtin");
|
|
|
|
|
|
|
|
|
|
memcpy(mem, builtin_font_data, builtin_font_size);
|
|
|
|
|
|
|
|
|
|
return newPackedFileMemory(mem, builtin_font_size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static VFontData *vfont_get_data(VFont *vfont)
|
|
|
|
|
{
|
|
|
|
|
if (!vfont->data) {
|
|
|
|
|
PackedFile *pf;
|
|
|
|
|
|
|
|
|
|
if (BLI_streq(vfont->name, "<builtin>")) {
|
|
|
|
|
pf= get_builtin_packedfile();
|
|
|
|
|
} else {
|
|
|
|
|
if (vfont->packedfile) {
|
|
|
|
|
pf= vfont->packedfile;
|
|
|
|
|
} else {
|
|
|
|
|
pf= newPackedFile(vfont->name);
|
|
|
|
|
}
|
2004-12-03 14:30:32 +00:00
|
|
|
if(!pf) {
|
|
|
|
|
printf("Font file doesn't exist: %s\n", vfont->name);
|
|
|
|
|
|
|
|
|
|
strcpy(vfont->name, "<builtin>");
|
|
|
|
|
pf= get_builtin_packedfile();
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pf) {
|
2005-09-04 09:30:57 +00:00
|
|
|
#ifdef WITH_FREETYPE2
|
|
|
|
|
vfont->data= BLI_vfontdata_from_freetypefont(pf);
|
|
|
|
|
#else
|
2002-10-12 11:37:38 +00:00
|
|
|
vfont->data= BLI_vfontdata_from_psfont(pf);
|
2005-09-04 09:30:57 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
if (pf != vfont->packedfile) {
|
|
|
|
|
freePackedFile(pf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vfont->data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VFont *load_vfont(char *name)
|
|
|
|
|
{
|
|
|
|
|
char filename[FILE_MAXFILE];
|
|
|
|
|
VFont *vfont= NULL;
|
|
|
|
|
PackedFile *pf;
|
|
|
|
|
int is_builtin;
|
|
|
|
|
|
|
|
|
|
if (BLI_streq(name, "<builtin>")) {
|
|
|
|
|
strcpy(filename, name);
|
|
|
|
|
|
|
|
|
|
pf= get_builtin_packedfile();
|
|
|
|
|
is_builtin= 1;
|
|
|
|
|
} else {
|
|
|
|
|
char dir[FILE_MAXDIR];
|
|
|
|
|
|
|
|
|
|
strcpy(dir, name);
|
|
|
|
|
BLI_splitdirstring(dir, filename);
|
|
|
|
|
|
|
|
|
|
pf= newPackedFile(name);
|
|
|
|
|
is_builtin= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pf) {
|
|
|
|
|
VFontData *vfd;
|
|
|
|
|
|
|
|
|
|
waitcursor(1);
|
|
|
|
|
|
2005-09-04 09:30:57 +00:00
|
|
|
#ifdef WITH_FREETYPE2
|
|
|
|
|
vfd= BLI_vfontdata_from_freetypefont(pf);
|
|
|
|
|
#else
|
2002-10-12 11:37:38 +00:00
|
|
|
vfd= BLI_vfontdata_from_psfont(pf);
|
2005-09-04 09:30:57 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if (vfd) {
|
|
|
|
|
vfont = alloc_libblock(&G.main->vfont, ID_VF, filename);
|
|
|
|
|
vfont->data = vfd;
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(vfont->name, name, sizeof(vfont->name));
|
|
|
|
|
|
|
|
|
|
// if autopack is on store the packedfile in de font structure
|
|
|
|
|
if (!is_builtin && (G.fileflags & G_AUTOPACK)) {
|
|
|
|
|
vfont->packedfile = pf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!vfont || vfont->packedfile != pf) {
|
|
|
|
|
freePackedFile(pf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
waitcursor(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vfont;
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
static VFont *which_vfont(Curve *cu, CharInfo *info)
|
|
|
|
|
{
|
|
|
|
|
switch(info->flag & CU_STYLE) {
|
|
|
|
|
case CU_BOLD:
|
|
|
|
|
return(cu->vfontb);
|
|
|
|
|
case CU_ITALIC:
|
|
|
|
|
return(cu->vfonti);
|
|
|
|
|
case (CU_BOLD|CU_ITALIC):
|
|
|
|
|
return(cu->vfontbi);
|
|
|
|
|
default:
|
|
|
|
|
return(cu->vfont);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, int charidx, short mat_nr)
|
|
|
|
|
{
|
|
|
|
|
Nurb *nu2;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
|
|
|
|
|
nu2 =(Nurb*) MEM_callocN(sizeof(Nurb),"underline_nurb");
|
|
|
|
|
if (nu2 == NULL) return;
|
|
|
|
|
nu2->resolu= cu->resolu;
|
|
|
|
|
nu2->bezt = NULL;
|
|
|
|
|
nu2->knotsu = nu2->knotsv = 0;
|
|
|
|
|
nu2->flag= 0;
|
|
|
|
|
nu2->charidx = charidx+1000;
|
|
|
|
|
nu2->mat_nr= mat_nr;
|
|
|
|
|
nu2->pntsu = 4;
|
|
|
|
|
nu2->pntsv = 1;
|
|
|
|
|
nu2->orderu = 4;
|
|
|
|
|
nu2->orderv = 1;
|
|
|
|
|
nu2->flagu = CU_CYCLIC;
|
|
|
|
|
|
|
|
|
|
bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint),"underline_bp");
|
|
|
|
|
if (bp == 0){
|
|
|
|
|
MEM_freeN(nu2);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
nu2->bp = bp;
|
|
|
|
|
|
|
|
|
|
nu2->bp[0].vec[0] = x1;
|
|
|
|
|
nu2->bp[0].vec[1] = y1;
|
|
|
|
|
nu2->bp[0].vec[2] = 0;
|
|
|
|
|
nu2->bp[0].vec[3] = 1.0;
|
|
|
|
|
nu2->bp[1].vec[0] = x2;
|
|
|
|
|
nu2->bp[1].vec[1] = y1;
|
|
|
|
|
nu2->bp[1].vec[2] = 0;
|
|
|
|
|
nu2->bp[1].vec[3] = 1.0;
|
|
|
|
|
nu2->bp[2].vec[0] = x2;
|
|
|
|
|
nu2->bp[2].vec[1] = y2;
|
|
|
|
|
nu2->bp[2].vec[2] = 0;
|
|
|
|
|
nu2->bp[2].vec[3] = 1.0;
|
|
|
|
|
nu2->bp[3].vec[0] = x1;
|
|
|
|
|
nu2->bp[3].vec[1] = y2;
|
|
|
|
|
nu2->bp[3].vec[2] = 0;
|
|
|
|
|
nu2->bp[3].vec[3] = 1.0;
|
|
|
|
|
|
|
|
|
|
nu2->type = CU_2D;
|
|
|
|
|
BLI_addtail(&(cu->nurb), nu2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
static void buildchar(Curve *cu, unsigned char ascii, CharInfo *info, float ofsx, float ofsy, float rot, int charidx)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
BezTriple *bezt1, *bezt2;
|
|
|
|
|
Nurb *nu1, *nu2;
|
|
|
|
|
float *fp, fsize, shear, x, si, co;
|
|
|
|
|
VFontData *vfd;
|
2005-06-17 21:04:27 +00:00
|
|
|
int i, sel=0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
vfd= vfont_get_data(which_vfont(cu, info));
|
2002-10-12 11:37:38 +00:00
|
|
|
if (!vfd) return;
|
2005-06-17 21:04:27 +00:00
|
|
|
|
|
|
|
|
if (cu->selend < cu->selstart) {
|
|
|
|
|
if ((charidx >= (cu->selend)) && (charidx <= (cu->selstart-2)))
|
|
|
|
|
sel= 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if ((charidx >= (cu->selstart-1)) && (charidx <= (cu->selend-1)))
|
|
|
|
|
sel= 1;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* make a copy at distance ofsx,ofsy with shear*/
|
2002-10-12 11:37:38 +00:00
|
|
|
fsize= cu->fsize;
|
|
|
|
|
shear= cu->shear;
|
|
|
|
|
si= (float)sin(rot);
|
|
|
|
|
co= (float)cos(rot);
|
|
|
|
|
|
|
|
|
|
nu1 = vfd->nurbsbase[ascii].first;
|
|
|
|
|
while(nu1)
|
|
|
|
|
{
|
|
|
|
|
bezt1 = nu1->bezt;
|
|
|
|
|
if (bezt1){
|
|
|
|
|
nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb");
|
|
|
|
|
if (nu2 == 0) break;
|
|
|
|
|
memcpy(nu2, nu1, sizeof(struct Nurb));
|
|
|
|
|
nu2->resolu= cu->resolu;
|
|
|
|
|
nu2->bp = 0;
|
|
|
|
|
nu2->knotsu = nu2->knotsv = 0;
|
2004-07-08 20:38:27 +00:00
|
|
|
nu2->flag= CU_SMOOTH;
|
2005-06-17 21:04:27 +00:00
|
|
|
nu2->charidx = charidx;
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
if (info->mat_nr) {
|
|
|
|
|
nu2->mat_nr= info->mat_nr-1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
nu2->mat_nr= 0;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
/* nu2->trim.first = 0; */
|
|
|
|
|
/* nu2->trim.last = 0; */
|
|
|
|
|
i = nu2->pntsu;
|
|
|
|
|
|
|
|
|
|
bezt2 = (BezTriple*)MEM_mallocN(i * sizeof(BezTriple),"duplichar_bezt2");
|
|
|
|
|
if (bezt2 == 0){
|
|
|
|
|
MEM_freeN(nu2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
memcpy(bezt2, bezt1, i * sizeof(struct BezTriple));
|
|
|
|
|
nu2->bezt = bezt2;
|
|
|
|
|
|
|
|
|
|
if (shear != 0.0) {
|
|
|
|
|
bezt2 = nu2->bezt;
|
|
|
|
|
|
|
|
|
|
for (i= nu2->pntsu; i > 0; i--) {
|
|
|
|
|
bezt2->vec[0][0] += shear * bezt2->vec[0][1];
|
|
|
|
|
bezt2->vec[1][0] += shear * bezt2->vec[1][1];
|
|
|
|
|
bezt2->vec[2][0] += shear * bezt2->vec[2][1];
|
|
|
|
|
bezt2++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(rot!=0.0) {
|
|
|
|
|
bezt2= nu2->bezt;
|
|
|
|
|
for (i=nu2->pntsu; i > 0; i--) {
|
|
|
|
|
fp= bezt2->vec[0];
|
|
|
|
|
|
|
|
|
|
x= fp[0];
|
|
|
|
|
fp[0]= co*x + si*fp[1];
|
|
|
|
|
fp[1]= -si*x + co*fp[1];
|
|
|
|
|
x= fp[3];
|
|
|
|
|
fp[3]= co*x + si*fp[4];
|
|
|
|
|
fp[4]= -si*x + co*fp[4];
|
|
|
|
|
x= fp[6];
|
|
|
|
|
fp[6]= co*x + si*fp[7];
|
|
|
|
|
fp[7]= -si*x + co*fp[7];
|
|
|
|
|
|
|
|
|
|
bezt2++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bezt2 = nu2->bezt;
|
2005-06-17 21:04:27 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
for (i= nu2->pntsu; i > 0; i--) {
|
|
|
|
|
fp= bezt2->vec[0];
|
|
|
|
|
|
|
|
|
|
fp[0]= (fp[0]+ofsx)*fsize;
|
|
|
|
|
fp[1]= (fp[1]+ofsy)*fsize;
|
|
|
|
|
fp[3]= (fp[3]+ofsx)*fsize;
|
|
|
|
|
fp[4]= (fp[4]+ofsy)*fsize;
|
|
|
|
|
fp[6]= (fp[6]+ofsx)*fsize;
|
|
|
|
|
fp[7]= (fp[7]+ofsy)*fsize;
|
|
|
|
|
bezt2++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&(cu->nurb), nu2);
|
|
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
nu1 = nu1->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
int getselection(int *start, int *end)
|
|
|
|
|
{
|
|
|
|
|
Curve *cu;
|
|
|
|
|
|
|
|
|
|
if (G.obedit==NULL || G.obedit->type != OB_FONT) return 0;
|
|
|
|
|
|
|
|
|
|
cu= G.obedit->data;
|
|
|
|
|
|
|
|
|
|
if (cu->selstart == 0) return 0;
|
|
|
|
|
if (cu->selstart <= cu->selend) {
|
|
|
|
|
*start = cu->selstart-1;
|
|
|
|
|
*end = cu->selend-1;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*start = cu->selend;
|
|
|
|
|
*end = cu->selstart-2;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
struct chartrans *text_to_curve(Object *ob, int mode)
|
|
|
|
|
{
|
2005-06-17 21:04:27 +00:00
|
|
|
VFont *vfont, *oldvfont;
|
2005-06-17 22:52:11 +00:00
|
|
|
VFontData *vfd= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
Curve *cu, *cucu;
|
|
|
|
|
struct chartrans *chartransdata, *ct;
|
|
|
|
|
float distfac, tabfac, ctime, dtime, tvec[4], vec[4], rotvec[3], minx, maxx, miny, maxy;
|
|
|
|
|
float cmat[3][3], timeofs, si, co, sizefac;
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
float *f, maxlen=0, xof, yof, xtrax, linedist, *linedata, *linedata2, *linedata3, *linedata4;
|
2005-06-17 21:04:27 +00:00
|
|
|
int i, slen, oldflag, j;
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
short cnr=0, lnr=0, wsnr= 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
char ascii, *mem;
|
2005-06-17 21:04:27 +00:00
|
|
|
int outta;
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
float vecyo[3], curofs;
|
2005-06-17 21:04:27 +00:00
|
|
|
CharInfo *info;
|
|
|
|
|
float wsfac;
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
float ulwidth, uloverlap;
|
2005-06-17 21:04:27 +00:00
|
|
|
TextBox *tb;
|
|
|
|
|
int curbox;
|
|
|
|
|
int selstart, selend;
|
2005-06-18 00:52:25 +00:00
|
|
|
SelBox *sb= NULL; /* to please gcc */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* renark: do calculations including the trailing '\0' of a string
|
|
|
|
|
because the cursor can be at that location */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(ob->type!=OB_FONT) return 0;
|
|
|
|
|
|
|
|
|
|
cu= ob->data;
|
2005-06-17 21:04:27 +00:00
|
|
|
mem= cu->str;
|
|
|
|
|
slen = strlen(mem);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
if (cu->ulheight == 0.0) cu->ulheight = 0.05;
|
|
|
|
|
if (cu->str==0) return 0;
|
2005-06-17 21:04:27 +00:00
|
|
|
if (cu->strinfo==NULL) { /* old file */
|
|
|
|
|
cu->strinfo = MEM_callocN((slen+1) * sizeof(CharInfo), "strinfo compat");
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* calc offset and rotation of each char */
|
2002-10-12 11:37:38 +00:00
|
|
|
ct = chartransdata =
|
|
|
|
|
(struct chartrans*)MEM_callocN((slen+1)* sizeof(struct chartrans),"buildtext");
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
/* We assume the worst case: 1 character per line (is freed at end anyway) */
|
|
|
|
|
|
|
|
|
|
linedata= MEM_mallocN(sizeof(float)*(slen+2),"buildtext2");
|
|
|
|
|
linedata2= MEM_mallocN(sizeof(float)*(slen+2),"buildtext3");
|
2005-06-18 00:52:25 +00:00
|
|
|
linedata3= MEM_callocN(sizeof(float)*(slen+2),"buildtext4");
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
linedata4= MEM_callocN(sizeof(float)*(slen+2),"buildtext5");
|
2005-06-17 21:04:27 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
linedist= cu->linedist;
|
2005-06-17 21:04:27 +00:00
|
|
|
|
|
|
|
|
xof= cu->xof + (cu->tb[0].x/cu->fsize);
|
|
|
|
|
yof= cu->yof + (cu->tb[0].y/cu->fsize);
|
|
|
|
|
|
|
|
|
|
xtrax= 0.5f*cu->spacing-0.5f;
|
|
|
|
|
|
|
|
|
|
oldvfont = NULL;
|
|
|
|
|
|
|
|
|
|
for (i=0; i<slen; i++) cu->strinfo[i].flag &= ~CU_WRAP;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
if (selboxes) MEM_freeN(selboxes);
|
|
|
|
|
selboxes = NULL;
|
|
|
|
|
if (getselection(&selstart, &selend))
|
|
|
|
|
selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes");
|
|
|
|
|
|
|
|
|
|
tb = &(cu->tb[0]);
|
|
|
|
|
curbox= 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
for (i = 0 ; i<=slen ; i++) {
|
2005-06-17 21:04:27 +00:00
|
|
|
makebreak:
|
2002-10-12 11:37:38 +00:00
|
|
|
ascii = cu->str[i];
|
2005-06-17 21:04:27 +00:00
|
|
|
info = &(cu->strinfo[i]);
|
|
|
|
|
vfont = which_vfont(cu, info);
|
|
|
|
|
if (vfont==0) return 0;
|
|
|
|
|
if (vfont != oldvfont) {
|
|
|
|
|
vfd= vfont_get_data(vfont);
|
|
|
|
|
oldvfont = vfont;
|
|
|
|
|
}
|
|
|
|
|
if (!vfd) return 0;
|
|
|
|
|
if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+vfd->width[ascii])*cu->fsize) > tb->w) {
|
|
|
|
|
// fprintf(stderr, "linewidth exceeded: %c%c%c...\n", cu->str[i], cu->str[i+1], cu->str[i+2]);
|
|
|
|
|
for (j=i; j && (cu->str[j] != '\n') && (cu->str[j] != '\r') && (chartransdata[j].dobreak==0); j--) {
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
if (cu->str[j]==' ' || cu->str[j]=='-') {
|
2005-06-17 21:04:27 +00:00
|
|
|
ct -= (i-(j-1));
|
|
|
|
|
cnr -= (i-(j-1));
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
if (cu->str[j] == ' ') wsnr--;
|
|
|
|
|
if (cu->str[j] == '-') wsnr++;
|
2005-06-17 21:04:27 +00:00
|
|
|
i = j-1;
|
|
|
|
|
xof = ct->xof;
|
|
|
|
|
ct[1].dobreak = 1;
|
|
|
|
|
cu->strinfo[i+1].flag |= CU_WRAP;
|
|
|
|
|
goto makebreak;
|
|
|
|
|
}
|
|
|
|
|
if (chartransdata[j].dobreak) {
|
|
|
|
|
// fprintf(stderr, "word too long: %c%c%c...\n", cu->str[j], cu->str[j+1], cu->str[j+2]);
|
|
|
|
|
ct->dobreak= 1;
|
|
|
|
|
cu->strinfo[i+1].flag |= CU_WRAP;
|
|
|
|
|
ct -= 1;
|
|
|
|
|
cnr -= 1;
|
|
|
|
|
i--;
|
|
|
|
|
xof = ct->xof;
|
|
|
|
|
goto makebreak;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ascii== '\n' || ascii== '\r' || ascii==0 || ct->dobreak) {
|
2002-10-12 11:37:38 +00:00
|
|
|
ct->xof= xof;
|
|
|
|
|
ct->yof= yof;
|
|
|
|
|
ct->linenr= lnr;
|
|
|
|
|
ct->charnr= cnr;
|
|
|
|
|
|
2004-01-16 14:50:22 +00:00
|
|
|
yof-= linedist;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
maxlen= MAX2(maxlen, (xof-tb->x/cu->fsize));
|
|
|
|
|
linedata[lnr]= xof-tb->x/cu->fsize;
|
2002-10-12 11:37:38 +00:00
|
|
|
linedata2[lnr]= cnr;
|
2005-06-17 21:04:27 +00:00
|
|
|
linedata3[lnr]= tb->w/cu->fsize;
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
linedata4[lnr]= wsnr;
|
2005-06-17 21:04:27 +00:00
|
|
|
|
|
|
|
|
if ( (tb->h != 0.0) &&
|
|
|
|
|
((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize))) &&
|
|
|
|
|
(cu->totbox > (curbox+1)) ) {
|
|
|
|
|
maxlen= 0;
|
|
|
|
|
tb++;
|
|
|
|
|
curbox++;
|
|
|
|
|
yof= cu->yof + tb->y/cu->fsize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xof= cu->xof + (tb->x/cu->fsize);
|
2002-10-12 11:37:38 +00:00
|
|
|
lnr++;
|
|
|
|
|
cnr= 0;
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
wsnr= 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else if(ascii==9) { /* TAB */
|
|
|
|
|
ct->xof= xof;
|
|
|
|
|
ct->yof= yof;
|
|
|
|
|
ct->linenr= lnr;
|
|
|
|
|
ct->charnr= cnr++;
|
|
|
|
|
|
|
|
|
|
tabfac= (xof-cu->xof+0.01f);
|
|
|
|
|
tabfac= (float)(2.0*ceil(tabfac/2.0));
|
|
|
|
|
xof= cu->xof+tabfac;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ct->xof= xof;
|
|
|
|
|
ct->yof= yof;
|
|
|
|
|
ct->linenr= lnr;
|
|
|
|
|
ct->charnr= cnr++;
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
if (selboxes && (i>=selstart) && (i<=selend)) {
|
|
|
|
|
sb = &(selboxes[i-selstart]);
|
|
|
|
|
sb->y = yof*cu->fsize-linedist*cu->fsize*0.1;
|
|
|
|
|
sb->h = linedist*cu->fsize;
|
|
|
|
|
sb->w = xof*cu->fsize;
|
|
|
|
|
}
|
|
|
|
|
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
if (ascii==32) {
|
|
|
|
|
wsfac = cu->wordspace;
|
|
|
|
|
wsnr++;
|
|
|
|
|
} else wsfac = 1.0;
|
2005-06-25 22:51:51 +00:00
|
|
|
xof += (vfd->width[ascii]*wsfac*(1.0+(info->kern/40.0)) ) + xtrax;
|
2005-06-17 21:04:27 +00:00
|
|
|
|
|
|
|
|
if (selboxes && (i>=selstart) && (i<=selend)) sb->w = (xof*cu->fsize) - sb->w;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
ct++;
|
|
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
cu->lines= 1;
|
|
|
|
|
ct= chartransdata;
|
|
|
|
|
for (i= 0; i<=slen; i++, mem++, ct++) {
|
|
|
|
|
ascii = *mem;
|
|
|
|
|
if(ascii== '\n' || ascii== '\r' || ct->dobreak) cu->lines++;
|
|
|
|
|
}
|
2003-07-29 13:36:18 +00:00
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
// linedata is now: width of line
|
|
|
|
|
// linedata2 is now: number of characters
|
|
|
|
|
// linedata3 is now: maxlen of that line
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
// linedata4 is now: number of whitespaces of line
|
2003-07-29 13:36:18 +00:00
|
|
|
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
if(cu->spacemode!=CU_LEFT) {
|
2002-10-12 11:37:38 +00:00
|
|
|
ct= chartransdata;
|
|
|
|
|
|
|
|
|
|
if(cu->spacemode==CU_RIGHT) {
|
2005-06-17 21:04:27 +00:00
|
|
|
for(i=0;i<lnr;i++) linedata[i]= linedata3[i]-linedata[i];
|
2002-10-12 11:37:38 +00:00
|
|
|
for (i=0; i<=slen; i++) {
|
|
|
|
|
ct->xof+= linedata[ct->linenr];
|
|
|
|
|
ct++;
|
|
|
|
|
}
|
|
|
|
|
} else if(cu->spacemode==CU_MIDDLE) {
|
2005-06-17 21:04:27 +00:00
|
|
|
for(i=0;i<lnr;i++) linedata[i]= (linedata3[i]-linedata[i])/2;
|
2002-10-12 11:37:38 +00:00
|
|
|
for (i=0; i<=slen; i++) {
|
|
|
|
|
ct->xof+= linedata[ct->linenr];
|
|
|
|
|
ct++;
|
|
|
|
|
}
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
} else if((cu->spacemode==CU_FLUSH) &&
|
2005-06-18 00:52:25 +00:00
|
|
|
(cu->tb[0].w != 0.0)) {
|
2002-10-12 11:37:38 +00:00
|
|
|
for(i=0;i<lnr;i++)
|
|
|
|
|
if(linedata2[i]>1)
|
2005-06-17 21:04:27 +00:00
|
|
|
linedata[i]= (linedata3[i]-linedata[i])/(linedata2[i]-1);
|
2002-10-12 11:37:38 +00:00
|
|
|
for (i=0; i<=slen; i++) {
|
2005-06-17 21:04:27 +00:00
|
|
|
for (j=i; (cu->str[j]) && (cu->str[j]!='\n') &&
|
|
|
|
|
(cu->str[j]!='\r') && (chartransdata[j].dobreak==0) && (j<slen); j++);
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
// if ((cu->str[j]!='\r') && (cu->str[j]!='\n') && (cu->str[j])) {
|
2005-06-17 21:04:27 +00:00
|
|
|
ct->xof+= ct->charnr*linedata[ct->linenr];
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
// }
|
2002-10-12 11:37:38 +00:00
|
|
|
ct++;
|
|
|
|
|
}
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
} else if((cu->spacemode==CU_JUSTIFY) &&
|
|
|
|
|
(cu->tb[0].w != 0.0)) {
|
|
|
|
|
curofs= 0;
|
|
|
|
|
for (i=0; i<=slen; i++) {
|
|
|
|
|
for (j=i; (cu->str[j]) && (cu->str[j]!='\n') &&
|
|
|
|
|
(cu->str[j]!='\r') && (chartransdata[j].dobreak==0) && (j<slen); j++);
|
|
|
|
|
if ((cu->str[j]!='\r') && (cu->str[j]!='\n') &&
|
|
|
|
|
((chartransdata[j].dobreak!=0))) {
|
|
|
|
|
if (cu->str[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[ct->linenr];
|
|
|
|
|
ct->xof+= curofs;
|
|
|
|
|
}
|
|
|
|
|
if (cu->str[i]=='\n' || cu->str[i]=='\r' || chartransdata[i].dobreak) curofs= 0;
|
|
|
|
|
ct++;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* TEXT ON CURVE */
|
|
|
|
|
if(cu->textoncurve) {
|
|
|
|
|
cucu= cu->textoncurve->data;
|
|
|
|
|
|
|
|
|
|
oldflag= cucu->flag;
|
|
|
|
|
cucu->flag |= (CU_PATH+CU_FOLLOW);
|
|
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
if(cucu->path==NULL) makeDispListCurveTypes(cu->textoncurve, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
if(cucu->path) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mat3CpyMat4(cmat, cu->textoncurve->obmat);
|
|
|
|
|
sizefac= Normalise(cmat[0])/cu->fsize;
|
|
|
|
|
|
|
|
|
|
minx=miny= 1.0e20f;
|
|
|
|
|
maxx=maxy= -1.0e20f;
|
|
|
|
|
ct= chartransdata;
|
|
|
|
|
for (i=0; i<=slen; i++, ct++) {
|
|
|
|
|
if(minx>ct->xof) minx= ct->xof;
|
|
|
|
|
if(maxx<ct->xof) maxx= ct->xof;
|
|
|
|
|
if(miny>ct->yof) miny= ct->yof;
|
|
|
|
|
if(maxy<ct->yof) maxy= ct->yof;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* we put the x-coordinaat exact at the curve, the y is rotated */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* length correction */
|
2002-10-12 11:37:38 +00:00
|
|
|
distfac= sizefac*cucu->path->totdist/(maxx-minx);
|
|
|
|
|
timeofs= 0.0;
|
|
|
|
|
|
|
|
|
|
if(distfac > 1.0) {
|
2003-04-26 11:56:44 +00:00
|
|
|
/* path longer than text: spacemode involves */
|
2002-10-12 11:37:38 +00:00
|
|
|
distfac= 1.0f/distfac;
|
|
|
|
|
|
|
|
|
|
if(cu->spacemode==CU_RIGHT) {
|
|
|
|
|
timeofs= 1.0f-distfac;
|
|
|
|
|
}
|
|
|
|
|
else if(cu->spacemode==CU_MIDDLE) {
|
|
|
|
|
timeofs= (1.0f-distfac)/2.0f;
|
|
|
|
|
}
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
else if(cu->spacemode==CU_FLUSH) distfac= 1.0f;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else distfac= 1.0;
|
|
|
|
|
|
|
|
|
|
distfac/= (maxx-minx);
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
timeofs+= distfac*cu->xof; /* not cyclic */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
ct= chartransdata;
|
|
|
|
|
for (i=0; i<=slen; i++, ct++) {
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* rotate around centre character */
|
2002-10-12 11:37:38 +00:00
|
|
|
ascii = cu->str[i];
|
2003-04-26 11:56:44 +00:00
|
|
|
dtime= distfac*0.35f*vfd->width[ascii]; /* why not 0.5? */
|
|
|
|
|
dtime= distfac*0.0f*vfd->width[ascii]; /* why not 0.5? */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
ctime= timeofs + distfac*( ct->xof - minx);
|
|
|
|
|
CLAMP(ctime, 0.0, 1.0);
|
2003-04-26 11:56:44 +00:00
|
|
|
|
|
|
|
|
/* calc the right loc AND the right rot separately */
|
2004-11-21 10:42:42 +00:00
|
|
|
/* vec, tvec need 4 items */
|
2002-10-12 11:37:38 +00:00
|
|
|
where_on_path(cu->textoncurve, ctime, vec, tvec);
|
|
|
|
|
where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec);
|
|
|
|
|
|
|
|
|
|
VecMulf(vec, sizefac);
|
|
|
|
|
|
|
|
|
|
ct->rot= (float)(M_PI-atan2(rotvec[1], rotvec[0]));
|
|
|
|
|
|
|
|
|
|
si= (float)sin(ct->rot);
|
|
|
|
|
co= (float)cos(ct->rot);
|
|
|
|
|
|
|
|
|
|
yof= ct->yof;
|
|
|
|
|
|
|
|
|
|
ct->xof= vec[0] + si*yof;
|
|
|
|
|
ct->yof= vec[1] + co*yof;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
cucu->flag= oldflag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
if (selboxes) {
|
|
|
|
|
ct= chartransdata;
|
|
|
|
|
for (i=0; i<=selend; i++, ct++) {
|
|
|
|
|
if (i>=selstart) {
|
|
|
|
|
selboxes[i-selstart].x = ct->xof*cu->fsize;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
if(mode==FO_CURSUP || mode==FO_CURSDOWN || mode==FO_PAGEUP || mode==FO_PAGEDOWN) {
|
2003-04-26 11:56:44 +00:00
|
|
|
/* 2: curs up
|
|
|
|
|
3: curs down */
|
2002-10-12 11:37:38 +00:00
|
|
|
ct= chartransdata+cu->pos;
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
if((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0);
|
|
|
|
|
else if((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr);
|
2002-10-12 11:37:38 +00:00
|
|
|
else {
|
2005-06-17 21:04:27 +00:00
|
|
|
switch(mode) {
|
|
|
|
|
case FO_CURSUP: lnr= ct->linenr-1; break;
|
|
|
|
|
case FO_CURSDOWN: lnr= ct->linenr+1; break;
|
|
|
|
|
case FO_PAGEUP: lnr= ct->linenr-10; break;
|
|
|
|
|
case FO_PAGEDOWN: lnr= ct->linenr+10; break;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
cnr= ct->charnr;
|
2003-04-26 11:56:44 +00:00
|
|
|
/* seek for char with lnr en cnr */
|
2002-10-12 11:37:38 +00:00
|
|
|
cu->pos= 0;
|
|
|
|
|
ct= chartransdata;
|
|
|
|
|
for (i= 0; i<slen; i++) {
|
|
|
|
|
if(ct->linenr==lnr) {
|
|
|
|
|
if(ct->charnr==cnr) break;
|
|
|
|
|
if( (ct+1)->charnr==0) break;
|
|
|
|
|
}
|
|
|
|
|
else if(ct->linenr>lnr) break;
|
|
|
|
|
cu->pos++;
|
|
|
|
|
ct++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* cursor first */
|
2002-10-12 11:37:38 +00:00
|
|
|
if(ob==G.obedit) {
|
|
|
|
|
ct= chartransdata+cu->pos;
|
|
|
|
|
si= (float)sin(ct->rot);
|
|
|
|
|
co= (float)cos(ct->rot);
|
|
|
|
|
|
|
|
|
|
f= G.textcurs[0];
|
|
|
|
|
|
|
|
|
|
f[0]= cu->fsize*(-0.1f*co + ct->xof);
|
|
|
|
|
f[1]= cu->fsize*(0.1f*si + ct->yof);
|
|
|
|
|
|
|
|
|
|
f[2]= cu->fsize*(0.1f*co + ct->xof);
|
|
|
|
|
f[3]= cu->fsize*(-0.1f*si + ct->yof);
|
|
|
|
|
|
|
|
|
|
f[4]= cu->fsize*( 0.1f*co + 0.8f*si + ct->xof);
|
|
|
|
|
f[5]= cu->fsize*(-0.1f*si + 0.8f*co + ct->yof);
|
|
|
|
|
|
|
|
|
|
f[6]= cu->fsize*(-0.1f*co + 0.8f*si + ct->xof);
|
|
|
|
|
f[7]= cu->fsize*( 0.1f*si + 0.8f*co + ct->yof);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
MEM_freeN(linedata);
|
|
|
|
|
MEM_freeN(linedata2);
|
|
|
|
|
MEM_freeN(linedata3);
|
|
|
|
|
MEM_freeN(linedata4);
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
if (mode == FO_SELCHANGE) {
|
|
|
|
|
MEM_freeN(chartransdata);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(mode==0) {
|
2003-04-26 11:56:44 +00:00
|
|
|
/* make nurbdata */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
freeNurblist(&cu->nurb);
|
|
|
|
|
|
|
|
|
|
ct= chartransdata;
|
2005-06-17 21:04:27 +00:00
|
|
|
if (cu->sepchar==0) {
|
|
|
|
|
for (i= 0; i<slen; i++) {
|
|
|
|
|
ascii = cu->str[i];
|
|
|
|
|
info = &(cu->strinfo[i]);
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
if (info->mat_nr > (ob->totcol)) {
|
|
|
|
|
printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr);
|
|
|
|
|
info->mat_nr = 0;
|
|
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
buildchar(cu, ascii, info, ct->xof, ct->yof, ct->rot, i);
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
if ((info->flag & CU_UNDERLINE) && (ascii != '\n') && (ascii != '\r')) {
|
|
|
|
|
uloverlap = 0;
|
|
|
|
|
if ( (i<(slen-1)) && (cu->str[i+1] != '\n') && (cu->str[i+1] != '\r') &&
|
|
|
|
|
((cu->str[i+1] != ' ') || (cu->strinfo[i+1].flag & CU_UNDERLINE)) && ((cu->strinfo[i+1].flag & CU_WRAP)==0)
|
|
|
|
|
) {
|
|
|
|
|
uloverlap = xtrax + 0.1;
|
|
|
|
|
}
|
|
|
|
|
ulwidth = cu->fsize * ((vfd->width[ascii]* (1.0+(info->kern/40.0)))+uloverlap);
|
|
|
|
|
build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05)*cu->fsize,
|
|
|
|
|
ct->xof*cu->fsize + ulwidth,
|
|
|
|
|
ct->yof*cu->fsize + (cu->ulpos-0.05)*cu->fsize - cu->ulheight*cu->fsize,
|
|
|
|
|
i, info->mat_nr);
|
|
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
ct++;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
else {
|
|
|
|
|
outta = 0;
|
|
|
|
|
for (i= 0; (i<slen) && (outta==0); i++) {
|
|
|
|
|
ascii = cu->str[i];
|
|
|
|
|
info = &(cu->strinfo[i]);
|
|
|
|
|
if (cu->sepchar == (i+1)) {
|
|
|
|
|
cu->str[0] = ascii;
|
|
|
|
|
cu->str[1] = 0;
|
|
|
|
|
cu->strinfo[0]= *info;
|
|
|
|
|
cu->pos = 1;
|
|
|
|
|
cu->len = 1;
|
|
|
|
|
vecyo[0] = ct->xof;
|
|
|
|
|
vecyo[1] = ct->yof;
|
|
|
|
|
vecyo[2] = 0;
|
|
|
|
|
Mat4MulVecfl(ob->obmat, vecyo);
|
|
|
|
|
VECCOPY(ob->loc, vecyo);
|
|
|
|
|
outta = 1;
|
|
|
|
|
cu->sepchar = 0;
|
|
|
|
|
}
|
|
|
|
|
ct++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(mode==FO_DUPLI) {
|
|
|
|
|
return chartransdata;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN(chartransdata);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ***************** DUPLI ***************** */
|
|
|
|
|
|
|
|
|
|
static Object *find_family_object(Object **obar, char *family, char ch)
|
|
|
|
|
{
|
|
|
|
|
Object *ob;
|
|
|
|
|
int flen;
|
|
|
|
|
|
|
|
|
|
if( obar[ch] ) return obar[ch];
|
|
|
|
|
|
|
|
|
|
flen= strlen(family);
|
|
|
|
|
|
|
|
|
|
ob= G.main->object.first;
|
|
|
|
|
while(ob) {
|
|
|
|
|
if( ob->id.name[flen+2]==ch ) {
|
|
|
|
|
if( strncmp(ob->id.name+2, family, flen)==0 ) break;
|
|
|
|
|
}
|
|
|
|
|
ob= ob->id.next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obar[ch]= ob;
|
|
|
|
|
|
|
|
|
|
return ob;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void font_duplilist(Object *par)
|
|
|
|
|
{
|
|
|
|
|
extern ListBase duplilist;
|
|
|
|
|
Object *ob, *newob, *obar[256];
|
|
|
|
|
Curve *cu;
|
|
|
|
|
struct chartrans *ct, *chartransdata;
|
|
|
|
|
float vec[3], pmat[4][4], fsize, xof, yof;
|
|
|
|
|
int slen, a;
|
|
|
|
|
|
|
|
|
|
Mat4CpyMat4(pmat, par->obmat);
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* in par the family name is stored, use this to find the other objects */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
chartransdata= text_to_curve(par, FO_DUPLI);
|
|
|
|
|
if(chartransdata==0) return;
|
|
|
|
|
|
|
|
|
|
memset(obar, 0, 256*4);
|
|
|
|
|
|
|
|
|
|
cu= par->data;
|
|
|
|
|
slen= strlen(cu->str);
|
|
|
|
|
fsize= cu->fsize;
|
|
|
|
|
xof= cu->xof;
|
|
|
|
|
yof= cu->yof;
|
|
|
|
|
|
|
|
|
|
ct= chartransdata;
|
|
|
|
|
|
|
|
|
|
for(a=0; a<slen; a++, ct++) {
|
|
|
|
|
|
|
|
|
|
ob= find_family_object(obar, cu->family, cu->str[a]);
|
|
|
|
|
if(ob) {
|
2005-07-15 20:56:55 +00:00
|
|
|
/* not clear if this free line here is still needed */
|
|
|
|
|
freedisplist(&ob->disp);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
vec[0]= fsize*(ct->xof - xof);
|
|
|
|
|
vec[1]= fsize*(ct->yof - yof);
|
|
|
|
|
vec[2]= 0.0;
|
|
|
|
|
|
|
|
|
|
Mat4MulVecfl(pmat, vec);
|
|
|
|
|
|
|
|
|
|
newob= MEM_mallocN(sizeof(Object), "newobj dupli");
|
|
|
|
|
memcpy(newob, ob, sizeof(Object));
|
|
|
|
|
newob->flag |= OB_FROMDUPLI;
|
2003-04-26 11:56:44 +00:00
|
|
|
newob->id.newid= (ID *)par; /* keep duplicator */
|
|
|
|
|
newob->totcol= par->totcol; /* for give_current_material */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
Mat4CpyMat4(newob->obmat, par->obmat);
|
|
|
|
|
VECCOPY(newob->obmat[3], vec);
|
|
|
|
|
|
|
|
|
|
newob->parent= 0;
|
|
|
|
|
newob->track= 0;
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&duplilist, newob);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2005-07-15 20:56:55 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(chartransdata);
|
|
|
|
|
}
|