summaryrefslogtreecommitdiff
path: root/tree
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2004-10-21 10:51:08 +0200
committerTor Andersson <tor@ghostscript.com>2004-10-21 10:51:08 +0200
commitded124f1cc463bac9e076146a4ffb77b8a370e0c (patch)
treec1b35fe12bd14ed507294b185587b428a92bcbef /tree
parent730cf84f6323b977bf7bcde1557d1803a16ad855 (diff)
downloadmupdf-ded124f1cc463bac9e076146a4ffb77b8a370e0c.tar.xz
rewrote resource dict handling
Diffstat (limited to 'tree')
-rw-r--r--tree/debug.c5
-rw-r--r--tree/font.c1
-rw-r--r--tree/node2.c24
-rw-r--r--tree/text.c64
4 files changed, 79 insertions, 15 deletions
diff --git a/tree/debug.c b/tree/debug.c
index 583608f5..e55d56e7 100644
--- a/tree/debug.c
+++ b/tree/debug.c
@@ -13,7 +13,8 @@ static void lispmeta(fz_metanode *node, int level)
fz_node *child;
indent(level);
printf("(meta ");
- fz_debugobj(node->info);
+ if (node->name) { fz_debugobj(node->name); }
+ if (node->dict) { printf("\n"); fz_debugobj(node->dict); }
printf("\n");
for (child = node->super.child; child; child = child->next)
lispnode(child, level + 1);
@@ -141,7 +142,7 @@ static void lisptext(fz_textnode *node, int level)
static void lispimage(fz_imagenode *node, int level)
{
indent(level);
- printf("(image %d %d %d %d)\n", node->w, node->h, node->n, node->a);
+ printf("(image)\n");
}
static void lispnode(fz_node *node, int level)
diff --git a/tree/font.c b/tree/font.c
index 5dfaec2e..58c194ae 100644
--- a/tree/font.c
+++ b/tree/font.c
@@ -39,6 +39,7 @@ fz_setfontwmode(fz_font *font, int wmode)
void
fz_setfontbbox(fz_font *font, int xmin, int ymin, int xmax, int ymax)
{
+printf(" bbox [%d %d %d %d]\n", xmin, ymin, xmax, ymax);
font->bbox.min.x = xmin;
font->bbox.min.y = ymin;
font->bbox.max.x = xmax;
diff --git a/tree/node2.c b/tree/node2.c
index d50936ef..6e28aaac 100644
--- a/tree/node2.c
+++ b/tree/node2.c
@@ -164,7 +164,7 @@ fz_boundtransformnode(fz_transformnode *node, fz_matrix ctm)
*/
fz_error *
-fz_newmetanode(fz_node **nodep, fz_obj *info)
+fz_newmetanode(fz_node **nodep, fz_obj *name, fz_obj *dict)
{
fz_metanode *node;
@@ -174,7 +174,13 @@ fz_newmetanode(fz_node **nodep, fz_obj *info)
*nodep = (fz_node*)node;
fz_initnode((fz_node*)node, FZ_NMETA);
- node->info = fz_keepobj(info);
+ node->name = nil;
+ node->dict = nil;
+
+ if (name)
+ node->name = fz_keepobj(name);
+ if (dict)
+ node->dict = fz_keepobj(dict);
return nil;
}
@@ -182,8 +188,10 @@ fz_newmetanode(fz_node **nodep, fz_obj *info)
void
fz_freemetanode(fz_metanode *node)
{
- if (node->info)
- fz_dropobj(node->info);
+ if (node->name)
+ fz_dropobj(node->name);
+ if (node->dict)
+ fz_dropobj(node->dict);
}
fz_rect
@@ -261,7 +269,7 @@ fz_boundcolornode(fz_colornode *node, fz_matrix ctm)
*/
fz_error *
-fz_newimagenode(fz_node **nodep, fz_colorspace *cs, int w, int h, int n, int a)
+fz_newimagenode(fz_node **nodep, fz_image *image)
{
fz_imagenode *node;
@@ -271,11 +279,7 @@ fz_newimagenode(fz_node **nodep, fz_colorspace *cs, int w, int h, int n, int a)
*nodep = (fz_node*)node;
fz_initnode((fz_node*)node, FZ_NIMAGE);
- node->cs = cs;
- node->w = w;
- node->h = h;
- node->n = n;
- node->a = a;
+ node->image = image;
return nil;
}
diff --git a/tree/text.c b/tree/text.c
index d822ec34..1832df9f 100644
--- a/tree/text.c
+++ b/tree/text.c
@@ -29,9 +29,67 @@ fz_freetextnode(fz_textnode *text)
fz_rect
fz_boundtextnode(fz_textnode *text, fz_matrix ctm)
{
- // FIXME convolve font bbox to all glyph x,y pairs
- /* fz_rect bounds = fz_boundglyph(text->font, text->els[0], ctm); */
- return fz_infiniterect();
+ fz_matrix trm;
+ fz_point ul, ur, ll, lr;
+ fz_rect bbox;
+ fz_rect fbox;
+ int i;
+
+ if (text->len == 0)
+ return fz_infiniterect();
+
+ /* find bbox of glyph origins in ctm space */
+
+ bbox.min.x = bbox.max.x = text->els[0].x;
+ bbox.min.y = bbox.max.y = text->els[0].y;
+
+ for (i = 1; i < text->len; i++)
+ {
+ bbox.min.x = MIN(bbox.min.x, text->els[i].x);
+ bbox.min.y = MIN(bbox.min.y, text->els[i].y);
+ bbox.max.x = MAX(bbox.max.x, text->els[i].x);
+ bbox.max.y = MAX(bbox.max.y, text->els[i].y);
+ }
+
+ ll.x = bbox.min.x; ll.y = bbox.min.y; ll = fz_transformpoint(ctm, ll);
+ ul.x = bbox.min.x; ul.y = bbox.max.y; ul = fz_transformpoint(ctm, ul);
+ ur.x = bbox.max.x; ur.y = bbox.max.y; ur = fz_transformpoint(ctm, ur);
+ lr.x = bbox.max.x; lr.y = bbox.min.y; lr = fz_transformpoint(ctm, lr);
+
+ bbox.min.x = MIN4(ll.x, ul.x, ur.x, lr.x);
+ bbox.min.y = MIN4(ll.y, ul.y, ur.y, lr.y);
+ bbox.max.x = MAX4(ll.x, ul.x, ur.x, lr.x);
+ bbox.max.y = MAX4(ll.y, ul.y, ur.y, lr.y);
+
+ /* find bbox of font in trm * ctm space */
+
+ trm = fz_concat(text->trm, ctm);
+ trm.e = 0;
+ trm.f = 0;
+
+ fbox.min.x = text->font->bbox.min.x * 0.001;
+ fbox.min.y = text->font->bbox.min.y * 0.001;
+ fbox.max.x = text->font->bbox.max.x * 0.001;
+ fbox.max.y = text->font->bbox.max.y * 0.001;
+
+ ll.x = fbox.min.x; ll.y = fbox.min.y; ll = fz_transformpoint(trm, ll);
+ ul.x = fbox.min.x; ul.y = fbox.max.y; ul = fz_transformpoint(trm, ul);
+ ur.x = fbox.max.x; ur.y = fbox.max.y; ur = fz_transformpoint(trm, ur);
+ lr.x = fbox.max.x; lr.y = fbox.min.y; lr = fz_transformpoint(trm, lr);
+
+ fbox.min.x = MIN4(ll.x, ul.x, ur.x, lr.x);
+ fbox.min.y = MIN4(ll.y, ul.y, ur.y, lr.y);
+ fbox.max.x = MAX4(ll.x, ul.x, ur.x, lr.x);
+ fbox.max.y = MAX4(ll.y, ul.y, ur.y, lr.y);
+
+ bbox.min.x += MIN4(ll.x, ul.x, ur.x, lr.x);
+ bbox.min.y += MIN4(ll.y, ul.y, ur.y, lr.y);
+ bbox.max.x += MAX4(ll.x, ul.x, ur.x, lr.x);
+ bbox.max.y += MAX4(ll.y, ul.y, ur.y, lr.y);
+
+// printf("text [ %g %g %g %g ]\n", bbox.min.x, bbox.min.y, bbox.max.x, bbox.max.y);
+
+ return bbox;
}
static fz_error *