Huw Davies : fontforge: Enable the width of individual bitmap strikes to be altered.

Alexandre Julliard julliard at winehq.org
Thu Apr 22 04:06:26 CDT 2010


Module: fontforge
Branch: master
Commit: 3d71a1e385d6e7f2bf53d1f563fb451e7f0806f7
URL:    http://source.winehq.org/git/fontforge.git/?a=commit;h=3d71a1e385d6e7f2bf53d1f563fb451e7f0806f7

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Apr 20 21:39:49 2010 +0100

fontforge: Enable the width of individual bitmap strikes to be altered.

---

 fontforge/bitmapview.c |   46 +++++++++++++++++++++++++---------------------
 1 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/fontforge/bitmapview.c b/fontforge/bitmapview.c
index e9affea..5310298 100644
--- a/fontforge/bitmapview.c
+++ b/fontforge/bitmapview.c
@@ -898,8 +898,8 @@ static void BVSetWidth(BitmapView *bv, int x) {
     BDFFont *bdf;
     BDFChar *bc = bv->bc;
 
+    bc->width = x;
     if ( bv->bdf->sf->onlybitmaps ) {
-	bc->width = x;
 	tot=0; cnt=0;
 	for ( bdf = bv->bdf->sf->bitmaps; bdf!=NULL; bdf=bdf->next )
 	    if ( bdf->glyphs[bc->orig_pos]) {
@@ -910,8 +910,9 @@ static void BVSetWidth(BitmapView *bv, int x) {
 	    bc->sc->width = tot/cnt;
 	    bc->sc->widthset = true;
 	}
-	BCCharChangedUpdate(bc);
     }
+    BCCharChangedUpdate(bc);
+
 }
 
 static void BVSetVWidth(BitmapView *bv, int y) {
@@ -919,18 +920,20 @@ static void BVSetVWidth(BitmapView *bv, int y) {
     BDFFont *bdf;
     BDFChar *bc = bv->bc;
 
-    if ( bv->bdf->sf->onlybitmaps && bv->bdf->sf->hasvmetrics ) {
+    if ( bv->bdf->sf->hasvmetrics ) {
 	bc->vwidth = bv->bdf->ascent-y;
-	tot=0; cnt=0;
-	for ( bdf = bv->bdf->sf->bitmaps; bdf!=NULL; bdf=bdf->next )
-	    if ( bdf->glyphs[bc->orig_pos]) {
-		tot += bdf->glyphs[bc->orig_pos]->vwidth*1000/(bdf->ascent+bdf->descent);
-		++cnt;
-	    }
-	if ( cnt!=0 ) {
-	    bc->sc->vwidth = tot/cnt;
-	    bc->sc->widthset = true;
-	}
+        if ( bv->bdf->sf->onlybitmaps ) {
+            tot=0; cnt=0;
+            for ( bdf = bv->bdf->sf->bitmaps; bdf!=NULL; bdf=bdf->next )
+                if ( bdf->glyphs[bc->orig_pos]) {
+                    tot += bdf->glyphs[bc->orig_pos]->vwidth*1000/(bdf->ascent+bdf->descent);
+                    ++cnt;
+                }
+            if ( cnt!=0 ) {
+                bc->sc->vwidth = tot/cnt;
+                bc->sc->widthset = true;
+            }
+        }
 	BCCharChangedUpdate(bc);
     }
 }
@@ -1008,12 +1011,11 @@ return;
 		GDrawSetCursor(bv->v,ct_shift);
 		/* otherwise we'll move the selection */
 	    }
-	} else if ( bc->sc->parent->onlybitmaps &&
-		event->u.mouse.x-bv->xoff > bc->width*bv->scale-3 &&
-		event->u.mouse.x-bv->xoff < bc->width*bv->scale+3 ) {
+	} else if ( event->u.mouse.x-bv->xoff > bc->width*bv->scale-3 &&
+                    event->u.mouse.x-bv->xoff < bc->width*bv->scale+3 ) {
 	    bv->active_tool = bvt_setwidth;
 	    BVToolsSetCursor(bv,event->u.mouse.state|(1<<(7+event->u.mouse.button)), event->u.mouse.device );
-	} else if ( bc->sc->parent->onlybitmaps && bc->sc->parent->hasvmetrics &&
+	} else if ( bc->sc->parent->hasvmetrics &&
 		bv->height-event->u.mouse.y-bv->yoff > (bv->bdf->ascent-bc->vwidth)*bv->scale-3 &&
 		bv->height-event->u.mouse.y-bv->yoff < (bv->bdf->ascent-bc->vwidth)*bv->scale+3 ) {
 	    bv->active_tool = bvt_setvwidth;
@@ -1535,8 +1537,6 @@ static void BVMenuSetWidth(GWindow gw,struct gmenuitem *mi,GEvent *g) {
     SplineChar *sc;
     int val;
 
-    if ( !bv->bdf->sf->onlybitmaps )
-return;
     if ( mi->mid==MID_SetWidth ) {
 	sprintf( buffer,"%d",bv->bc->width);
 	ret = gwwv_ask_string(_("Set Width..."),buffer,_("Set Width..."));
@@ -1555,6 +1555,10 @@ return;
     else
 	bv->bc->vwidth = val;
     BCCharChangedUpdate(bv->bc);
+
+    if ( !bv->bdf->sf->onlybitmaps )
+return;
+
     for ( bdf=bv->bdf->sf->bitmaps; bdf!=NULL; bdf=bdf->next )
 	if ( bdf->pixelsize > mysize )
 return;
@@ -1788,10 +1792,10 @@ static void mtlistcheck(GWindow gw,struct gmenuitem *mi,GEvent *e) {
     for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) {
 	switch ( mi->mid ) {
 	  case MID_SetWidth:
-	    mi->ti.disabled = !bv->bdf->sf->onlybitmaps;
+	    mi->ti.disabled = 0;
 	  break;
 	  case MID_SetVWidth:
-	    mi->ti.disabled = !bv->bdf->sf->onlybitmaps || !bv->bdf->sf->hasvmetrics;
+	    mi->ti.disabled = !bv->bdf->sf->hasvmetrics;
 	  break;
 	}
     }




More information about the wine-cvs mailing list