[Commit] twin ChangeLog, 1.15, 1.16 twin_font.c, 1.11, 1.12 twin_geom.c, 1.2, 1.3 twin_glyphs.c, 1.4, 1.5 xtwin.c, 1.14, 1.15

Keith Packard commit at keithp.com
Mon Oct 4 01:30:38 PDT 2004


Committed by: keithp

Update of /local/src/CVS/twin
In directory home.keithp.com:/tmp/cvs-serv9007

Modified Files:
	ChangeLog twin_font.c twin_geom.c twin_glyphs.c xtwin.c 
Log Message:
2004-10-04  Keith Packard  <keithp at keithp.com>

	* twin_font.c: (twin_has_ucs4), (twin_path_ucs4):
	Delete old glyph representation support code.
	
	* twin_geom.c: (_twin_distance_to_line_squared):
	Oops -- overflow not handled correctly in distance functions.
	
	* twin_glyphs.c:
	Replace new glyphs with versions using splines.

	* xtwin.c: (main):
	Whack around the default presentation a bit more


Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/twin/ChangeLog,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- ChangeLog	4 Oct 2004 07:49:49 -0000	1.15
+++ ChangeLog	4 Oct 2004 08:30:35 -0000	1.16
@@ -1,5 +1,19 @@
 2004-10-04  Keith Packard  <keithp at keithp.com>
 
+	* twin_font.c: (twin_has_ucs4), (twin_path_ucs4):
+	Delete old glyph representation support code.
+	
+	* twin_geom.c: (_twin_distance_to_line_squared):
+	Oops -- overflow not handled correctly in distance functions.
+	
+	* twin_glyphs.c:
+	Replace new glyphs with versions using splines.
+
+	* xtwin.c: (main):
+	Whack around the default presentation a bit more
+
+2004-10-04  Keith Packard  <keithp at keithp.com>
+
 	* twin.h:
 	* twin_draw.c: (twin_composite):
 	Fix a clipping bug

Index: twin_font.c
===================================================================
RCS file: /local/src/CVS/twin/twin_font.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- twin_font.c	4 Oct 2004 07:49:49 -0000	1.11
+++ twin_font.c	4 Oct 2004 08:30:35 -0000	1.12
@@ -41,7 +41,7 @@
 twin_bool_t
 twin_has_ucs4 (twin_ucs4_t ucs4)
 {
-    return ucs4 <= TWIN_FONT_MAX && _twin_glyph_offsets[ucs4] != 0;
+    return ucs4 <= TWIN_FONT_MAX && _twin_g_offsets[ucs4] != 0;
 }
 
 #define SNAPI(p)	(((p) + 0x7fff) & ~0xffff)
@@ -87,14 +87,6 @@
 #define SNAPX(p)	_snap (path, p, snap_x, nsnap_x)
 #define SNAPY(p)	_snap (path, p, snap_y, nsnap_y)
 
-static const twin_gpoint_t *
-_twin_ucs4_base(twin_ucs4_t ucs4)
-{
-    if (ucs4 > TWIN_FONT_MAX) ucs4 = 0;
-
-    return _twin_glyphs + _twin_glyph_offsets[ucs4];
-}
-
 static const signed char *
 _twin_g_base (twin_ucs4_t ucs4)
 {
@@ -167,310 +159,6 @@
     m->font_descent = font_ascent + Margin(pen_size);
 }
 
