Class: Harfbuzz::Face

Inherits:
Base
  • Object
show all
Defined in:
lib/harfbuzz/face.rb

Constant Summary collapse

MAX_NAME_LEN =
200

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#define_finalizer, finalize

Constructor Details

#initialize(blob, face_index = 0) ⇒ Face

Returns a new instance of Face.



52
53
54
55
56
# File 'lib/harfbuzz/face.rb', line 52

def initialize(blob, face_index=0)
  blob = Blob.new(blob) unless blob.kind_of?(Blob)
  @hb_face = Harfbuzz.hb_face_create(blob.hb_blob, face_index)
  define_finalizer(:hb_face_destroy, @hb_face)
end

Instance Attribute Details

#hb_faceObject (readonly)

Returns the value of attribute hb_face.



50
51
52
# File 'lib/harfbuzz/face.rb', line 50

def hb_face
  @hb_face
end

Instance Method Details

#font_family_name(language = nil) ⇒ Object



81
82
83
# File 'lib/harfbuzz/face.rb', line 81

def font_family_name(language=nil)
  name(HB_OT_NAME_ID_FONT_FAMILY, language)
end

#font_subfamily_name(language = nil) ⇒ Object



85
86
87
# File 'lib/harfbuzz/face.rb', line 85

def font_subfamily_name(language=nil)
  name(HB_OT_NAME_ID_FONT_SUBFAMILY, language)
end

#full_name(language = nil) ⇒ Object



89
90
91
# File 'lib/harfbuzz/face.rb', line 89

def full_name(language=nil)
  name(HB_OT_NAME_ID_FULL_NAME, language)
end

#glyph_countObject



66
67
68
# File 'lib/harfbuzz/face.rb', line 66

def glyph_count
  Harfbuzz.hb_face_get_glyph_count(@hb_face)
end

#indexObject



58
59
60
# File 'lib/harfbuzz/face.rb', line 58

def index
  Harfbuzz.hb_face_get_index(@hb_face)
end

#name(name_id, language = nil) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/harfbuzz/face.rb', line 72

def name(name_id, language=nil)
  text_size_ptr = FFI::MemoryPointer.new(:uint, 1)
  text_size_ptr.write_uint(MAX_NAME_LEN)
  text_ptr = FFI::MemoryPointer.new(:char, MAX_NAME_LEN) #FIXME: ?
  #FIXME: check result
  Harfbuzz.hb_ot_name_get_utf8(@hb_face, name_id, language, text_size_ptr, text_ptr)
  text_ptr.get_string(0, MAX_NAME_LEN)
end

#postscript_name(language = nil) ⇒ Object



93
94
95
# File 'lib/harfbuzz/face.rb', line 93

def postscript_name(language=nil)
  name(HB_OT_NAME_ID_POSTSCRIPT_NAME, language)
end

#upemObject



62
63
64
# File 'lib/harfbuzz/face.rb', line 62

def upem
  Harfbuzz.hb_face_get_upem(@hb_face)
end