mathtype 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +7 -0
  4. data/Rakefile +8 -0
  5. data/lib/file_parser/ole.rb +15 -0
  6. data/lib/file_parser/parser.rb +19 -0
  7. data/lib/file_parser/wmf.rb +28 -0
  8. data/lib/mathtype.rb +30 -7
  9. data/lib/mathtype/version.rb +1 -1
  10. data/lib/records/bintypes.rb +18 -0
  11. data/lib/records/mtef.rb +8 -114
  12. data/lib/records/nudge.rb +9 -5
  13. data/lib/records/ruler.rb +1 -1
  14. data/lib/records/typesizes.rb +5 -10
  15. data/lib/records3/char.rb +53 -0
  16. data/lib/records3/embell.rb +109 -0
  17. data/lib/records3/font.rb +27 -0
  18. data/lib/records3/line.rb +47 -0
  19. data/lib/records3/matrix.rb +80 -0
  20. data/lib/records3/mtef.rb +97 -0
  21. data/lib/records3/options.rb +5 -0
  22. data/lib/records3/pile.rb +43 -0
  23. data/lib/records3/size.rb +75 -0
  24. data/lib/records3/snapshot.rb +19 -0
  25. data/lib/records3/tmpl.rb +751 -0
  26. data/lib/{records → records5}/char.rb +6 -12
  27. data/lib/{records → records5}/color.rb +1 -1
  28. data/lib/{records → records5}/color_def.rb +8 -8
  29. data/lib/{records → records5}/embell.rb +2 -2
  30. data/lib/{records → records5}/encoding_def.rb +1 -1
  31. data/lib/{records → records5}/eqn_prefs.rb +2 -2
  32. data/lib/{records → records5}/font_def.rb +1 -1
  33. data/lib/{records → records5}/font_style_def.rb +1 -1
  34. data/lib/{records → records5}/future.rb +1 -1
  35. data/lib/{records → records5}/line.rb +3 -3
  36. data/lib/{records → records5}/matrix.rb +11 -3
  37. data/lib/records5/mtef.rb +129 -0
  38. data/lib/{records → records5}/pile.rb +2 -2
  39. data/lib/{records → records5}/size.rb +9 -7
  40. data/lib/records5/snapshot.rb +19 -0
  41. data/lib/{records → records5}/tmpl.rb +2 -2
  42. data/spec/fixtures/expected/mathtype3/ceil.xml +38 -0
  43. data/spec/fixtures/expected/mathtype3/fence.xml +77 -0
  44. data/spec/fixtures/expected/mathtype3/floor.xml +38 -0
  45. data/spec/fixtures/expected/mathtype3/frac.xml +136 -0
  46. data/spec/fixtures/expected/mathtype3/large_nudge.xml +135 -0
  47. data/spec/fixtures/expected/mathtype3/lim_embell.xml +247 -0
  48. data/spec/fixtures/expected/mathtype3/matrix_2x1.xml +500 -0
  49. data/spec/fixtures/expected/mathtype3/pile.xml +188 -0
  50. data/spec/fixtures/expected/mathtype3/sigma_subsup.xml +46 -0
  51. data/spec/fixtures/expected/mathtype3/small_nudge.xml +90 -0
  52. data/spec/fixtures/expected/mathtype3/sqrt.xml +132 -0
  53. data/spec/fixtures/expected/{299.xml → mathtype5/299.xml} +30 -15
  54. data/spec/fixtures/expected/{arrows.xml → mathtype5/arrows.xml} +30 -15
  55. data/spec/fixtures/expected/{embedded.xml → mathtype5/embedded.xml} +29 -14
  56. data/spec/fixtures/expected/{embellishments.xml → mathtype5/embellishments.xml} +30 -15
  57. data/spec/fixtures/expected/{equation1.xml → mathtype5/equation1.xml} +30 -15
  58. data/spec/fixtures/expected/{equation10.xml → mathtype5/equation10.xml} +30 -15
  59. data/spec/fixtures/expected/{equation11.xml → mathtype5/equation11.xml} +30 -15
  60. data/spec/fixtures/expected/{equation12.xml → mathtype5/equation12.xml} +30 -15
  61. data/spec/fixtures/expected/{equation13.xml → mathtype5/equation13.xml} +30 -15
  62. data/spec/fixtures/expected/{equation2.xml → mathtype5/equation2.xml} +30 -15
  63. data/spec/fixtures/expected/{equation3.xml → mathtype5/equation3.xml} +30 -15
  64. data/spec/fixtures/expected/{equation4.xml → mathtype5/equation4.xml} +30 -15
  65. data/spec/fixtures/expected/{equation5.xml → mathtype5/equation5.xml} +30 -15
  66. data/spec/fixtures/expected/{equation6.xml → mathtype5/equation6.xml} +30 -15
  67. data/spec/fixtures/expected/{equation7.xml → mathtype5/equation7.xml} +30 -15
  68. data/spec/fixtures/expected/{equation8.xml → mathtype5/equation8.xml} +30 -15
  69. data/spec/fixtures/expected/{equation9.xml → mathtype5/equation9.xml} +30 -15
  70. data/spec/fixtures/expected/{fences.xml → mathtype5/fences.xml} +30 -15
  71. data/spec/fixtures/expected/{integrals.xml → mathtype5/integrals.xml} +30 -15
  72. data/spec/fixtures/expected/mathtype5/matrix-border.xml +365 -0
  73. data/spec/fixtures/expected/mathtype5/matrix.xml +382 -0
  74. data/spec/fixtures/expected/{sizes.xml → mathtype5/sizes.xml} +30 -15
  75. data/spec/fixtures/input/mathtype3/ceil.bin +0 -0
  76. data/spec/fixtures/input/mathtype3/fence.bin +0 -0
  77. data/spec/fixtures/input/mathtype3/floor.bin +0 -0
  78. data/spec/fixtures/input/mathtype3/frac.bin +0 -0
  79. data/spec/fixtures/input/mathtype3/large_nudge.bin +0 -0
  80. data/spec/fixtures/input/mathtype3/lim_embell.bin +0 -0
  81. data/spec/fixtures/input/mathtype3/matrix_2x1.bin +0 -0
  82. data/spec/fixtures/input/mathtype3/pile.bin +0 -0
  83. data/spec/fixtures/input/mathtype3/sigma_subsup.bin +0 -0
  84. data/spec/fixtures/input/mathtype3/small_nudge.bin +0 -0
  85. data/spec/fixtures/input/mathtype3/sqrt.bin +0 -0
  86. data/spec/fixtures/input/{299.bin → mathtype5/299.bin} +0 -0
  87. data/spec/fixtures/input/{arrows.bin → mathtype5/arrows.bin} +0 -0
  88. data/spec/fixtures/input/{embedded.bin → mathtype5/embedded.bin} +0 -0
  89. data/spec/fixtures/input/{embellishments.bin → mathtype5/embellishments.bin} +0 -0
  90. data/spec/fixtures/input/{equation1.bin → mathtype5/equation1.bin} +0 -0
  91. data/spec/fixtures/input/{equation10.bin → mathtype5/equation10.bin} +0 -0
  92. data/spec/fixtures/input/{equation11.bin → mathtype5/equation11.bin} +0 -0
  93. data/spec/fixtures/input/{equation12.bin → mathtype5/equation12.bin} +0 -0
  94. data/spec/fixtures/input/{equation13.bin → mathtype5/equation13.bin} +0 -0
  95. data/spec/fixtures/input/{equation2.bin → mathtype5/equation2.bin} +0 -0
  96. data/spec/fixtures/input/{equation3.bin → mathtype5/equation3.bin} +0 -0
  97. data/spec/fixtures/input/{equation4.bin → mathtype5/equation4.bin} +0 -0
  98. data/spec/fixtures/input/{equation5.bin → mathtype5/equation5.bin} +0 -0
  99. data/spec/fixtures/input/{equation6.bin → mathtype5/equation6.bin} +0 -0
  100. data/spec/fixtures/input/{equation7.bin → mathtype5/equation7.bin} +0 -0
  101. data/spec/fixtures/input/{equation8.bin → mathtype5/equation8.bin} +0 -0
  102. data/spec/fixtures/input/{equation9.bin → mathtype5/equation9.bin} +0 -0
  103. data/spec/fixtures/input/{fences.bin → mathtype5/fences.bin} +0 -0
  104. data/spec/fixtures/input/{integrals.bin → mathtype5/integrals.bin} +0 -0
  105. data/spec/fixtures/input/mathtype5/matrix-border.bin +0 -0
  106. data/spec/fixtures/input/mathtype5/matrix.bin +0 -0
  107. data/spec/fixtures/input/{sizes.bin → mathtype5/sizes.bin} +0 -0
  108. data/spec/mathtype_spec.rb +11 -9
  109. data/test-mathtype.rb +2 -0
  110. metadata +168 -97
