From 61294f493e43dd273d7bc06eacf0b3f16baeb5c8 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 17 Aug 2008 16:22:40 +0000 Subject: Close fonts properly and default back to initial RastPort font. svn path=/trunk/netsurf/; revision=5136 --- amiga/font.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'amiga/font.c') diff --git a/amiga/font.c b/amiga/font.c index 735ffe0f7..1bb0674c2 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -49,8 +49,10 @@ bool nsfont_width(const struct css_style *style, const char *string, size_t length, int *width) { - ami_open_font(style); + struct TextFont *tfont = ami_open_font(style); *width = TextLength(currp,string,length); + ami_close_font(tfont); + return true; } @@ -72,12 +74,13 @@ bool nsfont_position_in_string(const struct css_style *style, int x, size_t *char_offset, int *actual_x) { struct TextExtent extent; - - ami_open_font(style); + struct TextFont *tfont = ami_open_font(style); *char_offset = TextFit(currp,string,length, &extent,NULL,1,x,32767); *actual_x = extent.te_Extent.MaxX; + + ami_close_font(tfont); return true; } @@ -106,8 +109,7 @@ bool nsfont_split(const struct css_style *style, struct TextExtent extent; ULONG co; char *charp; - - ami_open_font(style); + struct TextFont *tfont = ami_open_font(style); co = TextFit(currp,string,length, &extent,NULL,1,x,32767); @@ -121,10 +123,11 @@ bool nsfont_split(const struct css_style *style, *char_offset = co; *actual_x = TextLength(currp,string,co); + ami_close_font(tfont); return true; } -void ami_open_font(struct css_style *style) +struct TextFont *ami_open_font(struct css_style *style) { struct TextFont *tfont; struct TTextAttr tattr; @@ -216,5 +219,14 @@ void ami_open_font(struct css_style *style) TAG_DONE); } + return tfont; +} + +void ami_close_font(struct TextFont *tfont) +{ + SetRPAttrs(currp, + RPTAG_Font,origrpfont, + TAG_DONE); + CloseFont(tfont); } -- cgit v1.2.3