Class: Pdfrb::Font::CFF::File
- Inherits:
-
Object
- Object
- Pdfrb::Font::CFF::File
- Defined in:
- lib/pdfrb/font/cff/file.rb
Overview
Parsed CFF table (TN5176). Exposes the pieces a subsetter needs: header span, Name/String/Global-Subr INDEXes, Top DICT, charset (format 0), CharStrings INDEX, Private DICT span, and the Local Subr INDEX when present.
Instance Attribute Summary collapse
-
#charset_format ⇒ Object
readonly
Returns the value of attribute charset_format.
-
#charset_sids ⇒ Object
readonly
Returns the value of attribute charset_sids.
-
#charstrings ⇒ Object
readonly
Returns the value of attribute charstrings.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#global_subrs ⇒ Object
readonly
Returns the value of attribute global_subrs.
-
#header_size ⇒ Object
readonly
Returns the value of attribute header_size.
-
#local_subrs ⇒ Object
readonly
Returns the value of attribute local_subrs.
-
#name_index ⇒ Object
readonly
Returns the value of attribute name_index.
-
#private_span ⇒ Object
readonly
Returns the value of attribute private_span.
-
#string_index ⇒ Object
readonly
Returns the value of attribute string_index.
-
#top_dict ⇒ Object
readonly
Returns the value of attribute top_dict.
Instance Method Summary collapse
- #charstring(gid) ⇒ Object
-
#gid_for_sid(sid) ⇒ Object
Reverse charset: SID -> gid (first wins).
-
#initialize(data) ⇒ File
constructor
A new instance of File.
- #num_glyphs ⇒ Object
-
#sid_for_gid(gid) ⇒ Object
Charset (format 0 only): gid -> SID, with .notdef implicit at gid 0.
Constructor Details
#initialize(data) ⇒ File
Returns a new instance of File.
16 17 18 19 |
# File 'lib/pdfrb/font/cff/file.rb', line 16 def initialize(data) @data = data.b parse end |
Instance Attribute Details
#charset_format ⇒ Object (readonly)
Returns the value of attribute charset_format.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def charset_format @charset_format end |
#charset_sids ⇒ Object (readonly)
Returns the value of attribute charset_sids.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def charset_sids @charset_sids end |
#charstrings ⇒ Object (readonly)
Returns the value of attribute charstrings.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def charstrings @charstrings end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def data @data end |
#global_subrs ⇒ Object (readonly)
Returns the value of attribute global_subrs.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def global_subrs @global_subrs end |
#header_size ⇒ Object (readonly)
Returns the value of attribute header_size.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def header_size @header_size end |
#local_subrs ⇒ Object (readonly)
Returns the value of attribute local_subrs.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def local_subrs @local_subrs end |
#name_index ⇒ Object (readonly)
Returns the value of attribute name_index.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def name_index @name_index end |
#private_span ⇒ Object (readonly)
Returns the value of attribute private_span.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def private_span @private_span end |
#string_index ⇒ Object (readonly)
Returns the value of attribute string_index.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def string_index @string_index end |
#top_dict ⇒ Object (readonly)
Returns the value of attribute top_dict.
11 12 13 |
# File 'lib/pdfrb/font/cff/file.rb', line 11 def top_dict @top_dict end |
Instance Method Details
#charstring(gid) ⇒ Object
25 26 27 |
# File 'lib/pdfrb/font/cff/file.rb', line 25 def charstring(gid) charstrings[gid] if charstrings end |
#gid_for_sid(sid) ⇒ Object
Reverse charset: SID -> gid (first wins).
38 39 40 41 42 43 44 45 |
# File 'lib/pdfrb/font/cff/file.rb', line 38 def gid_for_sid(sid) @gid_by_sid ||= begin map = { 0 => 0 } @charset_sids.each_with_index { |s, i| map[s] ||= i + 1 } map end @gid_by_sid[sid] end |
#num_glyphs ⇒ Object
21 22 23 |
# File 'lib/pdfrb/font/cff/file.rb', line 21 def num_glyphs charstrings&.size || 0 end |
#sid_for_gid(gid) ⇒ Object
Charset (format 0 only): gid -> SID, with .notdef implicit at gid 0.
31 32 33 34 35 |
# File 'lib/pdfrb/font/cff/file.rb', line 31 def sid_for_gid(gid) return 0 if gid.zero? @charset_sids[gid - 1] end |