-#include <stdio.h>
-
-#define TWIN_MAX_POINTS	    50
-#define TWIN_MAX_STROKE	    50
-
-typedef enum { twin_gmove, twin_gline, twin_gcurve } twin_gcmd_t;
-
-typedef struct _twin_gop {
-    twin_gcmd_t	    cmd;
-    twin_gpoint_t   p[3];
-} twin_gop_t;
-    
-typedef struct _twin_stroke {
-    int		    n;
-    twin_gpoint_t   p[TWIN_MAX_STROKE];
-} twin_stroke_t;
-
-typedef struct _twin_snap {
-    int		    n;
-    twin_gfixed_t   s[TWIN_MAX_POINTS];
-} twin_snap_t;
-
-typedef struct _twin_glyph {
-    twin_ucs4_t	    ucs4;
-    int		    offset;
-    twin_bool_t	    exists;
-    twin_gfixed_t   left, right, top, bottom;
-    int		    n;
-    twin_stroke_t   s[TWIN_MAX_STROKE];
-    int		    nop;
-    twin_gop_t	    op[TWIN_MAX_STROKE];
-    twin_snap_t	    snap_x;
-    twin_snap_t	    snap_y;
-} twin_glyph_t;
-
-static twin_glyph_t glyphs[0x80];
-
-static void
-twin_add_snap (twin_snap_t *snap, twin_gfixed_t v)
-{
-    int	    n;
-
-    for (n = 0; n < snap->n; n++)
-    {
-	if (snap->s[n] == v)
-	    return;
-	if (snap->s[n] > v)
-	    break;
-    }
-    memmove (&snap->s[n+1], &snap->s[n], snap->n - n);
-    snap->s[n] = v;
-    snap->n++;
-}
-
-static int
-twin_n_in_spline (twin_gpoint_t *p, int n)
-{
-    return 0;
-}
-
-static void
-twin_spline_fit (twin_gpoint_t *p, int n, twin_gpoint_t *c1, twin_gpoint_t *c2)
-{
-}
-
-static char *
-_ucs4_string (twin_ucs4_t ucs4)
-{
-    static char	buf[10];
-    if (ucs4 < ' ' || ucs4 > '~')
-    {
-	if (!ucs4)
-	    return "\\0";
-	sprintf (buf, "\\0%o", ucs4);
-	return buf;
-    }
-    sprintf (buf, "%c", ucs4);
-    return buf;
-}
-
-static twin_gfixed_t
-px (const twin_gpoint_t *p, int i)
-{
-    return p[i].x << 1;
-}
-
-static twin_gfixed_t
-py (const twin_gpoint_t *p, int i)
-{
-    return p[i].y << 1;
-}
-
-static void
-twin_dump_glyphs (void)
-{
-    twin_ucs4_t	ucs4;
-    int		offset = 0;
-    int		i, j;
-    twin_gop_t	*gop;
-
-    for (ucs4 = 0; ucs4 < 0x80; ucs4++)
-    {
-	const twin_gpoint_t	*p = _twin_ucs4_base (ucs4);
-	twin_glyph_t		*g = &glyphs[ucs4];
-	twin_stroke_t		*s;
-	twin_gfixed_t		origin;
-	twin_gfixed_t		left, right, top, bottom;
-	twin_gfixed_t		baseline;
-	twin_gfixed_t		x, y;
-	twin_bool_t		move;
-	
-	g->ucs4 = ucs4;
-	g->n = 0;
-
-	if (ucs4 && p == _twin_glyphs) continue;
-	
-	if (p[1].y == -64)
-	{
-	    origin = 0;
-	    left = 0;
-	    right = 4;
-	    top = 18;
-	    bottom = 18;
-	    baseline = 18;
-	}
-	else
-	{
-	    origin = 64;
-	    left = 64;
-	    right = -64;
-	    top = 64;
-	    bottom = -64;
-	    baseline = 18;
-	    for (i = 1, move = TWIN_TRUE; p[i].y != -64; i++)
-	    {
-		if (p[i].x == -64) { move = TWIN_TRUE; continue; }
-		if (py(p,i) <= baseline && px(p,i) < origin) origin = px(p,i);
-		if (px(p,i) < left) left = px(p,i);
-		if (px(p,i) > right) right = px(p,i);
-		if (py(p,i) < top) top = py(p,i);
-		if (py(p,i) > bottom) bottom = py(p,i); 
-		move = TWIN_FALSE;
-	    }
-	}
-	left -= origin;
-	right -= origin;;
-	bottom -= baseline;
-	top -= baseline;
-
-	/*
-	 * Convert from hershey format to internal format
-	 */
-	for (i = 1, move = TWIN_TRUE; p[i].y != -64; i++)
-	{
-	    if (p[i].x == -64) { move = TWIN_TRUE; continue; }
-
-	    x = px(p,i) - origin;
-	    y = py(p,i) - baseline;
-	    if (move)
-		if (g->s[g->n].n)
-		    ++g->n;
-	    s = &g->s[g->n];
-	    s->p[s->n].x = x;
-	    s->p[s->n].y = y;
-	    s->n++;
-	    
-	    move = TWIN_FALSE;
-	}
-    	if (g->s[g->n].n)
-    	    ++g->n;
-
-	g->left = left;
-	g->right = right;
-	g->top = top;
-	g->bottom = bottom;
-
-	/*
-	 * Find snap points
-	 */
-	twin_add_snap (&g->snap_x, 0);	    /* origin */
-	twin_add_snap (&g->snap_x, right);  /* right */
-	
-	twin_add_snap (&g->snap_y, 0);	    /* baseline */
-	twin_add_snap (&g->snap_y, -15);    /* x height */
-	twin_add_snap (&g->snap_y, -21);    /* cap height */
-	
-	for (i = 0; i < g->n; i++)
-	{
-	    s = &g->s[i];
-	    for (j = 0; j < s->n - 1; j++)
-	    {
-		if (s->p[j].x == s->p[j+1].x)
-		    twin_add_snap (&g->snap_x, s->p[j].x);
-		if (s->p[j].y == s->p[j+1].y)
-		    twin_add_snap (&g->snap_y, s->p[j].y);
-	    }
-	}
-
-	/*
-	 * Now convert to gops and try to locate splines
-	 */
-	
-	gop = &g->op[0];
-	for (i = 0; i < g->n; i++)
-	{
-	    s = &g->s[i];
-	    gop->cmd = twin_gmove;
-	    gop->p[0] = s->p[0];
-	    gop++;
-	    for (j = 0; j < s->n - 1;)
-	    {
-		int ns = twin_n_in_spline (s->p + j, s->n - j);
-
-		if (ns)
-		{
-		    twin_spline_fit (s->p + j, ns,
-				     &gop->p[0], &gop->p[1]);
-		    gop->cmd = twin_gcurve;
-		    gop->p[2] = s->p[j + ns - 1];
-		    gop++;
-		    j += ns;
-		}
-		else
-		{
-		    gop->cmd = twin_gline;
-		    gop->p[0] = s->p[j+1];
-		    gop++;
-		    j++;
-		}
-	    }
-	}
-	g->nop = gop - &g->op[0];
-	g->exists = TWIN_TRUE;
-    }
-
-    printf ("const signed char _twin_gtable[] = {\n");
-    for (ucs4 = 0; ucs4 < 0x80; ucs4++)
-    {
-	twin_glyph_t		*g = &glyphs[ucs4];
-	
-	if (!g->exists) continue;
-	
-	g->offset = offset;
-
-	printf ("/* 0x%x '%s' */\n", g->ucs4, _ucs4_string (g->ucs4));
-	printf ("    %d, %d, %d, %d, %d, %d,\n",
-		g->left, g->right, -g->top, g->bottom, g->snap_x.n, g->snap_y.n);
-
-	offset += 6;
-
-	printf ("   ");
-	for (i = 0; i < g->snap_x.n; i++)
-	    printf (" %d,", g->snap_x.s[i]);
-	printf (" /* snap_x */\n");
-
-	offset += g->snap_x.n;
-	
-	printf ("   ");
-	for (i = 0; i < g->snap_y.n; i++)
-	    printf (" %d,", g->snap_y.s[i]);
-	printf (" /* snap_y */\n");
-	
-	offset += g->snap_y.n;
-
-#define CO(n)	gop->p[n].x, gop->p[n].y
-	for (i = 0; i < g->nop; i++)
-	{
-	    gop = &g->op[i];
-	    switch (gop->cmd) {
-	    case twin_gmove:
-		printf ("    'm', %d, %d,\n", CO(0));
-		offset += 3;
-		break;
-	    case twin_gline:
-		printf ("    'l', %d, %d,\n", CO(0));
-		offset += 3;
-		break;
-	    case twin_gcurve:
-		printf ("    'c', %d, %d, %d, %d, %d, %d,\n",
-			CO(0), CO(1), CO(2));
-		offset += 7;
-		break;
-	    }
-	}
-	printf ("    'e',\n");
-	offset++;
-    }
-    printf ("};\n\n");
-    printf ("const uint16_t _twin_g_offsets[] = {");
-    for (ucs4 = 0; ucs4 < 0x80; ucs4++)
-    {
-	twin_glyph_t		*g = &glyphs[ucs4];
-	
-	if ((ucs4 & 7) == 0)
-	    printf ("\n    ");
-	else
-	    printf (" ");
-	printf ("%4d,", g->offset);
-    }
-    printf ("\n};\n");
-    fflush (stdout);
-    exit (0);
-}
-
 void
 twin_path_ucs4 (twin_path_t *path, twin_ucs4_t ucs4)
 {
@@ -485,12 +173,6 @@
     twin_matrix_t	pen_matrix;
     twin_text_metrics_t	metrics;
     
-    if (0)
-    {
-	static int been_here = 0;
-	if (!been_here) { been_here = 1; twin_dump_glyphs (); }
-    }
-
     twin_text_metrics_ucs4 (path, ucs4, &metrics);
     
     origin = _twin_path_current_spoint (path);

Index: twin_geom.c
===================================================================
RCS file: /local/src/CVS/twin/twin_geom.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- twin_geom.c	27 Sep 2004 21:28:31 -0000	1.2
+++ twin_geom.c	4 Oct 2004 08:30:35 -0000	1.3
@@ -56,8 +56,10 @@
     twin_dfixed_t   den, num;
 
     num = A * p->x + B * p->y + C;
+    if (num < 0)
+	num = -num;
     den = A * A + B * B;
-    if (den == 0 || num >= 0x10000)
+    if (den == 0 || num >= 0x8000)
 	return _twin_distance_to_point_squared (p, p1);
     else
 	return (num * num) / den;

Index: twin_glyphs.c
===================================================================
RCS file: /local/src/CVS/twin/twin_glyphs.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- twin_glyphs.c	4 Oct 2004 07:49:49 -0000	1.4
+++ twin_glyphs.c	4 Oct 2004 08:30:35 -0000	1.5
@@ -24,458 +24,36 @@
 
 #include "twinint.h"
 
-const twin_gpoint_t _twin_glyphs[] = {
-/* box for missing chars */
-    { -9, 9 }, { -6, 8 }, { -6, -12 }, {  6, -12 }, {  6, 9 }, { -6, 9 },
-    { -64, -64 },
-/* space */
-    { -4, 4 }, { -64, -64 },
-/* ! */
-    { -5, 5 }, { 0, -12 }, { 0, 2 }, { -64, 0 },
[...2192 lines suppressed...]
-    2088, 2119, 2136, 2178, 2208, 2232, 2268, 2298,
-    2374, 2424, 2506, 2562, 2635, 2661, 2703, 2727,
-    2763, 2787, 2815, 2846, 2871, 2889, 2914, 2938,
-    2956, 2989, 3050, 3111, 3166, 3227, 3292, 3328,
-    3405, 3445, 3479, 3523, 3553, 3570, 3632, 3672,
-    3736, 3797, 3858, 3892, 3956, 3991, 4030, 4054,
-    4090, 4114, 4151, 4182, 4230, 4247, 4295,    0,
+      28,   40,   90,  114,  152,  224,  323,  390,
+     419,  441,  463,  494,  520,  556,  575,  604,
+     622,  666,  691,  736,  780,  809,  860,  919,
+     944, 1004, 1063, 1109, 1162, 1183, 1209, 1230,
+    1288, 1375, 1406, 1455, 1499, 1534, 1572, 1604,
+    1655, 1686, 1703, 1731, 1761, 1785, 1821, 1851,
+    1895, 1931, 1981, 2023, 2074, 2100, 2128, 2152,
+    2188, 2212, 2240, 2271, 2296, 2314, 2339, 2363,
+    2381, 2417, 2467, 2517, 2561, 2611, 2659, 2693,
+    2758, 2790, 2826, 2870, 2900, 2917, 2963, 2995,
+    3039, 3089, 3139, 3168, 3219, 3252, 3283, 3307,
+    3343, 3367, 3399, 3430, 3474, 3491, 3535,    0,
 };

Index: xtwin.c
===================================================================
RCS file: /local/src/CVS/twin/xtwin.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- xtwin.c	4 Oct 2004 07:49:49 -0000	1.14
+++ xtwin.c	4 Oct 2004 08:30:35 -0000	1.15
@@ -277,8 +277,8 @@
     TWIN_TEXT_BOLD|TWIN_TEXT_OBLIQUE
 };
 
