1 /* Copyright (C) 2000-2008 by George Williams */
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.
28 #include "baseviews.h"
37 static FontViewBase
*fv_list
=NULL
;
39 extern int onlycopydisplayed
;
45 static FontViewBase
*_FontViewBaseCreate(SplineFont
*sf
) {
46 FontViewBase
*fv
= gcalloc(1,sizeof(FontViewBase
));
49 fv
->nextsame
= sf
->fv
;
50 fv
->active_layer
= ly_fore
;
53 sf
->mm
->normal
->fv
= fv
;
54 for ( i
= 0; i
<sf
->mm
->instance_count
; ++i
)
55 sf
->mm
->instances
[i
]->fv
= fv
;
57 if ( sf
->subfontcnt
==0 ) {
59 if ( fv
->nextsame
!=NULL
) {
60 fv
->map
= EncMapCopy(fv
->nextsame
->map
);
61 fv
->normal
= fv
->nextsame
->normal
==NULL
? NULL
: EncMapCopy(fv
->nextsame
->normal
);
62 } else if ( sf
->compacted
) {
64 fv
->map
= CompactEncMap(EncMapCopy(sf
->map
),sf
);
71 for ( i
=0; i
<sf
->subfontcnt
; ++i
)
72 sf
->subfonts
[i
]->fv
= fv
;
73 for ( i
=0; i
<sf
->subfontcnt
; ++i
) /* Search for a subfont that contains more than ".notdef" (most significant in .gai fonts) */
74 if ( sf
->subfonts
[i
]->glyphcnt
>1 ) {
75 fv
->sf
= sf
->subfonts
[i
];
79 fv
->sf
= sf
->subfonts
[0];
81 if ( fv
->nextsame
==NULL
) EncMapFree(sf
->map
);
82 fv
->map
= EncMap1to1(sf
->glyphcnt
);
84 fv
->selected
= gcalloc(fv
->map
->enccount
,sizeof(char));
87 PyFF_InitFontHook(fv
);
92 static FontViewBase
*FontViewBase_Create(SplineFont
*sf
,int hide
) {
93 FontViewBase
*fv
= _FontViewBaseCreate(sf
);
98 static FontViewBase
*FontViewBase_Append(FontViewBase
*fv
) {
99 /* Normally fontviews get added to the fv list when their windows are */
100 /* created. but we don't create any windows here, so... */
103 if ( fv_list
==NULL
) fv_list
= fv
;
105 for ( test
= fv_list
; test
->next
!=NULL
; test
=test
->next
);
111 static void FontViewBase_Free(FontViewBase
*fv
) {
116 EncMapFree(fv
->cidmaster
->map
);
118 if ( fv
->nextsame
==NULL
&& fv
->sf
->fv
==fv
) {
120 SplineFontFree(fv
->cidmaster
?fv
->cidmaster
:fv
->sf
);
123 if ( fv
->sf
->fv
==fv
) {
124 if ( fv
->cidmaster
==NULL
)
125 fv
->sf
->fv
= fv
->nextsame
;
127 fv
->cidmaster
->fv
= fv
->nextsame
;
128 for ( i
=0; i
<fv
->cidmaster
->subfontcnt
; ++i
)
129 fv
->cidmaster
->subfonts
[i
]->fv
= fv
->nextsame
;
132 for ( prev
= fv
->sf
->fv
; prev
->nextsame
!=fv
; prev
=prev
->nextsame
);
133 prev
->nextsame
= fv
->nextsame
;
137 DictionaryFree(fv
->fontvars
);
147 static int FontViewBaseWinInfo(FontViewBase
*fv
, int *cc
, int *rc
) {
153 static void FontViewBaseSetTitle(FontViewBase
*foo
) { (void)foo
; }
154 static void FontViewBaseSetTitles(SplineFont
*foo
) { (void)foo
; }
155 static void FontViewBaseRefreshAll(SplineFont
*foo
) { (void)foo
; }
156 static void FontViewBaseReformatOne(FontViewBase
*foo
) { (void)foo
; }
157 static void FontViewBaseReformatAll(SplineFont
*foo
) { (void)foo
; }
158 static void FontViewBaseLayerChanged(FontViewBase
*foo
) {(void)foo
; }
159 static void FV_ToggleCharChanged(SplineChar
*foo
) {(void)foo
; }
160 static FontViewBase
*FVAny(void) { return fv_list
; }
161 static int FontIsActive(SplineFont
*sf
) {
164 for ( fv
=fv_list
; fv
!=NULL
; fv
=fv
->next
)
171 static SplineFont
*FontOfFilename(const char *filename
) {
175 GFileGetAbsoluteName((char *) filename
,buffer
,sizeof(buffer
));
176 for ( fv
=fv_list
; fv
!=NULL
; fv
=fv
->next
) {
177 if ( fv
->sf
->filename
!=NULL
&& strcmp(fv
->sf
->filename
,buffer
)==0 )
179 else if ( fv
->sf
->origname
!=NULL
&& strcmp(fv
->sf
->origname
,buffer
)==0 )
185 static void FVExtraEncSlots(FontViewBase
*fv
, int encmax
) {
190 static void FontViewBase_Close(FontViewBase
*fv
) {
195 for ( n
=fv_list
; n
->next
!=fv
; n
=n
->next
);
201 static void FVB_ChangeDisplayBitmap(FontViewBase
*fv
, BDFFont
*bdf
) {
202 fv
->active_bitmap
= bdf
;
205 static void FVB_ShowFilled(FontViewBase
*fv
) {
206 fv
->active_bitmap
= NULL
;
209 static void FVB_ReattachCVs(SplineFont
*old
, SplineFont
*new) {
214 static void FVB_DeselectAll(FontViewBase
*fv
) {
215 memset(fv
->selected
,0,fv
->map
->encmax
);
218 static void FVB_DisplayChar(FontViewBase
*fv
,int gid
) {
223 static int SFB_CloseAllInstrs(SplineFont
*sf
) {
228 struct fv_interface noui_fv
= {
233 FontViewBaseSetTitle
,
234 FontViewBaseSetTitles
,
235 FontViewBaseRefreshAll
,
236 FontViewBaseReformatOne
,
237 FontViewBaseReformatAll
,
238 FontViewBaseLayerChanged
,
239 FV_ToggleCharChanged
,
247 FVB_ChangeDisplayBitmap
,
257 struct fv_interface
*fv_interface
= &noui_fv
;
260 /******************************************************************************/
261 static int NoGlyphs(struct metricsview
*mv
) {
266 static SplineChar
*Nothing(struct metricsview
*mv
, int i
) {
272 static void NoReKern(struct splinefont
*sf
) {
276 static void NoCloseAll(struct splinefont
*sf
) {
280 struct mv_interface noui_mv
= {
287 struct mv_interface
*mv_interface
= &noui_mv
;