diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-08-17 16:22:40 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-08-17 16:22:40 +0000 |
commit | 61294f493e43dd273d7bc06eacf0b3f16baeb5c8 (patch) | |
tree | c5b6bad0acc77bf9d039a6d62b3ba4cd30e3d681 /amiga/font.c | |
parent | f71f8f82a1ef0878e622cf8a74d010e9c1a2c69d (diff) | |
download | netsurf-61294f493e43dd273d7bc06eacf0b3f16baeb5c8.tar.gz netsurf-61294f493e43dd273d7bc06eacf0b3f16baeb5c8.tar.bz2 |
Close fonts properly and default back to initial RastPort font.
svn path=/trunk/netsurf/; revision=5136
Diffstat (limited to 'amiga/font.c')
-rw-r--r-- | amiga/font.c | 24 |
1 files changed, 18 insertions, 6 deletions
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); } |