Class: Fontisan::Tables::Cff2
- Inherits:
-
Binary::BaseRecord
- Object
- BinData::Record
- Binary::BaseRecord
- Fontisan::Tables::Cff2
- Defined in:
- lib/fontisan/tables/cff2.rb,
lib/fontisan/tables/cff2/header.rb,
lib/fontisan/tables/cff2/fd_select.rb,
lib/fontisan/tables/cff2/dict_encoder.rb,
lib/fontisan/tables/cff2/table_reader.rb,
lib/fontisan/tables/cff2/index_builder.rb,
lib/fontisan/tables/cff2/operand_stack.rb,
lib/fontisan/tables/cff2/table_builder.rb,
lib/fontisan/tables/cff2/blend_operator.rb,
lib/fontisan/tables/cff2/region_matcher.rb,
lib/fontisan/tables/cff2/charstring_parser.rb,
lib/fontisan/tables/cff2/variation_data_extractor.rb,
lib/fontisan/tables/cff2/private_dict_blend_handler.rb
Overview
Parser for the 'CFF2' (Compact Font Format 2) table
CFF2 is used primarily in variable fonts with PostScript outlines. Key differences from CFF:
- No Name INDEX (font names come from name table)
- No Encoding or Charset (use cmap table instead)
- Support for blend operators in CharStrings for variations
- Different default values in DICTs
Reference: Adobe Technical Note #5177
Defined Under Namespace
Modules: Header Classes: BlendOperator, Cff2Header, CharstringParser, DictEncoder, FdSelect, IndexBuilder, OperandStack, PrivateDictBlendHandler, RegionMatcher, TableBuilder, TableReader, VariationDataExtractor
Instance Method Summary collapse
-
#charstring_for_glyph(glyph_id) ⇒ CharstringParser?
Get CharString for a specific glyph.
-
#charstrings ⇒ Array<CharstringParser>
Get all CharStrings.
-
#glyph_count ⇒ Integer
Get glyph count from font's maxp table.
-
#glyph_count=(count) ⇒ Object
Set glyph count (from maxp table).
-
#header ⇒ Cff2Header
Get the CFF2 header.
-
#num_axes ⇒ Integer
Get number of variation axes.
-
#num_axes=(count) ⇒ Object
Set number of variation axes (from fvar table).
-
#parse ⇒ self
Parse the CFF2 table.
-
#valid? ⇒ Boolean
Check if table is valid.
Methods inherited from Binary::BaseRecord
Instance Method Details
#charstring_for_glyph(glyph_id) ⇒ CharstringParser?
Get CharString for a specific glyph
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/fontisan/tables/cff2.rb', line 114 def charstring_for_glyph(glyph_id) parse unless @parsed return nil if @charstrings_index.nil? return nil if glyph_id >= @charstrings_index.count # Get CharString data from INDEX charstring_data = @charstrings_index[glyph_id] return nil if charstring_data.nil? # Parse with CFF2 CharString parser CharstringParser.new( charstring_data, @num_axes, @global_subr_index, nil, # local subrs (CFF2 may not have them) 0, # vsindex ).parse end |
#charstrings ⇒ Array<CharstringParser>
Get all CharStrings
136 137 138 139 140 141 142 |
# File 'lib/fontisan/tables/cff2.rb', line 136 def charstrings return [] unless @charstrings_index Array.new(@charstrings_index.count) do |glyph_id| charstring_for_glyph(glyph_id) end.compact end |
#glyph_count ⇒ Integer
Get glyph count from font's maxp table
CFF2 doesn't store glyph count internally - it relies on the maxp table
83 84 85 86 87 |
# File 'lib/fontisan/tables/cff2.rb', line 83 def glyph_count # This needs to be set externally or retrieved from maxp table # For now, return a default that indicates it needs to be set @glyph_count || 0 end |
#glyph_count=(count) ⇒ Object
Set glyph count (from maxp table)
92 93 94 |
# File 'lib/fontisan/tables/cff2.rb', line 92 def glyph_count=(count) @glyph_count = count end |
#header ⇒ Cff2Header
Get the CFF2 header
73 74 75 76 |
# File 'lib/fontisan/tables/cff2.rb', line 73 def header parse unless @parsed @header end |
#num_axes ⇒ Integer
Get number of variation axes
106 107 108 |
# File 'lib/fontisan/tables/cff2.rb', line 106 def num_axes @num_axes || 0 end |
#num_axes=(count) ⇒ Object
Set number of variation axes (from fvar table)
99 100 101 |
# File 'lib/fontisan/tables/cff2.rb', line 99 def num_axes=(count) @num_axes = count end |
#parse ⇒ self
Parse the CFF2 table
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fontisan/tables/cff2.rb', line 58 def parse return self if @parsed @header = parse_header @global_subr_index = parse_global_subr_index @top_dict = parse_top_dict @charstrings_index = parse_charstrings_index @parsed = true self end |
#valid? ⇒ Boolean
Check if table is valid
147 148 149 |
# File 'lib/fontisan/tables/cff2.rb', line 147 def valid? header.valid? end |