-#define WIDTH	512
-#define HEIGHT	512
+#define WIDTH	256
+#define HEIGHT	256
 
 int
 main (int argc, char **argv)
@@ -347,7 +347,8 @@
 #if 0
     stroke = twin_path_create ();
     twin_path_move (stroke, D(30), D(400));
-    twin_path_string (stroke, D(200), D(200), TWIN_TEXT_ROMAN, "jelly world.");
+    twin_path_set_font_size (stroke, D(100));
+    twin_path_utf8 (stroke, "jelly world.");
     twin_path_convolve (path, stroke, pen);
 /*    twin_path_append (path, stroke); */
     twin_path_destroy (stroke);
@@ -397,10 +398,10 @@
 #if 1
     fx = D(10);
     fy = 0;
-    for (g = 90; g < 91; g += 4)
+    for (g = 10; g <= 38; g += 4)
     {
         twin_path_set_font_size (path, D(g));
-#if 0
+#if 1
         fy += D(g+2);
 	twin_path_move (path, fx, fy);
 	twin_path_utf8 (path,
@@ -623,7 +624,7 @@
 #endif
 
 #if 1
-    twin_start_clock (x11->screen, 0, 0, 256, 256);
+    twin_start_clock (x11->screen, 0, 0, WIDTH, HEIGHT);
 #endif
 #if 0
     twin_start_clock (x11->screen, 0, 0, 256, 256);




More information about the Commit mailing list