From 88b7a198702707b72c4b174871b37b2eaf65ad83 Mon Sep 17 00:00:00 2001 From: Alexander Mankuta Date: Fri, 1 Mar 2024 17:27:35 +0200 Subject: [PATCH] Fix docs --- lib/ttfunk/bin_utils.rb | 2 +- lib/ttfunk/bit_field.rb | 2 +- lib/ttfunk/encoded_string.rb | 2 +- lib/ttfunk/resource_file.rb | 2 +- lib/ttfunk/sub_table.rb | 11 ++++++----- lib/ttfunk/subset/code_page.rb | 2 +- lib/ttfunk/subset/unicode.rb | 2 +- lib/ttfunk/subset/unicode_8bit.rb | 4 ++-- lib/ttfunk/table/cff/charstrings_index.rb | 8 +++++--- lib/ttfunk/table/cff/index.rb | 2 +- lib/ttfunk/table/cff/one_based_index.rb | 3 ++- lib/ttfunk/table/cff/private_dict.rb | 2 +- lib/ttfunk/table/cff/top_dict.rb | 2 +- lib/ttfunk/table/dsig.rb | 2 +- lib/ttfunk/table/glyf/compound.rb | 1 + lib/ttfunk/table/name.rb | 2 +- lib/ttfunk/table/post/format40.rb | 2 +- spec/support/path_helpers.rb | 6 ++++++ spec/support/test_file.rb | 1 + 19 files changed, 35 insertions(+), 23 deletions(-) diff --git a/lib/ttfunk/bin_utils.rb b/lib/ttfunk/bin_utils.rb index 5092da74..1599aaf9 100644 --- a/lib/ttfunk/bin_utils.rb +++ b/lib/ttfunk/bin_utils.rb @@ -7,7 +7,7 @@ module BinUtils # # @param arr [Array] # @param bit_width [Integer] bit width of the elements - # @return Integer + # @return [Integer] def stitch_int(arr, bit_width:) value = 0 diff --git a/lib/ttfunk/bit_field.rb b/lib/ttfunk/bit_field.rb index 4d815cbd..7a8d4f48 100644 --- a/lib/ttfunk/bit_field.rb +++ b/lib/ttfunk/bit_field.rb @@ -14,7 +14,7 @@ def initialize(value = 0) # Set bit on. # - # @prama pos [Integer] bit position + # @param pos [Integer] bit position # @return [void] def on(pos) @value |= 2**pos diff --git a/lib/ttfunk/encoded_string.rb b/lib/ttfunk/encoded_string.rb index 5f682850..0ede2244 100644 --- a/lib/ttfunk/encoded_string.rb +++ b/lib/ttfunk/encoded_string.rb @@ -27,7 +27,7 @@ def initialize # Append to string. # - # @param [String, Placeholder, EncodedString] + # @param obj [String, Placeholder, EncodedString] # @return [self] def <<(obj) case obj diff --git a/lib/ttfunk/resource_file.rb b/lib/ttfunk/resource_file.rb index 30e43ac3..466bb9d2 100644 --- a/lib/ttfunk/resource_file.rb +++ b/lib/ttfunk/resource_file.rb @@ -10,7 +10,7 @@ class ResourceFile # Open a resource file # - # @param [String, Pathname] + # @param path [String, Pathname] # @yieldparam resource_file [TTFunk::ResourceFile] # @return [any] result of the block def self.open(path) diff --git a/lib/ttfunk/sub_table.rb b/lib/ttfunk/sub_table.rb index bca84d90..a781f656 100644 --- a/lib/ttfunk/sub_table.rb +++ b/lib/ttfunk/sub_table.rb @@ -46,11 +46,12 @@ def eot? # Read a series of values. # - # @param bytes [Integer] number of bytes to read. - # @param format [String] format to parse the bytes. - # @return [Array] - # @raise [EOTError] - # @see # Ruby Packed data + # @overload read(bytes, format) + # @param bytes [Integer] number of bytes to read. + # @param format [String] format to parse the bytes. + # @return [Array] + # @raise [EOTError] + # @see # Ruby Packed data def read(*args) if eot? raise EOTError, 'attempted to read past the end of the table' diff --git a/lib/ttfunk/subset/code_page.rb b/lib/ttfunk/subset/code_page.rb index 499f92b3..1caf9f1c 100644 --- a/lib/ttfunk/subset/code_page.rb +++ b/lib/ttfunk/subset/code_page.rb @@ -63,7 +63,7 @@ def to_unicode_map # Add a character to subset. # - # @param [Integer] Unicode codepoint + # @param character [Integer] Unicode codepoint # @return [void] def use(character) @subset[from_unicode(character)] = character diff --git a/lib/ttfunk/subset/unicode.rb b/lib/ttfunk/subset/unicode.rb index 230a752a..c280e506 100644 --- a/lib/ttfunk/subset/unicode.rb +++ b/lib/ttfunk/subset/unicode.rb @@ -33,7 +33,7 @@ def to_unicode_map # Add a character to subset. # - # @param [Integer] Unicode codepoint + # @param character [Integer] Unicode codepoint # @return [void] def use(character) @subset << character diff --git a/lib/ttfunk/subset/unicode_8bit.rb b/lib/ttfunk/subset/unicode_8bit.rb index 63c4ba2b..c687664d 100644 --- a/lib/ttfunk/subset/unicode_8bit.rb +++ b/lib/ttfunk/subset/unicode_8bit.rb @@ -32,7 +32,7 @@ def to_unicode_map # Add a character to subset. # - # @param [Integer] Unicode codepoint + # @param character [Integer] Unicode codepoint # @return [void] def use(character) unless @unicodes.key?(character) @@ -44,7 +44,7 @@ def use(character) # Can this subset include the character? # - # @param _character [Integer] Unicode codepoint + # @param character [Integer] Unicode codepoint # @return [Boolean] def covers?(character) @unicodes.key?(character) || @next < 256 diff --git a/lib/ttfunk/table/cff/charstrings_index.rb b/lib/ttfunk/table/cff/charstrings_index.rb index e63a2b90..0fc9173b 100644 --- a/lib/ttfunk/table/cff/charstrings_index.rb +++ b/lib/ttfunk/table/cff/charstrings_index.rb @@ -9,9 +9,11 @@ class CharstringsIndex < TTFunk::Table::Cff::Index # @return [TTFunk::Table::Cff::TopDict] attr_reader :top_dict - # @param top_dict [TTFunk::Table:Cff::TopDict] - # @param file [TTFunk::File] - # @param subtable_start [Integer] + # @overload initialize(top_dict, file, offset, length = nil) + # @param top_dict [TTFunk::Table:Cff::TopDict] + # @param file [TTFunk::File] + # @param offset [Integer] + # @param length [Integer] def initialize(top_dict, *remaining_args) super(*remaining_args) @top_dict = top_dict diff --git a/lib/ttfunk/table/cff/index.rb b/lib/ttfunk/table/cff/index.rb index 5d4e0efc..18ac407e 100644 --- a/lib/ttfunk/table/cff/index.rb +++ b/lib/ttfunk/table/cff/index.rb @@ -46,7 +46,7 @@ def items_count # Encode index. # - # @param *args all arguments are passed to `encode_item` method. + # @param args all arguments are passed to `encode_item` method. # @return [TTFunk::EncodedString] def encode(*args) new_items = encode_items(*args) diff --git a/lib/ttfunk/table/cff/one_based_index.rb b/lib/ttfunk/table/cff/one_based_index.rb index bf93adb6..bf770fc0 100644 --- a/lib/ttfunk/table/cff/one_based_index.rb +++ b/lib/ttfunk/table/cff/one_based_index.rb @@ -20,7 +20,8 @@ class OneBasedIndex # @return [TTFunk::Table::Cff::Index] attr_reader :base_index - # @param *args [Array] all params are passed to the base index. + # @param args [Array] all params are passed to the base index. + # @see Index def initialize(*args) @base_index = Index.new(*args) end diff --git a/lib/ttfunk/table/cff/private_dict.rb b/lib/ttfunk/table/cff/private_dict.rb index 7bd64730..74f6e091 100644 --- a/lib/ttfunk/table/cff/private_dict.rb +++ b/lib/ttfunk/table/cff/private_dict.rb @@ -46,7 +46,7 @@ def encode # Finalize dict. # - # @param new_cff_data [TTFunk::EncodedString] + # @param private_dict_data [TTFunk::EncodedString] # @return [void] def finalize(private_dict_data) return unless subr_index diff --git a/lib/ttfunk/table/cff/top_dict.rb b/lib/ttfunk/table/cff/top_dict.rb index 19421fdb..0431e72a 100644 --- a/lib/ttfunk/table/cff/top_dict.rb +++ b/lib/ttfunk/table/cff/top_dict.rb @@ -59,7 +59,7 @@ def encode(*) # Finalize the table. # - # @prama new_cff_data [TTFunk::EncodedString] + # @param new_cff_data [TTFunk::EncodedString] # @param charmap [Hash{Integer => Hash}] keys are the charac codes, # values are hashes: # * `:old` (Integer) - glyph ID in the original font. diff --git a/lib/ttfunk/table/dsig.rb b/lib/ttfunk/table/dsig.rb index 2d417134..6aad3407 100644 --- a/lib/ttfunk/table/dsig.rb +++ b/lib/ttfunk/table/dsig.rb @@ -22,7 +22,7 @@ class SignatureRecord # @return [String] attr_reader :signature - # @param forma [Integer] + # @param format [Integer] # @param length [Integer] # @param offset [Integer] # @param signature [String] diff --git a/lib/ttfunk/table/glyf/compound.rb b/lib/ttfunk/table/glyf/compound.rb index 153b09f7..2cdcf53b 100644 --- a/lib/ttfunk/table/glyf/compound.rb +++ b/lib/ttfunk/table/glyf/compound.rb @@ -59,6 +59,7 @@ class Compound attr_reader :y_max + # IDs of compound glyphs. attr_reader :glyph_ids # Component glyph. diff --git a/lib/ttfunk/table/name.rb b/lib/ttfunk/table/name.rb index 560ba470..4740f6be 100644 --- a/lib/ttfunk/table/name.rb +++ b/lib/ttfunk/table/name.rb @@ -182,7 +182,7 @@ def strip_extended # Encode table. # - # @param name [TTFunk::Table::Name] + # @param names [TTFunk::Table::Name] # @param key [String] # @return [String] def self.encode(names, key = '') diff --git a/lib/ttfunk/table/post/format40.rb b/lib/ttfunk/table/post/format40.rb index 296b4138..aaf335d3 100644 --- a/lib/ttfunk/table/post/format40.rb +++ b/lib/ttfunk/table/post/format40.rb @@ -7,7 +7,7 @@ class Post module Format40 # Get glyph name for character code. # - # @param _code [Integer] + # @param code [Integer] # @return [String] def glyph_for(code) @map[code] || 0xFFFF diff --git a/spec/support/path_helpers.rb b/spec/support/path_helpers.rb index ffdda190..4773af2c 100644 --- a/spec/support/path_helpers.rb +++ b/spec/support/path_helpers.rb @@ -1,6 +1,12 @@ # frozen_string_literal: true module PathHelpers + # Get a test font file. + # + # @param name [String] name of the font file + # @param ext [Symbol, String] font file extension + # @return [String] full path to the test font file + # @raise [ArgumentError] if the requested font file can't be found def test_font(name, ext = :ttf) base_path = File.expand_path('../fonts', __dir__) valid_filename = File.join(base_path, "#{name}.#{ext}") diff --git a/spec/support/test_file.rb b/spec/support/test_file.rb index f6df5e47..57b13d99 100644 --- a/spec/support/test_file.rb +++ b/spec/support/test_file.rb @@ -8,6 +8,7 @@ def initialize(io) @io = io end + # Fake font directory entry for the table with the provided tag. def directory_info(*) { offset: 0, length: io.length } end