mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-07-01 06:05:17 +02:00
Ensure that fonts for hires bitmaps get deleted.
This commit is contained in:
parent
65aab17dba
commit
477162d1d3
2 changed files with 14 additions and 5 deletions
|
@ -46,7 +46,6 @@ void bitmapInitProps(Bitmap *b, VALUE self) {
|
|||
rb_obj_call_init(fontObj, 0, 0);
|
||||
|
||||
Font *font = getPrivateData<Font>(fontObj);
|
||||
b->setInitFont(font);
|
||||
|
||||
rb_iv_set(self, "font", fontObj);
|
||||
|
||||
|
@ -54,7 +53,15 @@ void bitmapInitProps(Bitmap *b, VALUE self) {
|
|||
if (b->hasHires()) {
|
||||
b->assumeRubyGC();
|
||||
wrapProperty(self, b->getHires(), "hires", BitmapType);
|
||||
|
||||
VALUE hiresFontObj = rb_obj_alloc(fontKlass);
|
||||
rb_obj_call_init(hiresFontObj, 0, 0);
|
||||
Font *hiresFont = getPrivateData<Font>(hiresFontObj);
|
||||
rb_iv_set(rb_iv_get(self, "hires"), "font", hiresFontObj);
|
||||
b->getHires()->setInitFont(hiresFont);
|
||||
|
||||
}
|
||||
b->setInitFont(font);
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapInitialize) {
|
||||
|
|
|
@ -2220,10 +2220,12 @@ void Bitmap::setFont(Font &value)
|
|||
void Bitmap::setInitFont(Font *value)
|
||||
{
|
||||
if (hasHires()) {
|
||||
Font *hiresFont = new Font(*value);
|
||||
// Disable the illegal font size check when creating a high-res font.
|
||||
hiresFont->setSize(hiresFont->getSize() * p->selfHires->width() / width(), false);
|
||||
p->selfHires->setInitFont(hiresFont);
|
||||
Font *hiresFont = p->selfHires->p->font;
|
||||
if (hiresFont && hiresFont != &shState->defaultFont())
|
||||
{
|
||||
// Disable the illegal font size check when creating a high-res font.
|
||||
hiresFont->setSize(hiresFont->getSize() * p->selfHires->width() / width(), false);
|
||||
}
|
||||
}
|
||||
|
||||
p->font = value;
|
||||
|
|
Loading…
Add table
Reference in a new issue