2008-07-14 01:15:55 +04:00
/* auspost.c - Handles Australia Post 4-State Barcode */
/*
libzint - the open source barcode library
2024-05-28 01:19:45 +03:00
Copyright ( C ) 2008 - 2024 Robin Stuart < rstuart114 @ gmail . com >
2013-05-16 21:26:38 +04:00
Redistribution and use in source and binary forms , with or without
modification , are permitted provided that the following conditions
are met :
2017-10-23 22:37:52 +03:00
1. Redistributions of source code must retain the above copyright
notice , this list of conditions and the following disclaimer .
2013-05-16 21:26:38 +04:00
2. Redistributions in binary form must reproduce the above copyright
2016-02-20 12:38:03 +03:00
notice , this list of conditions and the following disclaimer in the
2017-10-23 22:37:52 +03:00
documentation and / or other materials provided with the distribution .
2013-05-16 21:26:38 +04:00
3. Neither the name of the project nor the names of its contributors
2016-02-20 12:38:03 +03:00
may be used to endorse or promote products derived from this software
2017-10-23 22:37:52 +03:00
without specific prior written permission .
2013-05-16 21:26:38 +04:00
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS " AND
ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL
DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION )
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT
LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY
2017-10-23 22:37:52 +03:00
OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE .
2016-02-20 12:38:03 +03:00
*/
2022-06-24 16:38:48 +03:00
/* SPDX-License-Identifier: BSD-3-Clause */
2008-07-14 01:15:55 +04:00
2021-10-21 01:05:30 +03:00
static const char GDSET [ ] = " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz # " ;
# define GDSET_F (IS_NUM_F | IS_UPR_F | IS_LWR_F | IS_SPC_F | IS_HSH_F)
2008-07-14 01:15:55 +04:00
2021-10-21 01:05:30 +03:00
static const char AusNTable [ 10 ] [ 2 ] = {
{ ' 0 ' , ' 0 ' } , { ' 0 ' , ' 1 ' } , { ' 0 ' , ' 2 ' } , { ' 1 ' , ' 0 ' } , { ' 1 ' , ' 1 ' } , { ' 1 ' , ' 2 ' } , { ' 2 ' , ' 0 ' } , { ' 2 ' , ' 1 ' } , { ' 2 ' , ' 2 ' } , { ' 3 ' , ' 0 ' }
2016-02-20 12:38:03 +03:00
} ;
2021-10-21 01:05:30 +03:00
static const char AusCTable [ 64 ] [ 3 ] = {
{ ' 2 ' , ' 2 ' , ' 2 ' } , { ' 3 ' , ' 0 ' , ' 0 ' } , { ' 3 ' , ' 0 ' , ' 1 ' } , { ' 3 ' , ' 0 ' , ' 2 ' } , { ' 3 ' , ' 1 ' , ' 0 ' } , { ' 3 ' , ' 1 ' , ' 1 ' } ,
{ ' 3 ' , ' 1 ' , ' 2 ' } , { ' 3 ' , ' 2 ' , ' 0 ' } , { ' 3 ' , ' 2 ' , ' 1 ' } , { ' 3 ' , ' 2 ' , ' 2 ' } , { ' 0 ' , ' 0 ' , ' 0 ' } , { ' 0 ' , ' 0 ' , ' 1 ' } ,
{ ' 0 ' , ' 0 ' , ' 2 ' } , { ' 0 ' , ' 1 ' , ' 0 ' } , { ' 0 ' , ' 1 ' , ' 1 ' } , { ' 0 ' , ' 1 ' , ' 2 ' } , { ' 0 ' , ' 2 ' , ' 0 ' } , { ' 0 ' , ' 2 ' , ' 1 ' } ,
{ ' 0 ' , ' 2 ' , ' 2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 1 ' } ,
{ ' 1 ' , ' 3 ' , ' 2 ' } , { ' 1 ' , ' 3 ' , ' 3 ' } , { ' 2 ' , ' 0 ' , ' 0 ' } , { ' 2 ' , ' 0 ' , ' 1 ' } , { ' 2 ' , ' 0 ' , ' 2 ' } , { ' 2 ' , ' 0 ' , ' 3 ' } ,
{ ' 2 ' , ' 1 ' , ' 0 ' } , { ' 2 ' , ' 1 ' , ' 1 ' } , { ' 2 ' , ' 1 ' , ' 2 ' } , { ' 2 ' , ' 1 ' , ' 3 ' } , { ' 2 ' , ' 2 ' , ' 0 ' } , { ' 2 ' , ' 2 ' , ' 1 ' } ,
{ ' 2 ' , ' 2 ' , ' 2 ' } , { ' 2 ' , ' 2 ' , ' 3 ' } , { ' 2 ' , ' 3 ' , ' 0 ' } , { ' 2 ' , ' 3 ' , ' 1 ' } , { ' 2 ' , ' 3 ' , ' 2 ' } , { ' 2 ' , ' 3 ' , ' 3 ' } ,
{ ' 3 ' , ' 0 ' , ' 0 ' } , { ' 3 ' , ' 0 ' , ' 1 ' } , { ' 3 ' , ' 0 ' , ' 2 ' } , { ' 3 ' , ' 0 ' , ' 3 ' } , { ' 3 ' , ' 1 ' , ' 0 ' } , { ' 3 ' , ' 1 ' , ' 1 ' } ,
{ ' 3 ' , ' 1 ' , ' 2 ' } , { ' 3 ' , ' 1 ' , ' 3 ' } , { ' 3 ' , ' 2 ' , ' 0 ' } , { ' 3 ' , ' 2 ' , ' 1 ' } , { ' 3 ' , ' 2 ' , ' 2 ' } , { ' 3 ' , ' 2 ' , ' 3 ' } ,
{ ' 3 ' , ' 3 ' , ' 0 ' } , { ' 3 ' , ' 3 ' , ' 1 ' } , { ' 3 ' , ' 3 ' , ' 2 ' } , { ' 3 ' , ' 3 ' , ' 3 ' }
2016-02-20 12:38:03 +03:00
} ;
2008-07-14 01:15:55 +04:00
# include <stdio.h>
# include "common.h"
# include "reedsol.h"
2021-10-21 01:05:30 +03:00
static char aus_convert_pattern ( char data , int shift ) {
2016-02-20 12:38:03 +03:00
return ( data - ' 0 ' ) < < shift ;
2011-03-08 13:16:18 +03:00
}
2016-02-20 12:38:03 +03:00
/* Adds Reed-Solomon error correction to auspost */
2021-10-21 01:05:30 +03:00
static char * aus_rs_error ( char data_pattern [ ] , char * d ) {
int reader , length , triple_writer = 0 ;
2020-11-27 15:54:44 +03:00
unsigned char triple [ 31 ] ;
2016-02-20 12:38:03 +03:00
unsigned char result [ 5 ] ;
2020-11-27 15:54:44 +03:00
rs_t rs ;
2016-02-20 12:38:03 +03:00
2021-10-21 01:05:30 +03:00
for ( reader = 2 , length = d - data_pattern ; reader < length ; reader + = 3 , triple_writer + + ) {
triple [ triple_writer ] = aus_convert_pattern ( data_pattern [ reader ] , 4 )
+ aus_convert_pattern ( data_pattern [ reader + 1 ] , 2 )
+ aus_convert_pattern ( data_pattern [ reader + 2 ] , 0 ) ;
2016-02-20 12:38:03 +03:00
}
2020-11-27 15:54:44 +03:00
rs_init_gf ( & rs , 0x43 ) ;
rs_init_code ( & rs , 4 , 1 ) ;
rs_encode ( & rs , triple_writer , triple , result ) ;
2016-02-20 12:38:03 +03:00
2021-10-21 01:05:30 +03:00
for ( reader = 4 ; reader > 0 ; reader - - , d + = 3 ) {
2024-05-28 01:19:45 +03:00
memcpy ( d , AusBarTable [ result [ reader - 1 ] ] , 3 ) ;
2016-02-20 12:38:03 +03:00
}
2021-10-21 01:05:30 +03:00
return d ;
2008-07-14 01:15:55 +04:00
}
2021-10-21 01:05:30 +03:00
INTERNAL int daft_set_height ( struct zint_symbol * symbol , const float min_height , const float max_height ) ;
2021-06-19 15:11:23 +03:00
2016-02-20 12:38:03 +03:00
/* Handles Australia Posts's 4 State Codes */
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 02:13:39 +03:00
INTERNAL int auspost ( struct zint_symbol * symbol , unsigned char source [ ] , int length ) {
2016-02-20 12:38:03 +03:00
/* Customer Standard Barcode, Barcode 2 or Barcode 3 system determined automatically
( i . e . the FCC doesn ' t need to be specified by the user ) dependent
on the length of the input string */
/* The contents of data_pattern conform to the following standard:
0 = Tracker , Ascender and Descender
1 = Tracker and Ascender
2 = Tracker and Descender
3 = Tracker only */
2017-09-10 18:03:09 +03:00
int error_number ;
2016-02-20 12:38:03 +03:00
int writer ;
2020-12-23 13:57:24 +03:00
int loopey , reader ;
int h ;
2016-02-20 12:38:03 +03:00
char data_pattern [ 200 ] ;
2021-10-21 01:05:30 +03:00
char * d = data_pattern ;
char fcc [ 3 ] = { 0 } , dpid [ 10 ] ;
2016-02-20 12:38:03 +03:00
char localstr [ 30 ] ;
2021-10-21 01:05:30 +03:00
/* Do all of the length checking first to avoid stack smashing */
if ( symbol - > symbology = = BARCODE_AUSPOST ) {
if ( length ! = 8 & & length ! = 13 & & length ! = 16 & & length ! = 18 & & length ! = 23 ) {
2022-06-24 16:38:48 +03:00
strcpy ( symbol - > errtxt , " 401: Input wrong length (8, 13, 16, 18 or 23 characters only) " ) ;
2021-10-21 01:05:30 +03:00
return ZINT_ERROR_TOO_LONG ;
}
} else if ( length > 8 ) {
2022-06-24 16:38:48 +03:00
strcpy ( symbol - > errtxt , " 403: Input too long (8 character maximum) " ) ;
2021-10-21 01:05:30 +03:00
return ZINT_ERROR_TOO_LONG ;
}
2020-03-25 18:40:13 +03:00
/* Check input immediately to catch nuls */
2021-10-21 01:05:30 +03:00
if ( ! is_sane ( GDSET_F , source , length ) ) {
2021-07-06 21:53:31 +03:00
strcpy ( symbol - > errtxt , " 404: Invalid character in data (alphanumerics, space and \" # \" only) " ) ;
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 02:13:39 +03:00
return ZINT_ERROR_INVALID_DATA ;
2020-03-25 18:40:13 +03:00
}
2016-02-20 12:38:03 +03:00
2021-10-21 01:05:30 +03:00
localstr [ 0 ] = ' \0 ' ;
2016-02-20 12:38:03 +03:00
if ( symbol - > symbology = = BARCODE_AUSPOST ) {
/* Format control code (FCC) */
switch ( length ) {
case 8 :
strcpy ( fcc , " 11 " ) ;
break ;
case 13 :
strcpy ( fcc , " 59 " ) ;
break ;
case 16 :
strcpy ( fcc , " 59 " ) ;
2021-10-21 01:05:30 +03:00
if ( ! is_sane ( NEON_F , source , length ) ) {
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 02:13:39 +03:00
strcpy ( symbol - > errtxt , " 402: Invalid character in data (digits only for length 16) " ) ;
return ZINT_ERROR_INVALID_DATA ;
}
2016-02-20 12:38:03 +03:00
break ;
case 18 :
strcpy ( fcc , " 62 " ) ;
break ;
case 23 :
strcpy ( fcc , " 62 " ) ;
2021-10-21 01:05:30 +03:00
if ( ! is_sane ( NEON_F , source , length ) ) {
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 02:13:39 +03:00
strcpy ( symbol - > errtxt , " 406: Invalid character in data (digits only for length 23) " ) ;
return ZINT_ERROR_INVALID_DATA ;
}
2016-02-20 12:38:03 +03:00
break ;
}
2017-10-23 22:34:31 +03:00
} else {
2017-10-16 20:26:54 +03:00
int zeroes ;
2016-02-20 12:38:03 +03:00
switch ( symbol - > symbology ) {
case BARCODE_AUSREPLY : strcpy ( fcc , " 45 " ) ;
break ;
case BARCODE_AUSROUTE : strcpy ( fcc , " 87 " ) ;
break ;
case BARCODE_AUSREDIRECT : strcpy ( fcc , " 92 " ) ;
break ;
}
/* Add leading zeros as required */
2017-10-16 20:26:54 +03:00
zeroes = 8 - length ;
2016-02-20 12:38:03 +03:00
memset ( localstr , ' 0 ' , zeroes ) ;
2018-02-03 14:41:35 +03:00
localstr [ zeroes ] = ' \0 ' ;
2016-02-20 12:38:03 +03:00
}
2020-12-23 13:57:24 +03:00
if ( symbol - > debug & ZINT_DEBUG_PRINT ) {
printf ( " AUSPOST FCC: %s \n " , fcc ) ;
}
ustrncat ( localstr , source , length ) ;
h = ( int ) strlen ( localstr ) ;
2021-07-06 21:53:31 +03:00
/* Verify that the first 8 characters are numbers */
2016-02-20 12:38:03 +03:00
memcpy ( dpid , localstr , 8 ) ;
dpid [ 8 ] = ' \0 ' ;
2021-10-21 01:05:30 +03:00
if ( ! is_sane ( NEON_F , ( unsigned char * ) dpid , 8 ) ) {
2021-07-06 21:53:31 +03:00
strcpy ( symbol - > errtxt , " 405: Invalid character in DPID (first 8 characters) (digits only) " ) ;
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 02:13:39 +03:00
return ZINT_ERROR_INVALID_DATA ;
2016-02-20 12:38:03 +03:00
}
/* Start character */
2021-10-21 01:05:30 +03:00
memcpy ( d , " 13 " , 2 ) ;
d + = 2 ;
2016-02-20 12:38:03 +03:00
/* Encode the FCC */
2021-10-21 01:05:30 +03:00
for ( reader = 0 ; reader < 2 ; reader + + , d + = 2 ) {
memcpy ( d , AusNTable [ fcc [ reader ] - ' 0 ' ] , 2 ) ;
2016-02-20 12:38:03 +03:00
}
/* Delivery Point Identifier (DPID) */
2021-10-21 01:05:30 +03:00
for ( reader = 0 ; reader < 8 ; reader + + , d + = 2 ) {
memcpy ( d , AusNTable [ dpid [ reader ] - ' 0 ' ] , 2 ) ;
2016-02-20 12:38:03 +03:00
}
/* Customer Information */
if ( h > 8 ) {
if ( ( h = = 13 ) | | ( h = = 18 ) ) {
2021-10-21 01:05:30 +03:00
for ( reader = 8 ; reader < h ; reader + + , d + = 3 ) {
memcpy ( d , AusCTable [ posn ( GDSET , localstr [ reader ] ) ] , 3 ) ;
2016-02-20 12:38:03 +03:00
}
} else if ( ( h = = 16 ) | | ( h = = 23 ) ) {
2021-10-21 01:05:30 +03:00
for ( reader = 8 ; reader < h ; reader + + , d + = 2 ) {
memcpy ( d , AusNTable [ localstr [ reader ] - ' 0 ' ] , 2 ) ;
2016-02-20 12:38:03 +03:00
}
}
}
/* Filler bar */
2021-10-21 01:05:30 +03:00
h = d - data_pattern ;
2016-02-20 12:38:03 +03:00
switch ( h ) {
case 22 :
case 37 :
case 52 :
2021-10-21 01:05:30 +03:00
* d + + = ' 3 ' ;
2016-02-20 12:38:03 +03:00
break ;
default :
break ;
}
/* Reed Solomon error correction */
2021-10-21 01:05:30 +03:00
d = aus_rs_error ( data_pattern , d ) ;
2016-02-20 12:38:03 +03:00
/* Stop character */
2021-10-21 01:05:30 +03:00
memcpy ( d , " 13 " , 2 ) ;
d + = 2 ;
2016-02-20 12:38:03 +03:00
/* Turn the symbol into a bar pattern ready for plotting */
writer = 0 ;
2021-10-21 01:05:30 +03:00
h = d - data_pattern ;
2016-02-20 12:38:03 +03:00
for ( loopey = 0 ; loopey < h ; loopey + + ) {
if ( ( data_pattern [ loopey ] = = ' 1 ' ) | | ( data_pattern [ loopey ] = = ' 0 ' ) ) {
set_module ( symbol , 0 , writer ) ;
}
set_module ( symbol , 1 , writer ) ;
if ( ( data_pattern [ loopey ] = = ' 2 ' ) | | ( data_pattern [ loopey ] = = ' 0 ' ) ) {
set_module ( symbol , 2 , writer ) ;
}
writer + = 2 ;
}
Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility
Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
static get_zint_version() method, use QStringLiteral (QSL shorthand),
use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
add saveAs shortcut, add main menu, context menus and actions, add help,
reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
lessen triggering of update_preview(), shorten names of getters/setters,
simplify/shorten some update_preview() logic in switch,
CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
2021-10-09 02:13:39 +03:00
if ( symbol - > output_options & COMPLIANT_HEIGHT ) {
/* Australia Post Customer Barcoding Technical Specifications (Revised Aug 2012) Dimensions, placement and
printing p .12
( https : //auspost.com.au/content/dam/auspost_corp/media/documents/
customer - barcode - technical - specifications - aug2012 . pdf )
X 0.5 mm ( average of 0.4 mm - 0.6 mm ) , min height 4.2 mm / 0.6 mm ( X max ) = 7 , max 5.6 mm / 0.4 mm ( X min ) = 14
Tracker 1.3 mm ( average of 1 mm - 1.6 mm )
Ascender / Descender 3.15 mm ( average of 2.6 mm - 3.7 mm ) less T = 1.85 mm
*/
symbol - > row_height [ 0 ] = 3.7f ; /* 1.85f / 0.5f */
symbol - > row_height [ 1 ] = 2.6f ; /* 1.3f / 0.5f */
error_number = daft_set_height ( symbol , 7.0f , 14.0f ) ; /* Note using max X for minimum and min X for maximum */
} else {
symbol - > row_height [ 0 ] = 3.0f ;
symbol - > row_height [ 1 ] = 2.0f ;
error_number = daft_set_height ( symbol , 0.0f , 0.0f ) ;
}
2016-02-20 12:38:03 +03:00
symbol - > rows = 3 ;
symbol - > width = writer - 1 ;
return error_number ;
2008-07-14 01:15:55 +04:00
}
2022-06-24 16:38:48 +03:00
/* vim: set ts=4 sw=4 et : */