Skip to content

Commit

Permalink
Removed Gosu::Font#flags
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberarm committed Oct 3, 2022
1 parent b51965d commit c8ad6ef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/gosu.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/gosu/constants.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 4 additions & 7 deletions src/gosu/font.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c8ad6ef

Please sign in to comment.