Class: ChemScanner::ChemDraw::FontTable
- Defined in:
- lib/chem_scanner/chem_draw/node/font_table.rb
Overview
CDX Graphic parser
Constant Summary
Constants included from BaseValue
BaseValue::ARROW_NOGO_CROSS, BaseValue::CDXML_ARROW_TYPE, BaseValue::CDXML_ATOM_EXTERNAL_CONNECTION_TYPE, BaseValue::CDXML_CDX_POINT, BaseValue::CDXML_GRAPHIC_TYPE, BaseValue::CDXML_LINE_TYPE, BaseValue::CDXML_NODE_TYPE, BaseValue::CDXML_ORBITAL_TYPE, BaseValue::CDXML_OVAL_TYPE, BaseValue::TEXT_ATTRIBUTES
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Attributes inherited from BaseNode
#id, #parser, #parser_type, #polygon
Instance Method Summary collapse
-
#initialize(parser_type, data) ⇒ FontTable
constructor
A new instance of FontTable.
- #read ⇒ Object
- #read_cdx ⇒ Object
- #read_cdx_font_attribute(iter) ⇒ Object
- #read_cdxml ⇒ Object
Methods inherited from BaseNode
#assign_center, #bounding_box, #cdx_read, #cdxml_read, #center_x, #center_y, #get_tempid, #parse_node, #post_parse_node, #pre_parse_node, #set_cdx, #set_cdxml
Methods included from BaseValue
#binary_chunks, #cdx_styles, #cdx_text, #cdxml_text, #do_unhandled, #point_2d, #point_3d, #polygon_from_bb, #read_bounding_box, #read_ids, #read_int, #read_type, #read_value
Constructor Details
#initialize(parser_type, data) ⇒ FontTable
Returns a new instance of FontTable.
9 10 11 12 |
# File 'lib/chem_scanner/chem_draw/node/font_table.rb', line 9 def initialize(parser_type, data) @parser_type = parser_type @data = data end |
Instance Attribute Details
#table ⇒ Object (readonly)
Returns the value of attribute table.
7 8 9 |
# File 'lib/chem_scanner/chem_draw/node/font_table.rb', line 7 def table @table end |
Instance Method Details
#read ⇒ Object
14 15 16 |
# File 'lib/chem_scanner/chem_draw/node/font_table.rb', line 14 def read @parser_type == "cdx" ? read_cdx : read_cdxml end |
#read_cdx ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chem_scanner/chem_draw/node/font_table.rb', line 18 def read_cdx @table = [] run_count = read_int(@data[2, 2], true) iter = 4 (1..run_count).each do font, length = read_cdx_font_attribute(iter) @table.push(font) iter += 6 + length end @table end |
#read_cdx_font_attribute(iter) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/chem_scanner/chem_draw/node/font_table.rb', line 32 def read_cdx_font_attribute(iter) id = read_int(@data[iter, 2], true) charset = read_int(@data[iter + 2, 2], true) length = read_int(@data[iter + 4, 2], true) name = @data[iter + 6, length] [{ id: id, charset: charset, name: name }, length] end |
#read_cdxml ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/chem_scanner/chem_draw/node/font_table.rb', line 41 def read_cdxml @table = @data.element_children.each_with_object([]) do |font, table| next if font.name != "font" id = font.attr("id").to_i charset = font.attr("charset") name = font.attr("name") table.push(id: id, charset: charset, name: name) end end |