summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2002-10-12 13:05:16 +0000
committerJames Bursa <james@netsurf-browser.org>2002-10-12 13:05:16 +0000
commitf459052ef8d42041d582113cbf62cfe8912ebc1a (patch)
treed1192f8939bc1daa92c6a2f9fe4b0cdf6a2684e7
parent390fb8fb8dd559e2efbdaf7a19be9d2faa4042e2 (diff)
downloadnetsurf-f459052ef8d42041d582113cbf62cfe8912ebc1a.tar.gz
netsurf-f459052ef8d42041d582113cbf62cfe8912ebc1a.tar.bz2
[project @ 2002-10-12 13:05:16 by bursa]
Speed improvements in layout_line() (call Font_ScanString much less). svn path=/import/netsurf/; revision=43
-rw-r--r--makefile5
-rw-r--r--render/layout.c16
-rw-r--r--riscos/font.c31
-rw-r--r--riscos/font.h4
4 files changed, 42 insertions, 14 deletions
diff --git a/makefile b/makefile
index 47a5813c7..1cfcf1ce9 100644
--- a/makefile
+++ b/makefile
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.5 2002/10/08 11:15:29 bursa Exp $
+# $Id: makefile,v 1.6 2002/10/12 13:05:16 bursa Exp $
all: !NetSurf/!RunImage,ff8
clean:
@@ -38,3 +38,6 @@ riscos/objs-riscos/%.o: riscos/%.c $(HEADERS)
desktop/objs-riscos/%.o: desktop/%.c $(HEADERS)
$(CC) $(FLAGS) -o $@ -c $<
+netsurf.zip: !NetSurf/!RunImage,ff8
+ riscos-zip -9vr, netsurf.zip !NetSurf
+
diff --git a/render/layout.c b/render/layout.c
index f9e29bb90..07e848f5a 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1,5 +1,5 @@
/**
- * $Id: layout.c,v 1.20 2002/10/08 09:38:29 bursa Exp $
+ * $Id: layout.c,v 1.21 2002/10/12 13:05:16 bursa Exp $
*/
#include <assert.h>
@@ -13,6 +13,7 @@
#include "netsurf/render/box.h"
#include "netsurf/render/utils.h"
#include "netsurf/render/layout.h"
+#include "netsurf/utils/log.h"
#define DEBUG_LAYOUT
@@ -395,16 +396,9 @@ struct box * layout_line(struct box * first, unsigned long width, unsigned long
} else {
/* fit as many words as possible */
assert(space != 0);
- while (xp + w < x1 - x0 && space2 != 0) {
-/* fprintf(stderr, "%li + %li = %li < %li = %li - %li\n", */
-/* xp, w, xp + w, x1 - x0, x1, x0); */
- space = space2;
- wp = w;
- space2 = strchr(space + 1, ' ');
- if (space2 == 0)
- space2 = c->text + c->length;
- w = font_width(c->font, c->text, space2 - c->text);
- }
+ space = font_split(c->font, c->text, c->length, x1 - x0 - xp, &wp);
+ LOG(("'%.*s' %lu %lu (%c) %lu", c->length, c->text,
+ x1 - x0, space - c->text, *space, wp));
c2 = memcpy(xcalloc(1, sizeof(struct box)), c, sizeof(struct box));
c2->text = xstrdup(space + 1);
c2->length = c->length - ((space + 1) - c->text);
diff --git a/riscos/font.c b/riscos/font.c
index ee81560f8..91dab573b 100644
--- a/riscos/font.c
+++ b/riscos/font.c
@@ -1,5 +1,5 @@
/**
- * $Id: font.c,v 1.5 2002/10/08 11:15:29 bursa Exp $
+ * $Id: font.c,v 1.6 2002/10/12 13:05:16 bursa Exp $
*/
#include <assert.h>
@@ -204,3 +204,32 @@ void font_close(struct font_data *data)
free(data);
}
+
+char * font_split(struct font_data *data, const char * text, unsigned int length,
+ unsigned int width, unsigned int *used_width)
+{
+ os_error *error;
+ font_scan_block block;
+ char *split;
+
+ block.space.x = block.space.y = block.letter.x = block.letter.y = 0;
+ block.split_char = ' ';
+
+ error = xfont_scan_string(data->handle, text,
+ font_GIVEN_BLOCK | font_GIVEN_FONT | font_KERN | font_GIVEN_LENGTH,
+ ro_x_units(width) * 400, 0x7fffffff,
+ &block,
+ 0,
+ length,
+ &split,
+ used_width, 0, 0);
+ if (error != 0) {
+ fprintf(stderr, "%s\n", error->errmess);
+ die("font_scan_string failed");
+ }
+
+ *used_width = browser_x_units(*used_width / 400);
+
+ return split;
+}
+
diff --git a/riscos/font.h b/riscos/font.h
index 21e44bc24..36684d197 100644
--- a/riscos/font.h
+++ b/riscos/font.h
@@ -1,5 +1,5 @@
/**
- * $Id: font.h,v 1.3 2002/10/08 11:15:29 bursa Exp $
+ * $Id: font.h,v 1.4 2002/10/12 13:05:16 bursa Exp $
*/
#ifndef _NETSURF_RISCOS_FONT_H_
@@ -40,5 +40,7 @@ void font_position_in_string(const char* text, struct font_data *font,
struct font_set *font_new_set(void);
struct font_data *font_open(struct font_set *set, struct css_style *style);
void font_free_set(struct font_set *set);
+char * font_split(struct font_data *data, const char * text, unsigned int length,
+ unsigned int width, unsigned int *used_width);
#endif