Add -fullmultibyte to tcl frontend

This commit is contained in:
Harald Oehlmann 2020-04-06 18:37:39 +02:00
parent 22ba06a7cb
commit 2f99f0c4fd
2 changed files with 36 additions and 8 deletions

View file

@ -18,6 +18,9 @@ pack [::ttk::combobox .c -values [lsort [zint symbologies]] -state readonly] \
pack [::ttk::entry .e] -side top -fill x -padx $padx -pady $pady
.e insert end 12345
bind .e <Return> Generate
pack [::ttk::entry .o] -side top -fill x -padx $padx -pady $pady
.o insert end "-bold 1"
bind .o <Return> Generate
pack [::ttk::button .b -text Generate -command Generate] -fill x -side top \
-padx $padx -pady $pady
proc Generate {} {
@ -25,7 +28,7 @@ proc Generate {} {
::zintimg configure -width 1 -height 1
::zintimg blank
::zintimg configure -width 0 -height 0
if {[catch {zint encode [.e get] ::zintimg -barcode [.c get]} e]} {
if {[catch {zint encode [.e get] ::zintimg -barcode [.c get] {*}[.o get]} e]} {
tk_messageBox -message $e -title "Zint error"
} else {
set w [image width ::zintimg]

View file

@ -68,7 +68,9 @@
- Framework 2.7.0 update
- Add symbology rmqr
2020-02-01 2.7.1 HaO
- Framework 2.7.1 update
- Framework 2.7.1 update
2020-04-06 HaO
- Added option -fullmultibyte
*/
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
@ -400,7 +402,8 @@ static char help_message[] = "zint tcl(stub,obj) dll\n"
" -dotty bool: use dots instead of boxes for matrix codes\n"
" -dotsize number: radius ratio of dots from 0.01 to 1.0\n"
" -scale double: Scale the image to this factor\n"
" -format binary|unicode|gs1: input data format. Default:unicode\n"
" -format binary|unicode|gs1: input data format. Default:unicode\n"
" -fullmultibyte: allow multibyte compaction for xQR, HanXin, Gridmatrix\n"
" -gssep bool: for gs1, use gs as separator instead fnc1 (Datamatrix only)\n"
" -eci number: ECI to use\n"
" -notext bool: no interpretation line\n"
@ -559,7 +562,8 @@ static int Encode(Tcl_Interp *interp, int objc,
int destY0 = 0;
int destWidth = 0;
int destHeight = 0;
int ECIIndex = 0;
int ECIIndex = 0;
int fFullMultiByte = 0;
/*------------------------------------------------------------------------*/
/* >> Check if at least data and object is given and a pair number of */
/* >> options */
@ -589,13 +593,13 @@ static int Encode(Tcl_Interp *interp, int objc,
"-dmre", "-dotsize", "-dotty", "-eci", "-fg", "-format", "-gssep",
"-height", "-init", "-mode", "-notext", "-primary", "-rotate",
"-rows", "-scale", "-secure", "-smalltext", "-square", "-to",
"-vers", "-whitesp", NULL};
"-vers", "-whitesp", "-fullmultibyte", NULL};
enum iOption {
iBarcode, iBG, iBind, iBold, iBorder, iBox, iCols,
iDMRE, iDotSize, iDotty, iECI, iFG, iFormat, iGSSep, iHeight,
iInit, iMode, iNoText, iPrimary, iRotate, iRows,
iScale, iSecure, iSmallText, iSquare, iTo, iVers,
iWhiteSp
iWhiteSp, iFullMultiByte
};
int optionIndex;
int intValue;
@ -621,7 +625,8 @@ static int Encode(Tcl_Interp *interp, int objc,
case iInit:
case iNoText:
case iSmallText:
case iSquare:
case iSquare:
case iFullMultiByte:
/* >> Binary options */
if (TCL_OK != Tcl_GetBooleanFromObj(interp, objv[optionPos+1],
&intValue))
@ -725,7 +730,10 @@ static int Encode(Tcl_Interp *interp, int objc,
} else {
hSymbol->output_options &= ~GS1_GS_SEPARATOR;
}
break;
break;
case iFullMultiByte:
fFullMultiByte = intValue;
break;
case iECI:
if(Tcl_GetIndexFromObj(interp, objv[optionPos+1],
(const char **) s_eci_list,"-eci", optionPos, &ECIIndex)
@ -925,6 +933,23 @@ static int Encode(Tcl_Interp *interp, int objc,
}
}
}
/*------------------------------------------------------------------------*/
/* >>> Set fullmultibyte option if symbology matches*/
/* On wrong symbology, option is ignored (as does the zint program)*/
if (fFullMultiByte) {
switch (hSymbol->symbology) {
case BARCODE_QRCODE:
case BARCODE_MICROQR:
/*case BARCODE_HIBC_QR: Note character set restricted to ASCII subset*/
/*case BARCODE_UPNQR: Note does not use Kanji mode*/
case BARCODE_RMQR:
case BARCODE_HANXIN:
case BARCODE_GRIDMATRIX:
hSymbol->option_3 = ZINT_FULL_MULTIBYTE;
break;
}
}
/*------------------------------------------------------------------------*/
/* >>> Prepare input dstring and encode it to ECI encoding*/
Tcl_DStringInit(& dsInput);