Permalink
Browse files

Move all layers when we shift the lbearing or center the glyph

  • Loading branch information...
1 parent ff8d7e8 commit 0bb4de7edd17ea46e89a626ca8ff5c6ec7c8c7be @monkeyiq monkeyiq committed Mar 7, 2013
View
21 fontforge/charview.c
@@ -7926,14 +7926,14 @@ static void TransRef(RefChar *ref,real transform[6], enum fvtrans_flags flags) {
RefCharFindBounds(ref);
}
-void CVTransFunc(CharView *cv,real transform[6], enum fvtrans_flags flags) {
+void CVTransFuncLayer(CharView *cv,Layer *ly,real transform[6], enum fvtrans_flags flags)
+{
int anysel = cv->p.transany;
RefChar *refs;
ImageList *img;
AnchorPoint *ap;
KernPair *kp;
PST *pst;
- Layer *ly = cv->b.layerheads[cv->b.drawmode];
int l, cvlayer;
if ( cv->b.sc->inspiro && hasspiro() )
@@ -8004,6 +8004,21 @@ void CVTransFunc(CharView *cv,real transform[6], enum fvtrans_flags flags) {
}
}
+void CVTransFunc(CharView *cv,real transform[6], enum fvtrans_flags flags)
+{
+ Layer *ly = cv->b.layerheads[cv->b.drawmode];
+ CVTransFuncLayer( cv, ly, transform, flags );
+}
+
+void CVTransFuncAllLayers(CharView *cv,real transform[6], enum fvtrans_flags flags)
+{
+ for( int idx = 0; idx < cv->b.sc->layer_cnt; ++idx )
+ {
+ Layer *ly = &cv->b.sc->layers[ idx ];
+ CVTransFuncLayer( cv, ly, transform, flags );
+ }
+}
+
static void transfunc(void *d,real transform[6],int otype,BVTFunc *bvts,
enum fvtrans_flags flags) {
CharView *cv = (CharView *) d;
@@ -9900,7 +9915,7 @@ static void CVMenuCenter(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) {
if ( transform[4]!=0 ) {
cv->p.transany = false;
CVPreserveState(&cv->b);
- CVTransFunc(cv,transform,fvt_dontmovewidth);
+ CVTransFuncAllLayers(cv, transform, fvt_dontmovewidth );
CVCharChangedUpdate(&cv->b);
}
cv->b.drawmode = drawmode;
View
2 fontforge/fontviewbase.c
@@ -1592,7 +1592,7 @@ void FVMetricsCenter(FontViewBase *fv,int docenter) {
else
transform[4] = (sc->width-(bb.maxx-bb.minx))/3 - bb.minx;
if ( transform[4]!=0 ) {
- FVTrans(fv,sc,transform,NULL,fvt_dontmovewidth);
+ FVTrans(fv,sc,transform,NULL, fvt_dontmovewidth | fvt_alllayers );
bvts[0].x = transform[4];
for ( bdf = fv->sf->bitmaps; bdf!=NULL; bdf=bdf->next )
if ( gid<bdf->glyphcnt && bdf->glyphs[gid]!=NULL )
View
7 fontforge/fvmetrics.c
@@ -78,8 +78,9 @@ return;
else
transform[4] = scale*ib.minx*wd->scale/100 - ib.minx;
}
- if ( transform[4]!=0 ) {
- FVTrans(fv,sc,transform,NULL,fvt_dontmovewidth);
+ if ( transform[4]!=0 )
+ {
+ FVTrans(fv,sc,transform,NULL,fvt_dontmovewidth | fvt_alllayers );
bvts[0].x = transform[4];
for ( bdf = fv->sf->bitmaps; bdf!=NULL; bdf=bdf->next ) if ( bdf->glyphs[sc->orig_pos]!=NULL )
BCTrans(bdf,bdf->glyphs[sc->orig_pos],bvts,fv);
@@ -150,7 +151,7 @@ return;
SCSynchronizeWidth(sc,width,sc->width,fv);
}
if ( transform[4]!=0 ) {
- FVTrans(fv,sc,transform,NULL,fvt_dontmovewidth);
+ FVTrans(fv,sc,transform,NULL, fvt_dontmovewidth | fvt_alllayers );
bvts[0].x = transform[4];
for ( bdf = fv->sf->bitmaps; bdf!=NULL; bdf=bdf->next ) if ( bdf->glyphs[sc->orig_pos]!=NULL )
BCTrans(bdf,bdf->glyphs[sc->orig_pos],bvts,fv);
View
15 fontforge/metricsview.c
@@ -991,7 +991,7 @@ return( true );
DBounds bb;
SplineCharFindBounds(sc,&bb);
transform[4] = offset-bb.minx;
- FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,0);
+ FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL, 0 | fvt_alllayers );
SCSynchronizeWidth(sc,val,sc->width,NULL);
SCCharChangedUpdate(sc,ly_none);
@@ -1034,13 +1034,13 @@ return( true );
transform[0] = transform[3] = 1.0;
transform[1] = transform[2] = transform[5] = 0;
transform[4] = val-bb.minx;
- FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,0);
+ FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,0 | fvt_alllayers );
} else if ( mv->vertical && val!=sc->parent->ascent-bb.maxy ) {
real transform[6];
transform[0] = transform[3] = 1.0;
transform[1] = transform[2] = transform[4] = 0;
transform[5] = sc->parent->ascent-bb.maxy-val;
- FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,fvt_dontmovewidth);
+ FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL, fvt_dontmovewidth | fvt_alllayers );
}
} else if ( e->u.control.subtype == et_textfocuschanged &&
@@ -3132,7 +3132,8 @@ static void MVMenuChangeLayer(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e
GDrawRequestExpose(mv->v,NULL,false);
}
-static void MVMenuCenter(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) {
+static void MVMenuCenter(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e))
+{
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw);
int i;
DBounds bb;
@@ -3152,7 +3153,7 @@ static void MVMenuCenter(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) {
else
transform[4] = (sc->width-(bb.maxx-bb.minx))/3 - bb.minx;
if ( transform[4]!=0 )
- FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,fvt_dontmovewidth);
+ FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL, fvt_dontmovewidth| fvt_alllayers );
}
}
@@ -4255,7 +4256,7 @@ static void MVSubMouse(MetricsView *mv,GEvent *event) {
_MVSubVMouse(mv,event);
return;
}
-
+
ybase = mv->ybaseline - mv->yoff;
within = -1;
for ( i=0; i<mv->glyphcnt; ++i ) {
@@ -4507,7 +4508,7 @@ return;
transform[4] = diff*
(mv->sf->ascent+mv->sf->descent)/(mv->pixelsize*iscale);
if ( transform[4]!=0 )
- FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,false);
+ FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL, 0 | fvt_alllayers );
}
mv->pressedwidth = false;
mv->pressedkern = false;
View
6 fontforge/views.h
@@ -861,7 +861,13 @@ extern int CVPalettesWidth(void);
extern int BVPalettesWidth(void);
extern void CVDoTransform(CharView *cv, enum cvtools cvt );
+
+// apply transform to specified layer
+extern void CVTransFuncLayer(CharView *cv,Layer *ly,real transform[6], enum fvtrans_flags flags);
+// apply transform to the current layer only
extern void CVTransFunc(CharView *cv,real transform[6],enum fvtrans_flags);
+// apply transform to all layers
+extern void CVTransFuncAllLayers(CharView *cv,real transform[6], enum fvtrans_flags flags);
enum transdlg_flags { tdf_enableback=0x1, tdf_enablekerns=0x2,
tdf_defaultkerns=0x4, tdf_addapply=0x8 };
extern void TransformDlgCreate(void *data,void (*transfunc)(void *,real *,int,BVTFunc *,enum fvtrans_flags),
View
9 htdocs/metricsmenu.html
@@ -253,12 +253,18 @@ <H1 ALIGN=Center>
lbearing be the same as its rbearing) within the current width.
<P>
In the Font View the same thing is done for all selected glyphs.
+ <P>
+ Setting this value will adjust all layers
+ so that guides in the background etc will be adjusted with the rest of the glyph.
<DT>
<A NAME="Thirds">Thirds</A> in Width
<DD>
This is very like Center in Width above... except that I happen to prefer
having a bit more white space after my glyphs than before them. So this command
makes the rbearing twice the lbearing (instead of making them be the same).
+ <P>
+ Setting this value will adjust all layers
+ so that guides in the background etc will be adjusted with the rest of the glyph.
<DT>
<A NAME="WindowType">Window</A> Type
<DD>
@@ -292,7 +298,8 @@ <H1 ALIGN=Center>
<DD>
The Set LBearing command is similar to the Set Width command above, the dialog
is pretty much the same except that it applies to the left side bearing rather
- than to the width.
+ than to the width. Setting this value will adjust all layers
+ so that guides in the background etc will be adjusted with the rest of the glyph.
<DT>
Set <A NAME="RBearing">RBearing</A>...
<DD>
View
3 htdocs/python.html
@@ -1818,7 +1818,8 @@ <H1 ALIGN=Center>
</TR>
<TR>
<TD><CODE>left_side_bearing</CODE></TD>
- <TD colspan=2>The left side bearing of the glyph</TD>
+ <TD colspan=2>The left side bearing of the glyph. Setting this value will adjust all layers
+ so that guides in the background etc will be adjusted with the rest of the glyph</TD>
</TR>
<TR>
<TD><CODE>manualHints</CODE></TD>
View
2 htdocs/scripting-alpha.html
@@ -2753,6 +2753,8 @@ <H1 ALIGN=Center>
will be incremented by the first, and if the argument is 2 then the left
bearing will be scaled by &lt;first argument&gt;/100.0 . In bitmap only fonts
see the comment at <A HREF="#SelectBitmap">SelectBitmap</A> about units.
+ Setting this value will adjust all layers
+ so that guides in the background etc will be adjusted with the rest of the glyph.
<DT>
<A NAME="SetMacStyle">S</A>etMacStyle(val)<BR>
SetMacStyle(str)

0 comments on commit 0bb4de7

Please sign in to comment.