2010-07-13 22:21:59 +00:00
|
|
|
/* font.c
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/font.c
|
|
|
|
|
* \ingroup bke
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
2005-09-14 14:02:21 +00:00
|
|
|
#include <wchar.h>
|
2010-07-13 22:21:59 +00:00
|
|
|
#include <wctype.h>
|
2002-11-25 12:02:15 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_vfontdata.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "DNA_packedFile_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
|
#include "DNA_vfont_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
#include "BKE_packedFile.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_font.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_anim.h"
|
|
|
|
|
#include "BKE_curve.h"
|
|
|
|
|
#include "BKE_displist.h"
|
|
|
|
|
|
2007-12-24 18:38:03 +00:00
|
|
|
static ListBase ttfdata= {NULL, NULL};
|
|
|
|
|
|
2005-09-14 14:02:21 +00:00
|
|
|
/* UTF-8 <-> wchar transformations */
|
2011-04-15 03:47:54 +00:00
|
|
|
size_t chtoutf8(const unsigned long c, char o[4])
|
2005-09-14 14:02:21 +00:00
|
|
|
{
|
|
|
|
|
// Variables and initialization
|
2011-04-15 03:47:54 +00:00
|
|
|
/* memset(o, 0, 4); */
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
// Create the utf-8 string
|
2011-04-15 03:47:54 +00:00
|
|
|
if (c < 0x80) {
|
2005-09-14 14:02:21 +00:00
|
|
|
o[0] = (char) c;
|
2011-04-15 03:47:54 +00:00
|
|
|
return 1;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2011-04-15 03:47:54 +00:00
|
|
|
else if (c < 0x800) {
|
2005-09-14 14:02:21 +00:00
|
|
|
o[0] = (0xC0 | (c>>6));
|
|
|
|
|
o[1] = (0x80 | (c & 0x3f));
|
2011-04-15 03:47:54 +00:00
|
|
|
return 2;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2011-04-15 03:47:54 +00:00
|
|
|
else if (c < 0x10000) {
|
2005-09-14 14:02:21 +00:00
|
|
|
o[0] = (0xe0 | (c >> 12));
|
|
|
|
|
o[1] = (0x80 | (c >>6 & 0x3f));
|
|
|
|
|
o[2] = (0x80 | (c & 0x3f));
|
2011-04-15 03:47:54 +00:00
|
|
|
return 3;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2011-04-15 03:47:54 +00:00
|
|
|
else if (c < 0x200000) {
|
|
|
|
|
o[0] = (0xf0 | (c>>18));
|
|
|
|
|
o[1] = (0x80 | (c >>12 & 0x3f));
|
|
|
|
|
o[2] = (0x80 | (c >> 6 & 0x3f));
|
|
|
|
|
o[3] = (0x80 | (c & 0x3f));
|
|
|
|
|
return 4;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2011-04-15 03:47:54 +00:00
|
|
|
|
|
|
|
|
/* should we assert here? */
|
|
|
|
|
return 0;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-15 03:47:54 +00:00
|
|
|
void wcs2utf8s(char *dst, const wchar_t *src)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2011-04-15 03:47:54 +00:00
|
|
|
while(*src) {
|
|
|
|
|
dst += chtoutf8(*src++, dst);
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2011-04-15 03:47:54 +00:00
|
|
|
|
|
|
|
|
*dst= '\0';
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-15 03:47:54 +00:00
|
|
|
size_t wcsleninu8(wchar_t *src)
|
2005-09-14 14:02:21 +00:00
|
|
|
{
|
2011-04-15 03:47:54 +00:00
|
|
|
char ch_dummy[4];
|
|
|
|
|
size_t len = 0;
|
|
|
|
|
|
|
|
|
|
while(*src) {
|
|
|
|
|
len += chtoutf8(*src++, ch_dummy);
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-15 03:47:54 +00:00
|
|
|
static size_t utf8slen(const char *strc)
|
2005-09-14 14:02:21 +00:00
|
|
|
{
|
2010-11-26 18:13:27 +00:00
|
|
|
int len=0;
|
|
|
|
|
|
|
|
|
|
while(*strc) {
|
|
|
|
|
if ((*strc & 0xe0) == 0xc0) {
|
|
|
|
|
if((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
|
|
|
|
|
strc++;
|
|
|
|
|
} else if ((*strc & 0xf0) == 0xe0) {
|
|
|
|
|
if((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
|
|
|
|
|
strc += 2;
|
|
|
|
|
} else if ((*strc & 0xf8) == 0xf0) {
|
|
|
|
|
if((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
|
|
|
|
|
strc += 3;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2010-11-26 18:13:27 +00:00
|
|
|
|
|
|
|
|
strc++;
|
|
|
|
|
len++;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2010-11-26 18:13:27 +00:00
|
|
|
|
|
|
|
|
return len;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
2008-04-24 20:10:01 +00:00
|
|
|
|
|
|
|
|
/* Converts Unicode to wchar
|
|
|
|
|
|
|
|
|
|
According to RFC 3629 "UTF-8, a transformation format of ISO 10646"
|
|
|
|
|
(http://tools.ietf.org/html/rfc3629), the valid UTF-8 encoding are:
|
|
|
|
|
|
|
|
|
|
Char. number range | UTF-8 octet sequence
|
2010-03-22 09:30:00 +00:00
|
|
|
(hexadecimal) | (binary)
|
2008-04-24 20:10:01 +00:00
|
|
|
--------------------+---------------------------------------------
|
|
|
|
|
0000 0000-0000 007F | 0xxxxxxx
|
|
|
|
|
0000 0080-0000 07FF | 110xxxxx 10xxxxxx
|
|
|
|
|
0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
|
|
|
|
|
0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
|
|
|
|
|
|
|
|
|
If the encoding incidated by the first character is incorrect (because the
|
|
|
|
|
1 to 3 following characters do not match 10xxxxxx), the output is a '?' and
|
|
|
|
|
only a single input character is consumed.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2011-04-15 03:47:54 +00:00
|
|
|
size_t utf8towchar(wchar_t *w, const char *c)
|
2005-09-14 14:02:21 +00:00
|
|
|
{
|
2005-09-19 17:58:51 +00:00
|
|
|
int len=0;
|
2008-04-24 20:10:01 +00:00
|
|
|
|
2005-09-19 17:58:51 +00:00
|
|
|
if(w==NULL || c==NULL) return(0);
|
2008-04-24 20:10:01 +00:00
|
|
|
|
|
|
|
|
while(*c) {
|
|
|
|
|
if ((*c & 0xe0) == 0xc0) {
|
|
|
|
|
if((c[1] & 0x80) && (c[1] & 0x40) == 0x00) {
|
|
|
|
|
*w=((c[0] &0x1f)<<6) | (c[1]&0x3f);
|
2005-09-19 17:58:51 +00:00
|
|
|
c++;
|
2008-04-24 20:10:01 +00:00
|
|
|
} else {
|
|
|
|
|
*w = '?';
|
2005-09-19 17:58:51 +00:00
|
|
|
}
|
2008-04-24 20:10:01 +00:00
|
|
|
} else if ((*c & 0xf0) == 0xe0) {
|
|
|
|
|
if((c[1] & c[2] & 0x80) && ((c[1] | c[2]) & 0x40) == 0x00) {
|
|
|
|
|
*w=((c[0] & 0x0f)<<12) | ((c[1]&0x3f)<<6) | (c[2]&0x3f);
|
|
|
|
|
c += 2;
|
|
|
|
|
} else {
|
|
|
|
|
*w = '?';
|
2005-09-19 17:58:51 +00:00
|
|
|
}
|
2008-04-24 20:10:01 +00:00
|
|
|
} else if ((*c & 0xf8) == 0xf0) {
|
|
|
|
|
if((c[1] & c[2] & c[3] & 0x80) && ((c[1] | c[2] | c[3]) & 0x40) == 0x00) {
|
|
|
|
|
*w=((c[0] & 0x07)<<18) | ((c[1]&0x1f)<<12) | ((c[2]&0x3f)<<6) | (c[3]&0x3f);
|
|
|
|
|
c += 3;
|
|
|
|
|
} else {
|
|
|
|
|
*w = '?';
|
2005-09-19 17:58:51 +00:00
|
|
|
}
|
2008-04-24 20:10:01 +00:00
|
|
|
} else
|
2010-03-22 09:30:00 +00:00
|
|
|
*w=(c[0] & 0x7f);
|
2008-04-24 20:10:01 +00:00
|
|
|
|
|
|
|
|
c++;
|
|
|
|
|
w++;
|
|
|
|
|
len++;
|
|
|
|
|
}
|
2005-09-19 17:58:51 +00:00
|
|
|
return len;
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The vfont code */
|
|
|
|
|
void free_vfont(struct VFont *vf)
|
|
|
|
|
{
|
2011-02-13 10:52:18 +00:00
|
|
|
if (vf == NULL) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if (vf->data) {
|
2005-09-14 14:02:21 +00:00
|
|
|
while(vf->data->characters.first)
|
|
|
|
|
{
|
|
|
|
|
VChar *che = vf->data->characters.first;
|
|
|
|
|
|
|
|
|
|
while (che->nurbsbase.first) {
|
|
|
|
|
Nurb *nu = che->nurbsbase.first;
|
2002-10-12 11:37:38 +00:00
|
|
|
if (nu->bezt) MEM_freeN(nu->bezt);
|
2005-09-14 14:02:21 +00:00
|
|
|
BLI_freelinkN(&che->nurbsbase, nu);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
BLI_freelinkN(&vf->data->characters, che);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-24 18:38:03 +00:00
|
|
|
void free_ttfont(void)
|
|
|
|
|
{
|
|
|
|
|
struct TmpFont *tf;
|
2010-08-31 14:22:00 +00:00
|
|
|
|
|
|
|
|
for(tf= ttfdata.first; tf; tf= tf->next) {
|
|
|
|
|
if(tf->pf) freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */
|
2007-12-24 18:38:03 +00:00
|
|
|
tf->pf= NULL;
|
|
|
|
|
tf->vfont= NULL;
|
|
|
|
|
}
|
|
|
|
|
BLI_freelistN(&ttfdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct TmpFont *vfont_find_tmpfont(VFont *vfont)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2005-09-14 14:02:21 +00:00
|
|
|
struct TmpFont *tmpfnt = NULL;
|
|
|
|
|
|
Three new features:
1) Stride Bone
For walkcycles, you could already set an NLA strip to cycle over a path
based on a preset distance value. This cycling happens based on a linear
interpolation, with constant speed.
Not all cycles have a constant speed however, like hopping or jumping.
To ensure a perfect slipping-less foot contact, you now can set a Bone
in an Armature to define the stride. This "Stride Bone" then becomes a
sort-of ruler, a conveyor belt, on which the character walks. When using
the NLA "Use Path" option, it then tries to keep the Stride Bone entirely
motionless on the path, by cancelling out its motion (for the entire
Armature). This means that the animation keys for a Stride Bone have to be
exactly negative of the desired path. Only, at choice, the X,Y or Z Ipo
curve is used for this stride.
Examples:
http://www.blender.org/bf/0001_0040.avi
The top armature shows the actual Action, the bottom armature has been
parented to a Path, using the Stride Bone feature.
http://www.blender.org/bf/0001_0080.avi
Here the Stride Bone has a number of children, creating a ruler to be
used as reference while animating.
Test .blend:
http://www.blender.org/bf/motionblender1.blend
Notes:
- Note that action keys for Bones work local, based on the Bone's
orientation as set in EditMode. Therefore, an Y translation always
goes in the Bone's direction.
- To be able to get a "solvable" stride, the animation curve has
to be inverse evaluated, using a Newton Raphson root solver. That
means you can only create stride curves that keep moving forward, and
cannot return halfway.
- Set the Stride Bone in the Editing Buttons, Bone Panel. You can set
change the name or set the axis in the NLA Window, Strip Properties Panel.
- Files in this commit will move to the blender.org release section.
2) Armature Ghosting
In EditButtons, Armature Panel, you can set an armature to draw ghosts.
The number value denotes the amount of frames that have to be drawn extra
(for the active action!) around the current frame.
Ghosts only evaluate its own Pose, executing it's Actions, Constraints and
IK. No external dependencies are re-evaluated for it.
3) NLA/Action time control
If you click in the NLA window on the action (linked to Object), it makes
sure the Timing as drawn in the Action editor is not corrected for NLA.
If you also set the Object to "Action", this timing will be executed on the
Object as well (not NLA time).
(It's a bit confusing... will make a good doc & maybe review UI!)
2005-11-01 12:44:30 +00:00
|
|
|
if(vfont==NULL) return NULL;
|
|
|
|
|
|
2005-09-14 14:02:21 +00:00
|
|
|
// Try finding the font from font list
|
2007-12-24 18:38:03 +00:00
|
|
|
tmpfnt = ttfdata.first;
|
2005-09-14 14:02:21 +00:00
|
|
|
while(tmpfnt)
|
|
|
|
|
{
|
|
|
|
|
if(tmpfnt->vfont == vfont)
|
|
|
|
|
break;
|
|
|
|
|
tmpfnt = tmpfnt->next;
|
|
|
|
|
}
|
2007-12-24 18:38:03 +00:00
|
|
|
return tmpfnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static VFontData *vfont_get_data(VFont *vfont)
|
|
|
|
|
{
|
|
|
|
|
struct TmpFont *tmpfnt = NULL;
|
|
|
|
|
PackedFile *tpf;
|
|
|
|
|
|
|
|
|
|
if(vfont==NULL) return NULL;
|
|
|
|
|
|
|
|
|
|
// Try finding the font from font list
|
|
|
|
|
tmpfnt = vfont_find_tmpfont(vfont);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
// And then set the data
|
2002-10-12 11:37:38 +00:00
|
|
|
if (!vfont->data) {
|
|
|
|
|
PackedFile *pf;
|
|
|
|
|
|
2010-10-24 07:02:19 +00:00
|
|
|
if (strcmp(vfont->name, FO_BUILTIN_NAME)==0) {
|
2002-10-12 11:37:38 +00:00
|
|
|
pf= get_builtin_packedfile();
|
|
|
|
|
} else {
|
|
|
|
|
if (vfont->packedfile) {
|
|
|
|
|
pf= vfont->packedfile;
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
// We need to copy a tmp font to memory unless it is already there
|
|
|
|
|
if(!tmpfnt)
|
|
|
|
|
{
|
|
|
|
|
tpf= MEM_callocN(sizeof(*tpf), "PackedFile");
|
|
|
|
|
tpf->data= MEM_mallocN(pf->size, "packFile");
|
|
|
|
|
tpf->size= pf->size;
|
|
|
|
|
memcpy(tpf->data, pf->data, pf->size);
|
|
|
|
|
|
|
|
|
|
// Add temporary packed file to globals
|
|
|
|
|
tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
|
|
|
|
|
tmpfnt->pf= tpf;
|
|
|
|
|
tmpfnt->vfont= vfont;
|
2007-12-24 18:38:03 +00:00
|
|
|
BLI_addtail(&ttfdata, tmpfnt);
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
} else {
|
2009-06-30 19:20:45 +00:00
|
|
|
pf= newPackedFile(NULL, vfont->name);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
if(!tmpfnt)
|
|
|
|
|
{
|
2009-06-30 19:20:45 +00:00
|
|
|
tpf= newPackedFile(NULL, vfont->name);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
// Add temporary packed file to globals
|
|
|
|
|
tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
|
|
|
|
|
tmpfnt->pf= tpf;
|
|
|
|
|
tmpfnt->vfont= vfont;
|
2007-12-24 18:38:03 +00:00
|
|
|
BLI_addtail(&ttfdata, tmpfnt);
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2004-12-03 14:30:32 +00:00
|
|
|
if(!pf) {
|
|
|
|
|
printf("Font file doesn't exist: %s\n", vfont->name);
|
|
|
|
|
|
2010-10-24 07:02:19 +00:00
|
|
|
strcpy(vfont->name, FO_BUILTIN_NAME);
|
2004-12-03 14:30:32 +00:00
|
|
|
pf= get_builtin_packedfile();
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pf) {
|
2005-09-04 09:30:57 +00:00
|
|
|
vfont->data= BLI_vfontdata_from_freetypefont(pf);
|
2002-10-12 11:37:38 +00:00
|
|
|
if (pf != vfont->packedfile) {
|
|
|
|
|
freePackedFile(pf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vfont->data;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
VFont *load_vfont(const char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
char filename[FILE_MAXFILE];
|
|
|
|
|
VFont *vfont= NULL;
|
|
|
|
|
PackedFile *pf;
|
2005-09-14 14:02:21 +00:00
|
|
|
PackedFile *tpf = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
int is_builtin;
|
2005-09-14 14:02:21 +00:00
|
|
|
struct TmpFont *tmpfnt;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-10-24 07:02:19 +00:00
|
|
|
if (strcmp(name, FO_BUILTIN_NAME)==0) {
|
2011-02-13 03:21:27 +00:00
|
|
|
BLI_strncpy(filename, name, sizeof(filename));
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
pf= get_builtin_packedfile();
|
|
|
|
|
is_builtin= 1;
|
|
|
|
|
} else {
|
|
|
|
|
char dir[FILE_MAXDIR];
|
|
|
|
|
|
2011-02-13 03:21:27 +00:00
|
|
|
BLI_strncpy(dir, name, sizeof(dir));
|
2002-10-12 11:37:38 +00:00
|
|
|
BLI_splitdirstring(dir, filename);
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
pf= newPackedFile(NULL, name);
|
|
|
|
|
tpf= newPackedFile(NULL, name);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
is_builtin= 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pf) {
|
|
|
|
|
VFontData *vfd;
|
|
|
|
|
|
2005-09-04 09:30:57 +00:00
|
|
|
vfd= BLI_vfontdata_from_freetypefont(pf);
|
2002-10-12 11:37:38 +00:00
|
|
|
if (vfd) {
|
|
|
|
|
vfont = alloc_libblock(&G.main->vfont, ID_VF, filename);
|
|
|
|
|
vfont->data = vfd;
|
2010-01-11 05:10:57 +00:00
|
|
|
|
|
|
|
|
/* if there's a font name, use it for the ID name */
|
|
|
|
|
if (strcmp(vfd->name, "")!=0) {
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy(vfont->id.name+2, vfd->name, sizeof(vfont->id.name)-2);
|
2010-01-11 05:10:57 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
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;
|
|
|
|
|
}
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2010-10-24 07:02:19 +00:00
|
|
|
// Do not add FO_BUILTIN_NAME to temporary listbase
|
|
|
|
|
if(strcmp(filename, FO_BUILTIN_NAME))
|
2005-09-14 14:02:21 +00:00
|
|
|
{
|
|
|
|
|
tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
|
|
|
|
|
tmpfnt->pf= tpf;
|
|
|
|
|
tmpfnt->vfont= vfont;
|
2007-12-24 18:38:03 +00:00
|
|
|
BLI_addtail(&ttfdata, tmpfnt);
|
2005-09-14 14:02:21 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
// Free the packed file
|
2002-10-12 11:37:38 +00:00
|
|
|
if (!vfont || vfont->packedfile != pf) {
|
|
|
|
|
freePackedFile(pf);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-01 18:16:10 +00:00
|
|
|
//XXX waitcursor(0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vfont;
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
static VFont *which_vfont(Curve *cu, CharInfo *info)
|
|
|
|
|
{
|
2010-07-13 23:51:21 +00:00
|
|
|
switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) {
|
|
|
|
|
case CU_CHINFO_BOLD:
|
2005-10-31 16:46:22 +00:00
|
|
|
if (cu->vfontb) return(cu->vfontb); else return(cu->vfont);
|
2010-07-13 23:51:21 +00:00
|
|
|
case CU_CHINFO_ITALIC:
|
2005-10-31 16:46:22 +00:00
|
|
|
if (cu->vfonti) return(cu->vfonti); else return(cu->vfont);
|
2010-07-13 23:51:21 +00:00
|
|
|
case (CU_CHINFO_BOLD|CU_CHINFO_ITALIC):
|
2005-10-31 16:46:22 +00:00
|
|
|
if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont);
|
2005-09-19 17:58:51 +00:00
|
|
|
default:
|
|
|
|
|
return(cu->vfont);
|
|
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
VFont *get_builtin_font(void)
|
|
|
|
|
{
|
|
|
|
|
VFont *vf;
|
|
|
|
|
|
|
|
|
|
for (vf= G.main->vfont.first; vf; vf= vf->id.next)
|
2010-10-24 07:02:19 +00:00
|
|
|
if (strcmp(vf->name, FO_BUILTIN_NAME)==0)
|
2009-01-23 14:43:25 +00:00
|
|
|
return vf;
|
|
|
|
|
|
2010-10-24 07:02:19 +00:00
|
|
|
return load_vfont(FO_BUILTIN_NAME);
|
2009-01-23 14:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-13 23:51:21 +00:00
|
|
|
static VChar *find_vfont_char(VFontData *vfd, intptr_t character)
|
|
|
|
|
{
|
|
|
|
|
VChar *che= NULL;
|
|
|
|
|
|
|
|
|
|
for(che = vfd->characters.first; che; che = che->next) {
|
|
|
|
|
if(che->index == character)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return che; /* NULL if not found */
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2008-05-26 09:50:46 +00:00
|
|
|
nu2->knotsu = nu2->knotsv = NULL;
|
2009-09-08 00:23:33 +00:00
|
|
|
nu2->flag= CU_2D;
|
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
|
|
|
nu2->charidx = charidx+1000;
|
2006-05-23 15:11:08 +00:00
|
|
|
if (mat_nr > 0) nu2->mat_nr= mat_nr-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
|
|
|
nu2->pntsu = 4;
|
|
|
|
|
nu2->pntsv = 1;
|
|
|
|
|
nu2->orderu = 4;
|
|
|
|
|
nu2->orderv = 1;
|
merge own commits into render branch into trunk since 27560
27562, 27570, 27571, 27574, 27576, 27577, 27579, 27590, 27591, 27594, 27595, 27596, 27599, 27605, 27611, 27612, 27613, 27614, 27623
2010-03-20 16:41:01 +00:00
|
|
|
nu2->flagu = CU_NURB_CYCLIC;
|
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
|
|
|
|
|
|
|
|
bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint),"underline_bp");
|
2011-02-13 10:52:18 +00:00
|
|
|
if (bp == NULL){
|
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(nu2);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
nu2->bp = bp;
|
|
|
|
|
|
|
|
|
|
nu2->bp[0].vec[0] = x1;
|
|
|
|
|
nu2->bp[0].vec[1] = y1;
|
|
|
|
|
nu2->bp[0].vec[2] = 0;
|
2011-03-28 11:21:39 +00:00
|
|
|
nu2->bp[0].vec[3] = 1.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
|
|
|
nu2->bp[1].vec[0] = x2;
|
|
|
|
|
nu2->bp[1].vec[1] = y1;
|
|
|
|
|
nu2->bp[1].vec[2] = 0;
|
2011-03-28 11:21:39 +00:00
|
|
|
nu2->bp[1].vec[3] = 1.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
|
|
|
nu2->bp[2].vec[0] = x2;
|
|
|
|
|
nu2->bp[2].vec[1] = y2;
|
|
|
|
|
nu2->bp[2].vec[2] = 0;
|
2011-03-28 11:21:39 +00:00
|
|
|
nu2->bp[2].vec[3] = 1.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
|
|
|
nu2->bp[3].vec[0] = x1;
|
|
|
|
|
nu2->bp[3].vec[1] = y2;
|
|
|
|
|
nu2->bp[3].vec[2] = 0;
|
2011-03-28 11:21:39 +00:00
|
|
|
nu2->bp[3].vec[3] = 1.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
|
|
|
|
|
|
|
|
BLI_addtail(&(cu->nurb), nu2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-14 14:02:21 +00:00
|
|
|
static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float ofsx, float ofsy, float rot, int charidx)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
BezTriple *bezt1, *bezt2;
|
2005-09-14 14:02:21 +00:00
|
|
|
Nurb *nu1 = NULL, *nu2 = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
float *fp, fsize, shear, x, si, co;
|
2005-09-14 14:02:21 +00:00
|
|
|
VFontData *vfd = NULL;
|
|
|
|
|
VChar *che = NULL;
|
2010-10-05 21:22:33 +00:00
|
|
|
int i;
|
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
|
|
|
|
2010-10-05 21:22:33 +00:00
|
|
|
/*
|
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;
|
|
|
|
|
}
|
2010-10-05 21:22:33 +00:00
|
|
|
*/
|
2005-06-17 21:04:27 +00:00
|
|
|
|
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);
|
|
|
|
|
|
2010-07-13 23:51:21 +00:00
|
|
|
che= find_vfont_char(vfd, character);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
// Select the glyph data
|
|
|
|
|
if(che)
|
|
|
|
|
nu1 = che->nurbsbase.first;
|
|
|
|
|
|
|
|
|
|
// Create the character
|
2002-10-12 11:37:38 +00:00
|
|
|
while(nu1)
|
|
|
|
|
{
|
|
|
|
|
bezt1 = nu1->bezt;
|
|
|
|
|
if (bezt1){
|
|
|
|
|
nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb");
|
2011-02-13 10:52:18 +00:00
|
|
|
if (nu2 == NULL) break;
|
2002-10-12 11:37:38 +00:00
|
|
|
memcpy(nu2, nu1, sizeof(struct Nurb));
|
|
|
|
|
nu2->resolu= cu->resolu;
|
2011-02-13 10:52:18 +00:00
|
|
|
nu2->bp = NULL;
|
2008-05-26 09:50:46 +00:00
|
|
|
nu2->knotsu = nu2->knotsv = NULL;
|
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");
|
2011-02-13 10:52:18 +00:00
|
|
|
if (bezt2 == NULL){
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(nu2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
memcpy(bezt2, bezt1, i * sizeof(struct BezTriple));
|
|
|
|
|
nu2->bezt = bezt2;
|
|
|
|
|
|
2011-03-28 11:21:39 +00:00
|
|
|
if (shear != 0.0f) {
|
2002-10-12 11:37:38 +00:00
|
|
|
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++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-28 11:21:39 +00:00
|
|
|
if(rot != 0.0f) {
|
2002-10-12 11:37:38 +00:00
|
|
|
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
|
|
|
|
2010-07-13 23:51:21 +00:00
|
|
|
if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
|
2010-07-13 22:21:59 +00:00
|
|
|
const float sca= cu->smallcaps_scale;
|
|
|
|
|
for (i= nu2->pntsu; i > 0; i--) {
|
|
|
|
|
fp= bezt2->vec[0];
|
|
|
|
|
fp[0] *= sca;
|
|
|
|
|
fp[1] *= sca;
|
|
|
|
|
fp[3] *= sca;
|
|
|
|
|
fp[4] *= sca;
|
|
|
|
|
fp[6] *= sca;
|
|
|
|
|
fp[7] *= sca;
|
|
|
|
|
bezt2++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bezt2 = nu2->bezt;
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
int BKE_font_getselection(Object *ob, int *start, int *end)
|
2005-06-17 21:04:27 +00:00
|
|
|
{
|
2009-01-02 19:10:35 +00:00
|
|
|
Curve *cu= ob->data;
|
2005-06-17 21:04:27 +00:00
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
if (cu->editfont==NULL || ob->type != OB_FONT) return 0;
|
2005-06-17 21:04:27 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-07-13 22:21:59 +00:00
|
|
|
static float char_width(Curve *cu, VChar *che, CharInfo *info)
|
|
|
|
|
{
|
|
|
|
|
// The character wasn't found, propably ascii = 0, then the width shall be 0 as well
|
|
|
|
|
if(che == NULL) {
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
2010-07-13 23:51:21 +00:00
|
|
|
else if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) {
|
2010-07-13 22:21:59 +00:00
|
|
|
return che->width * cu->smallcaps_scale;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return che->width;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2005-06-17 21:04:27 +00:00
|
|
|
VFont *vfont, *oldvfont;
|
2005-06-17 22:52:11 +00:00
|
|
|
VFontData *vfd= NULL;
|
2009-01-23 14:43:25 +00:00
|
|
|
Curve *cu;
|
2010-12-31 20:01:38 +00:00
|
|
|
CharInfo *info = NULL, *custrinfo;
|
2005-06-17 21:04:27 +00:00
|
|
|
TextBox *tb;
|
2005-09-14 14:02:21 +00:00
|
|
|
VChar *che;
|
2009-01-23 14:43:25 +00:00
|
|
|
struct chartrans *chartransdata=NULL, *ct;
|
|
|
|
|
float *f, xof, yof, xtrax, linedist, *linedata, *linedata2, *linedata3, *linedata4;
|
2.5: Text edit mode operators back. Took me a while getting
them nicely repeatable, and splitting up the big edit_text
operator into individual operator so it's all nicely scriptable,
documented, configurable, etc..
* Insert Text, Line Break, Insert Lorem
* Toggle Case, Set Case, Toggle Style, Set Style, Set Material
* Copy Text, Cut Text, Paste Text, Paste File, Paste Buffer
* Move, Move Select, Delete
* Change Spacing, Change Character
Notes
* Text (datablock) to Object doesn't work yet, will need to
implement text editor context for that.
* Some shortcut keys don't work because screen/wm overrides them,
ctrl+x, ctrl+left/right. That override goes top down which works
well for some cases, but here we need to override in the other
direction.
* There's no unicode support in RNA, or the user interface code
for that matter, but text strings can contain these characters.
At the moment it stores a UTF-8 string in char arrays, which is
supposed to be nicely compatible with ascii. Seems reasonable to
add support for UTF-8 in the interface code, python bindings, ..
eventually?
2009-02-17 19:55:20 +00:00
|
|
|
float twidth, maxlen= 0;
|
2009-01-23 14:43:25 +00:00
|
|
|
int i, slen, j;
|
|
|
|
|
int curbox;
|
|
|
|
|
int selstart, selend;
|
2005-09-14 14:02:21 +00:00
|
|
|
int utf8len;
|
2009-01-23 14:43:25 +00:00
|
|
|
short cnr=0, lnr=0, wsnr= 0;
|
|
|
|
|
wchar_t *mem, *tmp, ascii;
|
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
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
if(ob->type!=OB_FONT) return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-09-14 14:02:21 +00:00
|
|
|
// Set font data
|
|
|
|
|
cu= (Curve *) ob->data;
|
|
|
|
|
vfont= cu->vfont;
|
2009-01-23 14:43:25 +00:00
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
if(cu->str == NULL) return NULL;
|
|
|
|
|
if(vfont == NULL) return NULL;
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
// Create unicode string
|
|
|
|
|
utf8len = utf8slen(cu->str);
|
2011-01-12 03:41:12 +00:00
|
|
|
mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2008-04-25 19:18:24 +00:00
|
|
|
utf8towchar(mem, cu->str);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
|
|
|
|
// Count the wchar_t string length
|
|
|
|
|
slen = wcslen(mem);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-03-28 11:21:39 +00:00
|
|
|
if (cu->ulheight == 0.0f)
|
|
|
|
|
cu->ulheight = 0.05f;
|
2009-01-23 14:43:25 +00:00
|
|
|
|
|
|
|
|
if (cu->strinfo==NULL) /* old file */
|
2009-06-15 09:54:37 +00:00
|
|
|
cu->strinfo = MEM_callocN((slen+4) * sizeof(CharInfo), "strinfo compat");
|
2009-01-23 14:43:25 +00:00
|
|
|
|
|
|
|
|
custrinfo= cu->strinfo;
|
|
|
|
|
if (cu->editfont)
|
|
|
|
|
custrinfo= cu->editfont->textbufinfo;
|
|
|
|
|
|
|
|
|
|
if (cu->tb==NULL)
|
2005-09-29 15:46:06 +00:00
|
|
|
cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "TextBox compat");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-09-14 14:02:21 +00:00
|
|
|
vfd= vfont_get_data(vfont);
|
2005-10-28 15:36:09 +00:00
|
|
|
|
|
|
|
|
/* The VFont Data can not be found */
|
2009-01-23 14:43:25 +00:00
|
|
|
if(!vfd) {
|
2005-10-28 15:36:09 +00:00
|
|
|
if(mem)
|
|
|
|
|
MEM_freeN(mem);
|
2011-02-13 10:52:18 +00:00
|
|
|
return NULL;
|
2005-10-28 15:36:09 +00:00
|
|
|
}
|
2005-09-14 14:02:21 +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) */
|
|
|
|
|
|
2009-12-14 20:01:52 +00:00
|
|
|
linedata= MEM_mallocN(sizeof(float)*(slen*2 + 1),"buildtext2");
|
|
|
|
|
linedata2= MEM_mallocN(sizeof(float)*(slen*2 + 1),"buildtext3");
|
|
|
|
|
linedata3= MEM_callocN(sizeof(float)*(slen*2 + 1),"buildtext4");
|
|
|
|
|
linedata4= MEM_callocN(sizeof(float)*(slen*2 + 1),"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;
|
|
|
|
|
|
2010-07-13 23:51:21 +00:00
|
|
|
for (i=0; i<slen; i++) custrinfo[i].flag &= ~(CU_CHINFO_WRAP|CU_CHINFO_SMALLCAPS_CHECK);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
if (cu->selboxes) MEM_freeN(cu->selboxes);
|
|
|
|
|
cu->selboxes = NULL;
|
|
|
|
|
if (BKE_font_getselection(ob, &selstart, &selend))
|
|
|
|
|
cu->selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes");
|
2005-06-17 21:04:27 +00:00
|
|
|
|
|
|
|
|
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:
|
2005-09-14 14:02:21 +00:00
|
|
|
// Characters in the list
|
2009-01-23 14:43:25 +00:00
|
|
|
info = &(custrinfo[i]);
|
2010-07-13 22:21:59 +00:00
|
|
|
ascii = mem[i];
|
2010-07-13 23:51:21 +00:00
|
|
|
if(info->flag & CU_CHINFO_SMALLCAPS) {
|
2010-07-13 22:21:59 +00:00
|
|
|
ascii = towupper(ascii);
|
|
|
|
|
if(mem[i] != ascii) {
|
|
|
|
|
mem[i]= ascii;
|
2010-07-13 23:51:21 +00:00
|
|
|
info->flag |= CU_CHINFO_SMALLCAPS_CHECK;
|
2010-07-13 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
vfont = which_vfont(cu, info);
|
2005-10-11 19:09:27 +00:00
|
|
|
|
|
|
|
|
if(vfont==NULL) break;
|
2010-07-13 23:51:21 +00:00
|
|
|
|
|
|
|
|
che= find_vfont_char(vfd, ascii);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2009-05-05 23:10:32 +00:00
|
|
|
/*
|
|
|
|
|
* The character wasn't in the current curve base so load it
|
2010-10-24 07:02:19 +00:00
|
|
|
* But if the font is FO_BUILTIN_NAME then do not try loading since
|
2009-05-05 23:10:32 +00:00
|
|
|
* whole font is in the memory already
|
|
|
|
|
*/
|
2010-10-24 07:02:19 +00:00
|
|
|
if(che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) {
|
2005-09-14 14:02:21 +00:00
|
|
|
BLI_vfontchar_from_freetypefont(vfont, ascii);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-05 23:10:32 +00:00
|
|
|
/* Try getting the character again from the list */
|
2010-07-13 23:51:21 +00:00
|
|
|
che= find_vfont_char(vfd, ascii);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2005-10-28 15:36:09 +00:00
|
|
|
/* No VFont found */
|
2011-02-13 10:52:18 +00:00
|
|
|
if (vfont==NULL) {
|
2005-10-28 15:36:09 +00:00
|
|
|
if(mem)
|
|
|
|
|
MEM_freeN(mem);
|
|
|
|
|
MEM_freeN(chartransdata);
|
2011-02-13 10:52:18 +00:00
|
|
|
return NULL;
|
2005-10-28 15:36:09 +00:00
|
|
|
}
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2005-10-28 15:36:09 +00:00
|
|
|
if (vfont != oldvfont) {
|
|
|
|
|
vfd= vfont_get_data(vfont);
|
|
|
|
|
oldvfont = vfont;
|
|
|
|
|
}
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2005-10-28 15:36:09 +00:00
|
|
|
/* VFont Data for VFont couldn't be found */
|
2009-01-23 14:43:25 +00:00
|
|
|
if (!vfd) {
|
2005-10-28 15:36:09 +00:00
|
|
|
if(mem)
|
|
|
|
|
MEM_freeN(mem);
|
|
|
|
|
MEM_freeN(chartransdata);
|
2011-02-13 10:52:18 +00:00
|
|
|
return NULL;
|
2005-10-28 15:36:09 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-13 22:21:59 +00:00
|
|
|
twidth = char_width(cu, che, info);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2005-10-28 15:36:09 +00:00
|
|
|
// Calculate positions
|
2011-03-28 11:21:39 +00:00
|
|
|
if((tb->w != 0.0f) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) {
|
2005-10-28 15:36:09 +00:00
|
|
|
// fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]);
|
|
|
|
|
for (j=i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak==0); j--) {
|
|
|
|
|
if (mem[j]==' ' || mem[j]=='-') {
|
2005-06-17 21:04:27 +00:00
|
|
|
ct -= (i-(j-1));
|
|
|
|
|
cnr -= (i-(j-1));
|
2005-09-14 14:02:21 +00:00
|
|
|
if (mem[j] == ' ') wsnr--;
|
|
|
|
|
if (mem[j] == '-') wsnr++;
|
2005-06-17 21:04:27 +00:00
|
|
|
i = j-1;
|
|
|
|
|
xof = ct->xof;
|
|
|
|
|
ct[1].dobreak = 1;
|
2010-07-13 23:51:21 +00:00
|
|
|
custrinfo[i+1].flag |= CU_CHINFO_WRAP;
|
2005-06-17 21:04:27 +00:00
|
|
|
goto makebreak;
|
2005-10-28 15:36:09 +00:00
|
|
|
}
|
|
|
|
|
if (chartransdata[j].dobreak) {
|
|
|
|
|
// fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]);
|
|
|
|
|
ct->dobreak= 1;
|
2010-07-13 23:51:21 +00:00
|
|
|
custrinfo[i+1].flag |= CU_CHINFO_WRAP;
|
2005-10-28 15:36:09 +00:00
|
|
|
ct -= 1;
|
|
|
|
|
cnr -= 1;
|
|
|
|
|
i--;
|
|
|
|
|
xof = ct->xof;
|
|
|
|
|
goto makebreak;
|
|
|
|
|
}
|
2005-09-19 17:58:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
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
|
|
|
|
2011-03-28 11:21:39 +00:00
|
|
|
if ( (tb->h != 0.0f) &&
|
2010-08-01 09:56:00 +00:00
|
|
|
((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize)) - cu->yof) &&
|
2010-03-22 09:30:00 +00:00
|
|
|
(cu->totbox > (curbox+1)) ) {
|
2005-06-17 21:04:27 +00:00
|
|
|
maxlen= 0;
|
|
|
|
|
tb++;
|
|
|
|
|
curbox++;
|
|
|
|
|
yof= cu->yof + tb->y/cu->fsize;
|
|
|
|
|
}
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2011-01-08 12:43:44 +00:00
|
|
|
/* XXX, has been unused for years, need to check if this is useful, r4613 r5282 - campbell */
|
|
|
|
|
#if 0
|
2005-09-14 14:02:21 +00:00
|
|
|
if(ascii == '\n' || ascii == '\r')
|
|
|
|
|
xof = cu->xof;
|
|
|
|
|
else
|
|
|
|
|
xof= cu->xof + (tb->x/cu->fsize);
|
2011-01-08 12:43:44 +00:00
|
|
|
#else
|
2005-06-17 21:04:27 +00:00
|
|
|
xof= cu->xof + (tb->x/cu->fsize);
|
2011-01-08 12:43:44 +00:00
|
|
|
#endif
|
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 */
|
2009-01-23 14:43:25 +00:00
|
|
|
float tabfac;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ct->xof= xof;
|
|
|
|
|
ct->yof= yof;
|
|
|
|
|
ct->linenr= lnr;
|
|
|
|
|
ct->charnr= cnr++;
|
|
|
|
|
|
|
|
|
|
tabfac= (xof-cu->xof+0.01f);
|
2011-03-28 11:21:39 +00:00
|
|
|
tabfac= 2.0f*ceilf(tabfac/2.0f);
|
2002-10-12 11:37:38 +00:00
|
|
|
xof= cu->xof+tabfac;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2009-01-23 14:43:25 +00:00
|
|
|
SelBox *sb= NULL;
|
|
|
|
|
float wsfac;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ct->xof= xof;
|
|
|
|
|
ct->yof= yof;
|
|
|
|
|
ct->linenr= lnr;
|
|
|
|
|
ct->charnr= cnr++;
|
|
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
if (cu->selboxes && (i>=selstart) && (i<=selend)) {
|
|
|
|
|
sb = &(cu->selboxes[i-selstart]);
|
2011-03-28 11:21:39 +00:00
|
|
|
sb->y = yof*cu->fsize-linedist*cu->fsize*0.1f;
|
2005-10-28 15:36:09 +00:00
|
|
|
sb->h = linedist*cu->fsize;
|
|
|
|
|
sb->w = xof*cu->fsize;
|
|
|
|
|
}
|
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
|
|
|
if (ascii==32) {
|
|
|
|
|
wsfac = cu->wordspace;
|
|
|
|
|
wsnr++;
|
2009-01-23 14:43:25 +00:00
|
|
|
}
|
2011-03-28 11:21:39 +00:00
|
|
|
else wsfac = 1.0f;
|
2009-01-23 14:43:25 +00:00
|
|
|
|
2005-09-14 14:02:21 +00:00
|
|
|
// Set the width of the character
|
2010-07-13 22:21:59 +00:00
|
|
|
twidth = char_width(cu, che, info);
|
2009-01-23 14:43:25 +00:00
|
|
|
|
2011-03-28 11:21:39 +00:00
|
|
|
xof += (twidth*wsfac*(1.0f+(info->kern/40.0f)) ) + xtrax;
|
2005-06-17 21:04:27 +00:00
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
if (sb)
|
|
|
|
|
sb->w = (xof*cu->fsize) - sb->w;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
ct++;
|
|
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
|
|
|
|
|
cu->lines= 1;
|
|
|
|
|
ct= chartransdata;
|
2005-09-14 14:02:21 +00:00
|
|
|
tmp = mem;
|
|
|
|
|
for (i= 0; i<=slen; i++, tmp++, ct++) {
|
|
|
|
|
ascii = *tmp;
|
2005-06-17 21:04:27 +00:00
|
|
|
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) &&
|
2011-03-28 11:21:39 +00:00
|
|
|
(cu->tb[0].w != 0.0f)) {
|
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-09-14 14:02:21 +00:00
|
|
|
for (j=i; (mem[j]) && (mem[j]!='\n') &&
|
2010-03-22 09:30:00 +00:00
|
|
|
(mem[j]!='\r') && (chartransdata[j].dobreak==0) && (j<slen); j++);
|
2005-09-14 14:02:21 +00:00
|
|
|
// if ((mem[j]!='\r') && (mem[j]!='\n') && (mem[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++;
|
|
|
|
|
}
|
2009-01-23 14:43:25 +00:00
|
|
|
}
|
2011-03-28 11:21:39 +00:00
|
|
|
else if((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) {
|
2009-01-23 14:43:25 +00:00
|
|
|
float curofs= 0.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
|
|
|
for (i=0; i<=slen; i++) {
|
2005-09-14 14:02:21 +00:00
|
|
|
for (j=i; (mem[j]) && (mem[j]!='\n') &&
|
2010-03-22 09:30:00 +00:00
|
|
|
(mem[j]!='\r') && (chartransdata[j].dobreak==0) && (j<slen); j++);
|
2005-09-14 14:02:21 +00:00
|
|
|
if ((mem[j]!='\r') && (mem[j]!='\n') &&
|
2010-03-22 09:30:00 +00:00
|
|
|
((chartransdata[j].dobreak!=0))) {
|
|
|
|
|
if (mem[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[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
|
|
|
ct->xof+= curofs;
|
|
|
|
|
}
|
2005-09-14 14:02:21 +00:00
|
|
|
if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 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
|
|
|
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 */
|
2010-03-13 11:22:39 +00:00
|
|
|
/* Note: Only OB_CURVE objects could have a path */
|
|
|
|
|
if(cu->textoncurve && cu->textoncurve->type==OB_CURVE) {
|
2009-01-23 14:43:25 +00:00
|
|
|
Curve *cucu= cu->textoncurve->data;
|
|
|
|
|
int oldflag= cucu->flag;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
cucu->flag |= (CU_PATH+CU_FOLLOW);
|
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if(cucu->path==NULL) makeDispListCurveTypes(scene, cu->textoncurve, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
if(cucu->path) {
|
2009-01-23 14:43:25 +00:00
|
|
|
float distfac, imat[4][4], imat3[3][3], cmat[3][3];
|
|
|
|
|
float minx, maxx, miny, maxy;
|
|
|
|
|
float timeofs, sizefac;
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, ob->obmat);
|
|
|
|
|
copy_m3_m4(imat3, imat);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(cmat, cu->textoncurve->obmat);
|
|
|
|
|
mul_m3_m3m3(cmat, cmat, imat3);
|
|
|
|
|
sizefac= normalize_v3(cmat[0])/cu->fsize;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
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);
|
2011-03-28 11:21:39 +00:00
|
|
|
timeofs= 0.0f;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-03-28 11:21:39 +00:00
|
|
|
if(distfac > 1.0f) {
|
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++) {
|
2009-01-23 14:43:25 +00:00
|
|
|
float ctime, dtime, vec[4], tvec[4], rotvec[3];
|
|
|
|
|
float si, co;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2007-04-04 13:18:41 +00:00
|
|
|
/* rotate around center character */
|
2005-09-14 14:02:21 +00:00
|
|
|
ascii = mem[i];
|
2010-07-13 23:51:21 +00:00
|
|
|
|
|
|
|
|
che= find_vfont_char(vfd, ascii);
|
2005-09-14 14:02:21 +00:00
|
|
|
|
2010-07-13 22:21:59 +00:00
|
|
|
twidth = char_width(cu, che, info);
|
2011-01-14 21:06:28 +00:00
|
|
|
|
|
|
|
|
dtime= distfac*0.5f*twidth;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ctime= timeofs + distfac*( ct->xof - minx);
|
2011-03-28 11:21:39 +00:00
|
|
|
CLAMP(ctime, 0.0f, 1.0f);
|
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 */
|
2010-04-21 11:59:47 +00:00
|
|
|
where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL, NULL);
|
|
|
|
|
where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL, NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(vec, sizefac);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
if (cu->selboxes) {
|
2005-06-17 21:04:27 +00:00
|
|
|
ct= chartransdata;
|
|
|
|
|
for (i=0; i<=selend; i++, ct++) {
|
|
|
|
|
if (i>=selstart) {
|
2009-01-23 14:43:25 +00:00
|
|
|
cu->selboxes[i-selstart].x = ct->xof*cu->fsize;
|
|
|
|
|
cu->selboxes[i-selstart].y = ct->yof*cu->fsize;
|
2005-06-17 21:04:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
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 */
|
2009-01-23 14:43:25 +00:00
|
|
|
if(cu->editfont) {
|
|
|
|
|
float si, co;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
ct= chartransdata+cu->pos;
|
|
|
|
|
si= (float)sin(ct->rot);
|
|
|
|
|
co= (float)cos(ct->rot);
|
|
|
|
|
|
2009-01-23 14:43:25 +00:00
|
|
|
f= cu->editfont->textcurs[0];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
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);
|
2005-09-14 14:02:21 +00:00
|
|
|
MEM_freeN(mem);
|
2005-06-17 21:04:27 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-22 15:39:43 +00:00
|
|
|
if(mode == FO_EDIT) {
|
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) {
|
2009-01-23 14:43:25 +00:00
|
|
|
for (i= 0; i<slen; i++) {
|
2010-10-05 21:22:33 +00:00
|
|
|
unsigned long cha = (uintptr_t) mem[i];
|
2009-06-15 09:54:37 +00:00
|
|
|
info = &(custrinfo[i]);
|
2009-01-23 14:43:25 +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-09-14 14:02:21 +00:00
|
|
|
// We do not want to see any character for \n or \r
|
|
|
|
|
if(cha != '\n' && cha != '\r')
|
2005-09-19 17:58:51 +00:00
|
|
|
buildchar(cu, cha, info, ct->xof, ct->yof, ct->rot, i);
|
2009-01-23 14:43:25 +00:00
|
|
|
|
2010-07-13 23:51:21 +00:00
|
|
|
if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) {
|
2009-01-23 14:43:25 +00:00
|
|
|
float ulwidth, uloverlap= 0.0f;
|
|
|
|
|
|
2005-09-19 17:58:51 +00:00
|
|
|
if ( (i<(slen-1)) && (mem[i+1] != '\n') && (mem[i+1] != '\r') &&
|
2010-07-13 23:51:21 +00:00
|
|
|
((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i+1].flag & CU_CHINFO_WRAP)==0)
|
2009-01-23 14:43:25 +00:00
|
|
|
) {
|
2011-03-28 11:21:39 +00:00
|
|
|
uloverlap = xtrax + 0.1f;
|
2005-09-19 17:58:51 +00:00
|
|
|
}
|
|
|
|
|
// Find the character, the characters has to be in the memory already
|
|
|
|
|
// since character checking has been done earlier already.
|
2010-07-13 23:51:21 +00:00
|
|
|
che= find_vfont_char(vfd, cha);
|
2010-07-13 22:21:59 +00:00
|
|
|
|
|
|
|
|
twidth = char_width(cu, che, info);
|
2011-03-28 11:21:39 +00:00
|
|
|
ulwidth = cu->fsize * ((twidth* (1.0f+(info->kern/40.0f)))+uloverlap);
|
|
|
|
|
build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05f)*cu->fsize,
|
2009-01-23 14:43:25 +00:00
|
|
|
ct->xof*cu->fsize + ulwidth,
|
2011-03-28 11:21:39 +00:00
|
|
|
ct->yof*cu->fsize + (cu->ulpos-0.05f)*cu->fsize - cu->ulheight*cu->fsize,
|
2009-01-23 14:43:25 +00:00
|
|
|
i, info->mat_nr);
|
2005-09-19 17:58:51 +00:00
|
|
|
}
|
2009-01-23 14:43:25 +00:00
|
|
|
ct++;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-06-17 21:04:27 +00:00
|
|
|
else {
|
2009-01-23 14:43:25 +00:00
|
|
|
int outta = 0;
|
|
|
|
|
for (i= 0; (i<slen) && (outta==0); i++) {
|
|
|
|
|
ascii = mem[i];
|
|
|
|
|
info = &(custrinfo[i]);
|
2005-06-17 21:04:27 +00:00
|
|
|
if (cu->sepchar == (i+1)) {
|
2010-11-03 06:31:53 +00:00
|
|
|
float vecyo[3];
|
|
|
|
|
|
|
|
|
|
vecyo[0]= ct->xof;
|
|
|
|
|
vecyo[1]= ct->yof;
|
|
|
|
|
vecyo[2]= 0.0f;
|
|
|
|
|
|
2005-09-14 14:02:21 +00:00
|
|
|
mem[0] = ascii;
|
|
|
|
|
mem[1] = 0;
|
2009-01-23 14:43:25 +00:00
|
|
|
custrinfo[0]= *info;
|
2005-06-17 21:04:27 +00:00
|
|
|
cu->pos = 1;
|
|
|
|
|
cu->len = 1;
|
2010-07-26 06:34:56 +00:00
|
|
|
mul_v3_m4v3(ob->loc, ob->obmat, vecyo);
|
2005-09-19 17:58:51 +00:00
|
|
|
outta = 1;
|
|
|
|
|
cu->sepchar = 0;
|
2005-06-17 21:04:27 +00:00
|
|
|
}
|
2009-01-23 14:43:25 +00:00
|
|
|
ct++;
|
|
|
|
|
}
|
2005-09-19 17:58:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(mode==FO_DUPLI) {
|
2005-09-14 14:02:21 +00:00
|
|
|
MEM_freeN(mem);
|
2002-10-12 11:37:38 +00:00
|
|
|
return chartransdata;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-14 14:02:21 +00:00
|
|
|
if(mem)
|
|
|
|
|
MEM_freeN(mem);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(chartransdata);
|
2011-02-13 10:52:18 +00:00
|
|
|
return NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|