Class: PDF::Reader::Font
- Inherits:
-
Object
- Object
- PDF::Reader::Font
- Defined in:
- lib/pdf/reader/font.rb
Instance Attribute Summary collapse
-
#basefont ⇒ Object
Returns the value of attribute basefont.
-
#descendantfonts ⇒ Object
Returns the value of attribute descendantfonts.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#label ⇒ Object
Returns the value of attribute label.
-
#subtype ⇒ Object
Returns the value of attribute subtype.
-
#tounicode ⇒ Object
Returns the value of attribute tounicode.
Class Method Summary collapse
-
.glyphnames ⇒ Object
returns a hash that maps glyph names to unicode codepoints.
Instance Method Summary collapse
Instance Attribute Details
#basefont ⇒ Object
Returns the value of attribute basefont.
29 30 31 |
# File 'lib/pdf/reader/font.rb', line 29 def basefont @basefont end |
#descendantfonts ⇒ Object
Returns the value of attribute descendantfonts.
28 29 30 |
# File 'lib/pdf/reader/font.rb', line 28 def descendantfonts @descendantfonts end |
#encoding ⇒ Object
Returns the value of attribute encoding.
28 29 30 |
# File 'lib/pdf/reader/font.rb', line 28 def encoding @encoding end |
#label ⇒ Object
Returns the value of attribute label.
28 29 30 |
# File 'lib/pdf/reader/font.rb', line 28 def label @label end |
#subtype ⇒ Object
Returns the value of attribute subtype.
28 29 30 |
# File 'lib/pdf/reader/font.rb', line 28 def subtype @subtype end |
#tounicode ⇒ Object
Returns the value of attribute tounicode.
28 29 30 |
# File 'lib/pdf/reader/font.rb', line 28 def tounicode @tounicode end |
Class Method Details
.glyphnames ⇒ Object
returns a hash that maps glyph names to unicode codepoints. The mapping is based on a text file supplied by Adobe at: www.adobe.com/devnet/opentype/archives/glyphlist.txt
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pdf/reader/font.rb', line 34 def self.glyphnames @@glyphs ||= {} if @@glyphs.empty? File.open(File.dirname(__FILE__) + "/glyphlist.txt","r") do |f| f.each do |l| m, name, code = *l.match(/([0-9A-Za-z]+);([0-9A-F]{4})/) @@glyphs[name] = "0x#{code}".hex if name end end end @@glyphs end |
Instance Method Details
#to_utf8(params) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pdf/reader/font.rb', line 60 def to_utf8(params) raise UnsupportedFeatureError, "font encoding '#{encoding}' currently unsupported" if encoding.kind_of?(String) if params.class == String # translate the bytestram into a UTF-8 string. # If an encoding hasn't been specified, assume the text using this # font is in Adobe Standard Encoding. (encoding || PDF::Reader::Encoding::StandardEncoding.new).to_utf8(params, tounicode) elsif params.class == Array params.collect { |param| self.to_utf8(param) } else params end end |