@@ -128,22 +128,22 @@ defmodule Mudbrick.ContentStream do
128
128
129
129
text ->
130
130
context
131
- |> align ( text , old_alignment , new_alignment )
132
- |> add ( Tj , font: tf . font , text: text )
133
- |> negate_right_alignment ( )
131
+ |> align ( text , old_alignment , new_alignment , fn ->
132
+ % Tj { font: tf . font , text: text }
133
+ end )
134
134
end
135
135
|> then ( fn context ->
136
136
for part <- parts , reduce: context do
137
137
acc ->
138
138
acc
139
- |> align ( part , new_alignment )
140
- |> add ( Apostrophe , font: tf . font , text: part )
141
- |> negate_right_alignment ( )
139
+ |> align ( part , new_alignment , fn ->
140
+ % Apostrophe { font: tf . font , text: part }
141
+ end )
142
142
end
143
143
end )
144
144
end
145
145
146
- defp align ( { _doc , content_stream } = context , text , old , new ) do
146
+ defp align ( { _doc , content_stream } = context , text , old , new , f ) do
147
147
case { old , new } do
148
148
{ _ , :left } ->
149
149
context
@@ -172,28 +172,32 @@ defmodule Mudbrick.ContentStream do
172
172
|> add ( Td , tx: - width , ty: 0 , purpose: :align_right )
173
173
|> put ( current_alignment: :right )
174
174
end
175
+ |> add ( f . ( ) )
176
+ |> negate_right_alignment ( )
175
177
end
176
178
177
- defp align ( { _doc , content_stream } = context , text , new ) do
178
- case new do
179
- :left ->
180
- context
181
- |> put ( current_alignment: :left )
179
+ defp align ( context , _text , :left , f ) do
180
+ context
181
+ |> put ( current_alignment: :left )
182
+ |> add ( f . ( ) )
183
+ |> negate_right_alignment ( )
184
+ end
182
185
183
- :right ->
184
- tf = Tf . latest! ( content_stream )
186
+ defp align ( { _doc , content_stream } = context , text , :right , f ) do
187
+ tf = Tf . latest! ( content_stream )
185
188
186
- case Font . width ( tf . font , tf . size , text ) do
187
- 0 ->
188
- context
189
- |> put ( current_alignment: :right )
189
+ case Font . width ( tf . font , tf . size , text ) do
190
+ 0 ->
191
+ context
192
+ |> put ( current_alignment: :right )
190
193
191
- width ->
192
- context
193
- |> add ( Td , tx: - width , ty: 0 , purpose: :align_right )
194
- |> put ( current_alignment: :right )
195
- end
194
+ width ->
195
+ context
196
+ |> add ( Td , tx: - width , ty: 0 , purpose: :align_right )
197
+ |> put ( current_alignment: :right )
196
198
end
199
+ |> add ( f . ( ) )
200
+ |> negate_right_alignment ( )
197
201
end
198
202
199
203
defp negate_right_alignment ( { _doc , cs } = context ) do
0 commit comments