mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 04:26:50 +03:00
[project @ 2002-10-08 11:15:29 by bursa]
Removed most Unicode support, because it slows things down too much. svn path=/import/netsurf/; revision=42
This commit is contained in:
parent
53c0e810e5
commit
390fb8fb8d
8
makefile
8
makefile
@ -1,6 +1,6 @@
|
|||||||
# $Id: makefile,v 1.4 2002/10/08 09:38:29 bursa Exp $
|
# $Id: makefile,v 1.5 2002/10/08 11:15:29 bursa Exp $
|
||||||
|
|
||||||
all: netsurf,ff8
|
all: !NetSurf/!RunImage,ff8
|
||||||
clean:
|
clean:
|
||||||
rm */objs-riscos/*
|
rm */objs-riscos/*
|
||||||
|
|
||||||
@ -23,8 +23,8 @@ HEADERS = render/box.h render/css.h render/css_enum.h \
|
|||||||
LIBS = ../../Tools/libxml2/libxml.ro ../../Tools/oslib/oslib.o \
|
LIBS = ../../Tools/libxml2/libxml.ro ../../Tools/oslib/oslib.o \
|
||||||
../../Tools/curl/libcurl.ro ../../Tools/libutf-8/libutf-8.ro
|
../../Tools/curl/libcurl.ro ../../Tools/libutf-8/libutf-8.ro
|
||||||
|
|
||||||
netsurf,ff8: $(OBJECTS)
|
!NetSurf/!RunImage,ff8: $(OBJECTS)
|
||||||
$(CC) $(FLAGS) -o netsurf,ff8 $(OBJECTS) $(LIBS)
|
$(CC) $(FLAGS) -o !NetSurf/!RunImage,ff8 $(OBJECTS) $(LIBS)
|
||||||
|
|
||||||
render/css_enum.c render/css_enum.h: render/css_enums render/makeenum
|
render/css_enum.c render/css_enum.h: render/css_enums render/makeenum
|
||||||
cd ..; netsurf/render/makeenum netsurf/render/css_enum < netsurf/render/css_enums
|
cd ..; netsurf/render/makeenum netsurf/render/css_enum < netsurf/render/css_enums
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* $Id: box.c,v 1.18 2002/10/08 09:38:29 bursa Exp $
|
* $Id: box.c,v 1.19 2002/10/08 11:15:29 bursa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -22,6 +22,7 @@
|
|||||||
void box_add_child(struct box * parent, struct box * child);
|
void box_add_child(struct box * parent, struct box * child);
|
||||||
struct box * box_create(xmlNode * node, box_type type, struct css_style * style,
|
struct box * box_create(xmlNode * node, box_type type, struct css_style * style,
|
||||||
const char *href);
|
const char *href);
|
||||||
|
char * tolat1(const xmlChar * s);
|
||||||
struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
|
struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
|
||||||
struct css_stylesheet * stylesheet,
|
struct css_stylesheet * stylesheet,
|
||||||
struct css_selector ** selector, unsigned int depth,
|
struct css_selector ** selector, unsigned int depth,
|
||||||
@ -140,7 +141,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
|
|||||||
{
|
{
|
||||||
struct box * box;
|
struct box * box;
|
||||||
struct box * inline_container_c;
|
struct box * inline_container_c;
|
||||||
struct css_style * style, * style2;
|
struct css_style * style;
|
||||||
xmlNode * c;
|
xmlNode * c;
|
||||||
char * s;
|
char * s;
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style,
|
|||||||
if (n->type == XML_TEXT_NODE) {
|
if (n->type == XML_TEXT_NODE) {
|
||||||
LOG(("text node"));
|
LOG(("text node"));
|
||||||
box = box_create(n, BOX_INLINE, parent_style, href);
|
box = box_create(n, BOX_INLINE, parent_style, href);
|
||||||
box->text = squash_whitespace(n->content);
|
box->text = squash_whitespace(tolat1(n->content));
|
||||||
box->length = strlen(box->text);
|
box->length = strlen(box->text);
|
||||||
LOG(("text node 2"));
|
LOG(("text node 2"));
|
||||||
box->font = font_open(fonts, box->style);
|
box->font = font_open(fonts, box->style);
|
||||||
@ -632,7 +633,7 @@ void box_normalise_inline_container(struct box *cont)
|
|||||||
struct box *child;
|
struct box *child;
|
||||||
struct box *prev_child = 0;
|
struct box *prev_child = 0;
|
||||||
|
|
||||||
LOG(("cont %p"));
|
LOG(("cont %p", cont));
|
||||||
assert(cont->type == BOX_INLINE_CONTAINER);
|
assert(cont->type == BOX_INLINE_CONTAINER);
|
||||||
|
|
||||||
for (child = cont->children; child != 0; prev_child = child, child = child->next) {
|
for (child = cont->children; child != 0; prev_child = child, child = child->next) {
|
||||||
|
102
riscos/font.c
102
riscos/font.c
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* $Id: font.c,v 1.4 2002/10/05 17:50:21 bursa Exp $
|
* $Id: font.c,v 1.5 2002/10/08 11:15:29 bursa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -12,36 +12,17 @@
|
|||||||
#include "netsurf/utils/log.h"
|
#include "netsurf/utils/log.h"
|
||||||
#include "oslib/font.h"
|
#include "oslib/font.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* RISC OS fonts are 8-bit, so Unicode is displayed by combining many
|
|
||||||
* font manager fonts. Each font manager font must have 128 characters of
|
|
||||||
* Unicode in order, starting at character 128.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* font id = font family * 4 + bold * 2 + slanted
|
* font id = font family * 4 + bold * 2 + slanted
|
||||||
* font family: 0 = sans-serif, 1 = serif, ...
|
* font family: 0 = sans-serif, 1 = serif, ...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char * const font_table[FONT_FAMILIES * 4][FONT_CHUNKS] = {
|
const char * const font_table[FONT_FAMILIES * 4] = {
|
||||||
/* sans-serif */
|
/* sans-serif */
|
||||||
{ "Homerton.Medium\\EU0000",
|
"Homerton.Medium\\ELatin1",
|
||||||
"Homerton.Medium\\EU0080",
|
"Homerton.Medium.Oblique\\ELatin1",
|
||||||
"Homerton.Medium\\EU0100" },
|
"Homerton.Bold\\ELatin1",
|
||||||
{ "Homerton.Medium.Oblique\\EU0000",
|
"Homerton.Bold.Oblique\\ELatin1",
|
||||||
"Homerton.Medium.Oblique\\EU0080",
|
|
||||||
"Homerton.Medium.Oblique\\EU0100" },
|
|
||||||
{ "Homerton.Bold\\EU0000",
|
|
||||||
"Homerton.Bold\\EU0080",
|
|
||||||
"Homerton.Bold\\EU0100" },
|
|
||||||
{ "Homerton.Bold.Oblique\\EU0000",
|
|
||||||
"Homerton.Bold.Oblique\\EU0080",
|
|
||||||
"Homerton.Bold.Oblique\\EU0100" },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* a font_set is just a linked list of font_data for each face for now */
|
|
||||||
struct font_set {
|
|
||||||
struct font_data *font[FONT_FAMILIES * 4];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void font_close(struct font_data *data);
|
void font_close(struct font_data *data);
|
||||||
@ -54,7 +35,6 @@ unsigned long font_width(struct font_data *font, const char * text, unsigned int
|
|||||||
{
|
{
|
||||||
font_scan_block block;
|
font_scan_block block;
|
||||||
os_error * error;
|
os_error * error;
|
||||||
char *text2;
|
|
||||||
|
|
||||||
assert(font != 0 && text != 0);
|
assert(font != 0 && text != 0);
|
||||||
|
|
||||||
@ -65,12 +45,11 @@ unsigned long font_width(struct font_data *font, const char * text, unsigned int
|
|||||||
block.letter.x = block.letter.y = 0;
|
block.letter.x = block.letter.y = 0;
|
||||||
block.split_char = -1;
|
block.split_char = -1;
|
||||||
|
|
||||||
text2 = font_utf8_to_string(font, text, length);
|
error = xfont_scan_string(font->handle, text,
|
||||||
error = xfont_scan_string(font->handle[0], text2,
|
font_GIVEN_BLOCK | font_GIVEN_FONT | font_KERN | font_RETURN_BBOX | font_GIVEN_LENGTH,
|
||||||
font_GIVEN_BLOCK | font_GIVEN_FONT | font_KERN | font_RETURN_BBOX,
|
|
||||||
0x7fffffff, 0x7fffffff,
|
0x7fffffff, 0x7fffffff,
|
||||||
&block,
|
&block,
|
||||||
0, 0,
|
0, length,
|
||||||
0, 0, 0, 0);
|
0, 0, 0, 0);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
fprintf(stderr, "%s\n", error->errmess);
|
fprintf(stderr, "%s\n", error->errmess);
|
||||||
@ -79,7 +58,6 @@ unsigned long font_width(struct font_data *font, const char * text, unsigned int
|
|||||||
|
|
||||||
/* fprintf(stderr, "font_width: '%.*s' => '%s' => %i %i %i %i\n", length, text, text2, */
|
/* fprintf(stderr, "font_width: '%.*s' => '%s' => %i %i %i %i\n", length, text, text2, */
|
||||||
/* block.bbox.x0, block.bbox.y0, block.bbox.x1, block.bbox.y1); */
|
/* block.bbox.x0, block.bbox.y0, block.bbox.x1, block.bbox.y1); */
|
||||||
free(text2);
|
|
||||||
|
|
||||||
if (length < 0x7fffffff)
|
if (length < 0x7fffffff)
|
||||||
{
|
{
|
||||||
@ -109,7 +87,6 @@ void font_position_in_string(const char* text, struct font_data* font,
|
|||||||
font_scan_block block;
|
font_scan_block block;
|
||||||
char* split_point;
|
char* split_point;
|
||||||
int x_out, y_out, length_out;
|
int x_out, y_out, length_out;
|
||||||
char *text2;
|
|
||||||
|
|
||||||
assert(font != 0 && text != 0);
|
assert(font != 0 && text != 0);
|
||||||
|
|
||||||
@ -117,14 +94,12 @@ void font_position_in_string(const char* text, struct font_data* font,
|
|||||||
block.letter.x = block.letter.y = 0;
|
block.letter.x = block.letter.y = 0;
|
||||||
block.split_char = -1;
|
block.split_char = -1;
|
||||||
|
|
||||||
text2 = font_utf8_to_string(font, text, length);
|
xfont_scan_string(font, text,
|
||||||
xfont_scan_string(font, text2,
|
font_GIVEN_BLOCK | font_GIVEN_FONT | font_KERN | font_RETURN_CARET_POS | font_GIVEN_LENGTH,
|
||||||
font_GIVEN_BLOCK | font_GIVEN_FONT | font_KERN | font_RETURN_CARET_POS,
|
|
||||||
ro_x_units(x) * 400,
|
ro_x_units(x) * 400,
|
||||||
0x7fffffff,
|
0x7fffffff,
|
||||||
&block, 0, 0,
|
&block, 0, length,
|
||||||
&split_point, &x_out, &y_out, &length_out);
|
&split_point, &x_out, &y_out, &length_out);
|
||||||
free(text2);
|
|
||||||
|
|
||||||
*char_offset = (int)(split_point - text);
|
*char_offset = (int)(split_point - text);
|
||||||
*pixel_offset = browser_x_units(x_out / 400);
|
*pixel_offset = browser_x_units(x_out / 400);
|
||||||
@ -148,7 +123,6 @@ struct font_set *font_new_set()
|
|||||||
struct font_data *font_open(struct font_set *set, struct css_style *style)
|
struct font_data *font_open(struct font_set *set, struct css_style *style)
|
||||||
{
|
{
|
||||||
struct font_data *data;
|
struct font_data *data;
|
||||||
unsigned int i;
|
|
||||||
unsigned int size = 16 * 11;
|
unsigned int size = 16 * 11;
|
||||||
unsigned int f = 0;
|
unsigned int f = 0;
|
||||||
|
|
||||||
@ -184,17 +158,17 @@ struct font_data *font_open(struct font_set *set, struct css_style *style)
|
|||||||
|
|
||||||
data = xcalloc(1, sizeof(*data));
|
data = xcalloc(1, sizeof(*data));
|
||||||
|
|
||||||
for (i = 0; i < FONT_CHUNKS; i++) {
|
{
|
||||||
font_f handle;
|
font_f handle;
|
||||||
os_error *error;
|
os_error *error;
|
||||||
|
|
||||||
LOG(("font_find_font '%s' %i", font_table[f][i], size));
|
LOG(("font_find_font '%s' %i", font_table[f], size));
|
||||||
error = xfont_find_font(font_table[f][i], size, size, 0, 0, &handle, 0, 0);
|
error = xfont_find_font(font_table[f], size, size, 0, 0, &handle, 0, 0);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
fprintf(stderr, "%s\n", error->errmess);
|
fprintf(stderr, "%s\n", error->errmess);
|
||||||
die("font_find_font failed");
|
die("font_find_font failed");
|
||||||
}
|
}
|
||||||
data->handle[i] = handle;
|
data->handle = handle;
|
||||||
}
|
}
|
||||||
data->size = size;
|
data->size = size;
|
||||||
|
|
||||||
@ -225,50 +199,8 @@ void font_free_set(struct font_set *set)
|
|||||||
|
|
||||||
void font_close(struct font_data *data)
|
void font_close(struct font_data *data)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
font_lose_font(data->handle);
|
||||||
|
|
||||||
for (i = 0; i < FONT_CHUNKS; i++)
|
|
||||||
font_lose_font(data->handle[i]);
|
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUFFER_CHUNK 100
|
|
||||||
|
|
||||||
char *font_utf8_to_string(struct font_data *font, const char *s, unsigned int length)
|
|
||||||
{
|
|
||||||
unsigned long buffer_len = BUFFER_CHUNK;
|
|
||||||
char *d = xcalloc(buffer_len, sizeof(char));
|
|
||||||
unsigned int chunk0 = 0, chunk1;
|
|
||||||
unsigned int u, chars, i = 0, j = 0;
|
|
||||||
|
|
||||||
assert(font != 0 && s != 0);
|
|
||||||
|
|
||||||
/* fprintf(stderr, "font_utf8_to_string: '%s'", s); */
|
|
||||||
|
|
||||||
while (j < length && s[j] != 0) {
|
|
||||||
u = sgetu8(s + j, &chars);
|
|
||||||
j += chars;
|
|
||||||
if (buffer_len < i + 5) {
|
|
||||||
buffer_len += BUFFER_CHUNK;
|
|
||||||
d = xrealloc(d, buffer_len * sizeof(char));
|
|
||||||
}
|
|
||||||
chunk1 = u / 0x80;
|
|
||||||
if (FONT_CHUNKS <= chunk1 || (u < 0x20 || (0x80 <= u && u <= 0x9f))) {
|
|
||||||
d[i++] = '?';
|
|
||||||
} else {
|
|
||||||
if (chunk0 != chunk1) {
|
|
||||||
d[i++] = font_COMMAND_FONT;
|
|
||||||
d[i++] = font->handle[chunk1];
|
|
||||||
chunk0 = chunk1;
|
|
||||||
}
|
|
||||||
d[i++] = 0x80 + (u % 0x80);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
d[i] = 0;
|
|
||||||
|
|
||||||
/* fprintf(stderr, " => '%s'\n", d); */
|
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* $Id: font.h,v 1.2 2002/09/26 21:38:33 bursa Exp $
|
* $Id: font.h,v 1.3 2002/10/08 11:15:29 bursa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _NETSURF_RISCOS_FONT_H_
|
#ifndef _NETSURF_RISCOS_FONT_H_
|
||||||
@ -15,13 +15,16 @@
|
|||||||
typedef unsigned int font_id;
|
typedef unsigned int font_id;
|
||||||
|
|
||||||
#define FONT_FAMILIES 1
|
#define FONT_FAMILIES 1
|
||||||
#define FONT_CHUNKS 3
|
|
||||||
#define FONT_BOLD 2
|
#define FONT_BOLD 2
|
||||||
#define FONT_SLANTED 1
|
#define FONT_SLANTED 1
|
||||||
|
|
||||||
struct font_set;
|
/* a font_set is just a linked list of font_data for each face for now */
|
||||||
|
struct font_set {
|
||||||
|
struct font_data *font[FONT_FAMILIES * 4];
|
||||||
|
};
|
||||||
|
|
||||||
struct font_data {
|
struct font_data {
|
||||||
font_f handle[FONT_CHUNKS];
|
font_f handle;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
struct font_data *next;
|
struct font_data *next;
|
||||||
};
|
};
|
||||||
@ -34,9 +37,8 @@ unsigned long font_width(struct font_data *font, const char * text, unsigned int
|
|||||||
void font_position_in_string(const char* text, struct font_data *font,
|
void font_position_in_string(const char* text, struct font_data *font,
|
||||||
int length, int x, int* char_offset, int* pixel_offset);
|
int length, int x, int* char_offset, int* pixel_offset);
|
||||||
|
|
||||||
struct font_set *font_new_set();
|
struct font_set *font_new_set(void);
|
||||||
struct font_data *font_open(struct font_set *set, struct css_style *style);
|
struct font_data *font_open(struct font_set *set, struct css_style *style);
|
||||||
void font_free_set(struct font_set *set);
|
void font_free_set(struct font_set *set);
|
||||||
char *font_utf8_to_string(struct font_data *data, const char *s, unsigned int length);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
riscos/gui.c
10
riscos/gui.c
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* $Id: gui.c,v 1.2 2002/09/26 21:38:33 bursa Exp $
|
* $Id: gui.c,v 1.3 2002/10/08 11:15:29 bursa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "netsurf/riscos/font.h"
|
#include "netsurf/riscos/font.h"
|
||||||
@ -357,13 +357,11 @@ if (g->data.browser.bw->current_content->data.html.text_selection.selected == 1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text = font_utf8_to_string(box->font, box->text, box->length);
|
font_paint(box->font->handle, box->text,
|
||||||
font_paint(box->font->handle[0], text,
|
font_OS_UNITS | font_GIVEN_FONT | font_KERN | font_GIVEN_LENGTH,
|
||||||
font_OS_UNITS | font_GIVEN_FONT | font_KERN,
|
|
||||||
x + box->x * 2, y - box->y * 2 - box->height * 2,
|
x + box->x * 2, y - box->y * 2 - box->height * 2,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
0);
|
box->length);
|
||||||
free(text);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user