1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
# frozen_string_literal: true
require 'forwardable'
module TTFunk
class Table
class Cff < TTFunk::Table
# CFF Index with indexing starting at 1.
class OneBasedIndex
extend Forwardable
def_delegators :base_index,
:each,
:table_offset,
:items_count,
:length,
:encode
# Underlaying Index.
# @return [TTFunk::Table::Cff::Index]
attr_reader :base_index
# @param args [Array] all params are passed to the base index.
# @see Index
def initialize(*args)
@base_index = Index.new(*args)
end
# Get item by index.
#
# @param idx [Integer]
# @return [any]
# @raise [IndexError] when requested index is 0.
def [](idx)
if idx.zero?
raise IndexError,
"index #{idx} was outside the bounds of the index"
end
base_index[idx - 1]
end
end
end
end
end
|