Module: HarfBuzz::C

Extended by:
FFI::Library
Defined in:
lib/harfbuzz/c/base.rb,
lib/harfbuzz/c/map.rb,
lib/harfbuzz/c/set.rb,
lib/harfbuzz/c/blob.rb,
lib/harfbuzz/c/draw.rb,
lib/harfbuzz/c/face.rb,
lib/harfbuzz/c/font.rb,
lib/harfbuzz/c/enums.rb,
lib/harfbuzz/c/paint.rb,
lib/harfbuzz/c/shape.rb,
lib/harfbuzz/c/buffer.rb,
lib/harfbuzz/c/common.rb,
lib/harfbuzz/c/ot/var.rb,
lib/harfbuzz/c/ot/font.rb,
lib/harfbuzz/c/ot/math.rb,
lib/harfbuzz/c/ot/meta.rb,
lib/harfbuzz/c/ot/name.rb,
lib/harfbuzz/c/structs.rb,
lib/harfbuzz/c/unicode.rb,
lib/harfbuzz/c/version.rb,
lib/harfbuzz/c/ot/color.rb,
lib/harfbuzz/c/ot/shape.rb,
lib/harfbuzz/c/ot/layout.rb,
lib/harfbuzz/c/aat/layout.rb,
lib/harfbuzz/c/font_funcs.rb,
lib/harfbuzz/c/ot/metrics.rb,
lib/harfbuzz/c/shape_plan.rb

Overview

Low-level FFI bindings to HarfBuzz C API

Defined Under Namespace

Classes: HbAatLayoutFeatureSelectorInfoT, HbDrawStateT, HbFeatureT, HbFontExtentsT, HbGlyphExtentsT, HbGlyphInfoT, HbGlyphPositionT, HbOtColorLayerT, HbOtMathGlyphPartT, HbOtMathGlyphVariantT, HbOtNameEntryT, HbOtVarAxisInfoT, HbSegmentPropertiesT, HbVariationT

Constant Summary collapse

HB_SET_VALUE_INVALID =
0xFFFFFFFF
MemoryMode =

hb_memory_mode_t

enum :hb_memory_mode_t, [
  :duplicate, 0,
  :readonly,
  :writable,
  :readonly_may_make_writable
]
Direction =

hb_direction_t

enum :hb_direction_t, [
  :invalid, 0,
  :ltr, 4,
  :rtl, 5,
  :ttb, 6,
  :btt, 7
]
BufferContentType =

hb_buffer_content_type_t

enum :hb_buffer_content_type_t, [
  :invalid, 0,
  :unicode,
  :glyphs
]
BufferClusterLevel =

hb_buffer_cluster_level_t

enum :hb_buffer_cluster_level_t, [
  :monotone_graphemes, 0,
  :monotone_characters, 1,
  :characters, 2
]
BufferSerializeFormat =

hb_buffer_serialize_format_t

enum :hb_buffer_serialize_format_t, [
  :text, 0x54455854,
  :json, 0x4A534F4E,
  :invalid, 0x00000000
]
UnicodeGeneralCategory =

hb_unicode_general_category_t

enum :hb_unicode_general_category_t, [
  :control, 0,           :format, 1,
  :unassigned, 2,        :private_use, 3,
  :surrogate, 4,         :lowercase_letter, 5,
  :modifier_letter, 6,   :other_letter, 7,
  :titlecase_letter, 8,  :uppercase_letter, 9,
  :spacing_mark, 10,     :enclosing_mark, 11,
  :non_spacing_mark, 12, :decimal_number, 13,
  :letter_number, 14,    :other_number, 15,
  :connect_punctuation, 16, :dash_punctuation, 17,
  :close_punctuation, 18,   :final_punctuation, 19,
  :initial_punctuation, 20, :other_punctuation, 21,
  :open_punctuation, 22,    :currency_symbol, 23,
  :modifier_symbol, 24,     :math_symbol, 25,
  :other_symbol, 26,        :line_separator, 27,
  :paragraph_separator, 28, :space_separator, 29
]
OtLayoutGlyphClass =

hb_ot_layout_glyph_class_t

enum :hb_ot_layout_glyph_class_t, [
  :unclassified, 0, :base_glyph, 1,
  :ligature, 2, :mark, 3, :component, 4
]
OtMetaTag =

hb_ot_meta_tag_t

enum :hb_ot_meta_tag_t, [
  :design_languages, 0x646C6E67,
  :supported_languages, 0x736C6E67
]
PaintCompositeMode =

hb_paint_composite_mode_t

enum :hb_paint_composite_mode_t, [
  :clear, 0, :src, :dest, :src_over, :dest_over,
  :src_in, :dest_in, :src_out, :dest_out,
  :src_atop, :dest_atop, :xor, :plus,
  :screen, :overlay, :darken, :lighten,
  :color_dodge, :color_burn, :hard_light, :soft_light,
  :difference, :exclusion, :multiply,
  :hsl_hue, :hsl_saturation, :hsl_color, :hsl_luminosity
]
BUFFER_FLAG_DEFAULT =

hb_buffer_flags_t

0x00000000
BUFFER_FLAG_BOT =
0x00000001
BUFFER_FLAG_EOT =
0x00000002
BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES =
0x00000004
BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES =
0x00000008
BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE =
0x00000010
BUFFER_FLAG_VERIFY =
0x00000020
BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT =
0x00000040
BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL =
0x00000080
BUFFER_FLAG_DEFINED =
0x000000FF
BUFFER_SERIALIZE_FLAG_DEFAULT =

