From a88064f8fca390d36e4458daa1ef2443f9b02a9b Mon Sep 17 00:00:00 2001 From: ccouliou Date: Fri, 15 Dec 2023 10:25:42 +0100 Subject: [PATCH] fix scale --- src/T2t.Barcode.Svg/BarcodeDraw.cs | 132 +++++++++--------- src/T2t.Barcode.Svg/BarcodeDrawFactory.cs | 28 ++-- src/T2t.Barcode.Svg/BinaryPitchBarcodeDraw.cs | 13 +- src/T2t.Barcode.Svg/Code11.cs | 2 +- src/T2t.Barcode.Svg/Code128.cs | 4 +- src/T2t.Barcode.Svg/Code25.cs | 13 +- src/T2t.Barcode.Svg/Code39.cs | 2 +- src/T2t.Barcode.Svg/Code93.cs | 4 +- src/T2t.Barcode.Svg/CodeEan13.cs | 8 +- src/T2t.Barcode.Svg/CodeEan8.cs | 4 +- src/T2t.Barcode.Svg/CodeQr.cs | 8 +- 11 files changed, 107 insertions(+), 111 deletions(-) diff --git a/src/T2t.Barcode.Svg/BarcodeDraw.cs b/src/T2t.Barcode.Svg/BarcodeDraw.cs index fa030d8..ecc1575 100644 --- a/src/T2t.Barcode.Svg/BarcodeDraw.cs +++ b/src/T2t.Barcode.Svg/BarcodeDraw.cs @@ -6,6 +6,7 @@ +using System.Globalization; using T2t.Barcode.Core; namespace T2t.Barcode.Svg; @@ -175,7 +176,7 @@ public abstract class BarcodeDraw #region Protected Constructors /// - /// Initializes a new instance of class. + /// Initializes a new instance of class. /// protected BarcodeDraw() { @@ -187,9 +188,9 @@ protected BarcodeDraw() /// Draws the specified text using the supplied barcode metrics. /// /// The text. - /// A object. + /// A object. /// - /// An object containing the rendered barcode. + /// A string containing the rendered barcode. /// public abstract string Draw(string text, BarcodeMetrics metrics); @@ -200,7 +201,7 @@ protected BarcodeDraw() /// The text. /// The maximum bar height. /// - /// An object containing the rendered barcode. + /// A string containing the rendered barcode. /// public string Draw(string text, int maxBarHeight) { @@ -218,7 +219,7 @@ public string Draw(string text, int maxBarHeight) /// The scale factor to use when rendering the barcode. /// /// - /// An object containing the rendered barcode. + /// A string containing the rendered barcode. /// public string Draw(string text, int maxBarHeight, float scale) { @@ -228,11 +229,11 @@ public string Draw(string text, int maxBarHeight, float scale) } /// - /// Gets a object containing default + /// Gets a object containing default /// settings for the specified maximum bar height. /// /// The maximum barcode height. - /// A object. + /// A object. public abstract BarcodeMetrics GetDefaultMetrics(int maxHeight); /// @@ -243,7 +244,7 @@ public string Draw(string text, int maxBarHeight, float scale) /// The desired barcode dimensions in hundredth of an inch. /// The print resolution in pixels per inch. /// Length of the barcode in characters. - /// A object. + /// A object. public abstract BarcodeMetrics GetPrintMetrics( T2Size desiredBarcodeDimensions, T2Size printResolution, int barcodeCharLength); @@ -255,10 +256,10 @@ public abstract BarcodeMetrics GetPrintMetrics( /// glyph factory and optional checksum generator classes. /// /// -/// A derived type. +/// A derived type. /// /// -/// A derived type. +/// A derived type. /// public abstract class BarcodeDrawBase : BarcodeDraw where TGlyphFactory : GlyphFactory @@ -273,7 +274,7 @@ public abstract class BarcodeDrawBase : BarcodeDraw #region Protected Constructors /// - /// Initialises an instance of . + /// Initialises an instance of . /// /// The factory. /// @@ -287,7 +288,7 @@ protected BarcodeDrawBase(TGlyphFactory factory, int encodingBitCount) } /// - /// Initialises an instance of . + /// Initialises an instance of . /// /// The factory. /// @@ -304,7 +305,7 @@ protected BarcodeDrawBase(TGlyphFactory factory, int encodingBitCount, } /// - /// Initialises an instance of . + /// Initialises an instance of . /// /// The factory. /// The checksum. @@ -321,7 +322,7 @@ protected BarcodeDrawBase(TGlyphFactory factory, TChecksum checksum, } /// - /// Initialises an instance of . + /// Initialises an instance of . /// /// The factory. /// The checksum. @@ -345,7 +346,7 @@ protected BarcodeDrawBase(TGlyphFactory factory, TChecksum checksum, /// Draws the specified text using the supplied barcode metrics. /// /// The text. - /// A object. + /// A object. /// public override sealed string Draw(string text, BarcodeMetrics metrics) { @@ -409,9 +410,9 @@ protected int WidthBitCount /// Draws the specified text using the supplied barcode metrics. /// /// The text. - /// A object. + /// A object. /// - /// An object containing the rendered barcode. + /// A string containing the rendered barcode. /// protected virtual string Draw1d(string text, BarcodeMetrics1d metrics) { @@ -419,7 +420,7 @@ protected virtual string Draw1d(string text, BarcodeMetrics1d metrics) Glyph[] barcode = GetFullBarcode(text); // Determine amount of inter-glyph space - int interGlyphSpace; + float interGlyphSpace; if (metrics.InterGlyphSpacing.HasValue) { interGlyphSpace = metrics.InterGlyphSpacing.Value; @@ -431,23 +432,23 @@ protected virtual string Draw1d(string text, BarcodeMetrics1d metrics) } // Determine bar code length in pixels - int totalImageWidth = GetBarcodeLength( + float totalImageWidth = GetBarcodeLength( barcode, - (int)(interGlyphSpace * metrics.Scale), - (int)(metrics.MinWidth * metrics.Scale), - (int)(metrics.MaxWidth * metrics.Scale)); + interGlyphSpace * metrics.Scale, + metrics.MinWidth * metrics.Scale, + metrics.MaxWidth * metrics.Scale); // Create image of correct size - T2Rect bounds = new(0, 0, totalImageWidth, metrics.MaxHeight); + T2Rect bounds = new(0, 0, (int)totalImageWidth, metrics.MaxHeight); List content = Render( barcode, bounds, - (int)(interGlyphSpace * metrics.Scale), - metrics.MinHeight, - (int)(metrics.MinWidth * metrics.Scale), - (int)(metrics.MaxWidth * metrics.Scale)); + interGlyphSpace * metrics.Scale, + metrics.MinHeight, + metrics.MinWidth * metrics.Scale, + metrics.MaxWidth * metrics.Scale); - return string.Format(SvgTmpl, totalImageWidth, metrics.MaxHeight, string.Join('\n', content)); + return string.Format(CultureInfo.InvariantCulture, SvgTmpl, totalImageWidth, metrics.MaxHeight, string.Join('\n', content)); } /// @@ -459,8 +460,8 @@ protected virtual string Draw1d(string text, BarcodeMetrics1d metrics) /// /// By default this method returns zero. /// - protected virtual int GetDefaultInterGlyphSpace( - int barMinWidth, int barMaxWidth) + protected virtual float GetDefaultInterGlyphSpace( + float barMinWidth, float barMaxWidth) { return 0; } @@ -469,7 +470,7 @@ protected virtual int GetDefaultInterGlyphSpace( /// Gets the glyphs needed to render a full barcode. /// /// Text to convert into bar-code. - /// A collection of objects. + /// A collection of objects. protected abstract Glyph[] GetFullBarcode(string text); /// @@ -484,11 +485,11 @@ protected virtual int GetDefaultInterGlyphSpace( /// Currently this method does not account for any "quiet space" /// around the barcode as dictated by each symbology standard. /// - protected virtual int GetBarcodeLength( - Glyph[] barcode, int interGlyphSpace, int barMinWidth, int barMaxWidth) + protected virtual float GetBarcodeLength( + Glyph[] barcode, float interGlyphSpace, float barMinWidth, float barMaxWidth) { // Determine bar code length in pixels - int totalImageWidth = GetBarcodeInterGlyphLength(barcode, interGlyphSpace); + float totalImageWidth = GetBarcodeInterGlyphLength(barcode, interGlyphSpace); foreach (BarGlyph glyph in barcode) { // Determine encoding bit-width for this character @@ -539,11 +540,11 @@ protected virtual int GetBarcodeLength( /// /// Gets the glyph's barcode encoding bit count. /// - /// A to be queried. + /// A to be queried. /// Number of bits needed to encode the glyph. /// /// By default this method returns the underlying encoding bit width. - /// If the glyph implements then the + /// If the glyph implements then the /// encoding width is requested from the interface. /// protected virtual int GetEncodingBitCount(Glyph glyph) @@ -560,7 +561,7 @@ protected virtual int GetEncodingBitCount(Glyph glyph) /// /// Gets the glyph's width encoding bit count. /// - /// A to be queried. + /// A to be queried. /// Number of bits needed to encode the width of the glyph. /// /// By default this method returns the underlying width bit count. @@ -576,12 +577,12 @@ protected virtual int GetWidthBitCount(Glyph glyph) /// incorporating the specified inter-glyph spacing. /// /// - /// Collection of objects to be rendered. + /// Collection of objects to be rendered. /// /// Amount of inter-glyph space (in pixels) to be applied. /// Width in pixels. - protected int GetBarcodeInterGlyphLength(Glyph[] barcode, - int interGlyphSpace) + protected float GetBarcodeInterGlyphLength(Glyph[] barcode, + float interGlyphSpace) { return (barcode.Length - 1) * interGlyphSpace; } @@ -589,9 +590,8 @@ protected int GetBarcodeInterGlyphLength(Glyph[] barcode, /// /// Renders the specified bar-code to the specified graphics port. /// - /// A collection of objects representing the + /// A collection of objects representing the /// barcode to be rendered. - /// A representing the draw context. /// The bounding rectangle. /// The inter glyph space in pixels. /// Minimum bar height in pixels. @@ -604,16 +604,16 @@ protected int GetBarcodeInterGlyphLength(Glyph[] barcode, protected virtual List Render( Glyph[] barcode, T2Rect bounds, - int interGlyphSpace, - int barMinHeight, - int barMinWidth, - int barMaxWidth) + float interGlyphSpace, + float barMinHeight, + float barMinWidth, + float barMaxWidth) { // Render the background List bars = new() - { - string.Format(RectTmpl, bounds.Left, bounds.Top, bounds.Width, bounds.Height, "white") - }; + { + string.Format(CultureInfo.InvariantCulture, RectTmpl, bounds.Left, bounds.Top, bounds.Width, bounds.Height, "white") + }; // Render the bars bars.AddRange(RenderBars(barcode, bounds, interGlyphSpace, barMinHeight, @@ -625,9 +625,8 @@ protected virtual List Render( /// /// Renders the barcode bars. /// - /// A collection of objects representing the + /// A collection of objects representing the /// barcode to be rendered. - /// A representing the draw context. /// The bounding rectangle. /// The inter glyph space in pixels. /// Minimum bar height in pixels. @@ -641,12 +640,12 @@ protected virtual List Render( protected virtual List RenderBars( Glyph[] barcode, T2Rect bounds, - int interGlyphSpace, - int barMinHeight, - int barMinWidth, - int barMaxWidth) + float interGlyphSpace, + float barMinHeight, + float barMinWidth, + float barMaxWidth) { - int barOffset = 0; + float barOffset = 0; List res = new(); @@ -667,8 +666,7 @@ protected virtual List RenderBars( /// Renders the bar-code glyph. /// /// Index of the glyph. - /// A object to be rendered. - /// A representing the draw context. + /// A object to be rendered. /// The bounding rectangle. /// The bar offset. /// Minimum bar height in pixels. @@ -682,10 +680,10 @@ protected virtual List RenderBar( int glyphIndex, BarGlyph glyph, T2Rect bounds, - ref int barOffset, - int barMinHeight, - int barMinWidth, - int barMaxWidth) + ref float barOffset, + float barMinHeight, + float barMinWidth, + float barMaxWidth) { List bars = new(); // Sanity check @@ -700,7 +698,7 @@ protected virtual List RenderBar( int glyphBits = GetGlyphEncoding(glyphIndex, glyph); // Get glyph height - int height = GetGlyphHeight(glyph, barMinHeight, bounds.Height); + float height = GetGlyphHeight(glyph, barMinHeight, bounds.Height); if (glyph is IBinaryPitchGlyph binGlyph) { @@ -710,7 +708,7 @@ protected virtual List RenderBar( for (int bitIndex = encodingBitCount - 1; bitIndex >= 0; --bitIndex) { int bitMask = 1 << bitIndex; - int barWidth = barMinWidth; + float barWidth = barMinWidth; bool currentBitState = false; if ((bitMask & glyphBits) != 0) @@ -749,7 +747,7 @@ protected virtual List RenderBar( int bitMask = 1 << bitIndex; if ((glyphBits & bitMask) != 0) { - bars.Add(string.Format(RectTmpl, barOffset, bounds.Top, barMinWidth, height, "black")); + bars.Add(string.Format(CultureInfo.InvariantCulture, RectTmpl, barOffset, bounds.Top, barMinWidth, height, "black")); } // Update offset @@ -778,14 +776,14 @@ protected virtual int GetGlyphEncoding(int glyphIndex, BarGlyph glyph) /// /// Gets the height of the glyph. /// - /// A to be queried. + /// A to be queried. /// Minimum bar height in pixels. /// Maximum bar height in pixels. /// The height of associated glyph. /// /// By default this method returns the maximum bar height. /// - protected virtual int GetGlyphHeight(Glyph glyph, int barMinHeight, int barMaxHeight) + protected virtual float GetGlyphHeight(Glyph glyph, float barMinHeight, float barMaxHeight) { return barMaxHeight; } diff --git a/src/T2t.Barcode.Svg/BarcodeDrawFactory.cs b/src/T2t.Barcode.Svg/BarcodeDrawFactory.cs index 15df53b..c3a9ecc 100644 --- a/src/T2t.Barcode.Svg/BarcodeDrawFactory.cs +++ b/src/T2t.Barcode.Svg/BarcodeDrawFactory.cs @@ -34,7 +34,7 @@ public static class BarcodeDrawFactory /// Gets an agent capable of rendering a Code39 barcode without /// adding a checksum glyph. /// - /// A object. + /// A object. public static Code39BarcodeDraw Code39WithoutChecksum { get @@ -49,7 +49,7 @@ public static Code39BarcodeDraw Code39WithoutChecksum /// Gets an agent capable of rendering a Code39 barcode with an /// added checksum glyph. /// - /// A object. + /// A object. public static Code39BarcodeDraw Code39WithChecksum { get @@ -64,7 +64,7 @@ public static Code39BarcodeDraw Code39WithChecksum /// Gets an agent capable of rendering a Code93 barcode with added /// checksum glyphs. /// - /// A object. + /// A object. public static Code93BarcodeDraw Code93WithChecksum { get @@ -79,7 +79,7 @@ public static Code93BarcodeDraw Code93WithChecksum /// Gets an agent capable of rendering a Code128 barcode with added /// checksum glyphs. /// - /// A object. + /// A object. public static Code128BarcodeDraw Code128WithChecksum { get @@ -93,7 +93,7 @@ public static Code128BarcodeDraw Code128WithChecksum /// /// Gets an agent capable of rendering a Code11 barcode. /// - /// A object. + /// A object. public static Code11BarcodeDraw Code11WithoutChecksum { get @@ -108,7 +108,7 @@ public static Code11BarcodeDraw Code11WithoutChecksum /// Gets an agent capable of rendering a Code11 barcode with added /// checksum glyphs. /// - /// A object. + /// A object. public static Code11BarcodeDraw Code11WithChecksum { get @@ -123,7 +123,7 @@ public static Code11BarcodeDraw Code11WithChecksum /// Gets an agent capable of rendering a Code EAN-13 barcode with /// added checksum glyphs. /// - /// A object. + /// A object. public static CodeEan13BarcodeDraw CodeEan13WithChecksum { get @@ -138,7 +138,7 @@ public static CodeEan13BarcodeDraw CodeEan13WithChecksum /// Gets an agent capable of rendering a Code EAN-8 barcode with /// added checksum glyphs. /// - /// A object. + /// A object. public static CodeEan8BarcodeDraw CodeEan8WithChecksum { get @@ -153,7 +153,7 @@ public static CodeEan8BarcodeDraw CodeEan8WithChecksum /// Gets an agent capable of rendering a Code 25 barcode without /// checksum glyphs. /// - /// A object. + /// A object. public static Code25BarcodeDraw Code25StandardWithoutChecksum { get @@ -168,7 +168,7 @@ public static Code25BarcodeDraw Code25StandardWithoutChecksum /// Gets an agent capable of rendering a Code 25 barcode with /// added checksum glyphs. /// - /// A object. + /// A object. public static Code25BarcodeDraw Code25StandardWithChecksum { get @@ -183,7 +183,7 @@ public static Code25BarcodeDraw Code25StandardWithChecksum /// Gets an agent capable of rendering a Code 25 barcode without /// checksum glyphs. /// - /// A object. + /// A object. public static Code25BarcodeDraw Code25InterleavedWithoutChecksum { get @@ -198,7 +198,7 @@ public static Code25BarcodeDraw Code25InterleavedWithoutChecksum /// Gets an agent capable of rendering a Code 25 barcode with /// added checksum glyphs. /// - /// A object. + /// A object. public static Code25BarcodeDraw Code25InterleavedWithChecksum { get @@ -212,7 +212,7 @@ public static Code25BarcodeDraw Code25InterleavedWithChecksum /// /// Gets an agent capable of rendering a Code QR barcode. /// - /// A object. + /// A object. public static CodeQrBarcodeDraw CodeQr { get @@ -232,7 +232,7 @@ public static CodeQrBarcodeDraw CodeQr /// A value from the enumeration. /// /// - /// A class derived from . + /// A class derived from . /// /// /// Thrown if the specified symbology is invalid or unknown. diff --git a/src/T2t.Barcode.Svg/BinaryPitchBarcodeDraw.cs b/src/T2t.Barcode.Svg/BinaryPitchBarcodeDraw.cs index 7dd0eb9..6a8c531 100644 --- a/src/T2t.Barcode.Svg/BinaryPitchBarcodeDraw.cs +++ b/src/T2t.Barcode.Svg/BinaryPitchBarcodeDraw.cs @@ -90,8 +90,8 @@ protected BinaryPitchBarcodeDraw(TGlyphFactory factory, TChecksum checksum, /// Minimum barcode width. /// Maximum barcode width. /// - protected override int GetBarcodeLength(Glyph[] barcode, - int interGlyphSpace, int barMinWidth, int barMaxWidth) + protected override float GetBarcodeLength(Glyph[] barcode, + float interGlyphSpace, float barMinWidth, float barMaxWidth) { // Sanity check if (barMinWidth == barMaxWidth) @@ -100,7 +100,7 @@ protected override int GetBarcodeLength(Glyph[] barcode, } // Determine bar code length in pixels - int totalImageWidth = GetBarcodeInterGlyphLength(barcode, interGlyphSpace); + float totalImageWidth = GetBarcodeInterGlyphLength(barcode, interGlyphSpace); foreach (BinaryPitchGlyph glyph in barcode) { // Determine encoding bit-width for this character @@ -158,7 +158,6 @@ protected virtual int GetGlyphEncodingBitCount(Glyph glyph) /// /// Index of the glyph. /// A to be rendered. - /// A representing the device context. /// The bounding rectangle. /// The bar offset in pixels. /// Minimum bar height in pixels. @@ -169,8 +168,8 @@ protected virtual int GetGlyphEncodingBitCount(Glyph glyph) /// bar rendering is attempted. /// protected override List RenderBar(int glyphIndex, BarGlyph glyph, - T2Rect bounds, ref int barOffset, int barMinHeight, - int barMinWidth, int barMaxWidth) + T2Rect bounds, ref float barOffset, float barMinHeight, + float barMinWidth, float barMaxWidth) { List res = new(); // Sanity check @@ -196,7 +195,7 @@ protected override List RenderBar(int glyphIndex, BarGlyph glyph, for (int bitIndex = encodingBitCount - 1; bitIndex >= 0; --bitIndex) { int bitMask = 1 << bitIndex; - int barWidth = barMinWidth; + float barWidth = barMinWidth; bool currentBitState = false; if ((bitMask & binGlyph.BitEncoding) != 0) diff --git a/src/T2t.Barcode.Svg/Code11.cs b/src/T2t.Barcode.Svg/Code11.cs index 1f16338..5a7f9e9 100644 --- a/src/T2t.Barcode.Svg/Code11.cs +++ b/src/T2t.Barcode.Svg/Code11.cs @@ -272,7 +272,7 @@ protected override Glyph[] GetFullBarcode(string text) /// /// /// - protected override int GetDefaultInterGlyphSpace(int barMinWidth, int barMaxWidth) + protected override float GetDefaultInterGlyphSpace(float barMinWidth, float barMaxWidth) { return barMinWidth; } diff --git a/src/T2t.Barcode.Svg/Code128.cs b/src/T2t.Barcode.Svg/Code128.cs index 08f041c..7ce9f5d 100644 --- a/src/T2t.Barcode.Svg/Code128.cs +++ b/src/T2t.Barcode.Svg/Code128.cs @@ -828,8 +828,8 @@ protected override Glyph[] GetFullBarcode(string text) /// Minimum bar width. /// Maximum bar width. /// - protected override int GetBarcodeLength(Glyph[] barcode, - int interGlyphSpace, int barMinWidth, int barMaxWidth) + protected override float GetBarcodeLength(Glyph[] barcode, + float interGlyphSpace, float barMinWidth, float barMaxWidth) { return base.GetBarcodeLength(barcode, interGlyphSpace, barMinWidth, barMaxWidth) - (9 * barMinWidth); diff --git a/src/T2t.Barcode.Svg/Code25.cs b/src/T2t.Barcode.Svg/Code25.cs index 91634ec..1b2649e 100644 --- a/src/T2t.Barcode.Svg/Code25.cs +++ b/src/T2t.Barcode.Svg/Code25.cs @@ -400,7 +400,7 @@ protected override Glyph[] GetFullBarcode(string text) /// /// /// - protected override int GetDefaultInterGlyphSpace(int barMinWidth, int barMaxWidth) + protected override float GetDefaultInterGlyphSpace(float barMinWidth, float barMaxWidth) { if (Factory is Code25StandardGlyphFactory) { @@ -424,8 +424,8 @@ protected override int GetDefaultInterGlyphSpace(int barMinWidth, int barMaxWidt /// Currently this method does not account for any "quiet space" /// around the barcode as dictated by each symbology standard. /// - protected override int GetBarcodeLength( - Glyph[] barcode, int interGlyphSpace, int barMinWidth, int barMaxWidth) + protected override float GetBarcodeLength( + Glyph[] barcode, float interGlyphSpace, float barMinWidth, float barMaxWidth) { if (Factory is not Code25InterleavedGlyphFactory) { @@ -438,9 +438,8 @@ protected override int GetBarcodeLength( /// /// Renders the barcode bars. /// - /// A collection of objects representing the + /// A collection of objects representing the /// barcode to be rendered. - /// A representing the draw context. /// The bounding rectangle. /// The inter glyph space in pixels. /// Minimum bar height in pixels. @@ -451,7 +450,7 @@ protected override int GetBarcodeLength( /// method, applying the specified /// inter-glyph spacing as necessary. /// - protected override List RenderBars(Glyph[] barcode, T2Rect bounds, int interGlyphSpace, int barMinHeight, int barMinWidth, int barMaxWidth) + protected override List RenderBars(Glyph[] barcode, T2Rect bounds, float interGlyphSpace, float barMinHeight, float barMinWidth, float barMaxWidth) { List res = new(); // Standard Code 2 of 5 can be rendered via base class @@ -462,7 +461,7 @@ protected override List RenderBars(Glyph[] barcode, T2Rect bounds, int i // Interleaved version needs custom rendering support - int barOffset = 0; + float barOffset = 0; for (int index = 0; index < barcode.Length;) { BarGlyph glyph = (BarGlyph)barcode[index]; diff --git a/src/T2t.Barcode.Svg/Code39.cs b/src/T2t.Barcode.Svg/Code39.cs index e056b19..c13b827 100644 --- a/src/T2t.Barcode.Svg/Code39.cs +++ b/src/T2t.Barcode.Svg/Code39.cs @@ -384,7 +384,7 @@ protected override Glyph[] GetFullBarcode(string text) /// /// /// - protected override int GetDefaultInterGlyphSpace(int barMinWidth, int barMaxWidth) + protected override float GetDefaultInterGlyphSpace(float barMinWidth, float barMaxWidth) { return barMinWidth; } diff --git a/src/T2t.Barcode.Svg/Code93.cs b/src/T2t.Barcode.Svg/Code93.cs index 1e82ab2..25d70ca 100644 --- a/src/T2t.Barcode.Svg/Code93.cs +++ b/src/T2t.Barcode.Svg/Code93.cs @@ -389,8 +389,8 @@ protected override Glyph[] GetFullBarcode(string text) /// Currently this method does not account for any "quiet space" /// around the barcode as dictated by each symbology standard. /// - protected override int GetBarcodeLength(Glyph[] barcode, - int interGlyphSpace, int barMinWidth, int barMaxWidth) + protected override float GetBarcodeLength(Glyph[] barcode, + float interGlyphSpace, float barMinWidth, float barMaxWidth) { return base.GetBarcodeLength(barcode, interGlyphSpace, barMinWidth, barMaxWidth) - (8 * barMinWidth); diff --git a/src/T2t.Barcode.Svg/CodeEan13.cs b/src/T2t.Barcode.Svg/CodeEan13.cs index 3444f72..a3cedd8 100644 --- a/src/T2t.Barcode.Svg/CodeEan13.cs +++ b/src/T2t.Barcode.Svg/CodeEan13.cs @@ -297,7 +297,7 @@ public CodeEan13BarcodeDraw(CodeEan13Checksum checksum) public override BarcodeMetrics GetDefaultMetrics(int maxHeight) { // TODO: Min bar height should be percentage of max height - return new BarcodeMetrics1d(1, 1, maxHeight - 5, maxHeight); + return new BarcodeMetrics1d(1, 1, (int)(maxHeight * .9), maxHeight); } /// @@ -414,7 +414,7 @@ protected override Glyph[] GetFullBarcode(string text) /// For EAN 13 the only full height glyphs are start/stop/seperator /// glyphs. /// - protected override int GetGlyphHeight(Glyph glyph, int barMinHeight, int barMaxHeight) + protected override float GetGlyphHeight(Glyph glyph, float barMinHeight, float barMaxHeight) { if (glyph.Character == '*' || glyph.Character == '|') { @@ -429,9 +429,9 @@ protected override int GetGlyphHeight(Glyph glyph, int barMinHeight, int barMaxH /// /// /// - protected override int GetDefaultInterGlyphSpace(int barMinWidth, int barMaxWidth) + protected override float GetDefaultInterGlyphSpace(float barMinWidth, float barMaxWidth) { - return 0; + return 0f; } #endregion } diff --git a/src/T2t.Barcode.Svg/CodeEan8.cs b/src/T2t.Barcode.Svg/CodeEan8.cs index 134a039..347e118 100644 --- a/src/T2t.Barcode.Svg/CodeEan8.cs +++ b/src/T2t.Barcode.Svg/CodeEan8.cs @@ -372,7 +372,7 @@ protected override Glyph[] GetFullBarcode(string text) /// For EAN 13 the only full height glyphs are start/stop/seperator /// glyphs. /// - protected override int GetGlyphHeight(Glyph glyph, int barMinHeight, int barMaxHeight) + protected override float GetGlyphHeight(Glyph glyph, float barMinHeight, float barMaxHeight) { if (glyph.Character == '*' || glyph.Character == '|') { @@ -387,7 +387,7 @@ protected override int GetGlyphHeight(Glyph glyph, int barMinHeight, int barMaxH /// /// /// - protected override int GetDefaultInterGlyphSpace(int barMinWidth, int barMaxWidth) + protected override float GetDefaultInterGlyphSpace(float barMinWidth, float barMaxWidth) { return 0; } diff --git a/src/T2t.Barcode.Svg/CodeQr.cs b/src/T2t.Barcode.Svg/CodeQr.cs index 6dd1559..9ce80e4 100644 --- a/src/T2t.Barcode.Svg/CodeQr.cs +++ b/src/T2t.Barcode.Svg/CodeQr.cs @@ -1238,7 +1238,7 @@ public virtual string Encode(string content) /// Draws the specified text using the supplied barcode metrics. /// /// The text. - /// A object. + /// A object. /// public override sealed string Draw(string text, BarcodeMetrics metrics) { @@ -1246,12 +1246,12 @@ public override sealed string Draw(string text, BarcodeMetrics metrics) } /// - /// Gets a object containing default + /// Gets a object containing default /// settings for the specified maximum bar height. /// /// The maximum barcode height. /// - /// A object. + /// A object. /// public override BarcodeMetrics GetDefaultMetrics(int maxHeight) { @@ -1276,7 +1276,7 @@ public override BarcodeMetrics GetDefaultMetrics(int maxHeight) /// The print resolution in pixels per inch. /// Length of the barcode in characters. /// - /// A object. + /// A object. /// public override BarcodeMetrics GetPrintMetrics( T2Size desiredBarcodeDimensions, T2Size printResolution, int barcodeCharLength)