summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--twin_font.c105
-rw-r--r--xtwin.c64
3 files changed, 85 insertions, 94 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a0d096..07fd247 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-09-25 Keith Packard <keithp@keithp.com>
+
+ * twin_font.c: (_snap), (twin_path_ucs4):
+ Reduce emboldening to +50% stroke thickness.
+ Clean up debug code.
+ Eliminate some dead code.
+ Try to adjust width computations a bit. Still not right.
+ * xtwin.c: (main):
+ draw in more colors
+
2004-09-24 Keith Packard <keithp@keithp.com>
* Makefile.am:
diff --git a/twin_font.c b/twin_font.c
index 9291999..2345654 100644
--- a/twin_font.c
+++ b/twin_font.c
@@ -24,9 +24,13 @@
#include "twinint.h"
+#if 0
#include <stdio.h>
-
#define F(x) twin_fixed_to_double(x)
+#define DBGOUT(x) printf x
+#else
+#define DBGOUT(x)
+#endif
#define S(f,s) ((twin_fixed_t) ((((twin_dfixed_t) (f) * (s)) >> 5)))
#define SX(x) (((x) * scale_x) >> 5)
@@ -72,20 +76,16 @@ _snap (twin_gfixed_t g, twin_fixed_t scale, twin_gfixed_t *snap, int nsnap)
twin_fixed_t dist_after = after - v;
twin_fixed_t move = ((twin_dfixed_t) dist_before * move_after +
(twin_dfixed_t) dist_after * move_before) / dist;
-#if 0
- printf ("%d <= %d <= %d\n", snap[s], g, snap[s+1]);
- printf ("%9.4f <= %9.4f <= %9.4f\n", F(before), F(v), F(after));
- printf ("before: %9.4f -> %9.4f\n", F(before), F(snap_before));
- printf ("after: %9.4f -> %9.4f\n", F(after), F(snap_after));
- printf ("v: %9.4f -> %9.4f\n", F(v), F(v+move));
-#endif
+ DBGOUT (("%d <= %d <= %d\n", snap[s], g, snap[s+1]));
+ DBGOUT (("%9.4f <= %9.4f <= %9.4f\n", F(before), F(v), F(after)));
+ DBGOUT (("before: %9.4f -> %9.4f\n", F(before), F(snap_before)));
+ DBGOUT (("after: %9.4f -> %9.4f\n", F(after), F(snap_after)));
+ DBGOUT (("v: %9.4f -> %9.4f\n", F(v), F(v+move)));
v += move;
break;
}
}
-#if 0
- printf ("_snap: %d => %9.4f\n", g, F(v));
-#endif
+ DBGOUT (("_snap: %d => %9.4f\n", g, F(v)));
return v;
}
@@ -112,21 +112,6 @@ _twin_ucs4_base(twin_ucs4_t ucs4)
return _twin_glyphs + _twin_glyph_offsets[ucs4];
}
-#if 0
-static int
-_twin_ucs4_points (twin_ucs4_t ucs4)
-{
- const twin_gpoint_t *p;
- int i;
-
- if (ucs4 > 0x7f || (p = _twin_font[ucs4]) == NULL)
- p = _twin_default_char;
-
- for (i = 0; p[i].y != -64; i++);
- return i + 1;
-}
-#endif
-
void
twin_path_ucs4 (twin_path_t *path,
twin_fixed_t scale_x,
@@ -146,39 +131,6 @@ twin_path_ucs4 (twin_path_t *path,
int nsnap_x, nsnap_y;
int npoints;
- static int been_here = 0;
-
-#if 0
- if (!been_here)
- {
- int off = _twin_ucs4_points (0);
- int this;
- been_here = 1;
- for (i = 0; i <= 0x7f; i++)
- {
- if ((i & 7) == 0)
- {
- printf ("/* 0x%02x */\n", i);
- printf (" ");
- }
- if (twin_has_ucs4 (i))
- {
- this = _twin_ucs4_points (i);
- printf ("%4d,", off);
- off += this;
- }
- else
- {
- printf ("%4d,", 0);
- }
- if ((i&7) == 7)
- printf ("\n");
- else
- printf (" ");
- }
- }
-#endif
-
p = _twin_ucs4_base (ucs4);
twin_path_cur_point (path, &xo, &yo);
@@ -221,28 +173,32 @@ twin_path_ucs4 (twin_path_t *path,
qsort (snap_y, nsnap_y, sizeof (twin_gfixed_t), compare_snap);
#if 0
- printf ("snap_x:");
+ DBGOUT (("snap_x:"));
for (i = 0; i < nsnap_x; i++)
- printf (" %d", snap_x[i]);
- printf ("\n");
+ DBGOUT ((" %d", snap_x[i]));
+ DBGOUT (("\n"));
- printf ("snap_y:");
+ DBGOUT (("snap_y:");
for (i = 0; i < nsnap_y; i++)
- printf (" %d", snap_y[i]);
- printf ("\n");
+ DBGOUT ((" %d", snap_y[i]));
+ DBGOUT (("\n"));
#endif
stroke = twin_path_create ();
/* snap pen size to half integer value */
- if (style & TWIN_TEXT_BOLD)
- pen_size = SNAPH(scale_y / 12);
- else
- pen_size = SNAPH(scale_y / 24);
-
+ pen_size = SNAPH(scale_y / 24);
if (pen_size < TWIN_FIXED_HALF)
pen_size = TWIN_FIXED_HALF;
+ if (style & TWIN_TEXT_BOLD)
+ {
+ twin_fixed_t pen_add = SNAPH(pen_size >> 1);
+ if (pen_add == 0)
+ pen_add = TWIN_FIXED_HALF;
+ pen_size += pen_add;
+ }
+
pen_adjust = pen_size & TWIN_FIXED_HALF;
pen = twin_path_create ();
@@ -277,11 +233,13 @@ twin_path_ucs4 (twin_path_t *path,
int
twin_ucs4_width (twin_ucs4_t ucs4, twin_fixed_t scale_x)
{
- const twin_gpoint_t *p;
+ const twin_gpoint_t *p = _twin_ucs4_base (ucs4);
+ twin_fixed_t left, right;
- p = _twin_ucs4_base (ucs4);
+ left = SNAPI(SX (p[0].x));
+ right = SNAPI(SX (p[0].y));
- return twin_fixed_ceil (SX (p[0].y) - SX (p[0].x));
+ return right - left;
}
static int
@@ -368,3 +326,4 @@ twin_path_string (twin_path_t *path,
string += len;
}
}
+)
diff --git a/xtwin.c b/xtwin.c
index 0d48412..626366b 100644
--- a/xtwin.c
+++ b/xtwin.c
@@ -40,10 +40,10 @@ int
main (int argc, char **argv)
{
Display *dpy = XOpenDisplay (0);
- twin_x11_t *x11 = twin_x11_create (dpy, 512, 512);
- twin_pixmap_t *red = twin_pixmap_create (TWIN_ARGB32, 512, 512);
+ twin_x11_t *x11 = twin_x11_create (dpy, 1024, 512);
+ twin_pixmap_t *red = twin_pixmap_create (TWIN_ARGB32, 1024, 512);
twin_pixmap_t *blue = twin_pixmap_create (TWIN_ARGB32, 100, 100);
- twin_pixmap_t *alpha = twin_pixmap_create (TWIN_A8, 512, 512);
+ twin_pixmap_t *alpha = twin_pixmap_create (TWIN_A8, 1024, 512);
twin_operand_t source, mask;
twin_path_t *path;
twin_path_t *pen;
@@ -56,10 +56,10 @@ main (int argc, char **argv)
int s;
pen = twin_path_create ();
- twin_path_circle (pen, D (0.5));
+ twin_path_circle (pen, D (1));
- twin_fill (red, 0x00000000, TWIN_SOURCE, 0, 0, 512, 512);
- twin_fill (alpha, 0x00000000, TWIN_SOURCE, 0, 0, 512, 512);
+ twin_fill (red, 0x00000000, TWIN_SOURCE, 0, 0, 1024, 512);
+ twin_fill (alpha, 0x00000000, TWIN_SOURCE, 0, 0, 1024, 512);
path = twin_path_create ();
#if 0
@@ -69,7 +69,7 @@ main (int argc, char **argv)
int glyph = g;
if (!twin_has_glyph (glyph)) glyph = 0;
twin_path_cur_point (path, &fx, &fy);
- if (fx + twin_glyph_width (glyph, D(10)) >= D(512) || g % 50 == 0)
+ if (fx + twin_glyph_width (glyph, D(10)) >= D(1024) || g % 50 == 0)
twin_path_move (path, D(3), fy + D(10));
twin_path_glyph (path, D(10), D(10), TWIN_TEXT_ROMAN,
glyph);
@@ -77,36 +77,37 @@ main (int argc, char **argv)
#endif
#if 1
fx = D(3);
- fy = D(10);
- for (g = 10; g < 40; g += 2)
+ fy = 0;
+ for (g = 8; g < 30; g += 4)
{
-#if 1
+#if 0
+ fy += D(g+2);
twin_path_move (path, fx, fy);
twin_path_string (path, D(g), D(g), TWIN_TEXT_ROMAN,
" !\"#$%&'()*+,-./0123456789:;<=>?");
- fy += D(g);
+ fy += D(g+2);
twin_path_move (path, fx, fy);
twin_path_string (path, D(g), D(g), TWIN_TEXT_ROMAN,
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_");
- fy += D(g);
+ fy += D(g+2);
twin_path_move (path, fx, fy);
twin_path_string (path, D(g), D(g), TWIN_TEXT_ROMAN,
"`abcdefghijklmnopqrstuvwxyz{|}~");
- fy += D(g);
#endif
-#if 0
+#if 1
for (s = 0; s < 4; s++)
{
+ fy += D(g+2);
+ twin_path_move (path, fx, fy);
twin_path_string (path, D(g), D(g), styles[s],
"the quick brown fox jumps over the lazy dog.");
twin_path_string (path, D(g), D(g), styles[s],
"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.");
- fy += D(g);
}
#endif
#if 0
- twin_path_string (path, D(g), D(g), "t");
fy += D(g);
+ twin_path_string (path, D(g), D(g), "t");
#endif
}
#endif
@@ -132,10 +133,9 @@ main (int argc, char **argv)
mask.source_kind = TWIN_PIXMAP;
mask.u.pixmap = alpha;
twin_composite (red, 0, 0, &source, 0, 0, &mask, 0, 0, TWIN_OVER,
- 512, 512);
+ 1024, 512);
twin_fill (blue, 0x00000000, TWIN_SOURCE, 0, 0, 100, 100);
- twin_fill (alpha, 0x00000000, TWIN_SOURCE, 0, 0, 100, 100);
#if 1
path = twin_path_create ();
@@ -151,14 +151,36 @@ main (int argc, char **argv)
twin_path_convolve (path, stroke, pen);
twin_path_destroy (stroke);
+ twin_fill (alpha, 0x00000000, TWIN_SOURCE, 0, 0, 100, 100);
twin_path_fill (alpha, path);
+ source.source_kind = TWIN_SOLID;
+ source.u.argb = 0xff00ff00;
+ mask.source_kind = TWIN_PIXMAP;
+ mask.u.pixmap = alpha;
+ twin_composite (blue, 0, 0, &source, 0, 0, &mask, 0, 0, TWIN_OVER,
+ 100, 100);
+
twin_path_destroy (path);
path = twin_path_create ();
+ stroke = twin_path_create ();
- twin_path_move (path, D (50), D (50));
- twin_path_curve (path, D (70), D (70), D (80), D (70), D (100), D (50));
+ twin_path_move (stroke, D (50), D (50));
+ twin_path_curve (stroke, D (70), D (70), D (80), D (70), D (100), D (50));
+ twin_fill (alpha, 0x00000000, TWIN_SOURCE, 0, 0, 100, 100);
+ twin_path_fill (alpha, stroke);
+
+ source.source_kind = TWIN_SOLID;
+ source.u.argb = 0xffff0000;
+ mask.source_kind = TWIN_PIXMAP;
+ mask.u.pixmap = alpha;
+ twin_composite (blue, 0, 0, &source, 0, 0, &mask, 0, 0, TWIN_OVER,
+ 100, 100);
+
+ twin_path_convolve (path, stroke, pen);
+
+ twin_fill (alpha, 0x00000000, TWIN_SOURCE, 0, 0, 100, 100);
twin_path_fill (alpha, path);
source.source_kind = TWIN_SOLID;
@@ -172,7 +194,7 @@ main (int argc, char **argv)
twin_pixmap_move (red, 0, 0);
twin_pixmap_move (blue, 100, 100);
twin_pixmap_show (red, x11->screen, 0);
-/* twin_pixmap_show (blue, x11->screen, 0); */
+ twin_pixmap_show (blue, x11->screen, 0);
had_motion = TWIN_FALSE;
for (;;)
{