@@ -14,7 +14,7 @@
14
14
 
15
15
  require_relative "snapshot"
16
16
 
17
- module Mathtype
17
+ module Mathtype5
18
18
  class RecordEmbell < BinData::Record; end
19
19
  class RecordChar < BinData::Record
20
20
  include Snapshot
@@ -24,11 +24,11 @@ module Mathtype
24
24
  endian :little
25
25
  int8 :options
26
26
 
27
- nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
27
+ record_nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
28
28
 
29
29
  int8 :_typeface
30
30
 
31
- int16 :_mt_code_value, onlyif: (lambda do
31
+ mtef16 :_mt_code_value, onlyif: (lambda do
32
32
  options & OPTIONS["mtefOPT_CHAR_ENC_NO_MTCODE"] == 0
33
33
  end)
34
34
 
@@ -47,7 +47,7 @@ module Mathtype
47
47
  char_enc_char_8 = options & OPTIONS["mtefOPT_CHAR_ENC_CHAR_8"] > 0
48
48
  char_enc_char_16 = options & OPTIONS["mtefOPT_CHAR_ENC_CHAR_16"] > 0
49
49
 
50
- return true if char_enc_char_8 || char_enc_char_16
50
+ char_enc_char_8 || char_enc_char_16
51
51
  end
52
52
 
53
53
  choice :font_position,
@@ -55,7 +55,7 @@ module Mathtype
55
55
  onlyif: font_position_present do
56
56
 
57
57
  uint8 8
58
- uint16 16
58
+ mtef16 16
59
59
  end
60
60
 
61
61
  array :embellishment_list,
@@ -65,13 +65,7 @@ module Mathtype
65
65
  end
66
66
 
67
67
  def mt_code_value
68
- mt_code = if _mt_code_value < 0
69
- 65536 + _mt_code_value # Two's complement
70
- else
71
- _mt_code_value
72
- end
73
-
74
- sprintf("0x%04X", mt_code)
68
+ sprintf("0x%04X", _mt_code_value)
75
69
  end
76
70
 
77
71
  def typeface
@@ -6,7 +6,7 @@
6
6
  # equation records (until the next COLOR record) have the color defined by the
7
7
  # indicated COLOR_DEF record.
8
8
 
9
- module Mathtype
9
+ module Mathtype5
10
10
  class RecordColor < BinData::Record
11
11
  int8 :color_def_index
12
12
  end
@@ -11,23 +11,23 @@
11
11
  # absence of the color and 1000 is a fully saturated color. So, an RGB color
12
12
  # definition for black has all three components at 0.
13
13
 
14
- module Mathtype
14
+ module Mathtype5
15
15
  class RecordColorDef < BinData::Record
16
16
  endian :little
17
17
 
18
18
  int8 :options
19
19
 
20
20
  struct :rgb, onlyif: lambda { options & OPTIONS["mtefCOLOR_CMYK"] == 0 } do
21
- int16 :r
22
- int16 :g
23
- int16 :b
21
+ mtef16 :r
22
+ mtef16 :g
23
+ mtef16 :b
24
24
  end
25
25
 
26
26
  struct :cmyk, onlyif: lambda { options & OPTIONS["mtefCOLOR_CMYK"] > 0} do
27
- int16 :c
28
- int16 :m
29
- int16 :y
30
- int16 :k
27
+ mtef16 :c
28
+ mtef16 :m
29
+ mtef16 :y
30
+ mtef16 :k
31
31
  end
32
32
 
33
33
  stringz :color_name, onlyif: (lambda do
@@ -46,7 +46,7 @@ require_relative "snapshot"
46
46
  # 36 embU_R1ARROW under right arrow (1 barb)
47
47
  # 37 embU_L1ARROW under left arrow (1 barb)
48
48
 
49
- module Mathtype
49
+ module Mathtype5
50
50
  class RecordEmbell < BinData::Record
51
51
  include Snapshot
52
52
  EXPOSED_IN_SNAPSHOT = %i(options nudge embell)
@@ -92,7 +92,7 @@ module Mathtype
92
92
 
93
93
  int8 :options
94
94
 
95
- nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
95
+ record_nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
96
96
 
97
97
  int8 :_embell
98
98
 
@@ -15,7 +15,7 @@
15
15
  # to have an index of 5. See Extending MathType's Font and Character Information
16
16
  # and MathType's Character Encodings for more information on font encodings.
17
17
 
18
- module Mathtype
18
+ module Mathtype5
19
19
  class RecordEncodingDef < BinData::Record
20
20
  stringz :name
21
21
  end
@@ -13,13 +13,12 @@
13
13
  # If the array is longer than expected, the extra values must be skipped to stay
14
14
  # in sync with the MTEF stream.
15
15
 
16
- module Mathtype
16
+ module Mathtype5
17
17
  class Entry < BinData::Record
18
18
  bit4 :unit
19
19
  array :nibbles, read_until: lambda { element == 0xF } do
20
20
  bit4
21
21
  end
22
- resume_byte_alignment
23
22
  end
24
23
 
25
24
  class RecordEqnPrefs < BinData::Record
@@ -40,5 +39,6 @@ module Mathtype
40
39
  int8 :font_def
41
40
  int8 :font_style, onlyif: lambda { font_def != 0x00 }
42
41
  end
42
+ resume_byte_alignment
43
43
  end
44
44
  end
@@ -6,7 +6,7 @@
6
6
  # This record associates an font encoding with a font name. See Definition
7
7
  # records.
8
8
 
9
- module Mathtype
9
+ module Mathtype5
10
10
  class RecordFontDef < BinData::Record
11
11
  uint8 :enc_def_index
12
12
  stringz :font_name
@@ -5,7 +5,7 @@
5
5
  # [char_style] character style bits
6
6
  # This record associates a character style with a font. See Definition records.
7
7
 
8
- module Mathtype
8
+ module Mathtype5
9
9
  class RecordFontStyleDef < BinData::Record
10
10
  uint8 :font_def_index
11
11
 
@@ -6,7 +6,7 @@
6
6
  # might be handy if all records had such a length value, it will only be present
7
7
  # on future expansion records (i.e. those with record types >= 100).
8
8
 
9
- module Mathtype
9
+ module Mathtype5
10
10
  class RecordFuture < BinData::Record
11
11
  uint8 :skip
12
12
  skip length: :skip
@@ -9,15 +9,15 @@
9
9
  # The line spacing value, if present, is the distance between the baseline of
10
10
  # this line and the line above it.
11
11
 
12
- module Mathtype
12
+ module Mathtype5
13
13
  class NamedRecord < BinData::Record; end
14
14
  class RecordLine < BinData::Record
15
15
  endian :little
16
16
  int8 :options
17
17
 
18
- nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
18
+ record_nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
19
19
 
20
- int16 :line_spacing, onlyif: (lambda do
20
+ mtef16 :line_spacing, onlyif: (lambda do
21
21
  options & OPTIONS["mtefOPT_LINE_LSPACE"] > 0
22
22
  end)
23
23
 
@@ -21,14 +21,14 @@ require_relative "snapshot"
21
21
  # (0 for none, 1 for solid, 2 for dashed, or 3 for dotted). Similarly for the
22
22
  # column partition lines.
23
23
 
24
- module Mathtype
24
+ module Mathtype5
25
25
  class RecordMatrix < BinData::Record
26
26
  include Snapshot
27
27
  EXPOSED_IN_SNAPSHOT = %i(options nudge valign h_just v_just rows cols
28
28
  row_parts col_parts object_list)
29
29
  int8 :options
30
30
 
31
- nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
31
+ record_nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
32
32
 
33
33
  int8 :_valign
34
34
  int8 :_h_just
@@ -36,10 +36,14 @@ module Mathtype
36
36
  int8 :rows
37
37
  int8 :cols
38
38
 
39
+ bit :_realign_rows, nbits: lambda { realign(rows) }
40
+
39
41
  array :row_parts, initial_length: lambda { rows + 1 } do
40
42
  bit nbits: 2
41
43
  end
42
44
 
45
+ bit :_realign_cols, nbits: lambda { realign(cols) }
46
+
43
47
  array :col_parts, initial_length: lambda { cols + 1 } do
44
48
  bit nbits: 2
45
49
  end
@@ -53,11 +57,15 @@ module Mathtype
53
57
  end
54
58
 
55
59
  def h_just
56
- HALIGN[_h_just + 1]
60
+ HALIGN[_h_just]
57
61
  end
58
62
 
59
63
  def v_just
60
64
  VALIGN[_v_just]
61
65
  end
66
+ def realign (nparts)
67
+ offset = (((nparts + 1) * 2) % 8)
68
+ return offset == 0 ? 0 : (8 - offset)
69
+ end
62
70
  end
63
71
  end
@@ -0,0 +1,129 @@
1
+ require_relative "line"
2
+ require_relative "embell"
3
+ require_relative "char"
4
+ require_relative "pile"
5
+ require_relative "tmpl"
6
+ require_relative "eqn_prefs"
7
+ require_relative "font_def"
8
+ require_relative "font_style_def"
9
+ require_relative "matrix"
10
+ require_relative "encoding_def"
11
+ require_relative "embell"
12
+ require_relative "size"
13
+ require_relative "color"
14
+ require_relative "color_def"
15
+ require_relative "future"
16
+
17
+ module Mathtype5
18
+ class RecordEnd < Mathtype::RecordEnd; end
19
+ class RecordNudge < Mathtype::RecordNudge; end
20
+ class RecordRuler < Mathtype::RecordRuler; end
21
+ class RecordNudge < Mathtype::RecordNudge; end
22
+ class RecordFull < Mathtype::RecordFull; end
23
+ class RecordSub < Mathtype::RecordSub; end
24
+ class RecordSub2 < Mathtype::RecordSub2; end
25
+ class RecordSym < Mathtype::RecordSym; end
26
+ class RecordSubsym < Mathtype::RecordSubsym; end
27
+
28
+ HALIGN = Mathtype::HALIGN
29
+ VALIGN = Mathtype::VALIGN
30
+
31
+ RECORD_NAMES = {
32
+ 0 => "end",
33
+ 1 => "slot",
34
+ 2 => "char",
35
+ 3 => "tmpl",
36
+ 4 => "pile",
37
+ 5 => "matrix",
38
+ 6 => "embell",
39
+ 7 => "ruler",
40
+ 8 => "font_style_def",
41
+ 9 => "size",
42
+ 10 => "full",
43
+ 11 => "sub",
44
+ 12 => "sub2",
45
+ 13 => "sym",
46
+ 14 => "subsym",
47
+ 15 => "color",
48
+ 16 => "color_def",
49
+ 17 => "font_def",
50
+ 18 => "eqn_prefs",
51
+ 19 => "encoding_def",
52
+ 100 => "future"
53
+ }
54
+
55
+ OPTIONS = {
56
+ # value => symbol # description
57
+ # Option flag values for all equation structure records:
58
+ "mtefOPT_NUDGE" => 0x08, # nudge values follow tag
59
+ # Option flag values for CHAR records:
60
+ "mtefOPT_CHAR_EMBELL" => 0x01, # character is followed by an embellishment list
61
+ "mtefOPT_CHAR_FUNC_START" => 0x02, # character starts a function (sin, cos, etc.)
62
+ "mtefOPT_CHAR_ENC_CHAR_8" => 0x04, # character is written with an 8-bit encoded value
63
+ "mtefOPT_CHAR_ENC_CHAR_16" => 0x10, # character is written with an 16-bit encoded value
64
+ "mtefOPT_CHAR_ENC_NO_MTCODE" => 0x20, # character is written without an 16-bit MTCode value
65
+ # Option flag values for LINE records:
66
+ "mtefOPT_LINE_NULL" => 0x01, # line is a placeholder only (i.e. not displayed)
67
+ "mtefOPT_LINE_LSPACE" => 0x04, # line spacing value follows tag
68
+ # Option flag values for LINE and PILE records:
69
+ "mtefOPT_LP_RULER" => 0x02, # RULER record follows LINE or PILE record
70
+ # Option flag values for COLOR_DEF records:
71
+ "mtefCOLOR_CMYK" => 0x01, # color model is CMYK, else RGB
72
+ "mtefCOLOR_SPOT" => 0x02, # color is a spot color, else a process color
73
+ "mtefCOLOR_NAME" => 0x04, # color has a name, else no name
74
+ }
75
+
76
+ ## Payload is the most important class to understand.
77
+ ## This abstraction allows recursive formats.
78
+ ## eg. lists can contain lists can contain lists.
79
+
80
+ class Payload < BinData::Choice
81
+ opt = {:_options => :options}
82
+ record_end 0 # end is a reserved keyword
83
+ record_line 1
84
+ record_char 2
85
+ record_tmpl 3
86
+ record_pile 4
87
+ record_matrix 5
88
+ record_embell 6
89
+ record_ruler 7
90
+ record_font_style_def 8
91
+ record_size 9
92
+ record_full 10
93
+ record_sub 11
94
+ record_sub2 12
95
+ record_sym 13
96
+ record_subsym 14
97
+ record_color 15
98
+ record_color_def 16
99
+ record_font_def 17
100
+ record_eqn_prefs 18
101
+ record_encoding_def 19
102
+ record_future 100
103
+ end
104
+
105
+ class NamedRecord < BinData::Record
106
+ int8 :record_type
107
+ payload :payload, :onlyif => :not_end_tag?, :selection => :record_type, :options => :record_options
108
+
109
+ def not_end_tag?
110
+ record_type != 0
111
+ end
112
+ end
113
+
114
+ class Equation < Mathtype::Equation
115
+ EXPOSED_IN_SNAPSHOT = %i(mtef_version platform product product_version
116
+ product_subversion application_key equation_options equation)
117
+
118
+ stringz :application_key
119
+ uint8 :_equation_options
120
+
121
+ def equation_options
122
+ _equation_options == 1 ? "inline" : "block"
123
+ end
124
+
125
+ array :equation, read_until: lambda { element.record_type == 0 } do
126
+ named_record
127
+ end
128
+ end
129
+ end
@@ -12,14 +12,14 @@ require_relative "snapshot"
12
12
  # [[RULER record]] if mtefOPT_LP_RULER is set
13
13
  # [object list] list of lines contained by the pile
14
14
 
15
- module Mathtype
15
+ module Mathtype5
16
16
  class RecordPile < BinData::Record
17
17
  include Snapshot
18
18
  EXPOSED_IN_SNAPSHOT = %i(options halign valign object_list)
19
19
 
20
20
  int8 :options
21
21
 
22
- nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
22
+ record_nudge :nudge, onlyif: lambda { options & OPTIONS["mtefOPT_NUDGE"] > 0 }
23
23
 
24
24
  int8 :_halign
25
25
  int8 :_valign
@@ -23,7 +23,7 @@ require_relative "snapshot"
23
23
  # Simple typesizes, without a delta value, are written using the records
24
24
  # described in the next section.
25
25
 
26
- module Mathtype
26
+ module Mathtype5
27
27
  class RecordSize < BinData::Record
28
28
  include Snapshot
29
29
  EXPOSED_IN_SNAPSHOT = %i(lsize dsize point_size)
@@ -31,25 +31,27 @@ module Mathtype
31
31
  endian :little
32
32
  int8 :_size_select
33
33
 
34
- uint16 :_point_size, onlyif: lambda { _size_select == 101 }
34
+ mtef16 :_point_size, onlyif: lambda { _size_select == 101 }
35
35
  uint8 :_lsize_large_delta, onlyif: lambda { _size_select == 100 }
36
36
 
37
37
  uint8 :_dsize, onlyif: lambda { _size_select != 100 && _size_select != 101 }
38
- uint16 :_dsize_large, onlyif: lambda { _size_select == 100 }
38
+ mtef16 :_dsize_large, onlyif: lambda { _size_select == 100 }
39
39
 
40
40
  def dsize
41
+ __dsize = nil
41
42
  case _size_select
42
43
  when 100
43
44
  if _dsize_large > 255
44
- (_dsize_large - (256 << 8)) / 32
45
+ __dsize = -(_dsize_large.getlow)
45
46
  else
46
- _dsize_large / 32
47
+ __dsize = _dsize_large
47
48
  end
48
49
  when 101
49
- nil
50
+ __dsize = nil
50
51
  else
51
- (_dsize - 128) / 32 # in 32nds of a point
52
+ __dsize = (_dsize - 128) # in 32nds of a point
52
53
  end
54
+ __dsize / 32
53
55
  end
54
56
 
55
57
  def lsize
@@ -0,0 +1,19 @@
1
+ require "bindata"
2
+
3
+ module Mathtype5
4
+ module Snapshot
5
+ def snapshot
6
+ snapshot = BinData::Record::Snapshot.new
7
+ exposed = self.class.const_get(:EXPOSED_IN_SNAPSHOT)
8
+ exposed.each do |name|
9
+ obj = find_obj_for_name(name)
10
+ if obj
11
+ snapshot[name] = obj.snapshot if include_obj?(obj)
12
+ else
13
+ snapshot[name] = self.send(name)
14
+ end
15
+ end
16
+ snapshot
17
+ end
18
+ end
19
+ end