beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luafontloader / fontforge / fontforge / cvundoes.c
bloba19bcb9a4c0e357cbbd11520abbd1ab8eff5d305
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:
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
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.
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.
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.
27 #define _DEFINE_SEARCHVIEW_
28 #include "fontforgevw.h"
29 #include <math.h>
30 #include <ustring.h>
31 #include <utype.h>
33 extern char *coord_sep;
35 int onlycopydisplayed = 0;
36 int copymetadata = 0;
37 int copyttfinstr = 0;
39 /* ********************************* Undoes ********************************* */
41 int maxundoes = 0; /* -1 is infinite */
43 static void UHintListFree(void *hints) {
44 StemInfo *h, *t, *p;
46 if ( hints==NULL )
47 return;
48 if ( ((StemInfo *) hints)->hinttype==ht_d )
49 DStemInfosFree(hints);
50 else {
51 h = t = hints;
52 p = NULL;
53 while ( t!=NULL && t->hinttype!=ht_d ) {
54 p = t;
55 t = t->next;
57 p->next = NULL;
58 StemInfosFree(h);
59 DStemInfosFree((DStemInfo *) t);
63 void UndoesFree(Undoes *undo) {
64 Undoes *unext;
66 while ( undo!=NULL ) {
67 unext = undo->next;
68 switch ( undo->undotype ) {
69 case ut_noop:
70 case ut_width: case ut_vwidth: case ut_lbearing: case ut_rbearing:
71 /* Nothing else to free */;
72 break;
73 case ut_state: case ut_tstate: case ut_statehint: case ut_statename:
74 case ut_hints: case ut_anchors: case ut_statelookup:
75 SplinePointListsFree(undo->u.state.splines);
76 RefCharsFree(undo->u.state.refs);
77 UHintListFree(undo->u.state.hints);
78 free(undo->u.state.instrs);
79 ImageListsFree(undo->u.state.images);
80 if ( undo->undotype==ut_statename ) {
81 free( undo->u.state.charname );
82 free( undo->u.state.comment );
83 PSTFree( undo->u.state.possub );
85 AnchorPointsFree(undo->u.state.anchor);
86 break;
87 case ut_bitmap:
88 free(undo->u.bmpstate.bitmap);
89 break;
90 case ut_multiple: case ut_layers:
91 UndoesFree( undo->u.multiple.mult );
92 break;
93 case ut_composit:
94 UndoesFree(undo->u.composit.state);
95 UndoesFree(undo->u.composit.bitmaps);
96 break;
97 default:
98 IError( "Unknown undo type in UndoesFree: %d", undo->undotype );
99 break;
101 chunkfree(undo,sizeof(Undoes));
102 undo = unext;
106 int getAdobeEnc(char *name) {
107 extern char *AdobeStandardEncoding[256];
108 int i;
110 for ( i=0; i<256; ++i )
111 if ( strcmp(name,AdobeStandardEncoding[i])==0 )
112 break;
113 if ( i==256 ) i = -1;
114 return( i );
117 int SCWasEmpty(SplineChar *sc, int skip_this_layer) {
118 int i;
120 for ( i=ly_fore; i<sc->layer_cnt; ++i ) if ( i!=skip_this_layer && !sc->layers[i].background ) {
121 if ( sc->layers[i].refs!=NULL )
122 return( false );
123 else if ( sc->layers[i].splines!=NULL ) {
124 SplineSet *ss;
125 for ( ss = sc->layers[i].splines; ss!=NULL; ss=ss->next ) {
126 if ( ss->first->prev!=NULL )
127 return( false ); /* Closed contour */
131 return( true );