Class: TTFunk::Table::Post
- Inherits:
-
TTFunk::Table
- Object
- TTFunk::Table
- TTFunk::Table::Post
- Defined in:
- lib/ttfunk/table/post.rb,
lib/ttfunk/table/post/format10.rb,
lib/ttfunk/table/post/format20.rb,
lib/ttfunk/table/post/format30.rb,
lib/ttfunk/table/post/format40.rb
Overview
PostScript (‘post`) table.
This class can be extended with version-specific modules.
Defined Under Namespace
Modules: Format10, Format20, Format30, Format40
Instance Attribute Summary collapse
-
#fixed_pitch ⇒ Integer
readonly
0 if the font is proportionally spaced, non-zero if the font is not proportionally spaced.
-
#format ⇒ Integer
readonly
Table version.
-
#italic_angle ⇒ Integer
readonly
Italic angle in counter-clockwise degrees from the vertical.
-
#max_mem_type1 ⇒ Integer
readonly
Maximum memory usage when an OpenType font is downloaded as a Type 1 font.
-
#max_mem_type42 ⇒ Integer
readonly
Maximum memory usage when an OpenType font is downloaded.
-
#min_mem_type1 ⇒ Integer
readonly
Minimum memory usage when an OpenType font is downloaded as a Type 1 font.
-
#min_mem_type42 ⇒ Integer
readonly
Minimum memory usage when an OpenType font is downloaded.
-
#subtable ⇒ TTFunk::Table::Post::Format10, ...
readonly
Version-specific fields.
-
#underline_position ⇒ Integer
readonly
Suggested distance of the top of the underline from the baseline.
-
#underline_thickness ⇒ Integer
readonly
Suggested values for the underline thickness.
Attributes inherited from TTFunk::Table
Class Method Summary collapse
-
.encode(post, mapping) ⇒ String?
Encode table.
Instance Method Summary collapse
-
#fixed_pitch? ⇒ Boolean
Is this font monospaced?.
-
#glyph_for(_code) ⇒ String
Get glyph name for character code.
-
#recode(mapping) ⇒ String
Re-encode this table.
Methods inherited from TTFunk::Table
#exists?, #initialize, #raw, #tag
Constructor Details
This class inherits a constructor from TTFunk::Table
Instance Attribute Details
#fixed_pitch ⇒ Integer (readonly)
0 if the font is proportionally spaced, non-zero if the font is not proportionally spaced.
35 36 37 |
# File 'lib/ttfunk/table/post.rb', line 35 def fixed_pitch @fixed_pitch end |
#format ⇒ Integer (readonly)
Table version.
18 19 20 |
# File 'lib/ttfunk/table/post.rb', line 18 def format @format end |
#italic_angle ⇒ Integer (readonly)
Italic angle in counter-clockwise degrees from the vertical.
22 23 24 |
# File 'lib/ttfunk/table/post.rb', line 22 def italic_angle @italic_angle end |
#max_mem_type1 ⇒ Integer (readonly)
Maximum memory usage when an OpenType font is downloaded as a Type 1 font.
53 54 55 |
# File 'lib/ttfunk/table/post.rb', line 53 def max_mem_type1 @max_mem_type1 end |
#max_mem_type42 ⇒ Integer (readonly)
Maximum memory usage when an OpenType font is downloaded.
43 44 45 |
# File 'lib/ttfunk/table/post.rb', line 43 def max_mem_type42 @max_mem_type42 end |
#min_mem_type1 ⇒ Integer (readonly)
Minimum memory usage when an OpenType font is downloaded as a Type 1 font.
48 49 50 |
# File 'lib/ttfunk/table/post.rb', line 48 def min_mem_type1 @min_mem_type1 end |
#min_mem_type42 ⇒ Integer (readonly)
Minimum memory usage when an OpenType font is downloaded.
39 40 41 |
# File 'lib/ttfunk/table/post.rb', line 39 def min_mem_type42 @min_mem_type42 end |
#subtable ⇒ TTFunk::Table::Post::Format10, ... (readonly)
Version-specific fields.
58 59 60 |
# File 'lib/ttfunk/table/post.rb', line 58 def subtable @subtable end |
#underline_position ⇒ Integer (readonly)
Suggested distance of the top of the underline from the baseline
26 27 28 |
# File 'lib/ttfunk/table/post.rb', line 26 def underline_position @underline_position end |
#underline_thickness ⇒ Integer (readonly)
Suggested values for the underline thickness.
30 31 32 |
# File 'lib/ttfunk/table/post.rb', line 30 def underline_thickness @underline_thickness end |
Class Method Details
.encode(post, mapping) ⇒ String?
Encode table.
66 67 68 69 70 |
# File 'lib/ttfunk/table/post.rb', line 66 def self.encode(post, mapping) return if post.nil? post.recode(mapping) end |
Instance Method Details
#fixed_pitch? ⇒ Boolean
Is this font monospaced?
75 76 77 |
# File 'lib/ttfunk/table/post.rb', line 75 def fixed_pitch? @fixed_pitch != 0 end |
#glyph_for(_code) ⇒ String
Get glyph name for character code.
This is a placeholder.
85 86 87 |
# File 'lib/ttfunk/table/post.rb', line 85 def glyph_for(_code) '.notdef' end |
#recode(mapping) ⇒ String
Re-encode this table.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ttfunk/table/post.rb', line 94 def recode(mapping) return raw if format == 0x00030000 table = raw[0, 32] table[0, 4] = [0x00020000].pack('N') index = [] strings = [] mapping.keys.sort.each do |new_id| post_glyph = glyph_for(mapping[new_id]) position = Format10::POSTSCRIPT_GLYPHS.index(post_glyph) if position index << position else index << (257 + strings.length) strings << post_glyph end end table << [mapping.length, *index].pack('n*') strings.each do |string| table << [string.length, string].pack('CA*') end table end |