hb_buffer_serialize_flags_t

0x00000000
BUFFER_SERIALIZE_FLAG_NO_CLUSTERS =
0x00000001
BUFFER_SERIALIZE_FLAG_NO_POSITIONS =
0x00000002
BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES =
0x00000004
BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS =
0x00000008
BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS =
0x00000010
BUFFER_SERIALIZE_FLAG_NO_ADVANCES =
0x00000020
BUFFER_DIFF_FLAG_EQUAL =

hb_buffer_diff_flags_t

0x0000
BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH =
0x0001
BUFFER_DIFF_FLAG_LENGTH_MISMATCH =
0x0002
BUFFER_DIFF_FLAG_NOTDEF_PRESENT =
0x0004
BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT =
0x0008
BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH =
0x0010
BUFFER_DIFF_FLAG_CLUSTER_MISMATCH =
0x0020
BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH =
0x0040
BUFFER_DIFF_FLAG_POSITION_MISMATCH =
0x0080
GLYPH_FLAG_UNSAFE_TO_BREAK =

hb_glyph_flags_t

0x00000001
GLYPH_FLAG_UNSAFE_TO_CONCAT =
0x00000002
GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL =
0x00000004
GLYPH_FLAG_DEFINED =
0x00000007
OT_VAR_AXIS_FLAG_HIDDEN =

hb_ot_var_axis_flags_t

0x0001
OT_COLOR_PALETTE_FLAG_DEFAULT =

hb_ot_color_palette_flags_t

0x0000
OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BG =
0x0001
OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BG =
0x0002
SUBSET_FLAGS_DEFAULT =

hb_subset_flags_t

0x0000
SUBSET_FLAGS_NO_HINTING =
0x0001
SUBSET_FLAGS_RETAIN_GIDS =
0x0002
SUBSET_FLAGS_DESUBROUTINIZE =
0x0004
SUBSET_FLAGS_NAME_LEGACY =
0x0008
SUBSET_FLAGS_SET_OVERLAPS_FLAG =
0x0010
SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED =
0x0020
SUBSET_FLAGS_NOTDEF_OUTLINE =
0x0040
SUBSET_FLAGS_GLYPH_NAMES =
0x0080
SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES =
0x0100
SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS =
0x0200

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hb_bool(value) ⇒ Boolean

Converts hb_bool_t (int) to Ruby boolean

Parameters:

  • value (Integer)

    HarfBuzz boolean (0 or non-zero)

Returns:

  • (Boolean)

    Ruby boolean



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

def self.from_hb_bool(value)
  !value.zero?
end

.tag_from_string(tag) ⇒ Integer

Converts a 4-character tag string to hb_tag_t (uint32)

Parameters:

  • tag (String)

    4-character tag (e.g., "GSUB")

Returns:

  • (Integer)

    Tag as uint32

Raises:

  • (ArgumentError)


96
97
98
99
100
101
102
103
104
105
# File 'lib/harfbuzz/c/base.rb', line 96

def self.tag_from_string(tag)
  raise ArgumentError, "Tag must be a String" unless tag.is_a?(String)

  # Pad or truncate to 4 bytes
  bytes = tag.bytes.take(4)
  bytes += [0x20] * (4 - bytes.size) if bytes.size < 4

  # Pack as big-endian uint32
  bytes.pack("C4").unpack1("N")
end

.tag_to_string(tag) ⇒ String

Converts hb_tag_t (uint32) to 4-character string

Parameters:

  • tag (Integer)

    Tag as uint32

Returns:

  • (String)

    4-character tag string



110
111
112
# File 'lib/harfbuzz/c/base.rb', line 110

def self.tag_to_string(tag)
  [tag].pack("N").unpack("C4").pack("C*")
end

.to_hb_bool(value) ⇒ Integer

Converts Ruby boolean to hb_bool_t (int)

Parameters:

  • value (Boolean)

    Ruby boolean

Returns:

  • (Integer)

    1 for true, 0 for false



82
83
84
# File 'lib/harfbuzz/c/base.rb', line 82

def self.to_hb_bool(value)
  value ? 1 : 0
end

Instance Method Details

#hb_versionvoid

This method returns an undefined value.

Returns the HarfBuzz library version

Parameters:

  • major (FFI::Pointer)

    Pointer to store major version

  • minor (FFI::Pointer)

    Pointer to store minor version

  • micro (FFI::Pointer)

    Pointer to store micro version



12
# File 'lib/harfbuzz/c/version.rb', line 12

attach_function :hb_version, [:pointer, :pointer, :pointer], :void

#hb_version_atleastInteger

Checks if the library version is at least the specified version

Parameters:

  • major (Integer)

    Major version

  • minor (Integer)

    Minor version

  • micro (Integer)

    Micro version

Returns:

  • (Integer)

    Non-zero if version >= specified, 0 otherwise



23
# File 'lib/harfbuzz/c/version.rb', line 23

attach_function :hb_version_atleast, [:uint, :uint, :uint], :hb_bool_t

#hb_version_stringString

Returns the HarfBuzz library version as a string

Returns:

  • (String)

    Version string (e.g., "8.3.0")



16
# File 'lib/harfbuzz/c/version.rb', line 16

attach_function :hb_version_string, [], :string