Class: DynamicPDFApi::Font
- Inherits:
-
Object
- Object
- DynamicPDFApi::Font
- Defined in:
- lib/ruby_client/Font.rb
Overview
Represents font.
Constant Summary collapse
- @@times_roman =
nil
- @@times_bold =
nil
- @@times_italic =
nil
- @@times_bold_italic =
nil
- @@helvetica =
nil
- @@helvetica_bold =
nil
- @@helvetica_oblique =
nil
- @@helvetica_boldOblique =
nil
- @@courier =
nil
- @@courier_bold =
nil
- @@courier_oblique =
nil
- @@courier_boldOblique =
nil
- @@symbol =
nil
- @@zapf_dingbats =
nil
Instance Attribute Summary collapse
-
#_name ⇒ Object
Returns the value of attribute _name.
-
#_resource ⇒ Object
Returns the value of attribute _resource.
-
#embed ⇒ Object
Gets or sets a boolean indicating whether to embed the font.
-
#resource_name ⇒ Object
Gets or sets a name for the font resource.
-
#subset ⇒ Object
Gets or sets a boolean indicating whether to subset embed the font.
Class Method Summary collapse
-
.courier ⇒ Object
Gets the Courier core font with Latin 1 encoding.
-
.courier_bold ⇒ Object
Gets the Courier Bold core font with Latin 1 encoding.
-
.courier_bold_oblique ⇒ Object
Gets the Courier Bold Oblique core font with Latin 1 encoding.
-
.courier_oblique ⇒ Object
Gets the Courier Oblique core font with Latin 1 encoding.
- .create_font(font_resource = nil, resource_name = nil) ⇒ Object
-
.from_file(file_path, resource_name = nil) ⇒ Object
Initializes a new instance of the Font class using the file path of the font and resource name.
- .from_stream(_stream, _resource_name = nil) ⇒ Object
- .get_google_font_text(name, weight, italic) ⇒ Object
-
.global(font_name) ⇒ Object
Gets the font from the global storage.
-
.google(font_name, bold = nil, italic = false) ⇒ Object
Gets the font from the google.
-
.helvetica ⇒ Object
Gets the Helvetica core font with Latin 1 encoding.
-
.helvetica_bold ⇒ Object
Gets the Helvetica Bold core font with Latin 1 encoding.
-
.helvetica_bold_oblique ⇒ Object
Gets the Helvetica Bold Oblique core font with Latin 1 encoding.
-
.helvetica_oblique ⇒ Object
Gets the Helvetica Oblique core font with Latin 1 encoding.
-
.symbol ⇒ Object
Gets the Symbol core font.
-
.times_bold ⇒ Object
Gets the Times Bold core font with Latin 1 encoding.
-
.times_bold_italic ⇒ Object
Gets the Times Bold Italic core font with Latin 1 encoding.
-
.times_italic ⇒ Object
Gets the Times Italic core font with Latin 1 encoding.
-
.times_roman ⇒ Object
Gets the Times Roman core font with Latin 1 encoding.
-
.zapf_dingbats ⇒ Object
Gets the Zapf Dingbats core font.
Instance Method Summary collapse
-
#initialize(cloud_resource_name = nil) ⇒ Font
constructor
Initializes a new instance of the Font class using the font name that is present in the cloud resource manager.
- #to_json(_options = {}) ⇒ Object
Constructor Details
#initialize(cloud_resource_name = nil) ⇒ Font
Initializes a new instance of the Font class using the font name that is present in the cloud resource manager.
14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_client/Font.rb', line 14 def initialize(cloud_resource_name = nil) @data = {} @_resource = nil @embed = nil @subset = nil @resource_name = cloud_resource_name @_name = SecureRandom.uuid end |
Instance Attribute Details
#_name ⇒ Object
Returns the value of attribute _name.
33 34 35 |
# File 'lib/ruby_client/Font.rb', line 33 def _name @_name end |
#_resource ⇒ Object
Returns the value of attribute _resource.
33 34 35 |
# File 'lib/ruby_client/Font.rb', line 33 def _resource @_resource end |
#embed ⇒ Object
Gets or sets a boolean indicating whether to embed the font.
38 39 40 |
# File 'lib/ruby_client/Font.rb', line 38 def @embed end |
#resource_name ⇒ Object
Gets or sets a name for the font resource.
48 49 50 |
# File 'lib/ruby_client/Font.rb', line 48 def resource_name @resource_name end |
#subset ⇒ Object
Gets or sets a boolean indicating whether to subset embed the font.
43 44 45 |
# File 'lib/ruby_client/Font.rb', line 43 def subset @subset end |
Class Method Details
.courier ⇒ Object
Gets the Courier core font with Latin 1 encoding.
133 134 135 136 137 138 |
# File 'lib/ruby_client/Font.rb', line 133 def self.courier @@courier = Font.new if @@courier.nil? @@courier._name = "courier" @@courier end |
.courier_bold ⇒ Object
Gets the Courier Bold core font with Latin 1 encoding.
143 144 145 146 147 148 |
# File 'lib/ruby_client/Font.rb', line 143 def self.courier_bold @@courier_bold = Font.new if @@courier_bold.nil? @@courier_bold._name = "courierBold" @@courier_bold end |
.courier_bold_oblique ⇒ Object
Gets the Courier Bold Oblique core font with Latin 1 encoding.
163 164 165 166 167 168 |
# File 'lib/ruby_client/Font.rb', line 163 def self.courier_bold_oblique @@courier_boldOblique = Font.new if @@courier_boldOblique.nil? @@courier_boldOblique._name = "courierBoldOblique" @@courier_boldOblique end |
.courier_oblique ⇒ Object
Gets the Courier Oblique core font with Latin 1 encoding.
153 154 155 156 157 158 |
# File 'lib/ruby_client/Font.rb', line 153 def self.courier_oblique @@courier_oblique = Font.new if @@courier_oblique.nil? @@courier_oblique._name = "courierOblique" @@courier_oblique end |
.create_font(font_resource = nil, resource_name = nil) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/ruby_client/Font.rb', line 24 def self.create_font(font_resource = nil, resource_name = nil) font = Font.new font._resource = font_resource font.resource_name = resource_name font._name = SecureRandom.uuid font end |
.from_file(file_path, resource_name = nil) ⇒ Object
Initializes a new instance of the Font class using the file path of the font and resource name.
196 197 198 199 |
# File 'lib/ruby_client/Font.rb', line 196 def self.from_file(file_path, resource_name = nil) resource = Resource.new(file_path, resource_name) Font.create_font(resource, resource.resource_name) end |
.from_stream(_stream, _resource_name = nil) ⇒ Object
201 202 203 204 |
# File 'lib/ruby_client/Font.rb', line 201 def self.from_stream(_stream, _resource_name = nil) resource = Resource.new(stream, resource_name) Font.create_font(resource, resource.resource_name) end |
.get_google_font_text(name, weight, italic) ⇒ Object
206 207 208 209 210 211 212 |
# File 'lib/ruby_client/Font.rb', line 206 def self.get_google_font_text(name, weight, italic) if italic == true name + ":" + weight.to_s + "italic" else name + ":" + weight.to_s end end |
.global(font_name) ⇒ Object
Gets the font from the global storage.
242 243 244 245 246 |
# File 'lib/ruby_client/Font.rb', line 242 def self.global(font_name) font = Font.new() font._name = font_name font end |
.google(font_name, bold = nil, italic = false) ⇒ Object
Gets the font from the google.
222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/ruby_client/Font.rb', line 222 def self.google(font_name, bold = nil, italic = false) font = Font.new() if bold == true font._name = Font.get_google_font_text(font_name, 700, italic) elsif (bold.is_a?(Integer) == true) font._name = Font.get_google_font_text(font_name, bold, italic); elsif bold == false font._name = Font.get_google_font_text(font_name, 400, italic); else font._name = font_name; end font end |
.helvetica ⇒ Object
Gets the Helvetica core font with Latin 1 encoding.
93 94 95 96 97 98 |
# File 'lib/ruby_client/Font.rb', line 93 def self.helvetica @@helvetica = Font.new if @@helvetica.nil? @@helvetica._name = "helvetica" @@helvetica end |
.helvetica_bold ⇒ Object
Gets the Helvetica Bold core font with Latin 1 encoding.
103 104 105 106 107 108 |
# File 'lib/ruby_client/Font.rb', line 103 def self.helvetica_bold @@helvetica_bold = Font.new if @@helvetica_bold.nil? @@helvetica_bold._name = "helveticaBold" @@helvetica_bold end |
.helvetica_bold_oblique ⇒ Object
Gets the Helvetica Bold Oblique core font with Latin 1 encoding.
123 124 125 126 127 128 |
# File 'lib/ruby_client/Font.rb', line 123 def self.helvetica_bold_oblique @@helvetica_boldOblique = Font.new if @@helvetica_boldOblique.nil? @@helvetica_boldOblique._name = "helveticaBoldOblique" @@helvetica_boldOblique end |
.helvetica_oblique ⇒ Object
Gets the Helvetica Oblique core font with Latin 1 encoding.
113 114 115 116 117 118 |
# File 'lib/ruby_client/Font.rb', line 113 def self.helvetica_oblique @@helvetica_oblique = Font.new if @@helvetica_oblique.nil? @@helvetica_oblique._name = "helveticaOblique" @@helvetica_oblique end |
.symbol ⇒ Object
Gets the Symbol core font.
173 174 175 176 177 178 |
# File 'lib/ruby_client/Font.rb', line 173 def self.symbol @@symbol = Font.new if @@symbol.nil? @@symbol._name = "symbol" @@symbol end |
.times_bold ⇒ Object
Gets the Times Bold core font with Latin 1 encoding.
63 64 65 66 67 68 |
# File 'lib/ruby_client/Font.rb', line 63 def self.times_bold @@times_bold = Font.new if @@times_bold.nil? @@times_bold._name = "timesBold" @@times_bold end |
.times_bold_italic ⇒ Object
Gets the Times Bold Italic core font with Latin 1 encoding.
83 84 85 86 87 88 |
# File 'lib/ruby_client/Font.rb', line 83 def self.times_bold_italic @@times_bold_italic = Font.new if @@times_bold_italic.nil? @@times_bold_italic._name = "timesBoldItalic" @@times_bold_italic end |
.times_italic ⇒ Object
Gets the Times Italic core font with Latin 1 encoding.
73 74 75 76 77 78 |
# File 'lib/ruby_client/Font.rb', line 73 def self.times_italic @@times_italic = Font.new if @@times_italic.nil? @@times_italic._name = "timesItalic" @@times_italic end |
Instance Method Details
#to_json(_options = {}) ⇒ Object
248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/ruby_client/Font.rb', line 248 def to_json( = {}) json_array = {} json_array["name"] = @_name unless @_name.nil? json_array["embed"] = @embed unless @embed.nil? json_array["subset"] = @subset unless @subset.nil? json_array["resourceName"] = @resource_name unless @resource_name.nil? JSON.pretty_generate(json_array) end |