w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

splinechar.c
Go to the documentation of this file.
1 /* Copyright (C) 2000-2008 by George Williams */
2 /*
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are met:
5 
6  * Redistributions of source code must retain the above copyright notice, this
7  * list of conditions and the following disclaimer.
8 
9  * Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12 
13  * The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15 
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 #include "fontforgevw.h"
28 #include <math.h>
29 #include <locale.h>
30 # include <ustring.h>
31 # include <utype.h>
32 #ifdef HAVE_IEEEFP_H
33 # include <ieeefp.h> /* Solaris defines isnan in ieeefp rather than math.h */
34 #endif
35 #include "ttf.h"
36 
37 int adjustwidth = true;
38 int adjustlbearing = true;
41 
43  SplineSet *ss;
44  SplinePoint *sp;
45 
46  for ( ss=sc->layers[layer].splines; ss!=NULL; ss=ss->next ) {
47  for ( sp=ss->first; ; ) {
48  sp->roundx = sp->roundy = false;
49  if ( sp->next==NULL )
50  break;
51  sp = sp->next->to;
52  if ( sp==ss->first )
53  break;
54  }
55  }
56 }
57 
58 
60  RefChar *refs, *next;
61 
62  SplinePointListsFree(sc->layers[layer].splines);
63  sc->layers[layer].splines = NULL;
64  for ( refs=sc->layers[layer].refs; refs!=NULL; refs = next ) {
65  next = refs->next;
67  }
68  sc->layers[layer].refs = NULL;
69  ImageListsFree(sc->layers[layer].images);
70  sc->layers[layer].images = NULL;
71 }
72 
74  int ly_first, ly_last;
75 
76  if ( sc==NULL )
77 return;
78  if ( sc->parent!=NULL && sc->parent->multilayer ) {
79  ly_first = ly_fore;
80  ly_last = sc->layer_cnt-1;
81  } else
82  ly_first = ly_last = layer;
83  for ( layer = ly_first; layer<=ly_last; ++layer )
85  --layer;
86 
87  if ( sc->parent!=NULL &&
88  (sc->parent->multilayer ||
89  (!sc->parent->layers[layer].background && SCWasEmpty(sc,layer)))) {
90  sc->widthset = false;
91  if ( sc->parent!=NULL && sc->width!=0 )
92  sc->width = sc->parent->ascent+sc->parent->descent;
93  AnchorPointsFree(sc->anchor);
94  sc->anchor = NULL;
95  StemInfosFree(sc->hstem); sc->hstem = NULL;
96  StemInfosFree(sc->vstem); sc->vstem = NULL;
97  DStemInfosFree(sc->dstem); sc->dstem = NULL;
98  MinimumDistancesFree(sc->md); sc->md = NULL;
99  free(sc->ttf_instrs);
100  sc->ttf_instrs = NULL;
101  sc->ttf_instrs_len = 0;
103  }
104 }
105 
106 
108 
109  sp->nextcp.x = rint(sp->nextcp.x*factor)/factor;
110  sp->nextcp.y = rint(sp->nextcp.y*factor)/factor;
111  if ( sp->next!=NULL && sp->next->order2 )
112  sp->next->to->prevcp = sp->nextcp;
113  sp->prevcp.x = rint(sp->prevcp.x*factor)/factor;
114  sp->prevcp.y = rint(sp->prevcp.y*factor)/factor;
115  if ( sp->prev!=NULL && sp->prev->order2 )
116  sp->prev->from->nextcp = sp->prevcp;
117  if ( sp->prev!=NULL && sp->next!=NULL && sp->next->order2 &&
118  sp->ttfindex == 0xffff ) {
119  sp->me.x = (sp->nextcp.x + sp->prevcp.x)/2;
120  sp->me.y = (sp->nextcp.y + sp->prevcp.y)/2;
121  } else {
122  sp->me.x = rint(sp->me.x*factor)/factor;
123  sp->me.y = rint(sp->me.y*factor)/factor;
124  }
125 }
126 
127 void SplineSetsRound2Int(SplineSet *spl,real factor, int inspiro, int onlysel) {
128  SplinePoint *sp;
129 
130  for ( ; spl!=NULL; spl=spl->next ) {
131  if ( inspiro ) {
132  } else {
133  for ( sp=spl->first; ; ) {
134  if ( sp->selected || !onlysel )
136  if ( sp->prev!=NULL )
137  SplineRefigure(sp->prev);
138  if ( sp->next==NULL )
139  break;
140  sp = sp->next->to;
141  if ( sp==spl->first )
142  break;
143  }
144  if ( spl->first->prev!=NULL )
145  SplineRefigure(spl->first->prev);
146  }
147  }
148 }
149 
151  int lc=0, cnt=0, out=false, i,j;
152  AnchorPoint *ap, **array;
153  /* Order so that first ligature index comes first */
154 
155  for ( ap=sc->anchor; ap!=NULL; ap=ap->next ) {
156  if ( ap->lig_index<lc ) out = true;
157  if ( ap->lig_index>lc ) lc = ap->lig_index;
158  ++cnt;
159  }
160  if ( !out )
161 return;
162 
163  array = galloc(cnt*sizeof(AnchorPoint *));
164  for ( i=0, ap=sc->anchor; ap!=NULL; ++i, ap=ap->next )
165  array[i] = ap;
166  for ( i=0; i<cnt-1; ++i ) {
167  for ( j=i+1; j<cnt; ++j ) {
168  if ( array[i]->lig_index>array[j]->lig_index ) {
169  ap = array[i];
170  array[i] = array[j];
171  array[j] = ap;
172  }
173  }
174  }
175  sc->anchor = array[0];
176  for ( i=0; i<cnt-1; ++i )
177  array[i]->next = array[i+1];
178  array[cnt-1]->next = NULL;
179  free( array );
180 }
181 
182 
184 }
185 
186 static void SCHintsChng(SplineChar *sc) {
187  sc->changedsincelasthinted = false;
188  if ( !sc->changed ) {
189  sc->changed = true;
190  sc->parent->changed = true;
191  }
192 }
193 
194 static void _SCChngNoUpdate(SplineChar *sc,int layer,int changed) {
195 }
196 
197 static void SCChngNoUpdate(SplineChar *sc,int layer) {
198  _SCChngNoUpdate(sc,layer,true);
199 }
200 
201 static void SCB_MoreLayers(SplineChar *sc,Layer *old) {
202 }
203 
204 static struct sc_interface noui_sc = {
208  SCHintsChng,
214 };
215 
217 
218 void FF_SetSCInterface(struct sc_interface *sci) {
219  sc_interface = sci;
220 }
221 
223 }
224 
226 }
227 
228 static void CVGlphRenameFixup(SplineFont *sf,char *oldname, char *newname) {
229 }
230 
232 }
233 
234 static struct cv_interface noui_cv = {
239 };
240 
242 
243 void FF_SetCVInterface(struct cv_interface *cvi) {
244  cv_interface = cvi;
245 }
double __cdecl rint(double _X)
#define sc
Definition: aptex-macros.h:57
#define next(a)
Definition: aptex-macros.h:924
#define ap
#define free(a)
Definition: decNumber.cpp:310
double real
Definition: dvips.h:66
char * newname(char *name, const char *ext)
Definition: filenames.c:64
FILE * out
Definition: hbf2gf.c:286
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
float factor
Definition: dimen.c:22
static const unsigned char cv[]
Definition: nkf.c:555
boolean changed
Definition: parse_ofm.c:90
static int cnt
Definition: pkout.c:166
C API: Unicode string handling functions.
int adjustwidth
Definition: splinechar.c:36
void StemInfosFree(StemInfo *h)
Definition: splineutil.c:2440
@ ly_fore
Definition: splinefont.h:1209
void DStemInfosFree(DStemInfo *h)
Definition: splineutil.c:2464
void AnchorPointsFree(AnchorPoint *ap)
Definition: splineutil.c:2490
void MinimumDistancesFree(MinimumDistance *md)
Definition: splineutil.c:2610
void SplineRefigure(Spline *spline)
void SplinePointListsFree(SplinePointList *head)
Definition: splineutil.c:179
int SCWasEmpty(SplineChar *sc, int skip_this_layer)
Definition: cvundoes.c:117
static void SCHintsChng(SplineChar *sc)
Definition: splinechar.c:186
int adjustlbearing
Definition: splinechar.c:38
int allow_utf8_glyphnames
Definition: splinechar.c:39
static void CV__LayerPaletteCheck(SplineFont *sf)
Definition: splinechar.c:231
void SCClearRounds(SplineChar *sc, int layer)
Definition: splinechar.c:42
static void SCChngNoUpdate(SplineChar *sc, int layer)
Definition: splinechar.c:197
static void CVChngNoUpdate(CharViewBase *cv)
Definition: splinechar.c:222
static void _CVChngNoUpdate(CharViewBase *cv, int changed)
Definition: splinechar.c:225
void SplinePointRound(SplinePoint *sp, double factor)
Definition: splinechar.c:107
static void CVGlphRenameFixup(SplineFont *sf, char *oldname, char *newname)
Definition: splinechar.c:228
static struct cv_interface noui_cv
Definition: splinechar.c:234
static void _SCChngNoUpdate(SplineChar *sc, int layer, int changed)
Definition: splinechar.c:194
void FF_SetCVInterface(struct cv_interface *cvi)
Definition: splinechar.c:243
void SCClearLayer(SplineChar *sc, int layer)
Definition: splinechar.c:59
static void SCUpdateNothing(SplineChar *sc)
Definition: splinechar.c:183
int clear_tt_instructions_when_needed
Definition: splinechar.c:40
void FF_SetSCInterface(struct sc_interface *sci)
Definition: splinechar.c:218
static void SCB_MoreLayers(SplineChar *sc, Layer *old)
Definition: splinechar.c:201
void SCOrderAP(SplineChar *sc)
Definition: splinechar.c:150
void SCClearContents(SplineChar *sc, int layer)
Definition: splinechar.c:73
void SplineSetsRound2Int(SplineSet *spl, double factor, int inspiro, int onlysel)
Definition: splinechar.c:127
static struct sc_interface noui_sc
Definition: splinechar.c:204
void SCRemoveDependent(SplineChar *dependent, RefChar *rf, int layer)
Definition: splineutil.c:2387
void ImageListsFree(ImageList *imgs)
Definition: splineutil.c:380
#define SCOutOfDateBackground
Definition: uiinterface.h:233
void * galloc(long size)
static unsigned long int lc(mp_ptr rp, gmp_randstate_t rstate)
Definition: randlc2x.c:72
struct refchar * next
Definition: splinefont.h:1117
Definition: tfmaux.c:31
struct spline * prev
Definition: splinefont.h:980
struct splinepointlist * next
Definition: splinefont.h:1073
SplinePoint * first
Definition: splinefont.h:1072
int j
Definition: t4ht.c:1589
#define sp
Definition: stack.c:11