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/index.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, Index, 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
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/fontisan/tables/cff2.rb', line 115 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
137 138 139 140 141 142 143 |
# File 'lib/fontisan/tables/cff2.rb', line 137 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
84 85 86 87 88 |
# File 'lib/fontisan/tables/cff2.rb', line 84 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)
93 94 95 |
# File 'lib/fontisan/tables/cff2.rb', line 93 def glyph_count=(count) @glyph_count = count end |
#header ⇒ Cff2Header
Get the CFF2 header
74 75 76 77 |
# File 'lib/fontisan/tables/cff2.rb', line 74 def header parse unless @parsed @header end |
#num_axes ⇒ Integer
Get number of variation axes
107 108 109 |
# File 'lib/fontisan/tables/cff2.rb', line 107 def num_axes @num_axes || 0 end |
#num_axes=(count) ⇒ Object
Set number of variation axes (from fvar table)
100 101 102 |
# File 'lib/fontisan/tables/cff2.rb', line 100 def num_axes=(count) @num_axes = count end |
#parse ⇒ self
Parse the CFF2 table
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fontisan/tables/cff2.rb', line 59 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
148 149 150 |
# File 'lib/fontisan/tables/cff2.rb', line 148 def valid? header.valid? end |