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.
Source Code
35 | def fixed_pitch |
36 | @fixed_pitch
|
37 | end
|
#format ⇒ Integer (readonly)
Table version.
Source Code
18 | def format |
19 | @format
|
20 | end
|
#italic_angle ⇒ Integer (readonly)
Italic angle in counter-clockwise degrees from the vertical.
Source Code
22 | def italic_angle |
23 | @italic_angle
|
24 | end
|
#max_mem_type1 ⇒ Integer (readonly)
Maximum memory usage when an OpenType font is downloaded as a Type 1 font.
Source Code
53 | def max_mem_type1 |
54 | @max_mem_type1
|
55 | end
|
#max_mem_type42 ⇒ Integer (readonly)
Maximum memory usage when an OpenType font is downloaded.
Source Code
43 | def max_mem_type42 |
44 | @max_mem_type42
|
45 | end
|
#min_mem_type1 ⇒ Integer (readonly)
Minimum memory usage when an OpenType font is downloaded as a Type 1 font.
Source Code
48 | def min_mem_type1 |
49 | @min_mem_type1
|
50 | end
|
#min_mem_type42 ⇒ Integer (readonly)
Minimum memory usage when an OpenType font is downloaded.
Source Code
39 | def min_mem_type42 |
40 | @min_mem_type42
|
41 | end
|
#subtable ⇒ TTFunk::Table::Post::Format10, ... (readonly)
Version-specific fields.
Source Code
58 | def subtable |
59 | @subtable
|
60 | end
|
#underline_position ⇒ Integer (readonly)
Suggested distance of the top of the underline from the baseline
Source Code
26 | def underline_position |
27 | @underline_position
|
28 | end
|
#underline_thickness ⇒ Integer (readonly)
Suggested values for the underline thickness.
Source Code
30 | def underline_thickness |
31 | @underline_thickness
|
32 | end
|
Class Method Details
.encode(post, mapping) ⇒ String?
Encode table.
Source Code
66 | def self.encode(post, mapping) |
67 | return if post.nil? |
68 | |
69 | post.recode(mapping) |
70 | end
|
Instance Method Details
#fixed_pitch? ⇒ Boolean
Is this font monospaced?
Source Code
75 | def fixed_pitch? |
76 | @fixed_pitch != 0 |
77 | end
|
#glyph_for(_code) ⇒ String
Get glyph name for character code.
This is a placeholder.
Source Code
85 | def glyph_for(_code) |
86 | '.notdef'
|
87 | end
|
#recode(mapping) ⇒ String
Re-encode this table.
Source Code
94 | def recode(mapping) |
95 | return raw if format == 0x00030000 |
96 | |
97 | table = raw[0, 32] |
98 | table[0, 4] = [0x00020000].pack('N') |
99 | |
100 | index = [] |
101 | strings = [] |
102 | |
103 | mapping.keys.sort.each do |new_id| |
104 | post_glyph = glyph_for(mapping[new_id]) |
105 | position = Format10::POSTSCRIPT_GLYPHS.index(post_glyph) |
106 | if position |
107 | index << position |
108 | else
|
109 | index << (257 + strings.length) |
110 | strings << post_glyph |
111 | end
|
112 | end
|
113 | |
114 | table << [mapping.length, *index].pack('n*') |
115 | strings.each do |string| |
116 | table << [string.length, string].pack('CA*') |
117 | end
|
118 | |
119 | table
|
120 | end
|