Skip to content

Commit

Permalink
Small update
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski committed Nov 23, 2024
1 parent 221808e commit 2227f29
Show file tree
Hide file tree
Showing 26 changed files with 29 additions and 27 deletions.
2 changes: 2 additions & 0 deletions upcean/encode/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/codabar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/code11.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/code128.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/code32.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions upcean/encode/code39.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions upcean/encode/code93.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/ean13.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/ean2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/ean5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/ean8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/itf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/itf14.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/plessey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/stf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions upcean/encode/upca.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -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)):
Expand Down
4 changes: 2 additions & 2 deletions upcean/encode/upcavar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion upcean/encode/upce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
Binary file modified upcean/fonts/OCRA.otf
Binary file not shown.
Binary file modified upcean/fonts/OCRA.ttf
Binary file not shown.
Binary file modified upcean/fonts/OCRB.otf
Binary file not shown.
Binary file modified upcean/fonts/OCRB.ttf
Binary file not shown.
4 changes: 2 additions & 2 deletions upcean/predraw/precairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions upcean/predraw/preqahirah.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion upcean/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2227f29

Please sign in to comment.