diff options
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); } |