diff --git a/upcean/encode/binary.py b/upcean/encode/binary.py index 8c30f944..4c4d82dc 100644 --- a/upcean/encode/binary.py +++ b/upcean/encode/binary.py @@ -138,6 +138,8 @@ def encode_binary_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, LineFixTxtStart = 0 if(tkintersupport and imageoutlib == "tkinter"): LineFixTxtStart = 4 + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): + LineTxtStart = 1 while(txtbari < txtbarmax): texthidden = False if hidetext or (upc['text']['type'][txtbari] == "sn" and (hidesn is None or hidesn)) or (upc['text']['type'][txtbari] == "cd" and (hidecd is None or hidecd)): diff --git a/upcean/encode/codabar.py b/upcean/encode/codabar.py index abcc2b6c..423f39b0 100644 --- a/upcean/encode/codabar.py +++ b/upcean/encode/codabar.py @@ -267,7 +267,7 @@ def encode_codabar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 LineTxtStartNorm = 20 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False diff --git a/upcean/encode/code11.py b/upcean/encode/code11.py index 5b8de0e1..20f290a0 100644 --- a/upcean/encode/code11.py +++ b/upcean/encode/code11.py @@ -226,7 +226,7 @@ def encode_code11_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, LineTxtStartNorm = 10 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/encode/code128.py b/upcean/encode/code128.py index e6f5fe93..85d86032 100644 --- a/upcean/encode/code128.py +++ b/upcean/encode/code128.py @@ -555,7 +555,7 @@ def encode_code128_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 LineTxtStartNorm = 16 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) if(barcode_is_rev): upc_print.reverse() diff --git a/upcean/encode/code32.py b/upcean/encode/code32.py index 175eede3..b766496e 100644 --- a/upcean/encode/code32.py +++ b/upcean/encode/code32.py @@ -267,7 +267,7 @@ def encode_code32_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, LineTxtStartNorm = 30 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False diff --git a/upcean/encode/code39.py b/upcean/encode/code39.py index e348e82b..c6453321 100644 --- a/upcean/encode/code39.py +++ b/upcean/encode/code39.py @@ -289,7 +289,7 @@ def encode_code39_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, LineTxtStartNorm = 15 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( barheight[0] * int(resize)), "*", barcolor[1], "ocrb", imageoutlib) @@ -613,7 +613,7 @@ def encode_code39extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei LineTxtStartNorm = 15 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) drawColorText(upc_img, 10 * int(resize * barwidth[1]), LineTxtStart * barwidth[0], vertical_text_fix + ( barheight[0] * int(resize)), "*", barcolor[1], "ocrb", imageoutlib) diff --git a/upcean/encode/code93.py b/upcean/encode/code93.py index a9300f30..b565447e 100644 --- a/upcean/encode/code93.py +++ b/upcean/encode/code93.py @@ -297,7 +297,7 @@ def encode_code93_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, LineTxtStartNorm = 18 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False @@ -624,7 +624,7 @@ def encode_code93extended_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barhei LineTxtStartNorm = 18 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False diff --git a/upcean/encode/ean13.py b/upcean/encode/ean13.py index e2010695..831e9fb9 100644 --- a/upcean/encode/ean13.py +++ b/upcean/encode/ean13.py @@ -397,7 +397,7 @@ def encode_ean13_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, LineTxtStartNorm = 2 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = list(re.findall("(\\d{13})", upc)[0])+[">"] while (NumTxtZero < len(upc_print)): diff --git a/upcean/encode/ean2.py b/upcean/encode/ean2.py index a0b123fa..375aeb60 100644 --- a/upcean/encode/ean2.py +++ b/upcean/encode/ean2.py @@ -250,7 +250,7 @@ def encode_ean2_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 LineTxtStartNorm = 6 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = LeftDigit while (NumTxtZero < len(upc_print)): diff --git a/upcean/encode/ean5.py b/upcean/encode/ean5.py index c4f4f7f0..9f13aaa6 100644 --- a/upcean/encode/ean5.py +++ b/upcean/encode/ean5.py @@ -337,7 +337,7 @@ def encode_ean5_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 LineTxtStartNorm = 7 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = LeftDigit while (NumTxtZero < len(upc_print)): diff --git a/upcean/encode/ean8.py b/upcean/encode/ean8.py index 0b7538b2..22370f40 100644 --- a/upcean/encode/ean8.py +++ b/upcean/encode/ean8.py @@ -404,7 +404,7 @@ def encode_ean8_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 LineTxtStartNorm = 0 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = ["<"]+list(re.findall("(\\d{8})", upc)[0])+[">"] while (NumTxtZero < len(upc_print)): diff --git a/upcean/encode/itf.py b/upcean/encode/itf.py index 6a903dee..61d4a660 100644 --- a/upcean/encode/itf.py +++ b/upcean/encode/itf.py @@ -292,7 +292,7 @@ def encode_itf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 LineTxtStartNorm = 20 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): ArrayDigit = list(upc_matches[NumTxtZero]) diff --git a/upcean/encode/itf14.py b/upcean/encode/itf14.py index 2ba5bdf2..0c416347 100644 --- a/upcean/encode/itf14.py +++ b/upcean/encode/itf14.py @@ -300,7 +300,7 @@ def encode_itf14_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, LineTxtStartNorm = 23 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): ArrayDigit = list(upc_matches[NumTxtZero]) diff --git a/upcean/encode/msi.py b/upcean/encode/msi.py index 3a5c9c3a..c278a10d 100644 --- a/upcean/encode/msi.py +++ b/upcean/encode/msi.py @@ -207,7 +207,7 @@ def encode_msi_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 LineTxtStartNorm = 16 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_print)): texthidden = False diff --git a/upcean/encode/plessey.py b/upcean/encode/plessey.py index e0bab39a..4470951f 100644 --- a/upcean/encode/plessey.py +++ b/upcean/encode/plessey.py @@ -235,7 +235,7 @@ def encode_plessey_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 LineTxtStartNorm = 30 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False diff --git a/upcean/encode/stf.py b/upcean/encode/stf.py index 014a9bfc..0da07553 100644 --- a/upcean/encode/stf.py +++ b/upcean/encode/stf.py @@ -244,7 +244,7 @@ def encode_stf_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 54 LineTxtStartNorm = 24 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) while (NumTxtZero < len(upc_matches)): texthidden = False diff --git a/upcean/encode/upca.py b/upcean/encode/upca.py index 835628bb..e6d06cec 100644 --- a/upcean/encode/upca.py +++ b/upcean/encode/upca.py @@ -331,7 +331,7 @@ def encode_upca_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 LineTxtStartNorm = 1 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = list(re.findall("(\\d{12})", upc)[0]) while (NumTxtZero < len(upc_print)): @@ -726,7 +726,7 @@ def encode_upcaean_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 LineTxtStartNorm = 2 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = [0]+list(re.findall("(\\d{12})", upc)[0])+[">"] while (NumTxtZero < len(upc_print)): diff --git a/upcean/encode/upcavar.py b/upcean/encode/upcavar.py index 5890234e..6cd75069 100644 --- a/upcean/encode/upcavar.py +++ b/upcean/encode/upcavar.py @@ -338,7 +338,7 @@ def encode_upcavar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48 LineTxtStartNorm = 1 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = list(re.findall("(\\d+)", upc)[0]) while (NumTxtZero < len(upc_print)): @@ -739,7 +739,7 @@ def encode_upcaeanvar_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight= LineTxtStartNorm = 2 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = [0]+list(re.findall("(\\d+)", upc)[0])+[">"] while (NumTxtZero < len(upc_print)): diff --git a/upcean/encode/upce.py b/upcean/encode/upce.py index 7129208c..2e7520fc 100644 --- a/upcean/encode/upce.py +++ b/upcean/encode/upce.py @@ -419,7 +419,7 @@ def encode_upce_barcode(inimage, upc, resize=1, shiftxy=(0, 0), barheight=(48, 5 LineTxtStartNorm = 1 if(tkintersupport and imageoutlib == "tkinter"): LineTxtStart += (4 * int(resize)) - elif(cairosupport and (imageoutlib == "cairo" or imageoutlib == "cairosvg")): + elif(svgwritesupport and not cairosvgsupport and imageoutlib == "svgwrite"): LineTxtStart += (1 * int(resize)) upc_print = list(re.findall("(\\d{8})", upc)[0]) while (NumTxtZero < len(upc_print)): diff --git a/upcean/fonts/OCRA.otf b/upcean/fonts/OCRA.otf index 86f56dcd..9cc8b41b 100644 Binary files a/upcean/fonts/OCRA.otf and b/upcean/fonts/OCRA.otf differ diff --git a/upcean/fonts/OCRA.ttf b/upcean/fonts/OCRA.ttf index ed702ff1..6a64901c 100644 Binary files a/upcean/fonts/OCRA.ttf and b/upcean/fonts/OCRA.ttf differ diff --git a/upcean/fonts/OCRB.otf b/upcean/fonts/OCRB.otf index 3dab41e0..c764b0f4 100644 Binary files a/upcean/fonts/OCRB.otf and b/upcean/fonts/OCRB.otf differ diff --git a/upcean/fonts/OCRB.ttf b/upcean/fonts/OCRB.ttf index 1406f555..eb9d4577 100644 Binary files a/upcean/fonts/OCRB.ttf and b/upcean/fonts/OCRB.ttf differ diff --git a/upcean/predraw/precairo.py b/upcean/predraw/precairo.py index c85fa882..364ff3fa 100644 --- a/upcean/predraw/precairo.py +++ b/upcean/predraw/precairo.py @@ -238,7 +238,7 @@ def drawColorRectangleAlt(ctx, x1, y1, x2, y2, color, line_width=1): return True # Define valid PyCairo output formats -cairo_valid_extensions = {"SVG", "PDF", "PS", "EPS", "RAW", "CAIRO"} +cairo_valid_extensions = {"SVG", "PDF", "PS", "EPS", "RAW", "CAIRO", "QAHIRAH"} def get_save_filename(outfile): """ @@ -377,7 +377,7 @@ def save_to_file(inimage, outfile, outfileext, imgcomment="barcode"): image_context.paint() image_surface.flush() image_surface.finish() - elif(outfileext == "CAIRO"): + elif(outfileext == "CAIRO" or outfileext == "QAHIRAH"): # Create an ScriptSurface with the exact dimensions of the recorded content image_surface = cairo.ScriptSurface(cairo.ScriptDevice(outfile), cairo.FORMAT_RGB24, int(width), int(height)) image_context = cairo.Context(image_surface) diff --git a/upcean/predraw/preqahirah.py b/upcean/predraw/preqahirah.py index 9d1e55b1..ef32df2f 100644 --- a/upcean/predraw/preqahirah.py +++ b/upcean/predraw/preqahirah.py @@ -182,7 +182,7 @@ def drawColorRectangleAlt(ctx, x1, y1, x2, y2, color, line_width=1): return True # Define valid Qahirah output formats -cairo_valid_extensions = {"SVG", "PDF", "PS", "EPS", "RAW", "CAIRO"} +cairo_valid_extensions = {"SVG", "PDF", "PS", "EPS", "RAW", "CAIRO", "QAHIRAH"} def get_save_filename(outfile): """ @@ -322,7 +322,7 @@ def save_to_file(inimage, outfile, outfileext, imgcomment="barcode"): image_context.set_source_surface(upc_preimg, (-x, -y)) image_context.paint() image_surface.flush() - if outfileext == "CAIRO": + elif outfileext == "CAIRO" or outfileext == "QAHIRAH": # Step 1: Create the ScriptDevice, specifying the output file script_device = qah.ScriptDevice.create(outfile) # Step 2: Create a proxy surface linked to the ScriptDevice diff --git a/upcean/support.py b/upcean/support.py index 2fd58068..6d31b591 100644 --- a/upcean/support.py +++ b/upcean/support.py @@ -70,7 +70,7 @@ def get_importing_script_path(): enable_pilsupport = True enable_cairosupport = True enable_qahirahsupport = True - enable_cairosvgsupport = True + enable_cairosvgsupport = False enable_wandsupport = True enable_magicksupport = True enable_pgmagicksupport = True