class Harfbuzz::Font
Attributes
hb_font[R]
Public Class Methods
new(face)
click to toggle source
# File lib/harfbuzz/font.rb, line 123 def initialize(face) @hb_font = Harfbuzz.hb_font_create(face.hb_face) Harfbuzz.hb_font_set_scale(@hb_font, face.upem, face.upem) Harfbuzz.hb_ft_font_set_funcs(@hb_font) define_finalizer(:hb_font_destroy, @hb_font) end
Public Instance Methods
extents()
click to toggle source
# File lib/harfbuzz/font.rb, line 192 def extents [h_extents, v_extents] end
extents_for_direction(direction)
click to toggle source
# File lib/harfbuzz/font.rb, line 196 def extents_for_direction(direction) extents = FontExtents.new func = "hb_font_get_#{direction}_extents".to_sym Harfbuzz.send(func, @hb_font, extents) extents end
glyph_extents(codepoint)
click to toggle source
# File lib/harfbuzz/font.rb, line 176 def glyph_extents(codepoint) glyph_extents = GlyphExtents.new Harfbuzz.hb_font_get_glyph_extents(@hb_font, codepoint, glyph_extents) glyph_extents end
glyph_from_name(name)
click to toggle source
# File lib/harfbuzz/font.rb, line 165 def glyph_from_name(name) name_ptr = FFI::MemoryPointer.new(:char, name.bytesize) name_ptr.put_bytes(0, name) glyph_ptr = FFI::MemoryPointer.new(:uint, 1) if Harfbuzz.hb_font_get_glyph_from_name(@hb_font, name_ptr, name.length, glyph_ptr) glyph_ptr.read_uint else nil end end
glyph_name(glyph)
click to toggle source
# File lib/harfbuzz/font.rb, line 156 def glyph_name(glyph) string_ptr = FFI::MemoryPointer.new(:char, 20) if Harfbuzz.hb_font_get_glyph_name(@hb_font, glyph, string_ptr, 20) string_ptr.get_string(0, 20) else nil end end
glyph_to_string(glyph)
click to toggle source
# File lib/harfbuzz/font.rb, line 150 def glyph_to_string(glyph) string_ptr = FFI::MemoryPointer.new(:char, 20) Harfbuzz.hb_font_glyph_to_string(@hb_font, glyph, string_ptr, 20) string_ptr.get_string(0, 20) end
h_extents()
click to toggle source
# File lib/harfbuzz/font.rb, line 184 def h_extents extents_for_direction(:h) end
ppem()
click to toggle source
# File lib/harfbuzz/font.rb, line 140 def ppem ppem_x_ptr = FFI::MemoryPointer.new(:uint, 1) ppem_y_ptr = FFI::MemoryPointer.new(:uint, 1) Harfbuzz.hb_font_get_ppem(@hb_font, ppem_x_ptr, ppem_y_ptr) [ ppem_x_ptr.read_uint, ppem_y_ptr.read_uint, ] end
scale()
click to toggle source
# File lib/harfbuzz/font.rb, line 130 def scale x_scale_ptr = FFI::MemoryPointer.new(:int, 1) y_scale_ptr = FFI::MemoryPointer.new(:int, 1) Harfbuzz.hb_font_get_scale(@hb_font, x_scale_ptr, y_scale_ptr) [ x_scale_ptr.read_int, y_scale_ptr.read_int, ] end
v_extents()
click to toggle source
# File lib/harfbuzz/font.rb, line 188 def v_extents extents_for_direction(:v) end