diff --git a/src/gosu.cr b/src/gosu.cr index fdf2f77..0e4bfbf 100644 --- a/src/gosu.cr +++ b/src/gosu.cr @@ -84,6 +84,8 @@ module Gosu fun clipboard = Gosu_clipboard() : UInt8* fun set_clipboard = Gosu_set_clipboard(text : UInt8*) + + fun last_error = Gosu_last_error() : UInt8* end # Returns the current framerate, in frames per second. @@ -386,4 +388,10 @@ module Gosu raise "No such mode: #{mode}" end end + + def self.check_last_error + if (err = GosuC.last_error) + raise String.new(err) + end + end end diff --git a/src/gosu/constants.cr b/src/gosu/constants.cr index 8e3431c..27d2d3d 100644 --- a/src/gosu/constants.cr +++ b/src/gosu/constants.cr @@ -566,4 +566,9 @@ module Gosu MS_NUM = Gosu::ButtonName::MS_NUM.to_u32 GP_NUM = Gosu::ButtonName::GP_NUM.to_u32 GP_NUM_PER_GAMEPAD = Gosu::ButtonName::GP_NUM_PER_GAMEPAD.to_u32 + + FF_BOLD = 1_u32 + FF_ITALIC = 2_u32 + FF_UNDERLINE = 4_u32 + FF_COMBINATIONS = 8_u32 end diff --git a/src/gosu/font.cr b/src/gosu/font.cr index 081d652..7664df6 100644 --- a/src/gosu/font.cr +++ b/src/gosu/font.cr @@ -4,7 +4,6 @@ module Gosu fun name = Gosu_Font_name(pointer : UInt8*) : UInt8* fun height = Gosu_Font_height(pointer : UInt8*) : Int32 - fun flags = Gosu_Font_flags(pointer : UInt8*) : UInt32 fun text_width = Gosu_Font_text_width(pointer : UInt8*, text : UInt8*) : Float64 fun markup_width = Gosu_Font_markup_width(pointer : UInt8*, text : UInt8*) : Float64 @@ -53,11 +52,6 @@ module Gosu FontC.height(pointer) end - # Returns the flags passed to `Gosu::Font` as a UInt32 - def flags : UInt32 - FontC.flags(pointer) - end - # Returns the width of a single line of text, in pixels, if it were drawn. def text_width(text) : Float64 FontC.text_width(pointer, text) @@ -116,7 +110,10 @@ module Gosu # # NOTE: For any given character, this method MUST NOT be called more than once, and MUST NOT be called if a string containing the character has already been drawn. def []=(codepoint : String, image : Gosu::Image) - FontC.set_image(pointer, codepoint, self.flags, image.pointer) + Gosu::FF_COMBINATIONS.times do |font_flags| + FontC.set_image(pointer, codepoint, font_flags, image.pointer) + Gosu.check_last_error + end end # :nodoc: