git: 9front

Download patch

ref: 64dd8f4356d70b24c11baf04d2c15c5b324a831f
parent: c360a081b34498e8ec80f7325d7ffd3d73ec8275
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Mon Apr 16 20:06:25 EDT 2012

mothra: fix bogus strtolength

--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -72,19 +72,17 @@
 	HORIZ,
 	VERT,
 };
-int strtolength(Hglob *g, int dir, char *str)
-{
+
+int strtolength(Hglob *g, int dir, char *str){
 	double f;
+	Point p;
 
 	f = atof(str);
-	if(cistrstr(str, "px"))
-		return floor(f);
 	if(cistrstr(str, "%"))
-		return floor(f*((dir==HORIZ) ? Dx(g->dst->text->r) : Dy(g->dst->text->r))/100);
+		return 0;
 	if(cistrstr(str, "em")){
-		Point z;
-		z = stringsize(g->dst->text->font, "M");
-		return floor(f*((dir==HORIZ) ? z.x : z.y));
+		p=stringsize(pl_whichfont(g->state->font, g->state->size)->font, "M");
+		return floor(f*((dir==HORIZ) ? p.x : p.y));
 	}
 	return floor(f);
 }
@@ -692,9 +690,9 @@
 				nstrcpy(g.state->image, str, sizeof(g.state->image));
 			g.state->ismap=pl_hasattr(g.attr, "ismap");
 			if(str=pl_getattr(g.attr, "width"))
-				g.state->width = strtolength(&g, HORIZ, str);
+				g.state->width=strtolength(&g, HORIZ, str);
 			if(str=pl_getattr(g.attr, "height"))
-				g.state->height = strtolength(&g, VERT, str);
+				g.state->height=strtolength(&g, VERT, str);
 			str=pl_getattr(g.attr, "alt");
 			if(str==0){
 				if(g.state->image[0])
--