mcc2 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/mcc2/layout_file.rb +2 -16
- data/lib/mcc2/printer/svg_drawer.rb +35 -26
- data/lib/mcc2/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c0644a22468b1f2859c31b47904bc3434bb74e241c58b0d98b6f7c50ee602b4
|
|
4
|
+
data.tar.gz: e424eb73bcf7a35e21ad822d7660b9cf1933cd66795058cbc78f5dd81d230d21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 347b50b032706fe1484a94d2e3985b4747d4079868bdec9f0c68b4dc500276b84a55f36fbcee4142f1134580f7e936ca7af301e2b7eb66d05361402ed26798e7
|
|
7
|
+
data.tar.gz: 7a95636ed27195bf9b000c12955d8239276933b3d6c2fd335378c62403204bfa18accc40cc9e9e6a2c865263ea5e83739ce567af0fd367889a31332b2836b27d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/mcc2/layout_file.rb
CHANGED
|
@@ -308,19 +308,6 @@ PRINT 1
|
|
|
308
308
|
get_pango_font(font_info, pt(fontsize))
|
|
309
309
|
end
|
|
310
310
|
|
|
311
|
-
def get_text_sizes(go)
|
|
312
|
-
data = go[GOA_SAMPLE_DATA].to_s
|
|
313
|
-
if !data.empty?
|
|
314
|
-
pango_font = pango_font_of(go)
|
|
315
|
-
context = pango_font_map.create_context
|
|
316
|
-
layout = Pango::Layout.new(context)
|
|
317
|
-
layout.font_description = pango_font
|
|
318
|
-
layout.text = data # set the text to render
|
|
319
|
-
|
|
320
|
-
layout.pixel_size.map{|px| px_to_mm(px) }
|
|
321
|
-
end
|
|
322
|
-
end
|
|
323
|
-
|
|
324
311
|
def get_new_coods(go)
|
|
325
312
|
x = go[GOA_X].to_f
|
|
326
313
|
y = go[GOA_Y].to_f
|
|
@@ -360,13 +347,12 @@ PRINT 1
|
|
|
360
347
|
.sub("Mitte", "mid")
|
|
361
348
|
.sub("Rechts", "right")
|
|
362
349
|
|
|
363
|
-
w, h = converter.get_text_sizes(go)
|
|
364
350
|
# set bounding box and keep a little bit of space for safty
|
|
365
351
|
if just == S_JUST_LEFT
|
|
366
352
|
# Don't change middle or right aligned, they should already be valid
|
|
367
|
-
set_object_by_ids([id], GOA_WIDTH,
|
|
353
|
+
set_object_by_ids([id], GOA_WIDTH, "")
|
|
368
354
|
end
|
|
369
|
-
set_object_by_ids([id], GOA_HEIGHT,
|
|
355
|
+
set_object_by_ids([id], GOA_HEIGHT, "")
|
|
370
356
|
|
|
371
357
|
x, y = converter.get_new_coods(go)
|
|
372
358
|
# move text up, because old old Y means text baseline
|
|
@@ -231,8 +231,8 @@ module Mcc2
|
|
|
231
231
|
# die allgemeinen Attribute ermitteln
|
|
232
232
|
x = go[GOA_X].to_f
|
|
233
233
|
y = go[GOA_Y].to_f
|
|
234
|
-
go_width = go[GOA_WIDTH].to_f
|
|
235
|
-
go_height = go[GOA_HEIGHT].to_f
|
|
234
|
+
go_width = go[GOA_WIDTH].to_f unless go[GOA_WIDTH].to_s.empty?
|
|
235
|
+
go_height = go[GOA_HEIGHT].to_f unless go[GOA_HEIGHT].to_s.empty?
|
|
236
236
|
rotation = go[GOA_ROTATION].to_f
|
|
237
237
|
typ = go[GOA_TYP]
|
|
238
238
|
|
|
@@ -245,21 +245,14 @@ module Mcc2
|
|
|
245
245
|
data = go[GOA_SAMPLE_DATA].to_s
|
|
246
246
|
end
|
|
247
247
|
|
|
248
|
-
|
|
249
|
-
rec = tra.translate(mm(x).round, mm(y).round).rotate(rotation)
|
|
250
|
-
rec2 = rec.translate(mm(go_width), 0)
|
|
251
|
-
rec3 = rec.translate(mm(go_width), mm(go_height))
|
|
252
|
-
rec4 = rec.translate(0, mm(go_height))
|
|
253
|
-
orec = ObjRectangle.new(rec.vector2d, rec2.vector2d, rec3.vector2d, rec4.vector2d, id)
|
|
254
|
-
rect_list.add(orec)
|
|
255
|
-
end
|
|
248
|
+
rec = tra.translate(mm(x).round, mm(y).round).rotate(rotation)
|
|
256
249
|
|
|
257
250
|
drawing.g transform: "rotate(#{rec.a})" do
|
|
258
251
|
opos = rec.inverse
|
|
259
252
|
|
|
260
253
|
begin
|
|
261
254
|
# die Objekt-spezifischen Attribute ermitteln
|
|
262
|
-
if typ == TEXTOBJECT
|
|
255
|
+
go_width, go_height = if typ == TEXTOBJECT
|
|
263
256
|
draw_textobject(drawing, opos, go, go_width, go_height, data.empty? ? data_nosub : data)
|
|
264
257
|
elsif typ == PICTUREOBJECT
|
|
265
258
|
draw_pictureobject(drawing, opos, go, go_width, go_height, data)
|
|
@@ -275,6 +268,12 @@ module Mcc2
|
|
|
275
268
|
raise err, "#{go[GOA_NAME]}: #{err}"
|
|
276
269
|
end
|
|
277
270
|
|
|
271
|
+
rec2 = rec.translate(mm(go_width), 0)
|
|
272
|
+
rec3 = rec.translate(mm(go_width), mm(go_height))
|
|
273
|
+
rec4 = rec.translate(0, mm(go_height))
|
|
274
|
+
orec = ObjRectangle.new(rec.vector2d, rec2.vector2d, rec3.vector2d, rec4.vector2d, id)
|
|
275
|
+
rect_list.add(orec)
|
|
276
|
+
|
|
278
277
|
# in Vorschau einen Rahmen um das selektierte Objekt zeichnen
|
|
279
278
|
if preview && selected_object_ids.include?(id)
|
|
280
279
|
# drawing.fill("none")
|
|
@@ -349,6 +348,19 @@ module Mcc2
|
|
|
349
348
|
|
|
350
349
|
if data && !data.empty?
|
|
351
350
|
font_info = get_font_info(font, go)
|
|
351
|
+
context = pango_font_map.create_context
|
|
352
|
+
layout = Pango::Layout.new(context)
|
|
353
|
+
|
|
354
|
+
pango_font = get_pango_font(font_info, pt(fontsize))
|
|
355
|
+
layout.font_description = pango_font
|
|
356
|
+
layout.width = mm(go_width) * Pango::SCALE if go_width
|
|
357
|
+
layout.height = mm(go_height) * Pango::SCALE if go_height
|
|
358
|
+
layout.wrap = Pango::WrapMode::WORD_CHAR
|
|
359
|
+
layout.justify = just_block
|
|
360
|
+
layout.alignment = pjust
|
|
361
|
+
layout.ellipsize = Pango::EllipsizeMode::END
|
|
362
|
+
layout.text = data # set the text to render
|
|
363
|
+
|
|
352
364
|
drawing.text_(fill: font_color,
|
|
353
365
|
'text-anchor': just,
|
|
354
366
|
'font-size': pt(fontsize),
|
|
@@ -358,20 +370,7 @@ module Mcc2
|
|
|
358
370
|
'font-stretch': font_info.font_stretch,
|
|
359
371
|
'xml:space': "preserve") do
|
|
360
372
|
|
|
361
|
-
|
|
362
|
-
layout = Pango::Layout.new(context)
|
|
363
|
-
|
|
364
|
-
pango_font = get_pango_font(font_info, pt(fontsize))
|
|
365
|
-
layout.font_description = pango_font
|
|
366
|
-
layout.width = mm(go_width) * Pango::SCALE
|
|
367
|
-
layout.height = mm(go_height) * Pango::SCALE
|
|
368
|
-
layout.wrap = Pango::WrapMode::WORD_CHAR
|
|
369
|
-
layout.justify = just_block
|
|
370
|
-
layout.alignment = pjust
|
|
371
|
-
layout.ellipsize = Pango::EllipsizeMode::END
|
|
372
|
-
layout.text = data # set the text to render
|
|
373
|
-
|
|
374
|
-
# iterate all lines of the text box
|
|
373
|
+
# iterate all characters of the text box
|
|
375
374
|
iter = layout.iter
|
|
376
375
|
loop do
|
|
377
376
|
|
|
@@ -398,12 +397,16 @@ module Mcc2
|
|
|
398
397
|
end
|
|
399
398
|
end
|
|
400
399
|
|
|
401
|
-
drawing.tspan(cluster_text, x: tra.x + line_x, y: tra.y + line_y_baseline, **overflow)
|
|
400
|
+
drawing.tspan(cluster_text, x: tra.x + line_x, y: tra.y + line_y_baseline, **(overflow || {}))
|
|
402
401
|
|
|
403
402
|
break unless next_byte_index
|
|
404
403
|
end
|
|
405
404
|
end
|
|
405
|
+
new_width, new_height = layout.pixel_size.map{|px| px_to_mm(px) }
|
|
406
|
+
|
|
407
|
+
return go_width || new_width, go_height || new_height
|
|
406
408
|
end
|
|
409
|
+
return 1, 1
|
|
407
410
|
end
|
|
408
411
|
|
|
409
412
|
def draw_pictureobject(drawing, tra, go, go_width, go_height, data)
|
|
@@ -458,6 +461,8 @@ module Mcc2
|
|
|
458
461
|
else
|
|
459
462
|
raise Printer::Base::ResourceNotFoundError, I18n.t(:image_not_found, default: "Das Bild '%{path}' konnte nicht gefunden werden.", path: )
|
|
460
463
|
end
|
|
464
|
+
|
|
465
|
+
return go_width, go_height
|
|
461
466
|
end
|
|
462
467
|
|
|
463
468
|
BARCODE_ALIAS = {
|
|
@@ -570,6 +575,7 @@ module Mcc2
|
|
|
570
575
|
'xml:space': "preserve")
|
|
571
576
|
end
|
|
572
577
|
end
|
|
578
|
+
return go_width, go_height
|
|
573
579
|
end
|
|
574
580
|
|
|
575
581
|
def barcode_mm_to_px(l, barcode_dpi)
|
|
@@ -592,6 +598,8 @@ module Mcc2
|
|
|
592
598
|
"stroke-width": mm(border_width).round,
|
|
593
599
|
x: tra.x, y: tra.y, width: mm(go_width).round, height: mm(go_height).round,
|
|
594
600
|
rx: mm(corner_radius), ry: mm(corner_radius))
|
|
601
|
+
|
|
602
|
+
return go_width, go_height
|
|
595
603
|
end
|
|
596
604
|
|
|
597
605
|
def draw_embedobject(drawing, tra, go, go_width, go_height, data, row_number, barcode_dpi)
|
|
@@ -630,6 +638,7 @@ module Mcc2
|
|
|
630
638
|
else
|
|
631
639
|
raise Printer::Base::ResourceNotFoundError, I18n.t(:embedded_object_not_found, default: "Das Layout '%{path}' konnte nicht gefunden werden.", path: )
|
|
632
640
|
end
|
|
641
|
+
return go_width, go_height
|
|
633
642
|
end
|
|
634
643
|
|
|
635
644
|
def get_font_info(font, obj)
|
data/lib/mcc2/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|