free subfonts correctly
This commit is contained in:
parent
3b634dc7e4
commit
b2f9ee0de5
3 changed files with 32 additions and 6 deletions
|
|
@ -65,6 +65,7 @@ _string(Image *dst, Point pt, Image *src, Point sp, Font *f, char *s, Rune *r, i
|
|||
char **sptr;
|
||||
Rune **rptr;
|
||||
Font *def;
|
||||
Subfont *sf;
|
||||
|
||||
if(s == nil){
|
||||
s = "";
|
||||
|
|
@ -76,6 +77,7 @@ _string(Image *dst, Point pt, Image *src, Point sp, Font *f, char *s, Rune *r, i
|
|||
rptr = nil;
|
||||
}else
|
||||
rptr = &r;
|
||||
sf = nil;
|
||||
while((*s || *r) && len){
|
||||
max = Max;
|
||||
if(len < max)
|
||||
|
|
@ -124,13 +126,18 @@ _string(Image *dst, Point pt, Image *src, Point sp, Font *f, char *s, Rune *r, i
|
|||
len -= n;
|
||||
}
|
||||
if(subfontname){
|
||||
if(_getsubfont(f->display, subfontname) == 0){
|
||||
def = f->display->defaultfont;
|
||||
freesubfont(sf);
|
||||
if((sf=_getsubfont(f->display, subfontname)) == 0){
|
||||
def = f->display ? f->display->defaultfont : nil;
|
||||
if(def && f!=def)
|
||||
f = def;
|
||||
else
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* must not free sf until cachechars has found it in the cache
|
||||
* and picked up its own reference.
|
||||
*/
|
||||
}
|
||||
}
|
||||
return pt;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue