mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-07-01 14:15:16 +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);
|
rb_obj_call_init(fontObj, 0, 0);
|
||||||
|
|
||||||
Font *font = getPrivateData<Font>(fontObj);
|
Font *font = getPrivateData<Font>(fontObj);
|
||||||
b->setInitFont(font);
|
|
||||||
|
|
||||||
rb_iv_set(self, "font", fontObj);
|
rb_iv_set(self, "font", fontObj);
|
||||||
|
|
||||||
|
@ -54,7 +53,15 @@ void bitmapInitProps(Bitmap *b, VALUE self) {
|
||||||
if (b->hasHires()) {
|
if (b->hasHires()) {
|
||||||
b->assumeRubyGC();
|
b->assumeRubyGC();
|
||||||
wrapProperty(self, b->getHires(), "hires", BitmapType);
|
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) {
|
RB_METHOD(bitmapInitialize) {
|
||||||
|
|
|
@ -2220,10 +2220,12 @@ void Bitmap::setFont(Font &value)
|
||||||
void Bitmap::setInitFont(Font *value)
|
void Bitmap::setInitFont(Font *value)
|
||||||
{
|
{
|
||||||
if (hasHires()) {
|
if (hasHires()) {
|
||||||
Font *hiresFont = new Font(*value);
|
Font *hiresFont = p->selfHires->p->font;
|
||||||
|
if (hiresFont && hiresFont != &shState->defaultFont())
|
||||||
|
{
|
||||||
// Disable the illegal font size check when creating a high-res font.
|
// Disable the illegal font size check when creating a high-res font.
|
||||||
hiresFont->setSize(hiresFont->getSize() * p->selfHires->width() / width(), false);
|
hiresFont->setSize(hiresFont->getSize() * p->selfHires->width() / width(), false);
|
||||||
p->selfHires->setInitFont(hiresFont);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p->font = value;
|
p->font = value;
|
||||||
|
|
Loading…
Add table
Reference in a new issue