Class: HexaPDF::Font::Type1::FontMetrics
- Inherits:
-
Object
- Object
- HexaPDF::Font::Type1::FontMetrics
- Defined in:
- lib/hexapdf/font/type1/font_metrics.rb
Overview
Represents the information stored in an AFM font metrics file for a Type1 font that is needed for working with that font in context of the PDF format.
Constant Summary collapse
- WEIGHT_NAME_TO_NUMBER =
:nodoc:
{'Bold' => 700, 'Medium' => 500, 'Roman' => 400}.freeze
Instance Attribute Summary collapse
-
#ascender ⇒ Object
Ascender of the font.
-
#bounding_box ⇒ Object
The font bounding box as array of four numbers, specifying the x- and y-coordinates of the bottom-left corner and the x- and y-coordinates of the top-right corner.
-
#cap_height ⇒ Object
The y-value of the top of the capital H (or 0 or nil if the font doesn’t contain a capital H).
-
#character_metrics ⇒ Object
Mapping of character codes and names to CharacterMetrics objects.
-
#character_set ⇒ Object
A string describing the character set of the font.
-
#descender ⇒ Object
Descender of the font.
-
#dominant_horizontal_stem_width ⇒ Object
Dominant width of horizontal stems.
-
#dominant_vertical_stem_width ⇒ Object
Dominant width of vertical stems.
-
#encoding_scheme ⇒ Object
A string indicating the default encoding used for the font.
-
#family_name ⇒ Object
Name of the typeface family to which the font belongs.
-
#font_name ⇒ Object
PostScript name of the font.
-
#full_name ⇒ Object
Full text name of the font.
-
#is_fixed_pitch ⇒ Object
Boolean specifying if the font is a fixed pitch (monospaced) font.
-
#italic_angle ⇒ Object
Angle (in degrees counter-clockwise from the vertical) of the dominant vertical strokes of the font.
-
#kerning_pairs ⇒ Object
Nested mapping of kerning pairs, ie.
-
#ligature_pairs ⇒ Object
Nested mapping of ligature pairs, ie.
-
#underline_position ⇒ Object
Distance from the baseline for centering underlining strokes.
-
#underline_thickness ⇒ Object
Stroke width for underlining.
-
#weight ⇒ Object
A string describing the weight of the font.
-
#x_height ⇒ Object
The y-value of the top of the lowercase x (or 0 or nil if the font doesnt’ contain a lowercase x).
Instance Method Summary collapse
-
#initialize ⇒ FontMetrics
constructor
:nodoc:.
-
#weight_class ⇒ Object
Returns the weight of the font as a number.
Constructor Details
#initialize ⇒ FontMetrics
:nodoc:
113 114 115 116 117 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 113 def initialize #:nodoc: @character_metrics = {} @kerning_pairs = {} @ligature_pairs = {} end |
Instance Attribute Details
#ascender ⇒ Object
Ascender of the font.
78 79 80 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 78 def ascender @ascender end |
#bounding_box ⇒ Object
The font bounding box as array of four numbers, specifying the x- and y-coordinates of the bottom-left corner and the x- and y-coordinates of the top-right corner.
67 68 69 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 67 def bounding_box @bounding_box end |
#cap_height ⇒ Object
The y-value of the top of the capital H (or 0 or nil if the font doesn’t contain a capital H).
71 72 73 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 71 def cap_height @cap_height end |
#character_metrics ⇒ Object
Mapping of character codes and names to CharacterMetrics objects.
103 104 105 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 103 def character_metrics @character_metrics end |
#character_set ⇒ Object
A string describing the character set of the font.
57 58 59 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 57 def character_set @character_set end |
#descender ⇒ Object
Descender of the font.
81 82 83 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 81 def descender @descender end |
#dominant_horizontal_stem_width ⇒ Object
Dominant width of horizontal stems.
84 85 86 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 84 def dominant_horizontal_stem_width @dominant_horizontal_stem_width end |
#dominant_vertical_stem_width ⇒ Object
Dominant width of vertical stems.
87 88 89 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 87 def dominant_vertical_stem_width @dominant_vertical_stem_width end |
#encoding_scheme ⇒ Object
A string indicating the default encoding used for the font.
60 61 62 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 60 def encoding_scheme @encoding_scheme end |
#family_name ⇒ Object
Name of the typeface family to which the font belongs.
54 55 56 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 54 def family_name @family_name end |
#font_name ⇒ Object
PostScript name of the font.
48 49 50 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 48 def font_name @font_name end |
#full_name ⇒ Object
Full text name of the font.
51 52 53 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 51 def full_name @full_name end |
#is_fixed_pitch ⇒ Object
Boolean specifying if the font is a fixed pitch (monospaced) font.
100 101 102 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 100 def is_fixed_pitch @is_fixed_pitch end |
#italic_angle ⇒ Object
Angle (in degrees counter-clockwise from the vertical) of the dominant vertical strokes of the font.
97 98 99 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 97 def italic_angle @italic_angle end |
#kerning_pairs ⇒ Object
Nested mapping of kerning pairs, ie. each key is a character name and each value is a mapping from the second character name to the kerning amount.
107 108 109 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 107 def kerning_pairs @kerning_pairs end |
#ligature_pairs ⇒ Object
Nested mapping of ligature pairs, ie. each key is a character name and each value is a mapping from the second character name to the ligature name.
111 112 113 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 111 def ligature_pairs @ligature_pairs end |
#underline_position ⇒ Object
Distance from the baseline for centering underlining strokes.
90 91 92 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 90 def underline_position @underline_position end |
#underline_thickness ⇒ Object
Stroke width for underlining.
93 94 95 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 93 def underline_thickness @underline_thickness end |
#weight ⇒ Object
A string describing the weight of the font.
63 64 65 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 63 def weight @weight end |
#x_height ⇒ Object
The y-value of the top of the lowercase x (or 0 or nil if the font doesnt’ contain a lowercase x)
75 76 77 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 75 def x_height @x_height end |
Instance Method Details
#weight_class ⇒ Object
Returns the weight of the font as a number.
The return value 0 is used if the weight class cannot be determined.
124 125 126 |
# File 'lib/hexapdf/font/type1/font_metrics.rb', line 124 def weight_class WEIGHT_NAME_TO_NUMBER.fetch(weight, 0) end |