Skip to content

Font file remains open after reading? #191

@alxx

Description

@alxx

I have a suspicion that once ruby2d reads the font, it neglects to close the file; this means that I'm currently unable to create more than 239 Text instances:

(['Abc'] * 239).each do |t|
  Text.new(t, font: __dir__ + '/../fonts/arial.ttf')
end

The code above works fine, but if I replace 239 with 240, I get the error Error Domain=NSPOSIXErrorDomain Code=24 "Too many open files"

I suggest that in ext/ruby2d/text.c at line 29 after opening the font with TTF_OpenFont it should also be closed with TTF_CloseFont, as per instructions here: https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf_18.html#SEC18

I'd try it locally myself, but I really don't know how to overwrite a C file in a gem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions