Support libzint >= 2.15 (#225,#222,#186))

- Update libzint support for 2.15 as new baseline version, removing support for earlier versions, avoiding '#ifdef'-hell
- Based on #186

---------

Co-authored-by: gitlost <burmartke@gmail.com>
This commit is contained in:
Jaye Evins
2025-08-16 17:00:14 -04:00
committed by GitHub
parent fa96cc5a17
commit 0e7049ed73
19 changed files with 957 additions and 162 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ matrix:
- sudo apt-get -y install pkgconf libqrencode-dev - sudo apt-get -y install pkgconf libqrencode-dev
- sudo apt-get -y install barcode - sudo apt-get -y install barcode
# Install zint from source # Install zint from source
- wget https://downloads.sourceforge.net/project/zint/zint/2.6.5/zint-2.6.5.tar.gz && tar xzf zint-2.6.5.tar.gz && ( cd zint-2.6.5 && mkdir build && cd build && cmake .. && make && sudo make install ) - wget https://downloads.sourceforge.net/project/zint/zint/2.12.0/zint-2.12.0-src.tar.gz && tar xzf zint-2.12.0-src.tar.gz && ( cd zint-2.12.0-src && mkdir build && cd build && cmake .. && make && sudo make install )
- export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH - export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
before_script: before_script:
+3 -1
View File
@@ -125,7 +125,9 @@ endif ()
find_package (ZLIB 1.2 QUIET) find_package (ZLIB 1.2 QUIET)
find_package (GnuBarcode 0.98 QUIET) find_package (GnuBarcode 0.98 QUIET)
find_package (LibQrencode 3.4 QUIET) find_package (LibQrencode 3.4 QUIET)
find_package (LibZint 2.6 EXACT QUIET) find_package (LibZint 2.15 QUIET)
# Unit testing support
find_package (Qt5Test 5.6 QUIET)
#======================================= #=======================================
+111 -43
View File
@@ -184,12 +184,17 @@ namespace glabels
glbarcode::Factory::registerType( "zint::ausrd", Zint::AusRD::create ); glbarcode::Factory::registerType( "zint::ausrd", Zint::AusRD::create );
glbarcode::Factory::registerType( "zint::aztec", Zint::Aztec::create ); glbarcode::Factory::registerType( "zint::aztec", Zint::Aztec::create );
glbarcode::Factory::registerType( "zint::azrun", Zint::Azrun::create ); glbarcode::Factory::registerType( "zint::azrun", Zint::Azrun::create );
glbarcode::Factory::registerType( "zint::bc412", Zint::Bc412::create );
glbarcode::Factory::registerType( "zint::cepnet", Zint::Cepnet::create );
glbarcode::Factory::registerType( "zint::cbr", Zint::Cbr::create ); glbarcode::Factory::registerType( "zint::cbr", Zint::Cbr::create );
glbarcode::Factory::registerType( "zint::cblockf", Zint::Cblockf::create );
glbarcode::Factory::registerType( "zint::channel", Zint::Channel::create );
glbarcode::Factory::registerType( "zint::code1", Zint::Code1::create ); glbarcode::Factory::registerType( "zint::code1", Zint::Code1::create );
glbarcode::Factory::registerType( "zint::code11", Zint::Code11::create ); glbarcode::Factory::registerType( "zint::code11", Zint::Code11::create );
glbarcode::Factory::registerType( "zint::c16k", Zint::C16k::create ); glbarcode::Factory::registerType( "zint::c16k", Zint::C16k::create );
glbarcode::Factory::registerType( "zint::c25m", Zint::C25m::create ); glbarcode::Factory::registerType( "zint::c25m", Zint::C25m::create );
glbarcode::Factory::registerType( "zint::c25i", Zint::C25i::create ); glbarcode::Factory::registerType( "zint::c25i", Zint::C25i::create );
glbarcode::Factory::registerType( "zint::c25ind", Zint::C25ind::create );
glbarcode::Factory::registerType( "zint::c25dl", Zint::C25dl::create ); glbarcode::Factory::registerType( "zint::c25dl", Zint::C25dl::create );
glbarcode::Factory::registerType( "zint::code32", Zint::Code32::create ); glbarcode::Factory::registerType( "zint::code32", Zint::Code32::create );
glbarcode::Factory::registerType( "zint::code39", Zint::Code39::create ); glbarcode::Factory::registerType( "zint::code39", Zint::Code39::create );
@@ -202,10 +207,16 @@ namespace glabels
glbarcode::Factory::registerType( "zint::dmtx", Zint::Dmtx::create ); glbarcode::Factory::registerType( "zint::dmtx", Zint::Dmtx::create );
glbarcode::Factory::registerType( "zint::dpl", Zint::Dpl::create ); glbarcode::Factory::registerType( "zint::dpl", Zint::Dpl::create );
glbarcode::Factory::registerType( "zint::dpi", Zint::Dpi::create ); glbarcode::Factory::registerType( "zint::dpi", Zint::Dpi::create );
glbarcode::Factory::registerType( "zint::dotcode", Zint::Dotcode::create );
glbarcode::Factory::registerType( "zint::dpd", Zint::Dpd::create );
glbarcode::Factory::registerType( "zint::kix", Zint::Kix::create ); glbarcode::Factory::registerType( "zint::kix", Zint::Kix::create );
glbarcode::Factory::registerType( "zint::ean", Zint::Ean::create ); glbarcode::Factory::registerType( "zint::ean", Zint::Ean::create );
glbarcode::Factory::registerType( "zint::ean14", Zint::Ean14::create );
glbarcode::Factory::registerType( "zint::fim", Zint::Fim::create );
glbarcode::Factory::registerType( "zint::flat", Zint::Flat::create );
glbarcode::Factory::registerType( "zint::gmtx", Zint::Gmtx::create ); glbarcode::Factory::registerType( "zint::gmtx", Zint::Gmtx::create );
glbarcode::Factory::registerType( "zint::gs1-128", Zint::Gs1128::create ); glbarcode::Factory::registerType( "zint::gs1-128", Zint::Gs1128::create );
glbarcode::Factory::registerType( "zint::hanxin", Zint::Hanxin::create );
glbarcode::Factory::registerType( "zint::rss14", Zint::Rss14::create ); glbarcode::Factory::registerType( "zint::rss14", Zint::Rss14::create );
glbarcode::Factory::registerType( "zint::rssltd", Zint::Rssltd::create ); glbarcode::Factory::registerType( "zint::rssltd", Zint::Rssltd::create );
glbarcode::Factory::registerType( "zint::rssexp", Zint::Rssexp::create ); glbarcode::Factory::registerType( "zint::rssexp", Zint::Rssexp::create );
@@ -218,6 +229,7 @@ namespace glabels
glbarcode::Factory::registerType( "zint::hibcqr", Zint::Hibcqr::create ); glbarcode::Factory::registerType( "zint::hibcqr", Zint::Hibcqr::create );
glbarcode::Factory::registerType( "zint::hibcpdf", Zint::Hibcpdf::create ); glbarcode::Factory::registerType( "zint::hibcpdf", Zint::Hibcpdf::create );
glbarcode::Factory::registerType( "zint::hibcmpdf", Zint::Hibcmpdf::create ); glbarcode::Factory::registerType( "zint::hibcmpdf", Zint::Hibcmpdf::create );
glbarcode::Factory::registerType( "zint::hibcblkf", Zint::Hibcblkf::create );
glbarcode::Factory::registerType( "zint::hibcaz", Zint::Hibcaz::create ); glbarcode::Factory::registerType( "zint::hibcaz", Zint::Hibcaz::create );
glbarcode::Factory::registerType( "zint::i25", Zint::I25::create ); glbarcode::Factory::registerType( "zint::i25", Zint::I25::create );
glbarcode::Factory::registerType( "zint::isbn", Zint::Isbn::create ); glbarcode::Factory::registerType( "zint::isbn", Zint::Isbn::create );
@@ -238,13 +250,18 @@ namespace glabels
glbarcode::Factory::registerType( "zint::pharma2", Zint::Pharma2::create ); glbarcode::Factory::registerType( "zint::pharma2", Zint::Pharma2::create );
glbarcode::Factory::registerType( "zint::pzn", Zint::Pzn::create ); glbarcode::Factory::registerType( "zint::pzn", Zint::Pzn::create );
glbarcode::Factory::registerType( "zint::qr", Zint::Qr::create ); glbarcode::Factory::registerType( "zint::qr", Zint::Qr::create );
glbarcode::Factory::registerType( "zint::rmqr", Zint::Rmqr::create );
glbarcode::Factory::registerType( "zint::rm4", Zint::Rm4::create ); glbarcode::Factory::registerType( "zint::rm4", Zint::Rm4::create );
glbarcode::Factory::registerType( "zint::rm4sm", Zint::Rm4sm::create );
glbarcode::Factory::registerType( "zint::rm2dm", Zint::Rm2dm::create );
glbarcode::Factory::registerType( "zint::tele", Zint::Tele::create ); glbarcode::Factory::registerType( "zint::tele", Zint::Tele::create );
glbarcode::Factory::registerType( "zint::telex", Zint::Telex::create ); glbarcode::Factory::registerType( "zint::telex", Zint::Telex::create );
glbarcode::Factory::registerType( "zint::upc-a", Zint::UpcA::create ); glbarcode::Factory::registerType( "zint::upc-a", Zint::UpcA::create );
glbarcode::Factory::registerType( "zint::upc-e", Zint::UpcE::create ); glbarcode::Factory::registerType( "zint::upc-e", Zint::UpcE::create );
glbarcode::Factory::registerType( "zint::upus10", Zint::UpuS10::create );
glbarcode::Factory::registerType( "zint::usps", Zint::Usps::create ); glbarcode::Factory::registerType( "zint::usps", Zint::Usps::create );
glbarcode::Factory::registerType( "zint::pls", Zint::Pls::create ); glbarcode::Factory::registerType( "zint::pls", Zint::Pls::create );
glbarcode::Factory::registerType( "zint::vin", Zint::Vin::create );
registerStyle( "ausp", "zint", tr("Australia Post Standard"), registerStyle( "ausp", "zint", tr("Australia Post Standard"),
false, false, true, false, "12345678901234567890123", true, 23 ); false, false, true, false, "12345678901234567890123", true, 23 );
@@ -261,38 +278,53 @@ namespace glabels
registerStyle( "aztec", "zint", tr("Aztec Code"), registerStyle( "aztec", "zint", tr("Aztec Code"),
false, false, true, false, "1234567890", true, 10 ); false, false, true, false, "1234567890", true, 10 );
registerStyle( "azrun", "zint", tr("Aztec Rune"), registerStyle( "azrun", "zint", tr("Aztec Runes"),
false, false, true, false, "255", true, 3 ); false, false, true, false, "255", true, 3 );
registerStyle( "bc412", "zint", tr("BC412 (SEMI TI-95)"),
true, true, true, false, "12345678", true, 8 );
registerStyle( "cepnet", "zint", tr("CEPNet (Brazilian Post)"),
false, false, true, false, "12345678", true, 8 );
registerStyle( "channel", "zint", tr("Channel Code"),
true, true, false, false, "00", true, 2 );
registerStyle( "cbr", "zint", tr("Codabar"), registerStyle( "cbr", "zint", tr("Codabar"),
true, true, true, false, "ABCDABCDAB", true, 10 ); true, true, true, true, "A00000000B", true, 10 );
registerStyle( "cblockf", "zint", tr("Codablock-F"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "code1", "zint", tr("Code One"), registerStyle( "code1", "zint", tr("Code One"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "code11", "zint", tr("Code 11"), registerStyle( "code11", "zint", tr("Code 11"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "c16k", "zint", tr("Code 16K"), registerStyle( "c16k", "zint", tr("Code 16K"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "c25m", "zint", tr("Code 2 of 5 Matrix"), registerStyle( "c25m", "zint", tr("Code 2 of 5 Standard"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "c25i", "zint", tr("Code 2 of 5 IATA"), registerStyle( "c25i", "zint", tr("Code 2 of 5 IATA"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "c25ind", "zint", tr("Code 2 of 5 Industrial"),
true, true, true, true, "0000000000", true, 10 );
registerStyle( "c25dl", "zint", tr("Code 2 of 5 Data Logic"), registerStyle( "c25dl", "zint", tr("Code 2 of 5 Data Logic"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "code32", "zint", tr("Code 32 (Italian Pharmacode)"), registerStyle( "code32", "zint", tr("Code 32 (Italian Pharmacode)"),
true, true, true, false, "12345678", true, 8 ); true, true, true, false, "12345678", true, 8 );
registerStyle( "code39", "zint", tr("Code 39"), registerStyle( "code39", "zint", tr("Code 39"),
true, true, false, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "code39e", "zint", tr("Code 39 Extended"), registerStyle( "code39e", "zint", tr("Code 39 Extended"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "code49", "zint", tr("Code 49"), registerStyle( "code49", "zint", tr("Code 49"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
@@ -317,36 +349,54 @@ namespace glabels
registerStyle( "dpi", "zint", tr("Deutsche Post Identcode"), registerStyle( "dpi", "zint", tr("Deutsche Post Identcode"),
true, true, true, false, "12345678901", true, 11 ); true, true, true, false, "12345678901", true, 11 );
registerStyle( "kix", "zint", tr("Dutch Post KIX Code"), registerStyle( "dotcode", "zint", tr("DotCode"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "dpd", "zint", tr("DPD Code"),
true, true, true, false, "000000000000000000000000000", true, 27 );
registerStyle( "kix", "zint", tr("Dutch Post KIX Code"),
false, false, false, false, "0000000000", true, 10 );
registerStyle( "ean", "zint", tr("EAN"), registerStyle( "ean", "zint", tr("EAN"),
true, true, true, false, "123456789012", false, 12 );
registerStyle( "ean14", "zint", tr("EAN-14"),
true, true, true, false, "1234567890123", false, 13 ); true, true, true, false, "1234567890123", false, 13 );
registerStyle( "fim", "zint", tr("FIM (Facing ID Mark)"),
false, false, false, false, "A", false, 1 );
registerStyle( "flat", "zint", tr("Flattermarken"),
false, false, false, false, "11111111", false, 8 );
registerStyle( "gmtx", "zint", tr("Grid Matrix"), registerStyle( "gmtx", "zint", tr("Grid Matrix"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "gs1-128", "zint", tr("GS1-128"), registerStyle( "gs1-128", "zint", tr("GS1-128"),
true, true, true, false, "[01]12345678901234", false, 18 ); true, true, true, false, "[01]12345678901231", false, 18 );
registerStyle( "rss14", "zint", tr("GS1 DataBar-14"), registerStyle( "rss14", "zint", tr("GS1 DataBar Omnidirectional"),
true, true, true, false, "1234567890123", true, 13 ); true, true, true, false, "1234567890123", true, 13 );
registerStyle( "rssltd", "zint", "GS1 DataBar-14 Limited", registerStyle( "rssltd", "zint", "GS1 DataBar Limited",
true, true, true, false, "1234567890123", true, 13 ); true, true, true, false, "1234567890123", true, 13 );
registerStyle( "rssexp", "zint", "GS1 DataBar Extended", registerStyle( "rssexp", "zint", "GS1 DataBar Expanded",
true, true, true, false, "[01]12345678901234", false, 18 ); true, true, true, false, "[01]12345678901231", false, 18 );
registerStyle( "rsss", "zint", tr("GS1 DataBar-14 Stacked"), registerStyle( "rsss", "zint", tr("GS1 DataBar Stacked"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "rssso", "zint", tr("GS1 DataBar-14 Stacked Omni."), registerStyle( "rssso", "zint", tr("GS1 DataBar Stacked Omni."),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "rssse", "zint", tr("GS1 DataBar Extended Stacked"), registerStyle( "rssse", "zint", tr("GS1 DataBar Expanded Stacked"),
false, false, true, false, "[01]12345678901234", false, 18 ); false, false, true, false, "[01]12345678901231", false, 18 );
registerStyle( "hanxin", "zint", tr("Han Xin"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "hibc128", "zint", tr("HIBC Code 128"), registerStyle( "hibc128", "zint", tr("HIBC Code 128"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, false, "0000000000", true, 10 );
@@ -363,14 +413,17 @@ namespace glabels
registerStyle( "hibcpdf", "zint", tr("HIBC PDF417"), registerStyle( "hibcpdf", "zint", tr("HIBC PDF417"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "hibcmpdf", "zint", tr("HIBC Micro PDF417"), registerStyle( "hibcmpdf", "zint", tr("HIBC MicroPDF417"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "hibcblkf", "zint", tr("HIBC Codablock-F"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "hibcaz", "zint", tr("HIBC Aztec Code"), registerStyle( "hibcaz", "zint", tr("HIBC Aztec Code"),
true, true, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "i25", "zint", tr("Interleaved 2 of 5"), registerStyle( "i25", "zint", tr("Interleaved 2 of 5"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "isbn", "zint", tr("ISBN"), registerStyle( "isbn", "zint", tr("ISBN"),
true, true, true, false, "123456789", false, 9 ); true, true, true, false, "123456789", false, 9 );
@@ -385,67 +438,82 @@ namespace glabels
true, true, true, false, "123456", false, 6 ); true, true, true, false, "123456", false, 6 );
registerStyle( "logm", "zint", tr("LOGMARS"), registerStyle( "logm", "zint", tr("LOGMARS"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "maxi", "zint", tr("Maxicode"), registerStyle( "maxi", "zint", tr("Maxicode"),
false, false, false, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "mpdf", "zint", tr("Micro PDF417"), registerStyle( "mpdf", "zint", tr("MicroPDF417"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "mqr", "zint", tr("Micro QR Code"), registerStyle( "mqr", "zint", tr("Micro QR Code"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "msi", "zint", tr("MSI Plessey"), registerStyle( "msi", "zint", tr("MSI Plessey"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, true, "0000000000", true, 10 );
registerStyle( "nve", "zint", tr("NVE-18"), registerStyle( "nve", "zint", tr("NVE-18 (SSCC-18)"),
true, true, true, false, "12345678901234567", false, 17 ); true, true, true, false, "12345678901234567", false, 17 );
registerStyle( "pdf", "zint", tr("PDF417"), registerStyle( "pdf", "zint", tr("PDF417"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "pdft", "zint", tr("PDF417 Truncated"), registerStyle( "pdft", "zint", tr("PDF417 Compact"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "plan", "zint", tr("PLANET"), registerStyle( "plan", "zint", tr("PLANET"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "00000000000", true, 11 );
registerStyle( "postnet", "zint", tr("PostNet"), registerStyle( "postnet", "zint", tr("POSTNET"),
true, true, true, false, "0000000000", true, 10 ); false, false, true, false, "00000000000", true, 11 );
registerStyle( "pharma", "zint", tr("Pharmacode"), registerStyle( "pharma", "zint", tr("Pharmacode"),
false, false, true, false, "123456", false, 6 ); false, false, false, false, "123456", false, 6 );
registerStyle( "pharma2", "zint", tr("Pharmacode 2-track"), registerStyle( "pharma2", "zint", tr("Pharmacode 2-track"),
false, false, true, false, "12345678", false, 8 ); false, false, false, false, "12345678", false, 8 );
registerStyle( "pzn", "zint", tr("Pharmazentral Nummer (PZN)"), registerStyle( "pzn", "zint", tr("Pharmazentralnummer (PZN)"),
true, true, true, false, "123456", false, 6 ); true, true, true, false, "1234567", false, 7 );
registerStyle( "qr", "zint", tr("QR Code"), registerStyle( "qr", "zint", tr("QR Code"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "rm4", "zint", tr("Royal Mail 4-State"),
false, false, true, false, "0000000000", true, 10 ); false, false, true, false, "0000000000", true, 10 );
registerStyle( "rmqr", "zint", tr("rMQR (Rectangular Micro QR)"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "rm4", "zint", tr("Royal Mail 4-State Customer"),
false, false, true, false, "0000000000", true, 10 );
registerStyle( "rm4sm", "zint", tr("Royal Mail 4-State Mailmark"),
false, false, true, false, "01000000000000000AA00AA0A", true, 25 );
registerStyle( "rm2dm", "zint", tr("Royal Mail 2-D Mailmark"),
false, false, true, false, "012100123412345678AB19XY1A 0", true, 28 );
registerStyle( "tele", "zint", tr("Telepen"), registerStyle( "tele", "zint", tr("Telepen"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, false, "0000000000", true, 10 );
registerStyle( "telex", "zint", tr("Telepen Numeric"), registerStyle( "telex", "zint", tr("Telepen Numeric"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, false, "0000000000", true, 10 );
registerStyle( "pls", "zint", tr("UK Plessey"),
true, true, true, false, "0000000000", true, 10 );
registerStyle( "upc-a", "zint", tr("UPC-A"), registerStyle( "upc-a", "zint", tr("UPC-A"),
true, true, true, false, "12345678901", false, 11 ); true, true, true, false, "12345678901", false, 11 );
registerStyle( "upc-e", "zint", tr("UPC-E"), registerStyle( "upc-e", "zint", tr("UPC-E"),
true, true, true, false, "1234567", false, 7 ); true, true, true, false, "1234567", false, 7 );
registerStyle( "usps", "zint", tr("USPS One Code"), registerStyle( "upus10", "zint", tr("UPU S10"),
true, true, true, false, "EE876543216CA", false, 13 );
registerStyle( "usps", "zint", tr("USPS Intelligent Mail"),
false, false, true, false, "12345678901234567890", true, 20 ); false, false, true, false, "12345678901234567890", true, 20 );
registerStyle( "pls", "zint", tr("UK Plessey"), registerStyle( "vin", "zint", tr("VIN (Vehicle ID Number)"),
true, true, true, false, "0000000000", true, 10 ); true, true, true, false, "12345678701234567", false, 27 );
#endif // HAVE_ZINT #endif // HAVE_ZINT
} }
+1
View File
@@ -19,6 +19,7 @@ endif ()
if (${LIBZINT_FOUND}) if (${LIBZINT_FOUND})
add_definitions (-DHAVE_ZINT=1) add_definitions (-DHAVE_ZINT=1)
add_definitions (-DHAVE_ZINT=1 -DLIBZINT_VERSION=${LIBZINT_VERSION})
set (OPTIONAL_ZINT ZINT::ZINT) set (OPTIONAL_ZINT ZINT::ZINT)
else () else ()
set (OPTIONAL_ZINT "") set (OPTIONAL_ZINT "")
+387 -28
View File
@@ -31,6 +31,7 @@ namespace
const double FONT_SCALE = 0.9; const double FONT_SCALE = 0.9;
const int W_PTS_DEFAULT = 144; const int W_PTS_DEFAULT = 144;
const int H_PTS_DEFAULT = 72; const int H_PTS_DEFAULT = 72;
const double TWO_DIVIDED_BY_SQRT3 = 1.15470053837925152902;
} }
@@ -42,6 +43,14 @@ namespace glabels
{ {
//
// Base constructor
//
Base::Base() : symbology(0), option_2(0)
{
}
// //
// Zint barcode data validation method // Zint barcode data validation method
// //
@@ -63,31 +72,24 @@ namespace glabels
/* /*
* First encode using Zint barcode library. * First encode using Zint barcode library.
*/ */
if ( w == 0 ) zint_symbol* symbol = ZBarcode_Create();
{
w = W_PTS_DEFAULT;
}
if ( h == 0 )
{
h = H_PTS_DEFAULT;
}
zint_symbol* symbol = ZBarcode_Create();;
symbol->symbology = symbology; symbol->symbology = symbology;
symbol->input_mode = UNICODE_MODE;
symbol->scale = 0.5f; // Pixels
symbol->option_2 = option_2; // Currently just check digit
symbol->show_hrt = showText();
if ( ZBarcode_Encode( symbol, (unsigned char*)(cookedData.c_str()), 0 ) != 0 ) if ( ZBarcode_Encode( symbol, (unsigned char*)(cookedData.c_str()), 0 ) >= 5 /*ZINT_ERROR*/ )
{ {
qDebug() << "Zint::ZBarcode_Encode: " << QString(symbol->errtxt); qDebug() << "Zint::ZBarcode_Encode: " << QString(symbol->errtxt);
setIsDataValid( false ); setIsDataValid( false );
return; return;
} }
symbol->show_hrt = showText(); if ( ZBarcode_Buffer_Vector( symbol, 0 ) >= 5 /*ZINT_ERROR*/ )
if ( ZBarcode_Render( symbol, (float)w, (float)h ) == 0 )
{ {
qDebug() << "Zint::ZBarcode_Render: " << QString(symbol->errtxt); qDebug() << "Zint::ZBarcode_Buffer_Vector: " << QString(symbol->errtxt);
setIsDataValid( false ); setIsDataValid( false );
return; return;
} }
@@ -96,32 +98,73 @@ namespace glabels
/* /*
* Now do the actual vectorization. * Now do the actual vectorization.
*/ */
zint_render *render = symbol->rendered; zint_vector *vector = symbol->vector;
setWidth( render->width ); w = std::max( w, 5.0 ); // TODO: proper minimum
setHeight( render->height ); h = std::max( h, 5.0 ); // TODO: proper minimum
for ( zint_render_line *zline = render->lines; zline != nullptr; zline = zline->next ) if ( ZBarcode_Cap( symbol->symbology, ZINT_CAP_FIXED_RATIO ) & ZINT_CAP_FIXED_RATIO )
{ {
addBox( zline->x, zline->y, zline->width, zline->length ); if ( vector->width == vector->height )
{
w = h = std::min(w, h);
}
else
{
// Keep aspect ratio
if ( h < w )
{
w = h * vector->width / vector->height;
}
else
{
h = w * vector->height / vector->width;
}
}
} }
for ( zint_render_ring *zring = render->rings; zring != nullptr; zring = zring->next ) double xscale = w / vector->width;
double yscale = h / vector->height;
setWidth( vector->width*xscale );
setHeight( vector->height*yscale );
for ( zint_vector_rect *zrect = vector->rectangles; zrect != nullptr; zrect = zrect->next )
{ {
addRing( zring->x, zring->y, zring->radius, zring->line_width ); addBox( zrect->x*xscale,
zrect->y*yscale,
zrect->width*xscale,
zrect->height*yscale );
} }
for ( zint_render_hexagon *zhexagon = render->hexagons; zhexagon != nullptr; zhexagon = zhexagon->next ) for ( zint_vector_circle *zcircle = vector->circles; zcircle != nullptr; zcircle = zcircle->next )
{ {
addHexagon( zhexagon->x, zhexagon->y, 2.89 ); double line_width = zcircle->width*xscale;
addRing( zcircle->x*xscale,
zcircle->y*yscale,
zcircle->diameter*xscale/2,
line_width );
}
for ( zint_vector_hexagon *zhexagon = vector->hexagons; zhexagon != nullptr; zhexagon = zhexagon->next )
{
// Convert from Zint's horizontal short diameter (X) to vertical long diameter (V).
double h = TWO_DIVIDED_BY_SQRT3*zhexagon->diameter*yscale;
addHexagon( zhexagon->x*xscale, // Center x same as apex x
zhexagon->y*yscale - h/2, // Subtract radius to convert from center y to apex y
h );
} }
if( showText() ) if( showText() )
{ {
for ( zint_render_string *zstring = render->strings; zstring != nullptr; zstring = zstring->next ) for ( zint_vector_string *zstring = vector->strings; zstring != nullptr; zstring = zstring->next )
{ {
double fsize = FONT_SCALE*zstring->fsize; auto halign = static_cast<glbarcode::HAlign>(zstring->halign); // zint values match glbarcode enum
addText( zstring->x, zstring->y+0.75*fsize, fsize, QString((char*)(zstring->text)).toStdString() ); addText( zstring->x*xscale,
zstring->y*yscale,
zstring->fsize*std::min( xscale, yscale ), // TODO: do something better here
std::string((const char*)zstring->text),
halign );
} }
} }
@@ -223,6 +266,22 @@ namespace glabels
symbology = BARCODE_AZRUNE; symbology = BARCODE_AZRUNE;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// Channel Code Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Channel::create()
{
return new Channel();
}
std::string Channel::encode( const std::string& cookedData )
{
symbology = BARCODE_CHANNEL;
return ""; // Actual encoding is done in vectorize
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
@@ -237,6 +296,26 @@ namespace glabels
std::string Cbr::encode( const std::string& cookedData ) std::string Cbr::encode( const std::string& cookedData )
{ {
symbology = BARCODE_CODABAR; symbology = BARCODE_CODABAR;
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Codablock-F Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Cblockf::create()
{
return new Cblockf();
}
std::string Cblockf::encode( const std::string& cookedData )
{
symbology = BARCODE_CODABLOCKF;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -269,6 +348,10 @@ namespace glabels
std::string Code11::encode( const std::string& cookedData ) std::string Code11::encode( const std::string& cookedData )
{ {
symbology = BARCODE_CODE11; symbology = BARCODE_CODE11;
if (!checksum()) // Note default is 2 visible check digits
{
option_2 = 2;
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -300,7 +383,11 @@ namespace glabels
std::string C25m::encode( const std::string& cookedData ) std::string C25m::encode( const std::string& cookedData )
{ {
symbology = BARCODE_C25MATRIX; symbology = BARCODE_C25MATRIX; // BARCODE_C25STANDARD
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -317,6 +404,30 @@ namespace glabels
std::string C25i::encode( const std::string& cookedData ) std::string C25i::encode( const std::string& cookedData )
{ {
symbology = BARCODE_C25IATA; symbology = BARCODE_C25IATA;
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Code 2 of 5 Industrial Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* C25ind::create()
{
return new C25ind();
}
std::string C25ind::encode( const std::string& cookedData )
{
symbology = BARCODE_C25IND;
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -333,6 +444,10 @@ namespace glabels
std::string C25dl::encode( const std::string& cookedData ) std::string C25dl::encode( const std::string& cookedData )
{ {
symbology = BARCODE_C25LOGIC; symbology = BARCODE_C25LOGIC;
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -365,6 +480,10 @@ namespace glabels
std::string Code39::encode( const std::string& cookedData ) std::string Code39::encode( const std::string& cookedData )
{ {
symbology = BARCODE_CODE39; symbology = BARCODE_CODE39;
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -381,6 +500,10 @@ namespace glabels
std::string Code39e::encode( const std::string& cookedData ) std::string Code39e::encode( const std::string& cookedData )
{ {
symbology = BARCODE_EXCODE39; symbology = BARCODE_EXCODE39;
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -511,6 +634,38 @@ namespace glabels
symbology = BARCODE_DPIDENT; symbology = BARCODE_DPIDENT;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// DotCode Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Dotcode::create()
{
return new Dotcode();
}
std::string Dotcode::encode( const std::string& cookedData )
{
symbology = BARCODE_DOTCODE;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// DPD Code Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Dpd::create()
{
return new Dpd();
}
std::string Dpd::encode( const std::string& cookedData )
{
symbology = BARCODE_DPD;
return ""; // Actual encoding is done in vectorize
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
@@ -543,6 +698,70 @@ namespace glabels
symbology = BARCODE_EANX; symbology = BARCODE_EANX;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// EAN-14 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Ean14::create()
{
return new Ean14();
}
std::string Ean14::encode( const std::string& cookedData )
{
symbology = BARCODE_EAN14;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Facing Identification Mark Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Fim::create()
{
return new Fim();
}
std::string Fim::encode( const std::string& cookedData )
{
symbology = BARCODE_FIM;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Flattermarken Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Flat::create()
{
return new Flat();
}
std::string Flat::encode( const std::string& cookedData )
{
symbology = BARCODE_FLAT;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Han Xin Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Hanxin::create()
{
return new Hanxin();
}
std::string Hanxin::encode( const std::string& cookedData )
{
symbology = BARCODE_HANXIN;
return ""; // Actual encoding is done in vectorize
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
@@ -639,6 +858,22 @@ namespace glabels
symbology = BARCODE_HIBC_MICPDF; symbology = BARCODE_HIBC_MICPDF;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// HIBC Codablock-F Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Hibcblkf::create()
{
return new Hibcblkf();
}
std::string Hibcblkf::encode( const std::string& cookedData )
{
symbology = BARCODE_HIBC_BLOCKF;
return ""; // Actual encoding is done in vectorize
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
@@ -669,6 +904,10 @@ namespace glabels
std::string I25::encode( const std::string& cookedData ) std::string I25::encode( const std::string& cookedData )
{ {
symbology = BARCODE_C25INTER; symbology = BARCODE_C25INTER;
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -749,6 +988,10 @@ namespace glabels
std::string Logm::encode( const std::string& cookedData ) std::string Logm::encode( const std::string& cookedData )
{ {
symbology = BARCODE_LOGMARS; symbology = BARCODE_LOGMARS;
if (checksum())
{
option_2 = 1;
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -1005,6 +1248,10 @@ namespace glabels
std::string Msi::encode( const std::string& cookedData ) std::string Msi::encode( const std::string& cookedData )
{ {
symbology = BARCODE_MSI_PLESSEY; symbology = BARCODE_MSI_PLESSEY;
if (checksum())
{
option_2 = 1; // 1 visible mod-10 check digit
}
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
@@ -1071,6 +1318,38 @@ namespace glabels
symbology = BARCODE_POSTNET; symbology = BARCODE_POSTNET;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// BC412 (SEMI T1-95) Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Bc412::create()
{
return new Bc412();
}
std::string Bc412::encode( const std::string& cookedData )
{
symbology = BARCODE_BC412;
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// CEPNet Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Cepnet::create()
{
return new Cepnet();
}
std::string Cepnet::encode( const std::string& cookedData )
{
symbology = BARCODE_CEPNET;
return ""; // Actual encoding is done in vectorize
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
@@ -1119,6 +1398,22 @@ namespace glabels
symbology = BARCODE_QRCODE; symbology = BARCODE_QRCODE;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// rMQR Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Rmqr::create()
{
return new Rmqr();
}
std::string Rmqr::encode( const std::string& cookedData )
{
symbology = BARCODE_RMQR;
return ""; // Actual encoding is done in vectorize
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
@@ -1135,6 +1430,38 @@ namespace glabels
symbology = BARCODE_RM4SCC; symbology = BARCODE_RM4SCC;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// Royal Mail 4-State Mailmark Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Rm4sm::create()
{
return new Rm4sm();
}
std::string Rm4sm::encode( const std::string& cookedData )
{
symbology = BARCODE_MAILMARK; // BARCODE_MAILMARK_4S
return ""; // Actual encoding is done in vectorize
}
//////////////////////////////////////////////////////
// Royal Mail 2-D Mailmark Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Rm2dm::create()
{
return new Rm2dm();
}
std::string Rm2dm::encode( const std::string& cookedData )
{
symbology = BARCODE_MAILMARK_2D;
return ""; // Actual encoding is done in vectorize
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
@@ -1167,6 +1494,22 @@ namespace glabels
symbology = BARCODE_UPCE; symbology = BARCODE_UPCE;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// UPU S10 Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* UpuS10::create()
{
return new UpuS10();
}
std::string UpuS10::encode( const std::string& cookedData )
{
symbology = BARCODE_UPU_S10;
return ""; // Actual encoding is done in vectorize
}
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
@@ -1199,6 +1542,22 @@ namespace glabels
symbology = BARCODE_PLESSEY; symbology = BARCODE_PLESSEY;
return ""; // Actual encoding is done in vectorize return ""; // Actual encoding is done in vectorize
} }
//////////////////////////////////////////////////////
// Vehicle Identification Number Barcode
//////////////////////////////////////////////////////
glbarcode::Barcode* Vin::create()
{
return new Vin();
}
std::string Vin::encode( const std::string& cookedData )
{
symbology = BARCODE_VIN;
return ""; // Actual encoding is done in vectorize
}
} }
+226 -2
View File
@@ -42,8 +42,11 @@ namespace glabels
{ {
protected: protected:
int symbology; int symbology;
int option_2;
Base();
bool validate( const std::string& rawData ) override; bool validate( const std::string& rawData ) override;
void vectorize( const std::string& encodedData, void vectorize( const std::string& encodedData,
@@ -132,6 +135,19 @@ namespace glabels
}; };
/**
* Channel Barcode
*/
class Channel : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* Cbr Barcode * Cbr Barcode
*/ */
@@ -145,6 +161,19 @@ namespace glabels
}; };
/**
* Codeblock-F Barcode
*/
class Cblockf : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* Code1 Barcode * Code1 Barcode
*/ */
@@ -210,6 +239,19 @@ namespace glabels
}; };
/**
* Code 2 of 5 Industrial Barcode
*/
class C25ind : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* C25dl Barcode * C25dl Barcode
*/ */
@@ -366,6 +408,32 @@ namespace glabels
}; };
/**
* DotCode Barcode
*/
class Dotcode : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* DPD Code Barcode
*/
class Dpd : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* Kix Barcode * Kix Barcode
*/ */
@@ -392,6 +460,58 @@ namespace glabels
}; };
/**
* EAN-14 Barcode
*/
class Ean14 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Facing Identification Mark Barcode
*/
class Fim : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Flattermarken Barcode
*/
class Flat : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Han Xin Barcode
*/
class Hanxin : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* Hibc128 Barcode * Hibc128 Barcode
*/ */
@@ -470,6 +590,19 @@ namespace glabels
}; };
/**
* HIBC Codablock-F Barcode
*/
class Hibcblkf : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* Hibcaz Barcode * Hibcaz Barcode
*/ */
@@ -821,6 +954,32 @@ namespace glabels
}; };
/**
* BC412 (SEMI T1-95) Barcode
*/
class Bc412 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* CEPNet Barcode
*/
class Cepnet : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* Pdf Barcode * Pdf Barcode
*/ */
@@ -860,6 +1019,19 @@ namespace glabels
}; };
/**
* rMQR Barcode
*/
class Rmqr : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* Rm4 Barcode * Rm4 Barcode
*/ */
@@ -873,6 +1045,32 @@ namespace glabels
}; };
/**
* Royal Mail 4-State Mailmark Barcode
*/
class Rm4sm : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/**
* Royal Mail 2-D Mailmark Barcode
*/
class Rm2dm : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* UpcA Barcode * UpcA Barcode
*/ */
@@ -899,6 +1097,19 @@ namespace glabels
}; };
/**
* UPU S10 Barcode
*/
class UpuS10 : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
/** /**
* Usps Barcode * Usps Barcode
*/ */
@@ -925,6 +1136,19 @@ namespace glabels
}; };
/**
* Vehicle Identification Number Barcode
*/
class Vin : public Base
{
public:
static Barcode* create();
protected:
std::string encode( const std::string& cookedData ) override;
};
} }
} }
} }
+18 -6
View File
@@ -37,17 +37,29 @@ if (LIBZINT_INCLUDE_DIR AND EXISTS "${LIBZINT_INCLUDE_DIR}/zint.h")
file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MAJOR_H REGEX "^#define ZINT_VERSION_MAJOR *[0-9]*") file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MAJOR_H REGEX "^#define ZINT_VERSION_MAJOR *[0-9]*")
file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MINOR_H REGEX "^#define ZINT_VERSION_MINOR *[0-9]*") file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MINOR_H REGEX "^#define ZINT_VERSION_MINOR *[0-9]*")
file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MICRO_H REGEX "^#define ZINT_VERSION_RELEASE *[0-9]*") file (STRINGS "${LIBZINT_INCLUDE_DIR}/zint.h" ZINT_MICRO_H REGEX "^#define ZINT_VERSION_RELEASE *[0-9]*")
string (REGEX REPLACE "^.*VERSION_MAJOR *([0-9]*)" "\\1" ZINT_MAJOR ${ZINT_MAJOR_H}) if (ZINT_MAJOR_H) # ZINT_MINOR_H and ZINT_MICRO_H may be zero so don't test
string (REGEX REPLACE "^.*VERSION_MINOR *([0-9]*)" "\\1" ZINT_MINOR ${ZINT_MINOR_H}) string (REGEX REPLACE "^.*VERSION_MAJOR *([0-9]*)" "\\1" ZINT_MAJOR ${ZINT_MAJOR_H})
string (REGEX REPLACE "^.*VERSION_RELEASE *([0-9]*)" "\\1" ZINT_MICRO ${ZINT_MICRO_H}) string (REGEX REPLACE "^.*VERSION_MINOR *([0-9]*)" "\\1" ZINT_MINOR "${ZINT_MINOR_H}")
set (LIBZINT_VERSION_STRING ${ZINT_MAJOR}.${ZINT_MINOR}.${ZINT_MICRO}) string (REGEX REPLACE "^.*VERSION_RELEASE *([0-9]*)" "\\1" ZINT_MICRO "${ZINT_MICRO_H}")
endif() set (LIBZINT_VERSION_STRING ${ZINT_MAJOR}.${ZINT_MINOR}.${ZINT_MICRO})
math (EXPR LIBZINT_VERSION "${ZINT_MAJOR} * 10000 + ${ZINT_MINOR} * 100 + ${ZINT_MICRO}")
else ()
execute_process(COMMAND "zint" "-h" OUTPUT_VARIABLE EXEC_ZINT_VERSION ERROR_QUIET)
if (EXEC_ZINT_VERSION)
string (REGEX REPLACE "^Zint version ([0-9.]+).*$" "\\1" LIBZINT_VERSION_STRING ${EXEC_ZINT_VERSION})
string (REGEX REPLACE "^([0-9]+).*$" "\\1" ZINT_MAJOR ${LIBZINT_VERSION_STRING})
string (REGEX REPLACE "^[0-9]+\.([0-9]+).*$" "\\1" ZINT_MINOR ${LIBZINT_VERSION_STRING})
string (REGEX REPLACE "^[0-9]+\.[0-9]+\.([0-9]+).*$" "\\1" ZINT_MICRO ${LIBZINT_VERSION_STRING})
math (EXPR LIBZINT_VERSION "${ZINT_MAJOR} * 10000 + ${ZINT_MINOR} * 100 + ${ZINT_MICRO}")
endif ()
endif ()
endif ()
# handle the QUIETLY and REQUIRED arguments and set LIBZINT_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set LIBZINT_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibZint find_package_handle_standard_args(LibZint
REQUIRED_VARS LIBZINT_LIBRARY LIBZINT_INCLUDE_DIR REQUIRED_VARS LIBZINT_LIBRARY LIBZINT_INCLUDE_DIR LIBZINT_VERSION
VERSION_VAR LIBZINT_VERSION_STRING) VERSION_VAR LIBZINT_VERSION_STRING)
mark_as_advanced(LIBZINT_INCLUDE_DIR LIBZINT_LIBRARY) mark_as_advanced(LIBZINT_INCLUDE_DIR LIBZINT_LIBRARY)
+5 -5
View File
@@ -42,11 +42,11 @@ _Zint (Optional)_
Install zint from source: Install zint from source:
``` ```
$ wget https://downloads.sourceforge.net/project/zint/zint/2.6.3/zint-2.6.3_final.tar.gz wget https://downloads.sourceforge.net/project/zint/zint/2.15.0/zint-2.15.0-src.tar.gz
$ tar xzf zint-2.6.3_final.tar.gz tar xzf zint-2.15.0-src.tar.gz
$ cd zint-2.6.3.src/ cd zint-2.15.0-src/
$ mkdir build && cd build && cmake .. && make mkdir build && cd build && cmake .. && make
$ sudo make install sudo make install
``` ```
_GNU Barcode (Optional)_ _GNU Barcode (Optional)_
+2 -2
View File
@@ -174,9 +174,9 @@ namespace glbarcode
} }
void Barcode::addText( double x, double y, double size, const std::string& text ) void Barcode::addText( double x, double y, double size, const std::string& text, HAlign halign )
{ {
d->mPrimitives.push_back( new DrawingPrimitiveText( x, y, size, text ) ); d->mPrimitives.push_back( new DrawingPrimitiveText( x, y, size, text, halign ) );
} }
+7 -5
View File
@@ -24,6 +24,7 @@
#include <string> #include <string>
#include "Enums.h"
#include "Renderer.h" #include "Renderer.h"
@@ -215,12 +216,13 @@ namespace glbarcode
* *
* @image html figure-primitive-text.svg "Text primitive properties" * @image html figure-primitive-text.svg "Text primitive properties"
* *
* @param[in] x X coordinate of text's origin (points) * @param[in] x X coordinate of text's origin (points)
* @param[in] y Y coordinate of text's origin (points) * @param[in] y Y coordinate of text's origin (points)
* @param[in] size Font size of text (points) * @param[in] size Font size of text (points)
* @param[in] text Text * @param[in] text Text
* @param[in] halign Horizontal text alignment
*/ */
void addText( double x, double y, double size, const std::string& text ); void addText( double x, double y, double size, const std::string& text, HAlign halign = H_ALIGN_CENTER );
/** /**
+8 -2
View File
@@ -81,8 +81,8 @@ namespace glbarcode
DrawingPrimitiveText::DrawingPrimitiveText( double x, double y, double size, const std::string& text ) DrawingPrimitiveText::DrawingPrimitiveText( double x, double y, double size, const std::string& text, HAlign halign )
: DrawingPrimitive( x, y ), mSize(size), mText(text) : DrawingPrimitive( x, y ), mSize(size), mText(text), mHalign(halign)
{ {
} }
@@ -99,6 +99,12 @@ namespace glbarcode
} }
HAlign DrawingPrimitiveText::halign() const
{
return mHalign;
}
DrawingPrimitiveRing::DrawingPrimitiveRing( double x, double y, double r, double w ) DrawingPrimitiveRing::DrawingPrimitiveRing( double x, double y, double r, double w )
: DrawingPrimitive( x, y ), mR(r), mW(w) : DrawingPrimitive( x, y ), mR(r), mW(w)
+14 -5
View File
@@ -22,6 +22,8 @@
#define glbarcode_DrawingPrimitives_h #define glbarcode_DrawingPrimitives_h
#include "Enums.h"
#include <string> #include <string>
@@ -163,12 +165,13 @@ namespace glbarcode
/** /**
* Text constructor * Text constructor
* *
* @param[in] x X coordinate of text's origin (points) * @param[in] x X coordinate of text's origin (points)
* @param[in] y Y coordinate of text's origin (points) * @param[in] y Y coordinate of text's origin (points)
* @param[in] size Font size of text (points) * @param[in] size Font size of text (points)
* @param[in] text Text * @param[in] text Text
* @param[in] halign Horizontal text alignment
*/ */
DrawingPrimitiveText( double x, double y, double size, const std::string& text ); DrawingPrimitiveText( double x, double y, double size, const std::string& text, HAlign halign = H_ALIGN_CENTER );
/** /**
* Get font size (points). * Get font size (points).
@@ -180,9 +183,15 @@ namespace glbarcode
*/ */
const std::string& text() const; const std::string& text() const;
/**
* Get horizontal alignment.
*/
HAlign halign() const;
private: private:
double mSize; /**< Font size of text (points). */ double mSize; /**< Font size of text (points). */
std::string mText; /**< Text. */ std::string mText; /**< Text. */
HAlign mHalign; /**< Horizontal alignment. */
}; };
+38
View File
@@ -0,0 +1,38 @@
/* Enums.h
*
* Copyright (C) 2013 Jaye Evins <evins@snaught.com>
*
* This file is part of glbarcode++.
*
* glbarcode++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* glbarcode++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with glbarcode++. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef glbarcode_Enums_h
#define glbarcode_Enums_h
namespace glbarcode
{
enum HAlign
{
H_ALIGN_CENTER = 0,
H_ALIGN_LEFT = 1,
H_ALIGN_RIGHT = 2
};
}
#endif // glbarcode_Enums_h
+13 -4
View File
@@ -30,6 +30,7 @@
namespace namespace
{ {
const double FONT_SCALE = 0.75; const double FONT_SCALE = 0.75;
const double MIN_POINT_SIZE = 0.4; // Less than ~0.37 causes issues for QFontMetricsF
} }
@@ -122,7 +123,7 @@ namespace glbarcode
} }
void QtRenderer::drawText( double x, double y, double size, const std::string& text ) void QtRenderer::drawText( double x, double y, double size, const std::string& text, HAlign halign )
{ {
if ( d->painter ) if ( d->painter )
{ {
@@ -131,10 +132,18 @@ namespace glbarcode
QFont font; QFont font;
font.setStyleHint( QFont::Monospace ); font.setStyleHint( QFont::Monospace );
font.setFamily( "monospace" ); font.setFamily( "monospace" );
font.setPointSizeF( FONT_SCALE*size ); font.setPointSizeF( std::max( FONT_SCALE*size, MIN_POINT_SIZE ) );
QFontMetricsF fm( font ); QFontMetricsF fm( font );
double xCorner = x - fm.horizontalAdvance( QString::fromStdString(text) )/2.0; double xCorner = x;
if ( halign == H_ALIGN_CENTER )
{
xCorner -= fm.horizontalAdvance( QString::fromStdString(text) )/2.0;
}
else if ( halign == H_ALIGN_RIGHT )
{
xCorner -= fm.horizontalAdvance( QString::fromStdString(text) );
}
double yCorner = y - fm.ascent(); double yCorner = y - fm.ascent();
QTextLayout layout( QString::fromStdString(text), font ); QTextLayout layout( QString::fromStdString(text), font );
@@ -151,7 +160,7 @@ namespace glbarcode
if ( d->painter ) if ( d->painter )
{ {
d->painter->setPen( QPen( d->color, w ) ); d->painter->setPen( QPen( d->color, w ) );
d->painter->setBrush( Qt::NoBrush ); d->painter->setBrush( w ? Qt::NoBrush : QBrush( d->color ) );
d->painter->drawEllipse( QPointF(x, y), r, r ); d->painter->drawEllipse( QPointF(x, y), r, r );
} }
+1 -1
View File
@@ -76,7 +76,7 @@ namespace glbarcode
void drawEnd() override; void drawEnd() override;
void drawLine( double x, double y, double w, double h ) override; void drawLine( double x, double y, double w, double h ) override;
void drawBox( double x, double y, double w, double h ) override; void drawBox( double x, double y, double w, double h ) override;
void drawText( double x, double y, double size, const std::string& text ) override; void drawText( double x, double y, double size, const std::string& text, HAlign halign = H_ALIGN_CENTER ) override;
void drawRing( double x, double y, double r, double w ) override; void drawRing( double x, double y, double r, double w ) override;
void drawHexagon( double x, double y, double h ) override; void drawHexagon( double x, double y, double h ) override;
+1 -1
View File
@@ -41,7 +41,7 @@ void glbarcode::Renderer::render( double w, double h, const std::list<DrawingPri
} }
else if ( auto* text = dynamic_cast<DrawingPrimitiveText*>(*primitive) ) else if ( auto* text = dynamic_cast<DrawingPrimitiveText*>(*primitive) )
{ {
drawText( text->x(), text->y(), text->size(), text->text() ); drawText( text->x(), text->y(), text->size(), text->text(), text->halign() );
} }
else if ( auto* ring = dynamic_cast<DrawingPrimitiveRing*>(*primitive) ) else if ( auto* ring = dynamic_cast<DrawingPrimitiveRing*>(*primitive) )
{ {
+1 -1
View File
@@ -132,7 +132,7 @@ namespace glbarcode
* @param[in] size Font size of text (points) * @param[in] size Font size of text (points)
* @param[in] text Text * @param[in] text Text
*/ */
virtual void drawText( double x, double y, double size, const std::string& text ) = 0; virtual void drawText( double x, double y, double size, const std::string& text, HAlign halign = H_ALIGN_CENTER ) = 0;
/** /**
+2 -1
View File
@@ -49,6 +49,7 @@ namespace glabels
const Distance pad = Distance::pt(4); const Distance pad = Distance::pt(4);
const Distance minW = Distance::pt(18); const Distance minW = Distance::pt(18);
const Distance minH = Distance::pt(18); const Distance minH = Distance::pt(18);
const double MIN_POINT_SIZE = 0.4; // Less than ~0.37 causes issues for QFontMetricsF
} }
@@ -508,7 +509,7 @@ namespace glabels
{ {
double scaleX = wPts / textRect.width(); double scaleX = wPts / textRect.width();
double scaleY = hPts / textRect.height(); double scaleY = hPts / textRect.height();
font.setPointSizeF( 6 * std::min( scaleX, scaleY ) ); font.setPointSizeF( std::max( 6 * std::min( scaleX, scaleY ), MIN_POINT_SIZE ) );
} }
// //
+118 -54
View File
@@ -2555,10 +2555,6 @@
<source>Aztec Code</source> <source>Aztec Code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Aztec Rune</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Code One</source> <source>Code One</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -2571,10 +2567,6 @@
<source>Code 16K</source> <source>Code 16K</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Code 2 of 5 Matrix</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Code 2 of 5 IATA</source> <source>Code 2 of 5 IATA</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -2627,22 +2619,6 @@
<source>GS1-128</source> <source>GS1-128</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>GS1 DataBar-14</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GS1 DataBar-14 Stacked</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GS1 DataBar-14 Stacked Omni.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GS1 DataBar Extended Stacked</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>HIBC Code 128</source> <source>HIBC Code 128</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -2663,10 +2639,6 @@
<source>HIBC PDF417</source> <source>HIBC PDF417</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>HIBC Micro PDF417</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>HIBC Aztec Code</source> <source>HIBC Aztec Code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -2691,10 +2663,6 @@
<source>Maxicode</source> <source>Maxicode</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Micro PDF417</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Micro QR Code</source> <source>Micro QR Code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -2703,26 +2671,14 @@
<source>MSI Plessey</source> <source>MSI Plessey</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>NVE-18</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>PDF417</source> <source>PDF417</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>PDF417 Truncated</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>PLANET</source> <source>PLANET</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>PostNet</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Pharmacode</source> <source>Pharmacode</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -2731,18 +2687,10 @@
<source>Pharmacode 2-track</source> <source>Pharmacode 2-track</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Pharmazentral Nummer (PZN)</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>QR Code</source> <source>QR Code</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Royal Mail 4-State</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Telepen</source> <source>Telepen</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -2752,11 +2700,127 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>USPS One Code</source> <source>UK Plessey</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>UK Plessey</source> <source>Aztec Runes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>CEPNet (Brazilian Post)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Codablock-F</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Code 2 of 5 Standard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GS1 DataBar Stacked</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GS1 DataBar Stacked Omni.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GS1 DataBar Expanded Stacked</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>HIBC MicroPDF417</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>MicroPDF417</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>NVE-18 (SSCC-18)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PDF417 Compact</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pharmazentralnummer (PZN)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Channel Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Code 2 of 5 Industrial</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DotCode</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>EAN-14</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>GS1 DataBar Omnidirectional</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Han Xin</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Flattermarken</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DPD Code</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>POSTNET</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Royal Mail 4-State Mailmark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UPU S10</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>FIM (Facing ID Mark)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>rMQR (Rectangular Micro QR)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Royal Mail 4-State Customer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>VIN (Vehicle ID Number)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>HIBC Codablock-F</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Royal Mail 2-D Mailmark</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>BC412 (SEMI TI-95)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>