changeset 31:da770188a44d

resize font size for changige of coord.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 05 Aug 2008 16:38:04 +0800
parents e06a4a667ce2
children 69c8e264890d
files src/X_main.c src/coord.c src/mb_types.h src/shape_text.c
diffstat 4 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/X_main.c	Tue Aug 05 12:40:45 2008 +0800
+++ b/src/X_main.c	Tue Aug 05 16:38:04 2008 +0800
@@ -143,7 +143,7 @@
     }
 
     for(i = 0; i < 5; i++) {
-	usleep(500000);
+	usleep(100000);
 	paint_color_set(fill1, 1, i % 2, 0, 0.5);
 	paint_color_set(fill2, 0, i % 2, 1, 0.5);
 	rdman_paint_changed(&rdman, fill1);
@@ -153,7 +153,7 @@
     }
 
     for(i = 0; i < 4; i++) {
-	usleep(500000);
+	usleep(100000);
 	path1->stroke_width -= 1;
 	path2->stroke_width -= 1;
 	rdman_shape_changed(&rdman, path1);
@@ -162,7 +162,7 @@
 	XFlush(display);
     }
     for(i = 0; i < 4; i++) {
-	usleep(500000);
+	usleep(100000);
 	path1->stroke_width += 1;
 	path2->stroke_width += 1;
 	rdman_shape_changed(&rdman, path1);
@@ -172,7 +172,7 @@
     }
 
     for(i = 0; i < 4; i++) {
-	usleep(500000);
+	usleep(100000);
 	text->stroke_width += 1;
 	rdman_shape_changed(&rdman, text);
 	coord3->matrix[2] += 5;
@@ -181,7 +181,7 @@
 	XFlush(display);
     }
     for(i = 0; i < 4; i++) {
-	usleep(500000);
+	usleep(100000);
 	text->stroke_width -= 1;
 	rdman_shape_changed(&rdman, text);
 	coord3->matrix[2] -= 5;
@@ -191,7 +191,7 @@
     }
 
     for(i = 0; i < 4; i++) {
-	usleep(500000);
+	usleep(100000);
 	text->stroke_width += 1;
 	rdman_shape_changed(&rdman, text);
 	coord3->matrix[5] += 5;
@@ -200,7 +200,7 @@
 	XFlush(display);
     }
     for(i = 0; i < 4; i++) {
-	usleep(500000);
+	usleep(100000);
 	text->stroke_width -= 1;
 	rdman_shape_changed(&rdman, text);
 	coord3->matrix[5] -= 5;
--- a/src/coord.c	Tue Aug 05 12:40:45 2008 +0800
+++ b/src/coord.c	Tue Aug 05 16:38:04 2008 +0800
@@ -4,6 +4,7 @@
  */
 #include <stdio.h>
 #include <string.h>
+#include <math.h>
 #include "mb_types.h"
 
 
@@ -110,6 +111,15 @@
     *y = ny;
 }
 
+co_aix coord_trans_size(coord_t *co, co_aix sz) {
+    co_aix x, y;
+
+    x = MUL(co->aggr_matrix[0], sz);
+    y = MUL(co->aggr_matrix[3], sz);
+
+    return sqrt(x * x + y * y);
+}
+
 coord_t *preorder_coord_subtree(coord_t *root, coord_t *last) {
     coord_t *next;
 
--- a/src/mb_types.h	Tue Aug 05 12:40:45 2008 +0800
+++ b/src/mb_types.h	Tue Aug 05 16:38:04 2008 +0800
@@ -92,6 +92,7 @@
 
 extern void coord_init(coord_t *co, coord_t *parent);
 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y);
+extern co_aix coord_trans_size(coord_t *co, co_aix size);
 extern void compute_aggr_of_coord(coord_t *coord);
 extern void update_aggr_matrix(coord_t *start);
 extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last);
--- a/src/shape_text.c	Tue Aug 05 12:40:45 2008 +0800
+++ b/src/shape_text.c	Tue Aug 05 16:38:04 2008 +0800
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <math.h>
 #include <cairo.h>
 #include "mb_types.h"
 #include "shapes.h"
@@ -14,6 +15,7 @@
     co_aix x, y;
     co_aix d_x, d_y;		/* device x and y */
     co_aix font_size;
+    co_aix d_font_size;
     cairo_font_face_t *face;
     cairo_scaled_font_t *scaled_font;
     int flags;
@@ -66,8 +68,8 @@
 	if(fopt == NULL)
 	    return ERR;
 	memset(&fmatrix, 0, sizeof(cairo_matrix_t));
-	fmatrix.xx = text->font_size;
-	fmatrix.yy = text->font_size;
+	fmatrix.xx = text->d_font_size;
+	fmatrix.yy = text->d_font_size;
 	memset(&ctm, 0, sizeof(cairo_matrix_t));
 	ctm.xx = 1;
 	ctm.yy = 1;
@@ -99,6 +101,9 @@
     int r;
 
     text = (sh_text_t *)shape;
+
+    text->d_font_size = coord_trans_size(shape->coord, text->font_size);
+
     x = text->x;
     y = text->y;
     coord_trans_pos(shape->coord, &x, &y);