Class: Fontisan::Binary::BaseRecord
- Inherits:
-
BinData::Record
- Object
- BinData::Record
- Fontisan::Binary::BaseRecord
- Defined in:
- lib/fontisan/binary/base_record.rb
Overview
Base class for all BinData record definitions
Provides common configuration for OpenType binary structures:
-
Big-endian byte order (OpenType standard)
-
Common helper methods
All table parsers and binary structures should inherit from this class to ensure consistent behavior across the codebase.
Direct Known Subclasses
OffsetTable, TableDirectoryEntry, Tables::Cff, Tables::Cff2, Tables::Cff2::Header, Tables::Cff::Header, Tables::Cmap, Tables::Cvar, Tables::Cvar::TupleVariationHeader, Tables::Fvar, Tables::Glyf, Tables::Gpos, Tables::Gsub, Tables::Gvar, Tables::Gvar::TupleVariationHeader, Tables::Head, Tables::Hhea, Tables::Hmtx, Tables::Hmtx::LongHorMetric, Tables::Hvar, Tables::InstanceRecord, Tables::LayoutCommon::Feature, Tables::LayoutCommon::FeatureList, Tables::LayoutCommon::FeatureRecord, Tables::LayoutCommon::LangSys, Tables::LayoutCommon::LangSysRecord, Tables::LayoutCommon::Script, Tables::LayoutCommon::ScriptList, Tables::LayoutCommon::ScriptRecord, Tables::Loca, Tables::Maxp, Tables::Mvar, Tables::Mvar::ValueRecord, Tables::Name, Tables::NameRecord, Tables::Os2, Tables::Post, Tables::VariationAxisRecord, Tables::VariationCommon::DeltaSetIndexMap, Tables::VariationCommon::ItemVariationData, Tables::VariationCommon::ItemVariationStore, Tables::VariationCommon::RegionAxisCoordinates, Tables::VariationCommon::VariationRegion, Tables::VariationCommon::VariationRegionList, Tables::Vvar
Class Method Summary collapse
-
.read(io) ⇒ Object
Override read to handle nil data gracefully.
Instance Method Summary collapse
-
#raw_data ⇒ String
Get the raw binary data that was read.
-
#valid? ⇒ Boolean
Check if the record is valid.
Class Method Details
.read(io) ⇒ Object
Override read to handle nil data gracefully
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fontisan/binary/base_record.rb', line 26 def self.read(io) return new if io.nil? || (io.respond_to?(:empty?) && io.empty?) # Store the original data for later parsing # Convert IO to string if needed if io.is_a?(String) data = io instance = super(StringIO.new(data)) else # For IO objects, read to string first data = io.read io.rewind if io.respond_to?(:rewind) instance = super(io) end instance.instance_variable_set(:@raw_data, data) instance end |
Instance Method Details
#raw_data ⇒ String
Get the raw binary data that was read
48 49 50 |
# File 'lib/fontisan/binary/base_record.rb', line 48 def raw_data @raw_data || to_binary_s end |
#valid? ⇒ Boolean
Check if the record is valid
55 56 57 |
# File 'lib/fontisan/binary/base_record.rb', line 55 def valid? true end |