diff --git a/binding/bitmap-binding.cpp b/binding/bitmap-binding.cpp index 5af6deb4..442b285c 100644 --- a/binding/bitmap-binding.cpp +++ b/binding/bitmap-binding.cpp @@ -46,7 +46,6 @@ void bitmapInitProps(Bitmap *b, VALUE self) { rb_obj_call_init(fontObj, 0, 0); Font *font = getPrivateData(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(hiresFontObj); + rb_iv_set(rb_iv_get(self, "hires"), "font", hiresFontObj); + b->getHires()->setInitFont(hiresFont); + } + b->setInitFont(font); } RB_METHOD(bitmapInitialize) { diff --git a/src/display/bitmap.cpp b/src/display/bitmap.cpp index bec7a2e0..86b11ae7 100644 --- a/src/display/bitmap.cpp +++ b/src/display/bitmap.cpp @@ -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;