Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 297ae85625bc764f84bab8e78d52872666fe922a 0 parents
Chris authored
Showing with 6,213 additions and 0 deletions.
  1. +401 −0 CocoaTouchBarcodes.xcodeproj/project.pbxproj
  2. +7 −0 CocoaTouchBarcodes_Prefix.pch
  3. +20 −0 JapanPostBarcode.h
  4. +323 −0 JapanPostBarcode.m
  5. +138 −0 NKDAbstractUPCEANBarcode.h
  6. +135 −0 NKDAbstractUPCEANBarcode.m
  7. +404 −0 NKDBarcode.h
  8. +395 −0 NKDBarcode.m
  9. +36 −0 NKDBarcodeFramework.h
  10. +71 −0 NKDBarcodeOffscreenView.h
  11. +235 −0 NKDBarcodeOffscreenView.m
  12. +36 −0 NKDCodabarBarcode.h
  13. +65 −0 NKDCodabarBarcode.m
  14. +178 −0 NKDCode128Barcode.h
  15. +491 −0 NKDCode128Barcode.m
  16. +71 −0 NKDCode39Barcode.h
  17. +209 −0 NKDCode39Barcode.m
  18. +95 −0 NKDEAN13Barcode.h
  19. +308 −0 NKDEAN13Barcode.m
  20. +87 −0 NKDEAN8Barcode.h
  21. +122 −0 NKDEAN8Barcode.m
  22. +50 −0 NKDExtendedCode39Barcode.h
  23. +139 −0 NKDExtendedCode39Barcode.m
  24. +38 −0 NKDIndustrialTwoOfFiveBarcode.h
  25. +39 −0 NKDIndustrialTwoOfFiveBarcode.m
  26. +99 −0 NKDInterleavedTwoOfFiveBarcode.h
  27. +135 −0 NKDInterleavedTwoOfFiveBarcode.m
  28. +117 −0 NKDModifiedPlesseyBarcode.h
  29. +105 −0 NKDModifiedPlesseyBarcode.m
  30. +38 −0 NKDModifiedPlesseyHexBarcode.h
  31. +40 −0 NKDModifiedPlesseyHexBarcode.m
  32. +27 −0 NKDPlanetBarcode.h
  33. +22 −0 NKDPlanetBarcode.m
  34. +117 −0 NKDPostnetBarcode.h
  35. +224 −0 NKDPostnetBarcode.m
  36. +146 −0 NKDRoyalMailBarcode.h
  37. +301 −0 NKDRoyalMailBarcode.m
  38. +76 −0 NKDUPCABarcode.h
  39. +161 −0 NKDUPCABarcode.m
  40. +98 −0 NKDUPCEBarcode.h
  41. +155 −0 NKDUPCEBarcode.m
  42. +41 −0 NSString-UPCEAN.h
  43. +48 −0 NSString-UPCEAN.m
  44. +34 −0 UIImage-NKDBarcode.h
  45. +24 −0 UIImage-NKDBarcode.m
  46. +41 −0 UIImage-Normalize.h
  47. +71 −0 UIImage-Normalize.m
401 CocoaTouchBarcodes.xcodeproj/project.pbxproj
@@ -0,0 +1,401 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 58D6E8C91174144900357FF5 /* JapanPostBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E89A1174144900357FF5 /* JapanPostBarcode.h */; };
+ 58D6E8CA1174144900357FF5 /* JapanPostBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E89B1174144900357FF5 /* JapanPostBarcode.m */; };
+ 58D6E8CB1174144900357FF5 /* NKDAbstractUPCEANBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E89C1174144900357FF5 /* NKDAbstractUPCEANBarcode.h */; };
+ 58D6E8CC1174144900357FF5 /* NKDAbstractUPCEANBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E89D1174144900357FF5 /* NKDAbstractUPCEANBarcode.m */; };
+ 58D6E8CD1174144900357FF5 /* NKDBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E89E1174144900357FF5 /* NKDBarcode.h */; };
+ 58D6E8CE1174144900357FF5 /* NKDBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E89F1174144900357FF5 /* NKDBarcode.m */; };
+ 58D6E8CF1174144900357FF5 /* NKDBarcodeFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8A01174144900357FF5 /* NKDBarcodeFramework.h */; };
+ 58D6E8D21174144900357FF5 /* NKDBarcodeOffscreenView.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8A31174144900357FF5 /* NKDBarcodeOffscreenView.h */; };
+ 58D6E8D31174144900357FF5 /* NKDBarcodeOffscreenView.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8A41174144900357FF5 /* NKDBarcodeOffscreenView.m */; };
+ 58D6E8D41174144900357FF5 /* NKDCodabarBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8A51174144900357FF5 /* NKDCodabarBarcode.h */; };
+ 58D6E8D51174144900357FF5 /* NKDCodabarBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8A61174144900357FF5 /* NKDCodabarBarcode.m */; };
+ 58D6E8D61174144900357FF5 /* NKDCode39Barcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8A71174144900357FF5 /* NKDCode39Barcode.h */; };
+ 58D6E8D71174144900357FF5 /* NKDCode39Barcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8A81174144900357FF5 /* NKDCode39Barcode.m */; };
+ 58D6E8D81174144900357FF5 /* NKDCode128Barcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8A91174144900357FF5 /* NKDCode128Barcode.h */; };
+ 58D6E8D91174144900357FF5 /* NKDCode128Barcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8AA1174144900357FF5 /* NKDCode128Barcode.m */; };
+ 58D6E8DA1174144900357FF5 /* NKDEAN8Barcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8AB1174144900357FF5 /* NKDEAN8Barcode.h */; };
+ 58D6E8DB1174144900357FF5 /* NKDEAN8Barcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8AC1174144900357FF5 /* NKDEAN8Barcode.m */; };
+ 58D6E8DC1174144900357FF5 /* NKDEAN13Barcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8AD1174144900357FF5 /* NKDEAN13Barcode.h */; };
+ 58D6E8DD1174144900357FF5 /* NKDEAN13Barcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8AE1174144900357FF5 /* NKDEAN13Barcode.m */; };
+ 58D6E8DE1174144900357FF5 /* NKDExtendedCode39Barcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8AF1174144900357FF5 /* NKDExtendedCode39Barcode.h */; };
+ 58D6E8DF1174144900357FF5 /* NKDExtendedCode39Barcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8B01174144900357FF5 /* NKDExtendedCode39Barcode.m */; };
+ 58D6E8E01174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8B11174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.h */; };
+ 58D6E8E11174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8B21174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.m */; };
+ 58D6E8E21174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8B31174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.h */; };
+ 58D6E8E31174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8B41174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.m */; };
+ 58D6E8E41174144900357FF5 /* NKDModifiedPlesseyBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8B51174144900357FF5 /* NKDModifiedPlesseyBarcode.h */; };
+ 58D6E8E51174144900357FF5 /* NKDModifiedPlesseyBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8B61174144900357FF5 /* NKDModifiedPlesseyBarcode.m */; };
+ 58D6E8E61174144900357FF5 /* NKDModifiedPlesseyHexBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8B71174144900357FF5 /* NKDModifiedPlesseyHexBarcode.h */; };
+ 58D6E8E71174144900357FF5 /* NKDModifiedPlesseyHexBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8B81174144900357FF5 /* NKDModifiedPlesseyHexBarcode.m */; };
+ 58D6E8E81174144900357FF5 /* NKDPlanetBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8B91174144900357FF5 /* NKDPlanetBarcode.h */; };
+ 58D6E8E91174144900357FF5 /* NKDPlanetBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8BA1174144900357FF5 /* NKDPlanetBarcode.m */; };
+ 58D6E8EA1174144900357FF5 /* NKDPostnetBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8BB1174144900357FF5 /* NKDPostnetBarcode.h */; };
+ 58D6E8EB1174144900357FF5 /* NKDPostnetBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8BC1174144900357FF5 /* NKDPostnetBarcode.m */; };
+ 58D6E8EC1174144900357FF5 /* NKDRoyalMailBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8BD1174144900357FF5 /* NKDRoyalMailBarcode.h */; };
+ 58D6E8ED1174144900357FF5 /* NKDRoyalMailBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8BE1174144900357FF5 /* NKDRoyalMailBarcode.m */; };
+ 58D6E8EE1174144900357FF5 /* NKDUPCABarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8BF1174144900357FF5 /* NKDUPCABarcode.h */; };
+ 58D6E8EF1174144900357FF5 /* NKDUPCABarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8C01174144900357FF5 /* NKDUPCABarcode.m */; };
+ 58D6E8F01174144900357FF5 /* NKDUPCEBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8C11174144900357FF5 /* NKDUPCEBarcode.h */; };
+ 58D6E8F11174144900357FF5 /* NKDUPCEBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8C21174144900357FF5 /* NKDUPCEBarcode.m */; };
+ 58D6E8F21174144900357FF5 /* UIImage-NKDBarcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8C31174144900357FF5 /* UIImage-NKDBarcode.h */; };
+ 58D6E8F31174144900357FF5 /* UIImage-NKDBarcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8C41174144900357FF5 /* UIImage-NKDBarcode.m */; };
+ 58D6E8F41174144900357FF5 /* UIImage-Normalize.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8C51174144900357FF5 /* UIImage-Normalize.m */; };
+ 58D6E8F51174144900357FF5 /* UIImage-Normalize.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8C61174144900357FF5 /* UIImage-Normalize.h */; };
+ 58D6E8F61174144900357FF5 /* NSString-UPCEAN.h in Headers */ = {isa = PBXBuildFile; fileRef = 58D6E8C71174144900357FF5 /* NSString-UPCEAN.h */; };
+ 58D6E8F71174144900357FF5 /* NSString-UPCEAN.m in Sources */ = {isa = PBXBuildFile; fileRef = 58D6E8C81174144900357FF5 /* NSString-UPCEAN.m */; };
+ AA747D9F0F9514B9006C5449 /* CocoaTouchBarcodes_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* CocoaTouchBarcodes_Prefix.pch */; };
+ AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 58D6E89A1174144900357FF5 /* JapanPostBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JapanPostBarcode.h; sourceTree = "<group>"; };
+ 58D6E89B1174144900357FF5 /* JapanPostBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JapanPostBarcode.m; sourceTree = "<group>"; };
+ 58D6E89C1174144900357FF5 /* NKDAbstractUPCEANBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDAbstractUPCEANBarcode.h; sourceTree = "<group>"; };
+ 58D6E89D1174144900357FF5 /* NKDAbstractUPCEANBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDAbstractUPCEANBarcode.m; sourceTree = "<group>"; };
+ 58D6E89E1174144900357FF5 /* NKDBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDBarcode.h; sourceTree = "<group>"; };
+ 58D6E89F1174144900357FF5 /* NKDBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDBarcode.m; sourceTree = "<group>"; };
+ 58D6E8A01174144900357FF5 /* NKDBarcodeFramework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDBarcodeFramework.h; sourceTree = "<group>"; };
+ 58D6E8A31174144900357FF5 /* NKDBarcodeOffscreenView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDBarcodeOffscreenView.h; sourceTree = "<group>"; };
+ 58D6E8A41174144900357FF5 /* NKDBarcodeOffscreenView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDBarcodeOffscreenView.m; sourceTree = "<group>"; };
+ 58D6E8A51174144900357FF5 /* NKDCodabarBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDCodabarBarcode.h; sourceTree = "<group>"; };
+ 58D6E8A61174144900357FF5 /* NKDCodabarBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDCodabarBarcode.m; sourceTree = "<group>"; };
+ 58D6E8A71174144900357FF5 /* NKDCode39Barcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDCode39Barcode.h; sourceTree = "<group>"; };
+ 58D6E8A81174144900357FF5 /* NKDCode39Barcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDCode39Barcode.m; sourceTree = "<group>"; };
+ 58D6E8A91174144900357FF5 /* NKDCode128Barcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDCode128Barcode.h; sourceTree = "<group>"; };
+ 58D6E8AA1174144900357FF5 /* NKDCode128Barcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDCode128Barcode.m; sourceTree = "<group>"; };
+ 58D6E8AB1174144900357FF5 /* NKDEAN8Barcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDEAN8Barcode.h; sourceTree = "<group>"; };
+ 58D6E8AC1174144900357FF5 /* NKDEAN8Barcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDEAN8Barcode.m; sourceTree = "<group>"; };
+ 58D6E8AD1174144900357FF5 /* NKDEAN13Barcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDEAN13Barcode.h; sourceTree = "<group>"; };
+ 58D6E8AE1174144900357FF5 /* NKDEAN13Barcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDEAN13Barcode.m; sourceTree = "<group>"; };
+ 58D6E8AF1174144900357FF5 /* NKDExtendedCode39Barcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDExtendedCode39Barcode.h; sourceTree = "<group>"; };
+ 58D6E8B01174144900357FF5 /* NKDExtendedCode39Barcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDExtendedCode39Barcode.m; sourceTree = "<group>"; };
+ 58D6E8B11174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDIndustrialTwoOfFiveBarcode.h; sourceTree = "<group>"; };
+ 58D6E8B21174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDIndustrialTwoOfFiveBarcode.m; sourceTree = "<group>"; };
+ 58D6E8B31174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDInterleavedTwoOfFiveBarcode.h; sourceTree = "<group>"; };
+ 58D6E8B41174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDInterleavedTwoOfFiveBarcode.m; sourceTree = "<group>"; };
+ 58D6E8B51174144900357FF5 /* NKDModifiedPlesseyBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDModifiedPlesseyBarcode.h; sourceTree = "<group>"; };
+ 58D6E8B61174144900357FF5 /* NKDModifiedPlesseyBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDModifiedPlesseyBarcode.m; sourceTree = "<group>"; };
+ 58D6E8B71174144900357FF5 /* NKDModifiedPlesseyHexBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDModifiedPlesseyHexBarcode.h; sourceTree = "<group>"; };
+ 58D6E8B81174144900357FF5 /* NKDModifiedPlesseyHexBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDModifiedPlesseyHexBarcode.m; sourceTree = "<group>"; };
+ 58D6E8B91174144900357FF5 /* NKDPlanetBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDPlanetBarcode.h; sourceTree = "<group>"; };
+ 58D6E8BA1174144900357FF5 /* NKDPlanetBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDPlanetBarcode.m; sourceTree = "<group>"; };
+ 58D6E8BB1174144900357FF5 /* NKDPostnetBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDPostnetBarcode.h; sourceTree = "<group>"; };
+ 58D6E8BC1174144900357FF5 /* NKDPostnetBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDPostnetBarcode.m; sourceTree = "<group>"; };
+ 58D6E8BD1174144900357FF5 /* NKDRoyalMailBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDRoyalMailBarcode.h; sourceTree = "<group>"; };
+ 58D6E8BE1174144900357FF5 /* NKDRoyalMailBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDRoyalMailBarcode.m; sourceTree = "<group>"; };
+ 58D6E8BF1174144900357FF5 /* NKDUPCABarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDUPCABarcode.h; sourceTree = "<group>"; };
+ 58D6E8C01174144900357FF5 /* NKDUPCABarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDUPCABarcode.m; sourceTree = "<group>"; };
+ 58D6E8C11174144900357FF5 /* NKDUPCEBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NKDUPCEBarcode.h; sourceTree = "<group>"; };
+ 58D6E8C21174144900357FF5 /* NKDUPCEBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NKDUPCEBarcode.m; sourceTree = "<group>"; };
+ 58D6E8C31174144900357FF5 /* UIImage-NKDBarcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage-NKDBarcode.h"; sourceTree = "<group>"; };
+ 58D6E8C41174144900357FF5 /* UIImage-NKDBarcode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage-NKDBarcode.m"; sourceTree = "<group>"; };
+ 58D6E8C51174144900357FF5 /* UIImage-Normalize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage-Normalize.m"; sourceTree = "<group>"; };
+ 58D6E8C61174144900357FF5 /* UIImage-Normalize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage-Normalize.h"; sourceTree = "<group>"; };
+ 58D6E8C71174144900357FF5 /* NSString-UPCEAN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString-UPCEAN.h"; sourceTree = "<group>"; };
+ 58D6E8C81174144900357FF5 /* NSString-UPCEAN.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString-UPCEAN.m"; sourceTree = "<group>"; };
+ AA747D9E0F9514B9006C5449 /* CocoaTouchBarcodes_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoaTouchBarcodes_Prefix.pch; sourceTree = SOURCE_ROOT; };
+ AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ D2AAC07E0554694100DB518D /* libCocoaTouchBarcodes.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCocoaTouchBarcodes.a; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ D2AAC07C0554694100DB518D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 034768DFFF38A50411DB9C8B /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ D2AAC07E0554694100DB518D /* libCocoaTouchBarcodes.a */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 0867D691FE84028FC02AAC07 /* CocoaTouchBarcodes */ = {
+ isa = PBXGroup;
+ children = (
+ 08FB77AEFE84172EC02AAC07 /* Classes */,
+ 32C88DFF0371C24200C91783 /* Other Sources */,
+ 0867D69AFE84028FC02AAC07 /* Frameworks */,
+ 034768DFFF38A50411DB9C8B /* Products */,
+ );
+ name = CocoaTouchBarcodes;
+ sourceTree = "<group>";
+ };
+ 0867D69AFE84028FC02AAC07 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ AACBBE490F95108600F1A2B1 /* Foundation.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 08FB77AEFE84172EC02AAC07 /* Classes */ = {
+ isa = PBXGroup;
+ children = (
+ 58D6E89A1174144900357FF5 /* JapanPostBarcode.h */,
+ 58D6E89B1174144900357FF5 /* JapanPostBarcode.m */,
+ 58D6E89C1174144900357FF5 /* NKDAbstractUPCEANBarcode.h */,
+ 58D6E89D1174144900357FF5 /* NKDAbstractUPCEANBarcode.m */,
+ 58D6E89E1174144900357FF5 /* NKDBarcode.h */,
+ 58D6E89F1174144900357FF5 /* NKDBarcode.m */,
+ 58D6E8A01174144900357FF5 /* NKDBarcodeFramework.h */,
+ 58D6E8A31174144900357FF5 /* NKDBarcodeOffscreenView.h */,
+ 58D6E8A41174144900357FF5 /* NKDBarcodeOffscreenView.m */,
+ 58D6E8A51174144900357FF5 /* NKDCodabarBarcode.h */,
+ 58D6E8A61174144900357FF5 /* NKDCodabarBarcode.m */,
+ 58D6E8A71174144900357FF5 /* NKDCode39Barcode.h */,
+ 58D6E8A81174144900357FF5 /* NKDCode39Barcode.m */,
+ 58D6E8A91174144900357FF5 /* NKDCode128Barcode.h */,
+ 58D6E8AA1174144900357FF5 /* NKDCode128Barcode.m */,
+ 58D6E8AB1174144900357FF5 /* NKDEAN8Barcode.h */,
+ 58D6E8AC1174144900357FF5 /* NKDEAN8Barcode.m */,
+ 58D6E8AD1174144900357FF5 /* NKDEAN13Barcode.h */,
+ 58D6E8AE1174144900357FF5 /* NKDEAN13Barcode.m */,
+ 58D6E8AF1174144900357FF5 /* NKDExtendedCode39Barcode.h */,
+ 58D6E8B01174144900357FF5 /* NKDExtendedCode39Barcode.m */,
+ 58D6E8B11174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.h */,
+ 58D6E8B21174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.m */,
+ 58D6E8B31174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.h */,
+ 58D6E8B41174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.m */,
+ 58D6E8B51174144900357FF5 /* NKDModifiedPlesseyBarcode.h */,
+ 58D6E8B61174144900357FF5 /* NKDModifiedPlesseyBarcode.m */,
+ 58D6E8B71174144900357FF5 /* NKDModifiedPlesseyHexBarcode.h */,
+ 58D6E8B81174144900357FF5 /* NKDModifiedPlesseyHexBarcode.m */,
+ 58D6E8B91174144900357FF5 /* NKDPlanetBarcode.h */,
+ 58D6E8BA1174144900357FF5 /* NKDPlanetBarcode.m */,
+ 58D6E8BB1174144900357FF5 /* NKDPostnetBarcode.h */,
+ 58D6E8BC1174144900357FF5 /* NKDPostnetBarcode.m */,
+ 58D6E8BD1174144900357FF5 /* NKDRoyalMailBarcode.h */,
+ 58D6E8BE1174144900357FF5 /* NKDRoyalMailBarcode.m */,
+ 58D6E8BF1174144900357FF5 /* NKDUPCABarcode.h */,
+ 58D6E8C01174144900357FF5 /* NKDUPCABarcode.m */,
+ 58D6E8C11174144900357FF5 /* NKDUPCEBarcode.h */,
+ 58D6E8C21174144900357FF5 /* NKDUPCEBarcode.m */,
+ 58D6E8C31174144900357FF5 /* UIImage-NKDBarcode.h */,
+ 58D6E8C41174144900357FF5 /* UIImage-NKDBarcode.m */,
+ 58D6E8C51174144900357FF5 /* UIImage-Normalize.m */,
+ 58D6E8C61174144900357FF5 /* UIImage-Normalize.h */,
+ 58D6E8C71174144900357FF5 /* NSString-UPCEAN.h */,
+ 58D6E8C81174144900357FF5 /* NSString-UPCEAN.m */,
+ );
+ name = Classes;
+ sourceTree = "<group>";
+ };
+ 32C88DFF0371C24200C91783 /* Other Sources */ = {
+ isa = PBXGroup;
+ children = (
+ AA747D9E0F9514B9006C5449 /* CocoaTouchBarcodes_Prefix.pch */,
+ );
+ name = "Other Sources";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+ D2AAC07A0554694100DB518D /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AA747D9F0F9514B9006C5449 /* CocoaTouchBarcodes_Prefix.pch in Headers */,
+ 58D6E8C91174144900357FF5 /* JapanPostBarcode.h in Headers */,
+ 58D6E8CB1174144900357FF5 /* NKDAbstractUPCEANBarcode.h in Headers */,
+ 58D6E8CD1174144900357FF5 /* NKDBarcode.h in Headers */,
+ 58D6E8CF1174144900357FF5 /* NKDBarcodeFramework.h in Headers */,
+ 58D6E8D21174144900357FF5 /* NKDBarcodeOffscreenView.h in Headers */,
+ 58D6E8D41174144900357FF5 /* NKDCodabarBarcode.h in Headers */,
+ 58D6E8D61174144900357FF5 /* NKDCode39Barcode.h in Headers */,
+ 58D6E8D81174144900357FF5 /* NKDCode128Barcode.h in Headers */,
+ 58D6E8DA1174144900357FF5 /* NKDEAN8Barcode.h in Headers */,
+ 58D6E8DC1174144900357FF5 /* NKDEAN13Barcode.h in Headers */,
+ 58D6E8DE1174144900357FF5 /* NKDExtendedCode39Barcode.h in Headers */,
+ 58D6E8E01174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.h in Headers */,
+ 58D6E8E21174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.h in Headers */,
+ 58D6E8E41174144900357FF5 /* NKDModifiedPlesseyBarcode.h in Headers */,
+ 58D6E8E61174144900357FF5 /* NKDModifiedPlesseyHexBarcode.h in Headers */,
+ 58D6E8E81174144900357FF5 /* NKDPlanetBarcode.h in Headers */,
+ 58D6E8EA1174144900357FF5 /* NKDPostnetBarcode.h in Headers */,
+ 58D6E8EC1174144900357FF5 /* NKDRoyalMailBarcode.h in Headers */,
+ 58D6E8EE1174144900357FF5 /* NKDUPCABarcode.h in Headers */,
+ 58D6E8F01174144900357FF5 /* NKDUPCEBarcode.h in Headers */,
+ 58D6E8F21174144900357FF5 /* UIImage-NKDBarcode.h in Headers */,
+ 58D6E8F51174144900357FF5 /* UIImage-Normalize.h in Headers */,
+ 58D6E8F61174144900357FF5 /* NSString-UPCEAN.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+ D2AAC07D0554694100DB518D /* CocoaTouchBarcodes */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "CocoaTouchBarcodes" */;
+ buildPhases = (
+ D2AAC07A0554694100DB518D /* Headers */,
+ D2AAC07B0554694100DB518D /* Sources */,
+ D2AAC07C0554694100DB518D /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = CocoaTouchBarcodes;
+ productName = CocoaTouchBarcodes;
+ productReference = D2AAC07E0554694100DB518D /* libCocoaTouchBarcodes.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 0867D690FE84028FC02AAC07 /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CocoaTouchBarcodes" */;
+ compatibilityVersion = "Xcode 3.1";
+ hasScannedForEncodings = 1;
+ mainGroup = 0867D691FE84028FC02AAC07 /* CocoaTouchBarcodes */;
+ productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ D2AAC07D0554694100DB518D /* CocoaTouchBarcodes */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ D2AAC07B0554694100DB518D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 58D6E8CA1174144900357FF5 /* JapanPostBarcode.m in Sources */,
+ 58D6E8CC1174144900357FF5 /* NKDAbstractUPCEANBarcode.m in Sources */,
+ 58D6E8CE1174144900357FF5 /* NKDBarcode.m in Sources */,
+ 58D6E8D31174144900357FF5 /* NKDBarcodeOffscreenView.m in Sources */,
+ 58D6E8D51174144900357FF5 /* NKDCodabarBarcode.m in Sources */,
+ 58D6E8D71174144900357FF5 /* NKDCode39Barcode.m in Sources */,
+ 58D6E8D91174144900357FF5 /* NKDCode128Barcode.m in Sources */,
+ 58D6E8DB1174144900357FF5 /* NKDEAN8Barcode.m in Sources */,
+ 58D6E8DD1174144900357FF5 /* NKDEAN13Barcode.m in Sources */,
+ 58D6E8DF1174144900357FF5 /* NKDExtendedCode39Barcode.m in Sources */,
+ 58D6E8E11174144900357FF5 /* NKDIndustrialTwoOfFiveBarcode.m in Sources */,
+ 58D6E8E31174144900357FF5 /* NKDInterleavedTwoOfFiveBarcode.m in Sources */,
+ 58D6E8E51174144900357FF5 /* NKDModifiedPlesseyBarcode.m in Sources */,
+ 58D6E8E71174144900357FF5 /* NKDModifiedPlesseyHexBarcode.m in Sources */,
+ 58D6E8E91174144900357FF5 /* NKDPlanetBarcode.m in Sources */,
+ 58D6E8EB1174144900357FF5 /* NKDPostnetBarcode.m in Sources */,
+ 58D6E8ED1174144900357FF5 /* NKDRoyalMailBarcode.m in Sources */,
+ 58D6E8EF1174144900357FF5 /* NKDUPCABarcode.m in Sources */,
+ 58D6E8F11174144900357FF5 /* NKDUPCEBarcode.m in Sources */,
+ 58D6E8F31174144900357FF5 /* UIImage-NKDBarcode.m in Sources */,
+ 58D6E8F41174144900357FF5 /* UIImage-Normalize.m in Sources */,
+ 58D6E8F71174144900357FF5 /* NSString-UPCEAN.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 1DEB921F08733DC00010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ COPY_PHASE_STRIP = NO;
+ DSTROOT = /tmp/CocoaTouchBarcodes.dst;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = CocoaTouchBarcodes_Prefix.pch;
+ INSTALL_PATH = /usr/local/lib;
+ PRODUCT_NAME = CocoaTouchBarcodes;
+ };
+ name = Debug;
+ };
+ 1DEB922008733DC00010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ DSTROOT = /tmp/CocoaTouchBarcodes.dst;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = CocoaTouchBarcodes_Prefix.pch;
+ INSTALL_PATH = /usr/local/lib;
+ PRODUCT_NAME = CocoaTouchBarcodes;
+ };
+ name = Release;
+ };
+ 1DEB922308733DC00010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CODE_SIGN_IDENTITY = "iPhone Developer: Chris Zelenak (3K884E72M6)";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ OTHER_LDFLAGS = "-ObjC";
+ PREBINDING = NO;
+ PROVISIONING_PROFILE = "1E0C7EE7-96DC-4A89-8F3E-7297355AFD89";
+ SDKROOT = iphoneos3.2;
+ };
+ name = Debug;
+ };
+ 1DEB922408733DC00010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ OTHER_LDFLAGS = "-ObjC";
+ PREBINDING = NO;
+ SDKROOT = iphoneos3.2;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "CocoaTouchBarcodes" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB921F08733DC00010E9CD /* Debug */,
+ 1DEB922008733DC00010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CocoaTouchBarcodes" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB922308733DC00010E9CD /* Debug */,
+ 1DEB922408733DC00010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
+}
7 CocoaTouchBarcodes_Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'CocoaTouchStaticLibrary' target in the 'CocoaTouchStaticLibrary' project.
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+#endif
20 JapanPostBarcode.h
@@ -0,0 +1,20 @@
+//
+// JapanPostBarcode.h
+// BarcodePod
+//
+// Created by 佐藤 昭 on Mon Jun 30 2003.
+// Copyright (c) 2003 SatoAkira. All rights reserved.
+//
+// 基本的に4ステイト3バー。数字と制御コードは3本のバーで1つのキャラクタ。大文字A~Zは制御コード+数字で1つのキャラクタ。スタートコード(STC)、ストップコード(SPC)は2本のバー。スタートコード(1)+郵便番号(7)+住居表示番号(13)+チェックデジット(1)+ストップコード(1)。郵便番号のハイフンは削除する。0で右側の不足分を埋める。住居表示番号は右側の不足分をCC4制御コードで埋める。英字は2つに数えるので13個目が制御コードのときは中途半端になる。バー幅は0.6mm。黒バーの間隔は1.2mmなので、(2 + (7+13+1) * 3 + 1) * 1.2 = 79.2mmが最初のバー中心から最後のバー中心までの長さになる。基準線の間隔は1.2mm。合計3.6mmになるので10ポイント相当になる。なお、この設定は10ポイントに設定したときの値である。8.5ポイントから11.5ポイントまで許容されているので、全数値を0.85から1.15の範囲で乗じても良い。 //
+
+#import <Foundation/Foundation.h>
+#import "NKDBarcode.h"
+
+@interface JapanPostBarcode : NKDBarcode {
+ @private
+ NSString *japanpostContents;
+}
+
+- (NSString *)japanpostContents;
+
+@end
323 JapanPostBarcode.m
@@ -0,0 +1,323 @@
+//
+// JapanPostBarcode.m
+// BarcodePod
+//
+// Created by 佐藤 昭 on Mon Jun 30 2003.
+// Copyright (c) 2003 SatoAkira. All rights reserved.
+//
+
+#import "JapanPostBarcode.h"
+
+@implementation JapanPostBarcode
+
+#define MILLIMETERPERPOINT 0.3527777777777777 // base72.0 //
+#define JP_DESCENDER_BOTTOM 0.0 // 最下段基準線(mm) //
+#define JP_TRACK_BOTTOM 1.2 // 中段下基準線(mm) //
+#define JP_TRACK_TOP 2.4 // 中段上基準線(mm) //
+#define JP_ASCENDER_TOP 3.6 // 最上段基準線(mm) //
+#define JP_ASCENDER_MASK (0x222)
+#define JP_DESCENDER_MASK (0x111)
+
+// -----------------------------------------------------------------------------------
+// Constants
+// -----------------------------------------------------------------------------------
+
+// Each hex constant represents a 4-bar code of the barcode corresponding to a single number or letter. The digits represent bars in this fashion: //
+// 0 - タイミングバー (JP_TRACK_BOTTOM to JP_TRACK_TOP) //
+// 1 - 下セミロングバー (JP_DESCENDER_BOTTOM to JP_TRACK_TOP) //
+// 2 - 上セミロングバー (JP_TRACK_BOTTOM to JP_ASCENDER_TOP) //
+// 3 - ロングバー (JP_DESCENDER_BOTTOM to JP_ASCENDER_TOP) //
+unsigned int openBracketLength = 2;
+unsigned int openBracket = 0x31; // スタートコード //
+unsigned int closeBracketLength = 2;
+unsigned int closeBracket = 0x13; // ストップコード //
+NSString *barFormat = @"101010101010101010101010";
+unsigned int numberLength = 3;
+unsigned int numberCodesOfJapan[] = {
+ 0x030, // - //
+ 0x003, // CC7 . //
+ 0x333, // CC8 / //
+ 0x300, // 0 //
+ 0x330, // 1 //
+ 0x312, // 2 //
+ 0x132, // 3 //
+ 0x321, // 4 //
+ 0x303, // 5 //
+ 0x123, // 6 //
+ 0x231, // 7 //
+ 0x213, // 8 //
+ 0x033, // 9 //
+ 0x120, // CC1 : //
+ 0x102, // CC2 ; //
+ 0x210, // CC3 < //
+ 0x012, // CC4 = //
+ 0x201, // CC5 > //
+ 0x021 // CC6 ? //
+};
+
+double japanpost_barTop(unsigned int hexDigit,double size) { // mm単位で返す。 //
+ return (hexDigit & JP_ASCENDER_MASK) ? JP_ASCENDER_TOP * size / 10.0 : JP_TRACK_TOP * size / 10.0;
+}
+double japanpost_barBottom(unsigned int hexDigit,double size) { // mm単位で返す。 //
+ return (hexDigit & JP_DESCENDER_MASK) ? JP_DESCENDER_BOTTOM * size / 10.0 : JP_TRACK_BOTTOM * size / 10.0;
+}
+unsigned int japanpost_characterDescriptor(unichar character) {
+ return numberCodesOfJapan[character - '-'];
+}
+
+unsigned int japanpost_barDescriptor(unsigned int descriptor,unsigned int bar,unsigned int bars)
+{
+ unsigned int shift = (bars - 1 - (bar / 2)) * 4; // 4ビットずつで1つのバーを表す。bar / 2 番目 //
+ unsigned int mask = 0xF << shift; // 0xfは4ビット分 //
+
+ return (descriptor & mask) >> shift;
+}
+
+- (unsigned int)_barDescriptor:(unsigned int)index
+// barcode is [self initiator][self barcode][self terminator] //
+// 2 * numberLength がほぼ定数に近い働きをしており、これを変数にすることが難しい。よって'A'~'Z'は2文字の扱いをした。 //
+{
+ unsigned int bar;
+ unsigned int hexDigit;
+ unsigned int descriptor;
+ unsigned int contentLength = [japanpostContents length];
+
+ if ([[self initiator] length] > index) {
+ bar = index % [[self initiator] length];
+ hexDigit = openBracket;
+ descriptor = japanpost_barDescriptor(hexDigit,bar,openBracketLength);
+ }
+ else {
+ if (index >= (contentLength + 1) * (2 * numberLength) + [[self initiator] length]) {
+ bar = (index - [[self initiator] length] - (contentLength + 1) * (2 * numberLength)) % [[self terminator] length];
+ hexDigit = closeBracket;
+ descriptor = japanpost_barDescriptor(hexDigit,bar,closeBracketLength);
+ }
+ else {
+ unsigned int digit = (index - [[self initiator] length]) / (2 * numberLength); // 何文字目か //
+
+ bar = (index - [[self initiator] length]) % (2 * numberLength); // 1文字の中の何番目のバーになるか //
+ if (digit != contentLength) {
+ hexDigit = japanpost_characterDescriptor( [[self japanpostContents] characterAtIndex:digit] );
+ descriptor = japanpost_barDescriptor( hexDigit, bar,numberLength);
+ }
+ else { // last digit is checksum
+ hexDigit = japanpost_characterDescriptor( [self checkDigit] );
+ descriptor = japanpost_barDescriptor( hexDigit, bar,numberLength);
+ }
+ }
+ }
+ return descriptor;
+}
+
+- (NSString *)japanpostContents {
+ return japanpostContents;
+}
+
+// override //
+
+- (id)initWithContent:(NSString *)inContent printsCaption:(BOOL)inPrints andBarWidth:(float)inBarWidth andHeight:(float)inHeight andFontSize:(float)inFontSize andCheckDigit:(char)inDigit
+// inPrints,inBarWidth,inFontSize,inDigitは意味を持たない。 //
+{
+ if ((nil != inContent) && (nil != (self = [super init]))) {
+ [self setContent:inContent];
+ if ((8.0 <= inHeight) && (11.5 >= inHeight))
+ [self setHeight:inHeight];
+ else
+ [self setHeight:10.0];
+ }
+ return self;
+}
+
+- (void)setHeight:(float)inHeight
+// inHeight:ポイント単位 //
+{
+ if (8.5 > inHeight)
+ height = 8.5;
+ else {
+ if (11.5 < inHeight)
+ height = 11.5;
+ else
+ height = inHeight;
+ }
+ barWidth = (float)((double)height / (double)6.0);
+ [self calculateWidth];
+}
+
+- (void)setBarWidth:(float)inBarWidth
+// inBarWidth:point単位 //
+{
+ if (1.3333333333333333 > inBarWidth) // 8.0 / 6.0 //
+ barWidth = 1.3333333333333333;
+ else {
+ if (1.9166666666667 < inBarWidth) // 11.5 / 6.0 //
+ barWidth = 1.9166666666667;
+ else
+ barWidth = inBarWidth;
+ }
+ height = (float)((double)6.0 * (double)barWidth);
+ [self calculateWidth];
+}
+
+- (void)generateChecksum
+{
+ unsigned int i,cd;
+ unichar uChar,character;
+ unsigned int checkValue = 0;
+
+ for (i = 0; i < [japanpostContents length]; i++) {
+ uChar = [japanpostContents characterAtIndex:i];
+ if ('-' == uChar)
+ checkValue += 10; // 10 //
+ else {
+ if ((',' == uChar) || ('/' == uChar))
+ checkValue += (uChar - '-') + 16; // 17 or 18 //
+ else {
+ if (('0' <= uChar) && ('9' >= uChar))
+ checkValue += uChar - '0'; // 0 ~ 9 //
+ else {
+ checkValue += uChar - ':' + 11; // 11 ~ 16 //
+ }
+ }
+ }
+ }
+ cd = 19 * (checkValue / 19 + 1) - checkValue;
+ if ((0 <= cd) && (10 > cd))
+ character = '0' + cd;
+ else {
+ if (10 == cd)
+ character = '-';
+ else {
+ if ((10 < cd) && (16 >= cd))
+ character = ':' + cd - 11;
+ else
+ character = '-' + cd - 16;
+ }
+ }
+ [self setCheckDigit:character];
+}
+
+- (void)setContent:(NSString *)inContent
+// 大文字化する。20文字に揃える。使用できない文字を排除する。郵便番号の整合性はチェックしない。 //
+{
+ unichar uChar;
+ unsigned int i;
+ NSString *uppercaseString = [inContent uppercaseString];
+ NSMutableString *tempStr = [NSMutableString string];
+ NSMutableString *tempContents = [NSMutableString string];
+ NSString *tenStr = @"0123456789";
+ unsigned int maxLength = 20; // 郵便番号7文字+住居表示番号13文字 //
+
+ for (i = 0; i < [uppercaseString length]; i++) {
+ uChar = [uppercaseString characterAtIndex:i];
+ if (('A' <= uChar) && ('Z' >= uChar)) {
+ if ('K' > uChar) {
+ [tempStr appendString:@":"]; // CC1 //
+ [tempStr appendString:[tenStr substringWithRange:NSMakeRange((unsigned int)(uChar - 'A'),1)]];
+ [tempContents appendString:[NSString stringWithCharacters:&uChar length:1]];
+ }
+ else {
+ if ('U' > uChar) {
+ [tempStr appendString:@";"]; // CC2 //
+ [tempStr appendString:[tenStr substringWithRange:NSMakeRange((unsigned int)(uChar - 'K'),1)]];
+ [tempContents appendString:[NSString stringWithCharacters:&uChar length:1]];
+ }
+ else { // ('Z' >= uChar) //
+ [tempStr appendString:@"<"]; // CC3 //
+ [tempStr appendString:[tenStr substringWithRange:NSMakeRange((unsigned int)(uChar - 'U'),1)]];
+ [tempContents appendString:[NSString stringWithCharacters:&uChar length:1]];
+ }
+ }
+ }
+ else {
+ if (('-' == uChar) || (('0' <= uChar) && ('9' >= uChar))) {
+ [tempStr appendString:[NSString stringWithCharacters:&uChar length:1]];
+ [tempContents appendString:[NSString stringWithCharacters:&uChar length:1]];
+ } // 使用できない文字を排除する。 //
+ }
+ }
+ if (maxLength > [tempStr length]) {
+ for (i = [tempStr length]; i < maxLength; i++)
+ [tempStr appendString:@"="]; // CC4 //
+ }
+ else {
+ if (maxLength < [tempStr length]) {
+ unsigned int validCount;
+ unsigned int tempL = [tempStr length];
+ NSString *tempCStr = [NSString stringWithString:tempContents];
+
+ [tempStr deleteCharactersInRange:NSMakeRange(maxLength,tempL - maxLength)];
+ tempL = [tempStr length];
+ validCount = 0;
+ for (i = 0; i < [tempStr length]; i++) {
+ uChar = [tempStr characterAtIndex:i];
+ if (('-' == uChar) || (('0' <= uChar) && ('9' >= uChar))) // 'A'~'Z'も制御文字+数字文字になっているのでカウントできる。 //
+ validCount++;
+ }
+ tempContents = [NSMutableString stringWithString:[tempCStr substringWithRange:NSMakeRange(0,validCount)]];
+ }
+ }
+ [japanpostContents release];
+ japanpostContents = [[NSString allocWithZone:[self zone]] initWithString:tempStr];
+ [content release];
+ content = [[NSString allocWithZone:[self zone]] initWithString:tempContents];
+ [self generateChecksum];
+}
+
+- (BOOL)isContentValid
+{
+ unsigned int i;
+ unichar uChar;
+ BOOL result = YES;
+
+ for (i = 0; i < 7; i++) {
+ uChar = [content characterAtIndex:i];
+ if (('0' > uChar) || ('9' < uChar)) {
+ result = NO;
+ break;
+ }
+ }
+ return result;
+}
+
+- (NSString *)barcode
+// japanpostContentsを参照するところがNKDBarcodeと異なる。 //
+{
+ unsigned int i;
+ NSMutableString *theReturn = [NSMutableString string];
+
+ for (i = 0; i < [japanpostContents length]; i++)
+ [theReturn appendString:[self _encodeChar:[japanpostContents characterAtIndex:i]]];
+ if (checkDigit != -1)
+ [theReturn appendString:[self _encodeChar:checkDigit]];
+ return theReturn;
+}
+
+- (BOOL)printsCaption {
+ return NO;
+}
+
+- (NSString *)initiator {
+ return [barFormat substringToIndex:2 * openBracketLength];
+}
+- (NSString *)terminator {
+ return [barFormat substringToIndex:2 * closeBracketLength - 1]; // 最後の"0"は不要 //
+}
+
+- (float)barTop:(int)index {
+ return (float)(japanpost_barTop([self _barDescriptor:(unsigned int)index],(double)height) / (double)MILLIMETERPERPOINT);
+}
+- (float)barBottom:(int)index {
+ return (float)(japanpost_barBottom([self _barDescriptor:(unsigned int)index],(double)height) / (double)MILLIMETERPERPOINT);
+}
+
+- (NSString *)_encodeChar:(char)inChar {
+ return [barFormat substringToIndex:2 * numberLength];
+}
+
+- (void)calculateWidth
+{
+ [self setWidth:(float)((double)[[self completeBarcode] length] * (double)[self barWidth])];
+}
+
+@end
138 NKDAbstractUPCEANBarcode.h
@@ -0,0 +1,138 @@
+// -----------------------------------------------------------------------------------
+// NKDAbstractUPCEANBarcode.h
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Sat May 11 2002.
+// ©2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+#import <Foundation/Foundation.h>
+#import "NKDBarcode.h"
+#import "NSString-UPCEAN.h"
+/*!
+@header NKDAbstractUPCEANBarcode.h
+ This is an abstract object to encapsulate the functionality that the various UPC and EAN barcodes have in common,
+ including parity-swapping and digit encoding.
+ */
+
+/*!
+@typedef Parity
+ @discussion Defines a type of "Parity" (as a BOOL) to make methods that take one of the precompiler defined parity values
+ more readable.
+ */
+typedef BOOL Parity;
+
+/*!
+@typedef Handedness
+ @discussion Defiens a type of Handedness (as a BOOL) to deal with the difference between left and right handed encoding schemes
+ */
+typedef BOOL Handedness;
+
+/*!
+@defined EVEN_PARITY
+ @discussion UPC / EAN codes use parity swapping to increase the number of values that can be encoded. This
+ defines EVEN_PARITY as YES to make the code more readable.
+ */
+#define EVEN_PARITY YES
+
+/*!
+@defined ODD_PARITY
+ @discussion UPC / EAN codes use parity swapping to increase the number of values that can be encoded. This
+ defines ODD_PARITY as NO to make the code more readable.
+ */
+#define ODD_PARITY NO
+
+/*!
+ @defined LEFT_HANDEDNESS
+ */
+#define LEFT_HANDEDNESS
+
+/*!
+ @defined RIGHT_HANDEDNESS
+ */
+#define RIGHT_HANDEDNESS
+
+/*!
+ @class NKDAbstractUPCEANBarcode
+ @discussion This abstract class holds all the functionality shared by UPC-A, UPC-E, EAN-13 and EAN-8
+ */
+@interface NKDAbstractUPCEANBarcode : NKDBarcode
+{
+
+}
+/*!
+ @method calculateWidth
+ @abstract Overridden to provide extra space to the left and right needed for printing first and last characters
+ */
+-(void)calculateWidth;
+
+/*!
+ @method firstBar
+ @abstract Overridden to set a first bar position indented in from the left to provide room for the first digit
+ @result A value that is 10% of the total width. The total width is calculated at 120% needed to hold the barcode.
+*/
+-(float)firstBar;
+
+/*!
+ @method lastBar
+ @abstract Overridden to set a last bar position indented from the right to provide room for the check digit.
+ @result A value that is 90% of the total width. The total width is calculated at 120% needed to hold the barcode.
+*/
+-(float)lastBar;
+
+/*!
+ @method _encodeChar
+ @abstract Simple encoding scheme that returns a 7 character string
+ @discussion This routine returns the left-hand odd encoding. Either the handedness or parity can be converted using
+ the routines _swapParity: and _swapHandedness
+ @result String of 0s and 1s representing this character
+*/
+-(NSString *)_encodeChar:(char)inChar;
+
+/*!
+ @method initiator
+ @abstract Returns start character for UPC-A
+ @result "101" The start and end character for UPC / EAN
+*/
+-(NSString *)initiator;
+
+/*!
+ @method terminator
+ @abstract Returns end character for UPC or EAN barcode
+ @result "101" The start and end character for UPC / EAN
+*/
+-(NSString *)terminator;
+
+/*!
+ @method digitsToRight
+ @abstract Overridden to specify that one character of the caption prints to the right of the barcode
+ @result 1
+*/
+-(int)digitsToRight;
+
+/*!
+ @method barBottom:
+ @abstract Overridden to specify that guard bars, terminator and initiator should extend down into the caption area
+ @param index The index of the bar that you want to find the bottom for (assuming origin at lower left) as an index of
+ completeBarcode
+ @result Bottom of the bar specified in inches * kScreenResolution
+*/
+-(float)barBottom:(int)index;
+
+/*!
+ @method digitsToLeft
+ @abstract Overridden to specify that one character of the caption prints to the left of the barcode
+ @result 1
+*/
+-(int)digitsToLeft;
+
+/*!
+ @method rightCaption
+ @abstract Overridden to specify that the check digit prints to the right of the caption
+ @result The check digit wrapped in an NSString *
+*/
+-(NSString *)rightCaption;
+
+@end
135 NKDAbstractUPCEANBarcode.m
@@ -0,0 +1,135 @@
+// -----------------------------------------------------------------------------------
+// NKDAbstractUPCEANBarcode.m
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Sat May 11 2002.
+// ©2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+#import "NKDAbstractUPCEANBarcode.h"
+
+
+@implementation NKDAbstractUPCEANBarcode
+// -----------------------------------------------------------------------------------
+-(void)calculateWidth
+// -----------------------------------------------------------------------------------
+{
+ // We need to add additional width for the characters to the left and right
+ if ([[self content] length] != 0)
+ [self setWidth:([[self completeBarcode] length] * [self barWidth]) * 1.2];
+ else
+ [self setWidth:0.0];
+}
+// -----------------------------------------------------------------------------------
+-(float)firstBar
+// -----------------------------------------------------------------------------------
+{
+ return [self width] * .1;
+}
+// -----------------------------------------------------------------------------------
+-(float)lastBar
+// -----------------------------------------------------------------------------------
+{
+ return ([self width] * .9) - [self barWidth];
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)_encodeChar:(char)inChar
+// -----------------------------------------------------------------------------------
+{
+ switch (inChar)
+ {
+ case '0':
+ return @"0001101";
+ case '1':
+ return @"0011001";
+ case '2':
+ return @"0010011";
+ case '3':
+ return @"0111101";
+ case '4':
+ return @"0100011";
+ case '5':
+ return @"0110001";
+ case '6':
+ return @"0101111";
+ case '7':
+ return @"0111011";
+ case '8':
+ return @"0110111";
+ case '9':
+ return @"0001011";
+ default:
+ return @"";
+ break;
+ }
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)initiator
+// -----------------------------------------------------------------------------------
+{
+ return @"101";
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)terminator
+// -----------------------------------------------------------------------------------
+{
+ return @"101";
+}
+// -----------------------------------------------------------------------------------
+-(int)digitsToRight
+// -----------------------------------------------------------------------------------
+{
+ return 1;
+}
+// -----------------------------------------------------------------------------------
+-(float)barBottom:(int)index
+// -----------------------------------------------------------------------------------
+{
+
+ if ( (index < 7) || (index > ([[self completeBarcode] length] - 7)) || ( (index >= 45) && (index <= 49)))
+ return 0.05*kScreenResolution;
+ else
+ return [self captionHeight] * kScreenResolution;
+
+}
+// -----------------------------------------------------------------------------------
+-(void)generateChecksum
+// -----------------------------------------------------------------------------------
+{
+ int oddSum = 0;
+ int evenSum = 0;
+ int i, checkInt;
+ int even = 1;
+ //char * code = (char *) [content lossyCString];
+ char * code = (char *) [content cString];
+ if (strlen(code) == 11)
+ {
+ i = strlen(code);
+ while (i-- > 0) {
+ if (even) evenSum += code[i]-'0';
+ else oddSum += code[i]-'0';
+ even = !even;
+ }
+
+ i = (3*evenSum + oddSum) % 10;
+ checkInt = (10-i) % 10; // complement to 10
+
+ checkDigit = checkInt + '0';
+ }
+}
+// -----------------------------------------------------------------------------------
+-(int)digitsToLeft
+// -----------------------------------------------------------------------------------
+{
+ return 1;
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)rightCaption
+// -----------------------------------------------------------------------------------
+{
+ return [NSString stringWithFormat:@"%c", checkDigit];
+}
+
+@end
404 NKDBarcode.h
@@ -0,0 +1,404 @@
+// -----------------------------------------------------------------------------------
+// NKDBarcode.h
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Wed May 01 2002.
+// Copyright (c) 2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+/*!
+@header NKDBarcode.h
+ NKDBarcode is a quasi-abstract class that contains state and actions common to generating many
+ different types of barcodes. It encapsulates much of the common behavior of the concrete subclasses that
+ implement varoius one dimensional (linear) barcodes. Subclasses will respond to a barcode message by
+ returning an NSString of 1s and 0s, assuming that a value of '1' represents a bar of the narrowest size needed
+ by this encoding scheme, and that '0' represents a gap of the same size.
+
+ If a subclass modifies this behavior, it should be well documented, and NKDBarcodeOffscreenView will possibly
+ have to be modified to accommodate the change.
+
+ Although most barcode specifications allow narrow bar widths as small as 7.5 mils, I am using a default
+ size of 13 mils for all barcodes that don't have strict bar-width requirements in their specification (e.g. PostNet)
+ because this is an acceptable bar width for most barcodes and many inkjet and laser printers have insufficient resolution
+ to produce a readable code on plain paper at bar widths smaller than this size.
+
+ The framework currently contains subclasses for Code 3 of 9, Extended Code 3 of 9, Interleaved Code
+ 2 of 5, Modified Plessey and Modified Plessey Hex (not compliant with specs, untested), PostNet,
+ UPC-A, Code 128, Industrial 2 of 5, and EAN-13, Codabar, EAN-8 and UPC-E. In some cases, I do not have the complete
+ or official specifications. I also, unfortunately, do not have equipment to test some types of barcode, so I welcome
+ any help debugging, testing, and validating the encoding schemes of the provided subclasses. No guarantee is made concerning
+ the creation of readable code for any given hardware - I've done the best job that I could armed only with my PowerBook,
+ a Cue Cat and the specifications I could find.
+
+ If you have complete specifications or information about any dimensional linear barcodes or (for that matter) and other feedback,
+ please send it to me at <code>jeff_lamarche&#064;mac.com</code> and I will try to respond. Support for 2-dimensional (matrix)
+ barcodes is not currently planned as part of this framework, but if there's an interest, I'll consider adding it.
+*/
+#import <Foundation/Foundation.h>
+
+/*!
+ @defined kScreenResolution
+ @discussion This value is used to determine the drawing location of various bars. Though many
+ devices have different resolution, drawing in Cocoa seems to based on 72 pixels per inch
+ */
+#define kScreenResolution 72.00
+
+/*!
+ @class NKDBarcode
+ @abstract Superclass of concrete barcode classes.
+ @discussion The Naked Barcode Framework is designed to allow rapid creation and easy maintenance of
+ a set of classes for generating resolution independent one-dimensional linear barcodes. NKDBarcode is the root class
+ of the NKDBarcode framework.
+ */
+@interface NKDBarcode : NSObject <NSCopying, NSCoding>
+{
+ NSString *content;
+ float height;
+ float width;
+ char checkDigit;
+ float barWidth; // bar width in mils (thousands of an inch)
+ BOOL printsCaption;
+ float fontSize;
+ float captionHeight;
+}
+
+/*!
+ @method initWithContent:
+ @abstract Initializes new barcode object to encode provided data.
+ @param inContent A string containing the data to be encoded; should use only <B>ASCII-8</B> characters
+ (those that can be encoded using a single char in UTF-8)
+ @result Returns initialized NKDBarcode class
+ */
+-(id)initWithContent: (NSString *)inContent;
+
+/*!
+ @method initWithContent:printsCaption
+ @abstract Initializes new barcode object with provided data and specifies whether a caption should be printed
+ below the barcode.
+ @param inContent A string containing the data to be encoded; should use only <B>ASCII-8</B> characters
+ (those that can be encoded using a single char in UTF-8)
+ @param inPrints YES if caption should print.
+ @result Returns initialized NKDBarcode class
+ */
+-(id)initWithContent: (NSString *)inContent
+ printsCaption: (BOOL)inPrints;
+
+/*!
+@method initWithContent:printsCaption:andBarWidth:andHeight:andFontSize:andCheckDigit:
+ @abstract Designated initializer for abstract barcode object.
+ @param inContent A string containing the data to be encoded; should use only <B>ASCII-8</B> characters
+ (those that can be encoded using a single char in UTF-8)
+ @param inPrints YES if caption should print.
+ @param inBarWidth Width of the smallest bar or gap to be used, in base units (points)
+ @param inHeight Height of the bar (excluding caption) in base units
+ @param inFontSize Size of the font to use for the caption
+ @param inDigit Check Digit either provided or calculated, -1 if not used or not yet calculated
+ @result Returns initialized NKDBarcode class
+ */
+-(id)initWithContent: (NSString *)inContent
+ printsCaption: (BOOL)inPrints
+ andBarWidth: (float)inBarWidth
+ andHeight: (float)inHeight
+ andFontSize: (float)inFontSize
+ andCheckDigit: (char)inDigit;
+
+/*!
+ @method setContent:
+ @abstract Sets the content to provided NSString.
+ @param inContent A string containing the data to be encoded; should use only <B>ASCII-8</B> characters
+ (those that can be encoded using a single char in UTF-8)
+*/
+-(void)setContent:(NSString *)inContent;
+
+/*!
+ @method setHeight:
+ @abstract Sets the barcode height to the provided value.
+ @param inHeight Value to set the height to.
+ */
+-(void)setHeight:(float)inHeight;
+
+/*!
+ @method setWidth:
+ @abstract Sets the barcode width to the provided value.
+ @param inWidth Value to set the width to.
+ */
+-(void)setWidth:(float)inWidth;
+
+/*!
+ @method setFontSize:
+ @abstract Sets the size of the font to use
+ @param inSize The size (as a float) of the font to use
+ */
+-(void)setFontSize:(float)inSize;
+
+/*!
+ @method setCaptionHeight:
+ @abstract: Set amount of space to leave under barcode for the caption
+ @param inHeight: Floating point amount of space to set (in inches)
+ */
+-(void)setCaptionHeight:(float)inHeight;
+
+/*!
+ @method captionHeight
+ @abstract Returns the amount of space to leave under the barcode for the caption
+ @result Floating point value representing the amount of space to leave (in inches)
+ */
+-(float)captionHeight;
+
+/*!
+@method calculateWidth
+ @abstract Calculates the correct width for the barcode based on the encoding scheme and the specified bar width.
+ */
+-(void)calculateWidth;
+
+/*!
+ @method setCheckDigit:
+ @abstract Sets the check digit to the provided character.
+ @param inCheckDigit Character (char, not unichar) to set the check digit to.
+ */
+-(void)setCheckDigit:(char)inCheckDigit;
+
+/*!
+ @method setPrintsCaption:
+ @abstract Sets whether this barcode should print the content below the code.
+ @param inPrints Boolean value to specify whether the caption should print.
+ */
+-(void)setPrintsCaption:(BOOL)inPrints;
+
+/*!
+ @method setBarWidth:
+ @abstract Sets the width of a single bar (represented by a single 1 in the barcode string).
+ @param inBarWidth The value to use for the width of a single bar.
+ */
+-(void)setBarWidth:(float)inBarWidth;
+
+/*!
+@method content
+ @abstract Accessor method for the data being encoded by this barcode.
+ @result Pointer to the NSString that stores the barcode's data.
+ */
+-(NSString *)content;
+
+/*!
+@method height
+ @abstract Accessor method for the height of this barcode.
+ @result The current height of the barcode in inches.
+ */
+-(float)height;
+
+/*!
+@method width
+ @abstract Accessor method for the width of this barcode.
+ @result The current width of this barcode in inches.
+ */
+-(float)width;
+
+/*!
+ @method checkDigit
+ @abstract Accessor method for the checkDigit for this barcode.
+ @discussion Many barcodes offer and some require a check digit that is calculated based on the rest of the content. This
+ value shouldn't print as part of the caption and will need to be recalculated if the content changes, so
+ it makes sense to store it separately
+ @result The check digit character (ASCII-8 char, not unichar)
+ */
+-(char)checkDigit;
+
+/*!
+ @method printsCaption
+ @abstract Accessor method for printsCaption.
+ @result YES if the content should be printed below the barcode.
+ */
+-(BOOL)printsCaption;
+
+/*!
+ @method barWidth
+ @abstract Accessor method for the current width of a single bar in inches
+ @result The current width in inches of a single bar or gap.
+ */
+-(float)barWidth;
+
+/*!
+ @method fontSize
+ @abstract returns the size of the font to use for the caption
+ @result Floating point value representing the size of the font (in points) to use for the caption
+ */
+-(float) fontSize;
+
+/*!
+ @method isSizeValid
+ @abstract (Deprecated) Returns true if the supplied image size provides sufficient
+ space to create a valid (open) barcode using this encoding scheme.
+ @discussion The first version of this barcode framework allowed the user to specify
+ the size of the barcode when it was instantiated. This method was
+ implemented as a check to make sure that the barcode that was created
+ didn't result in a barWidth less than the barcode's specification allowed
+ (usually 7.5 mils)
+ @result YES if the bar width at these settings is okay according to the specifications.
+ */
+-(BOOL)isSizeValid;
+
+/*!
+ @method generateChecksum
+ @abstract Generates the check digit or checksum for this barcode encoding scheme.
+ @discussion This can be overridden by objects implementing encoding schemes that
+ have a checksum algorithm. You can either require the entire, correct
+ number be passed in the constructor including the check digit (parsing
+ it out as appropriate, or you can accept the number without the checksum
+ and modify the content accordingly here.
+*/
+-(void)generateChecksum;
+
+/*!
+ @method isContentValid
+ @abstract Validates that this barcode supports the data it is encoding.
+ @discussion This method checks the actual content string to make sure that this encoding
+ scheme can encode the data it contains. For example, numeric-only schemes
+ should return false if a string with one or more letters is passed. If there
+ is a checksum used for the content. that can also be checked here. Don't
+ override if validation isn't desired or required.
+ */
+-(BOOL) isContentValid;
+
+/*!
+ @method initiator
+ @abstract Returns the encoded initiator or alignment bar(s)
+ @discussion Returns encoded string representing the left most character. While some barcodes
+ do not use this, many do have a required character of sequence of bars or gaps
+ that are used for calibration. Sublasses only need to override if such a character
+ is needed.
+ @result String of 0s and 1s representing the first (non-content) character or alignment bar(s).
+ */
+-(NSString *)initiator;
+
+/*!
+ @method terminator
+ @abstract Returns the encoded terminator or alignment bar(s)
+ @discussion Returns encoded string representing the right-most characte. While some barcodes
+ do not use this, many do have a required character of sequence of bars or gaps
+ that are used for calibration. Sublasses only need to override if such a character
+ is needed.
+ @result String of 0s and 1s representing the last (non-content) character or alignment bar(s).
+ */
+-(NSString *)terminator;
+
+/*!
+ @method _encodeChar
+ @abstract Private method to turn a single character into a string of 1s and 0s.
+ @discussion This routine returns an NSString representing a single character. This private method
+ is used by the default getBarcode function, which is responsible for ordering the
+ characters (if necessary and returning the entire encoded string, excluding the
+ terminator and initiator.
+ @result String of 0s and 1s representing inChar encoded for this barcode.
+ */
+-(NSString *)_encodeChar:(char)inChar;
+
+/*!
+ @method barcode:
+ @abstract Returns string of 0s and 1s representing the content for this type of barcode.
+ @discussion This method returns a string representing the entire barcode, excluding the initiator
+ and terminator.
+ @result String of 0s and 1s representing the content.
+ */
+-(NSString *)barcode;
+
+/*!
+ @method completeBarcode
+ @abstract Method to get the entire barcode as a string of 0s and 1s
+ @discussion Returns a string representing the entire barcode, including terminator and initiator.
+ @result String of 0s and 1s representing the entire barcode
+ */
+-(NSString *)completeBarcode;
+
+/*!
+ @method digitsToLeft
+ @abstract Returns number of digits to print to the left of the first bar.
+ @discussion For encoders with intruding captions such as UPC and EAN barcodes, this method
+ tells how many of the digits of the content should be printed to the left of the barcode,
+ rather than intruding on the barcode or printing below the barcode. This only needs to be
+ overridden if you need a value other than 0
+ @result The number of characters to print to the left.
+ */
+-(int)digitsToLeft;
+
+/*!
+ @method digitsToRight
+ @abstract Returns number of digits to print to the right of the last bar.
+ @discussion For encoders with intruding captions such as UPC and EAN barcodes, this method
+ tells how many of the digits of the content should be printed to the right of the barcode,
+ rather than intruding on the barcode or printing below the barcode. This only needs to be
+ overridden if you need a value other than 0
+ @result The number of characters to print to the right.
+*/
+-(int)digitsToRight;
+
+/*!
+ @method leftCaption
+ @abstract Returns string representing the characters to print to the left of the first bar
+ @discussion Returns string representing the portion of the caption that goes to the left of the barcode.
+ @result A string with the data to print to the left.
+*/
+-(NSString *)leftCaption;
+
+/*!
+ @method rightCaption
+ @abstract Returns string representing the characters to print to the right of the last bar
+ @discussion Returns string representing the portion of the caption that goes to the right of the barcode.
+ @result A string with the data to print to the right.
+ */
+-(NSString *)rightCaption;
+
+/*!
+ @method caption
+ @abstract Returns content to print below the barcode.
+ @result String representing the portion of the caption that goes under (or intrudes upon) the barcode.
+*/
+-(NSString *)caption;
+
+/*!
+ @method barBottom:
+ @abstract Designates the bottom of the bar within the barcode for the bar at a given index.
+ @discussion Given an index which corresponds to the bar / gap number (counting from left), where should
+ the bottom of the bar be. For most barcodes this value will always be the bottom of the barcode
+ excluding the caption, but some, like UPC and EAN have different bar bottoms for some bars.
+ Assumes that origin (0,0) is in lower left.
+ @param index The bar (from the left, 0-indexed) to specify the bottom position for.
+ @result The bottom of the bar in inches from the bottom of the barcode.
+*/
+-(float)barBottom:(int)index;
+
+/*!
+ @method barTop:
+ @abstract Designates the top of the bar within the barcode for the bar at a given index.
+ @discussion Given an index which corresponds to the bar/gap number (counting from left, 0-indexed),
+ this method will tell where the top of the bar should be. For most barcodes this value will
+ always be the top of the barcode excluding the caption, since most barcodes have a uniform top, but
+ some, like PostNet use different bar tops as part of the encoding scheme.
+ @param index The bar (from the left, 0 indexed) to specify the top position for.
+ @result The top of the bar in inches from the bottom of the barcode.
+ */
+-(float)barTop:(int)index;
+
+/*!
+ @method firstBar
+ @abstract Returns the position, from the left, specified in inches where the first bar prints
+ @discussion Returns the the horizontal position of the left edge of the first bar or gap. Typically, this is 0,
+ but some code, like EAN/UPC require some digits to print to the left and/or right of the code, meaning
+ that we need allocate some white space by skipping some pixels before drawing the first bar
+ @result The x-position in inches where the first bar prints
+ */
+-(float)firstBar;
+
+/*!
+ @method lastBar
+ @abstract Returns the position, from the left, specified in inches where the last bar ends
+ @discussion Returns the the horizontal position of the right edge of the last bar or gap. Typically, this is the
+ same as [barcode width] but some codes, like EAN/UPC require some digits to print to the left and/or
+ right of the code, meaning that we need allocate some white space by ending the codes before the end
+ of the barcode. This is generally the right edge of the last barcode less one barwidth
+ @result The x-position in inches where the last bar ends
+ */
+-(float)lastBar;
+
+@end
395 NKDBarcode.m
@@ -0,0 +1,395 @@
+// -----------------------------------------------------------------------------------
+// NKDBarcode.m
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Wed May 01 2002.
+// Copyright (c) 2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+#import "NKDBarcode.h"
+#import <UIKit/UIKit.h>
+
+@implementation NKDBarcode
+// -----------------------------------------------------------------------------------
+-(id)initWithContent: (NSString *)inContent
+// -----------------------------------------------------------------------------------
+{
+ return [self initWithContent: inContent
+ printsCaption: YES];
+}
+// -----------------------------------------------------------------------------------
+-(id)initWithContent: (NSString *)inContent
+ printsCaption: (BOOL)inPrints
+// -----------------------------------------------------------------------------------
+{
+ return [self initWithContent:inContent
+ printsCaption:inPrints
+ andBarWidth:.013*kScreenResolution
+ andHeight:.5*kScreenResolution
+ andFontSize:6.0
+ andCheckDigit:(char)-1];
+}
+// -----------------------------------------------------------------------------------
+-(id)initWithContent: (NSString *)inContent
+ printsCaption: (BOOL)inPrints
+ andBarWidth: (float)inBarWidth
+ andHeight: (float)inHeight
+ andFontSize: (float)inFontSize
+ andCheckDigit: (char)inDigit
+// -----------------------------------------------------------------------------------
+{
+ if (self = [super init])
+ {
+ if (!inContent)
+ {
+ [self release];
+ return nil;
+ }
+ [self setContent:inContent];
+
+ [self setBarWidth:inBarWidth];
+ [self setPrintsCaption:inPrints];
+
+ //if (![self printsCaption])
+ [self setHeight:inHeight];
+ //else
+ [self setHeight:inHeight + (captionHeight*kScreenResolution)];
+
+ // Calculate width based on number of bars needed to encode this content
+ [self calculateWidth];
+
+ [self setFontSize: inFontSize];
+
+ // Check digit of -1 means no check digit - couldn't use 0 because
+ // 0 could be a valid check digit. Typically calculated, not set
+ // outside of the class
+ [self setCheckDigit: inDigit];
+ }
+ return self;
+}
+// -----------------------------------------------------------------------------------
+-(void)setContent:(NSString *)inContent
+// -----------------------------------------------------------------------------------
+{
+ [content autorelease];
+ content = [inContent retain];
+}
+// -----------------------------------------------------------------------------------
+-(void)setHeight:(float)inHeight
+// -----------------------------------------------------------------------------------
+{
+ height = inHeight;
+}
+// -----------------------------------------------------------------------------------
+-(void)setWidth:(float)inWidth
+// -----------------------------------------------------------------------------------
+{
+ width = inWidth;
+}
+// -----------------------------------------------------------------------------------
+-(void)calculateWidth
+// -----------------------------------------------------------------------------------
+{
+ [self setWidth:[[self completeBarcode] length] * [self barWidth]];
+}
+// -----------------------------------------------------------------------------------
+-(void)setCheckDigit:(char)inCheckDigit
+// -----------------------------------------------------------------------------------
+{
+ checkDigit = inCheckDigit;
+}
+// -----------------------------------------------------------------------------------
+-(void)setPrintsCaption:(BOOL)inPrints
+// -----------------------------------------------------------------------------------
+{
+ printsCaption = inPrints;
+}
+// -----------------------------------------------------------------------------------
+-(void)setBarWidth:(float)inBarWidth
+// -----------------------------------------------------------------------------------
+{
+ barWidth = inBarWidth;
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)content
+// -----------------------------------------------------------------------------------
+{
+ return content;
+}
+// -----------------------------------------------------------------------------------
+-(float)height
+// -----------------------------------------------------------------------------------
+{
+ return height;
+}
+// -----------------------------------------------------------------------------------
+-(float)width
+// -----------------------------------------------------------------------------------
+{
+ return width;
+}
+// -----------------------------------------------------------------------------------
+-(char)checkDigit
+// -----------------------------------------------------------------------------------
+{
+ return checkDigit;
+}
+// -----------------------------------------------------------------------------------
+-(BOOL)printsCaption
+// -----------------------------------------------------------------------------------
+{
+ return printsCaption;
+}
+// -----------------------------------------------------------------------------------
+-(float)barWidth
+// -----------------------------------------------------------------------------------
+{
+ return barWidth;
+}
+// -----------------------------------------------------------------------------------
+-(BOOL)isSizeValid
+// -----------------------------------------------------------------------------------
+{
+ return YES;
+}
+// -----------------------------------------------------------------------------------
+-(void)generateChecksum
+// -----------------------------------------------------------------------------------
+{
+ // Stub
+}
+// -----------------------------------------------------------------------------------
+-(BOOL) isContentValid
+// -----------------------------------------------------------------------------------
+{
+ int i;
+ char *contentString;
+
+ contentString = (char *)[[self content] lossyCString];
+
+ for (i = 0; i < strlen(contentString); i++)
+ if ([[self _encodeChar:contentString[i]] isEqual:@""])
+ return NO;
+
+ return YES;
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)initiator
+// -----------------------------------------------------------------------------------
+{
+ return @"";
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)terminator
+// -----------------------------------------------------------------------------------
+{
+ return @"";
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)_encodeChar:(char)inChar
+// -----------------------------------------------------------------------------------
+{
+ // Subclasses MUST override - we'll encode dummy character for testing
+ return @"1010";
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)barcode
+// -----------------------------------------------------------------------------------
+{
+ NSMutableString *theReturn = [NSMutableString stringWithString:@""];
+ int i;
+ char *contentString;
+
+ contentString = (char *)[[self content] lossyCString];
+
+ for (i = 0; i < strlen(contentString); i++)
+ [theReturn appendString:[self _encodeChar:contentString[i]]];
+
+ if (checkDigit != -1)
+ [theReturn appendString:[self _encodeChar:checkDigit]];
+
+ return theReturn;
+
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)completeBarcode
+// -----------------------------------------------------------------------------------
+{
+ return [NSString stringWithFormat:@"%@%@%@", [self initiator], [self barcode], [self terminator]];
+}
+// -----------------------------------------------------------------------------------
+-(void)setCaptionHeight:(float)inHeight
+// -----------------------------------------------------------------------------------
+{
+ captionHeight = inHeight;
+}
+// -----------------------------------------------------------------------------------
+-(float)captionHeight
+// -----------------------------------------------------------------------------------
+{
+ return captionHeight;
+}
+// -----------------------------------------------------------------------------------
+-(void)setFontSize:(float)inSize
+// -----------------------------------------------------------------------------------
+{
+ UIFont *font;
+
+ fontSize = inSize;
+
+ font = [UIFont systemFontOfSize:[self fontSize]];
+
+ [self setCaptionHeight: ([font capHeight]/72) + (.35 * ([font capHeight]/72))];
+}
+// -----------------------------------------------------------------------------------
+-(float) fontSize
+// -----------------------------------------------------------------------------------
+{
+ return fontSize;
+}
+// -----------------------------------------------------------------------------------
+-(int)digitsToLeft
+// -----------------------------------------------------------------------------------
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------------
+-(int)digitsToRight
+// -----------------------------------------------------------------------------------
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)leftCaption
+// -----------------------------------------------------------------------------------
+{
+ return [content substringWithRange:NSMakeRange(0, [self digitsToLeft])];
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)rightCaption
+// -----------------------------------------------------------------------------------
+{
+ return [content substringWithRange:NSMakeRange([content length] - [self digitsToRight], [self digitsToRight])];
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)caption
+// -----------------------------------------------------------------------------------
+{
+ if ( ([self digitsToRight] == 0) && ([self digitsToLeft] == 0))
+ return content;
+ else
+ return [content substringWithRange:NSMakeRange([self digitsToLeft],
+ [content length] - [self digitsToLeft] - [self digitsToRight])];
+}
+// -----------------------------------------------------------------------------------
+-(float)barBottom:(int)index
+// -----------------------------------------------------------------------------------
+{
+ if ([self printsCaption])
+ return captionHeight * kScreenResolution;
+ else
+ return 0.0;
+}
+// -----------------------------------------------------------------------------------
+-(float)barTop:(int)index
+// -----------------------------------------------------------------------------------
+{
+ return [self height];
+}
+// -----------------------------------------------------------------------------------
+-(float)firstBar
+// -----------------------------------------------------------------------------------
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------------
+-(float)lastBar
+// -----------------------------------------------------------------------------------
+{
+ return [self width] - [self barWidth];
+}
+// -----------------------------------------------------------------------------------
+-(NSString *)description
+// -----------------------------------------------------------------------------------
+{
+ return [NSString stringWithFormat:@"\n\tBarcode Class: %@\n\tContent: %@\n\tCheck Digit:%c\n\tWidth:%f\n\t%Height:%f\n\tBar Width:%f\n\tFont Size:%f\n\tCaption Height:%f",
+ [self class],
+ [self content],
+ [self checkDigit],
+ [self width],
+ [self height],
+ [self barWidth],
+ [self fontSize],
+ [self captionHeight]];
+}
+// -----------------------------------------------------------------------------------
+- (BOOL)isEqual:(id)anObject
+// -----------------------------------------------------------------------------------
+{
+ NKDBarcode *compare;
+
+ compare = anObject;
+
+ return ([[self content] isEqual:[compare content]]);
+}
+// -----------------------------------------------------------------------------------
+- (id)copyWithZone:(NSZone *)zone
+// -----------------------------------------------------------------------------------
+{
+ NKDBarcode *ret = [[[self class] alloc] initWithContent: [self content]
+ printsCaption: [self printsCaption]
+ andBarWidth: [self barWidth]
+ andHeight: [self height]
+ andFontSize: [self fontSize]
+ andCheckDigit: [self checkDigit]];
+ [ret calculateWidth];
+ return ret;
+}
+// -----------------------------------------------------------------------------------
+- (id)initWithCoder:(NSCoder *)coder
+// -----------------------------------------------------------------------------------
+{
+
+
+ // Since we subclass NSObject, this call to super
+ // init is not necessary, but it's good form to
+ // include it, as it is possible that someday
+ // NSObject's -init method will do something
+ // -----------------------------------------------
+ self = [super init];
+
+ [self setContent:[coder decodeObject]];
+ [coder decodeValueOfObjCType:@encode(BOOL) at:&printsCaption];
+ [coder decodeValueOfObjCType:@encode(float) at:&barWidth];
+ [coder decodeValueOfObjCType:@encode(float) at:&width];
+ [coder decodeValueOfObjCType:@encode(float) at:&height];
+ [coder decodeValueOfObjCType:@encode(float) at:&fontSize];
+ [coder decodeValueOfObjCType:@encode(float) at:&captionHeight];
+ [coder decodeValueOfObjCType:@encode(char) at:&checkDigit];
+
+ return self;
+}
+//----------------------------------------------------------------------
+- (void) encodeWithCoder: (NSCoder *)coder
+//----------------------------------------------------------------------
+{
+ [coder encodeObject:[self content]];
+ [coder encodeValueOfObjCType:@encode(BOOL) at:&printsCaption];
+ [coder encodeValueOfObjCType:@encode(float) at:&barWidth];
+ [coder encodeValueOfObjCType:@encode(float) at:&width];
+ [coder encodeValueOfObjCType:@encode(float) at:&height];
+ [coder encodeValueOfObjCType:@encode(float) at:&fontSize];
+ [coder encodeValueOfObjCType:@encode(float) at:&captionHeight];
+ [coder encodeValueOfObjCType:@encode(char) at:&checkDigit];
+
+}
+// -----------------------------------------------------------------------------------
+-(void)dealloc
+// -----------------------------------------------------------------------------------
+{
+ [content release];
+ [super dealloc];
+}
+@end
36 NKDBarcodeFramework.h
@@ -0,0 +1,36 @@
+// -----------------------------------------------------------------------------------
+// NKDBarcodeFramework.h
+// -----------------------------------------------------------------------------------
+// Copyright (c) 2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+
+/*!
+ @header NKDBarcodeFramework.h
+
+ Header file includes all other header files in the framework for convenience.
+ */
+
+#import "NKDBarcode.h"
+#import "NKDBarcodeOffscreenView.h"
+#import "NKDCode39Barcode.h"
+#import "NKDExtendedCode39Barcode.h"
+#import "NKDInterleavedTwoOfFiveBarcode.h"
+#import "NKDModifiedPlesseyBarcode.h"
+#import "NKDPostnetBarcode.h"
+#import "NKDUPCABarcode.h"
+#import "NKDModifiedPlesseyHexBarcode.h"
+#import "NKDIndustrialTwoOfFiveBarcode.h"
+#import "NKDEAN13Barcode.h"
+#import "NKDCode128Barcode.h"
+#import "NKDCodabarBarcode.h"
+#import "NSImage-NKDBarcode.h"
+#import "UIImage-Normalize.h"
+#import "NKDUPCEBarcode.h"
+#import "NKDEAN8Barcode.h"
+#import "NKDRoyalMailBarcode.h"
+#import "NKDPlanetBarcode.h"
+#import "JapanPostBarcode.h"
71 NKDBarcodeOffscreenView.h
@@ -0,0 +1,71 @@
+// -----------------------------------------------------------------------------------
+// NKDBarcodeOffscreenView.h
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Mon May 06 2002.
+// �2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+#import <UIKit/UIKit.h>
+#import <UIKit/UIGeometry.h>
+#import "NKDBarcode.h"
+
+/*!
+ @class NKDBarcodeOffscreenView
+ @abstract View subclass for rendering the barcode. This view does all of the drawing work for the framework. Barcodes
+ are drawn here so that we can create a resolution-independent NSImage. Were we to draw directly into an NSImage,
+ it would use a bitmap at screen resolution and not utilize full resolution when printed on other devices.
+
+ This view should not be placed on a view. Although it <i>should</i> work correctly (albeit, dictating its display size),
+ it is really designed to be used as an offscreen drawing area.
+ */
+@interface NKDBarcodeOffscreenView : UIView
+{
+ NKDBarcode *barcode;
+
+ volatile BOOL doneRendering;
+
+}
+/*!
+ @method initWithBarcode:
+ @abstract Intialize the view with an NKDBarcode object.
+ @param inBarcode The NKDBarcode to draw inside the view. The view will size itself to the bounds rectangle of
+ the barcode.
+ @result Initialized view that draws the barcode.
+ */
+-(id)initWithBarcode:(NKDBarcode *)inBarcode;
+
+/*!
+ @method barcode
+ @abstract Accessor method for contained NKDBarcode object.
+ @result The barcode object.
+ */
+-(NKDBarcode *)barcode;
+
+/*!
+ @method setBarcode
+ @abstract Specifies an NKDBarcode that should be drawn
+ */
+-(void)setBarcode:(NKDBarcode *)inBarcode;
+
+/*!
+ @method knowsPageRange:
+ @abstract Override view behavior so that we can print barcodes in a resolution-dependent manner without creating a separate object.
+ @param rptr An NSRange that we will populate with the page range to be printed.
+ @result YES to signify that we know our page range (a barcode will almost always fit on one page).
+ */
+-(BOOL)knowsPageRange:(NSRange *)rptr;
+
+/*!
+ @method rectForPage:
+ @abstract Override NSView behavior to specify the part of the view to print for this page.
+ @discussion We are making the (possibly erroneous) assumption that the barcode will print on a single page, so this
+ will always return the view's bounds rect.
+ @result The view's bounds rect, which will be equal to a rectangle of the barcode's size at the origin.
+ */
+-(CGRect)rectForPage:(int)pageNum;
+
+- (UIImage *)imageWithPNGInsideRect:(CGRect)rect;
+@end
235 NKDBarcodeOffscreenView.m
@@ -0,0 +1,235 @@
+// -----------------------------------------------------------------------------------
+// NKDBarcodeOffscreenView.m
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Mon May 06 2002.
+// �2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+#import "NKDBarcodeOffscreenView.h"
+
+
+@implementation NKDBarcodeOffscreenView
+
+- (id)initWithBarcode:(NKDBarcode *)inBarcode
+{
+ CGRect frame = CGRectMake(0,0,[inBarcode width], [inBarcode height]);
+ // Calculate frame and then...
+
+
+ self = [super initWithFrame:frame];
+ if (self)
+ {
+ [self setBarcode:inBarcode];
+ }
+ return self;
+}
+
+// A more elegant solution offered by Sato Akira (arigoto!)
+- (void)drawRect:(CGRect)rect
+{
+ CGContextRef context = UIGraphicsGetCurrentContext();
+ int i, barCount=0;
+ float curPos = [barcode firstBar];
+ NSString *codeString = [barcode completeBarcode];
+
+ BOOL started = NO;
+ int lastBarIndex = -1;
+
+ for (i = 0; i < [codeString length]; i++)
+ {
+ if ([codeString characterAtIndex:i] == '1')
+ {
+ if (!started)
+ started = YES;
+
+ barCount++;
+ lastBarIndex = i;
+
+ // If last character is a bar, it needs to be printed here.
+ if (i == [codeString length]-1)
+ {
+ CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor);
+ CGContextSetLineWidth(context, 0.0);
+ CGContextFillRect(context, CGRectMake(curPos,
+ [barcode barBottom:lastBarIndex],
+ [barcode barWidth] * barCount,
+ [barcode barTop:lastBarIndex] - [barcode barBottom:lastBarIndex]));
+
+ CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
+ }
+ }
+ else
+ {
+ if (started)
+ {
+ CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor);
+ CGContextSetLineWidth(context, 0.0);
+ CGContextFillRect(context, CGRectMake(curPos,
+ [barcode barBottom:lastBarIndex],
+ [barcode barWidth] * barCount,
+ [barcode barTop:lastBarIndex] - [barcode barBottom:lastBarIndex] ));
+ CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
+
+ }
+ curPos += [barcode barWidth] * (barCount + 1);
+ barCount = 0;
+ started = NO;
+ }
+ }
+ if ([barcode printsCaption])
+ {
+ NSLog(@":::::::NOTE:::::: DOES NOT CURRENTLY PRINT CAPTION");
+ NSLog(@":::::::NOTE:::::: FIX PROGRAMMER");
+ /*
+ NSMutableAttributedString *sAttr;
+ float kerning;
+ CGSize captionSize;
+ CGRect bBounds = [self bounds];
+ float heightSpace = 0.0;
+ float widthSpace = 0.0;
+ float barWidth = [barcode barWidth];
+ NSString *leftCaption = [barcode leftCaption];
+ NSString *caption = [barcode caption];
+ NSString *rightCaption = [barcode rightCaption];
+ float yPos = bBounds.origin.y + heightSpace;
+ //NSFont *font = [NSFont fontWithName:@"Lucida Grande" size:[barcode fontSize]];
+ UIFont *font = [UIFont systemFontOfSize:[barcode fontSize]];
+
+ NSMutableParagraphStyle *leftAligmentStyle = [[NSMutableParagraphStyle allocWithZone:[self zone]] init];
+
+ [leftAligmentStyle setParagraphStyle:[NSParagraphStyle defaultParagraphStyle]];
+ // Left caption for UPC / EAN
+ if ((nil != leftCaption) && (NO == [leftCaption isEqualToString:@""])) {
+ kerning = 0.0;
+ sAttr = [[NSMutableAttributedString allocWithZone:[self zone]] initWithString:leftCaption attributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,leftAligmentStyle,NSParagraphStyleAttributeName,[NSNumber numberWithFloat:kerning],NSKernAttributeName,nil]];
+ captionSize = [sAttr size];
+ [sAttr drawAtPoint:NSMakePoint(bBounds.origin.x + widthSpace + 0.25 * [barcode firstBar],yPos + 3.0)];
+ [sAttr release];
+ }
+
+ // Draw the main caption under the barcode
+ if ((nil != caption) && (NO == [caption isEqualToString:@""])) {
+ unsigned int cCount,captionLength;
+ NSRange range;
+ float container;
+ NSArray *captions = [caption componentsSeparatedByString:@"\t"];
+
+ if (((nil != leftCaption) && (NO == [leftCaption isEqualToString:@""])) || (1 < [captions count])) {
+ if (1 == [captions count]) // for UPCE //
+ container = [barcode width] / (float)[captions count] - 2.0 * [[barcode initiator] length] * barWidth - 2.0 * [barcode firstBar];
+ else // for UPCA,EAN8,EAN13 //
+ container = [barcode width] / (float)[captions count] - 1.0 * [[barcode initiator] length] * barWidth - [barcode firstBar]; // [[barcode initiator] length] == [[barcode terminator] length]; && [barcode firstBar] == [barcode width] - [barcode lastBar]; //
+ for (cCount = 0; cCount < [captions count]; cCount++) {
+ kerning = 0.0;
+ sAttr = [[NSMutableAttributedString allocWithZone:[self zone]] initWithString:[captions objectAtIndex:cCount] attributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,leftAligmentStyle,NSParagraphStyleAttributeName,[NSNumber numberWithFloat:kerning],NSKernAttributeName,nil]];
+ captionSize = [sAttr size];
+ captionLength = [(NSString *)[captions objectAtIndex:cCount] length];
+ kerning = (container - captionSize.width) / (float)(2 * captionLength);
+ range = NSMakeRange(0,captionLength);
+ [sAttr setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName,leftAligmentStyle,NSParagraphStyleAttributeName,[NSNumber numberWithFloat:1.3 * kerning],NSKernAttributeName,nil] range:range];
+ [sAttr drawAtPoint:NSMakePoint(bBounds.origin.x + widthSpace + kerning * 3 + [barcode firstBar] + (float)(cCount + 1) * [[barcode initiator] length] * barWidth + (float)cCount * container,yPos)];
+ [sAttr release];
+ }
+ }
+ else {
+ cCount = 0;
+ kerning = 0.0;
+ sAttr = [[NSMutableAttributedString allocWithZone:[self zone]] initWithString:[captions objectAtIndex:cCount] attributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,leftAligmentStyle,NSParagraphStyleAttributeName,[NSNumber numberWithFloat:kerning],NSKernAttributeName,nil]];
+ captionSize = [sAttr size];
+ captionLength = [(NSString *)[captions objectAtIndex:cCount] length];
+ container = [barcode width];
+ kerning = (container - captionSize.width) / (float)(2 * captionLength);
+ range = NSMakeRange(0,captionLength);
+ [sAttr setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName,leftAligmentStyle,NSParagraphStyleAttributeName,[NSNumber numberWithFloat:2.0 * kerning],NSKernAttributeName,nil] range:range];
+ [sAttr drawAtPoint:NSMakePoint(bBounds.origin.x + widthSpace + kerning,yPos)];
+ [sAttr release];
+ }
+ }
+
+ // Right caption for UPC / EAN
+ if ((nil != rightCaption) && (NO == [rightCaption isEqualToString:@""])) {
+ kerning = 0.0;
+ sAttr = [[NSMutableAttributedString allocWithZone:[self zone]] initWithString:rightCaption attributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,leftAligmentStyle,NSParagraphStyleAttributeName,[NSNumber numberWithFloat:kerning],NSKernAttributeName,nil]];
+ [sAttr drawAtPoint:NSMakePoint(bBounds.origin.x + widthSpace + [barcode lastBar] + ([barcode width] * 0.07),yPos + 3.0)];
+ [sAttr release];
+ }
+ [leftAligmentStyle release];
+ */
+ }
+}
+// -----------------------------------------------------------------------------------
+-(NKDBarcode *)barcode
+// -----------------------------------------------------------------------------------
+{
+ return barcode;
+}
+// -----------------------------------------------------------------------------------
+-(void)setBarcode:(NKDBarcode *)inBarcode
+// -----------------------------------------------------------------------------------
+{
+ [barcode autorelease];
+ barcode = inBarcode;
+}
+// -----------------------------------------------------------------------------------
+-(BOOL)knowsPageRange:(NSRange *)rptr
+// -----------------------------------------------------------------------------------
+{
+ rptr->location = 1;
+ rptr->length = 1;
+ return YES;
+}
+// -----------------------------------------------------------------------------------
+-(CGRect)rectForPage:(int)pageNum
+// -----------------------------------------------------------------------------------
+{
+ return CGRectMake(0,0,[[self barcode] width], [[self barcode] height]);
+}
+- (void)_renderViewAsPNG:(NSMutableDictionary *)info
+ /* this method is not intended to be called directly */
+/* used by dataWithPDFInsideRect: when multithreading is required */
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ CGRect rect = [(NSValue *)[info objectForKey:@"region"] CGRectValue];
+ UIGraphicsBeginImageContext(CGSizeMake(rect.size.width, rect.size.height));
+ [self drawRect:rect];
+ UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
+ UIGraphicsEndImageContext();
+ NSData * data = UIImagePNGRepresentation(img);
+ NSMutableData * output = [info objectForKey:@"output"];
+ [output appendData:data];
+ doneRendering = TRUE;
+
+ [pool release];
+}
+
+- (UIImage *)imageWithPNGInsideRect:(CGRect)rect
+ /* This method overrides the default NSView version to allow the view
+ to be rendered to PDF within another print operation. If there is
+ already a print operation running on the current thread, this method
+ spawns a new thread to render the PDF, otherwise the default NSView
+ version of dataWithPDFInsideRect: is called... */
+{
+ NSMutableDictionary *info = [NSMutableDictionary dictionary];
+ NSValue * v = [NSValue valueWithCGRect:rect];
+ NSMutableData * d = [NSMutableData data];
+ [info setObject:v forKey:@"region"];
+ [info setObject:d forKey:@"output"];
+
+ doneRendering = FALSE;
+ [self _renderViewAsPNG:info];
+/*
+ [NSThread detachNewThreadSelector:@selector(_renderViewAsPNG:) toTarget:self withObject:info];
+
+ while (!doneRendering)
+ [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]];
+*/
+ UIImage * output = [UIImage imageWithData:d];
+ return output;
+}
+
+
+
+@end
36 NKDCodabarBarcode.h
@@ -0,0 +1,36 @@
+// -----------------------------------------------------------------------------------
+// NKDCodabarBarcode.h
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Sun May 12 2002.
+// ©2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+#import <Foundation/Foundation.h>
+#import "NKDBarcode.h"
+/*!
+ @header NKDCodabarBarcode.h
+ This concrete subclass of NKDBarcode implements the self-checking Codabar style barcode used
+ by FedEx and in blood banks. It can encode 20 different characters - numeric digits 0-9, plus
+ four start/stop characters (A, B, C, D), and 6 other common symbols
+ */
+
+/*!
+ @class NKDCodabarBarcode
+ @discussion Implementation of the Codabar barcode using 1:2 narrow to wide ratio.
+ */
+@interface NKDCodabarBarcode : NKDBarcode
+{
+
+}
+
+/*!
+ @method _encodeChar
+ @abstract Private method to turn a single character into a string of 1s and 0s.
+ @discussion Encodes characters according to Codabar's specification
+ @result String of 0s and 1s representing inChar encoded for this barcode.
+*/
+-(NSString *) _encodeChar:(char)inChar;
+@end
65 NKDCodabarBarcode.m
@@ -0,0 +1,65 @@
+// -----------------------------------------------------------------------------------
+// NKDCodabarBarcode.h
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Sun May 12 2002.
+// ©2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+#import "NKDCodabarBarcode.h"
+
+@implementation NKDCodabarBarcode
+// -----------------------------------------------------------------------------------
+-(NSString *) _encodeChar:(char)inChar
+// -----------------------------------------------------------------------------------
+{
+ switch (inChar)
+ {
+
+ case '0':
+ return @"1010100110";
+ case '1':
+ return @"1010110010";
+ case '2':
+ return @"1010010110";
+ case '3':
+ return @"1100101010";
+ case '4':
+ return @"1011010010";
+ case '5':
+ return @"1101010010";
+ case '6':
+ return @"1001010110";
+ case '7':
+ return @"1001011010";
+ case '8':
+ return @"100110101";
+ case '9':
+ return @"1101001010";
+ case '-':
+ return @"1010011010";
+ case '$':
+ return @"1011001010";
+ case ':':
+ return @"11010110110";
+ case '/':
+ return @"11011010110";
+ case '.':
+ return @"11011011010";
+ case '+':
+ return @"1011001100110";
+ case 'A':
+ return @"10110010010";
+ case 'B':
+ return @"10100100110";
+ case 'C':
+ return @"10010010110";
+ case 'D':
+ return @"10100110010";
+ }
+ return @"";
+}
+
+@end
178 NKDCode128Barcode.h
@@ -0,0 +1,178 @@
+// -----------------------------------------------------------------------------------
+// NKDCode128Barcode.h
+// -----------------------------------------------------------------------------------
+// Created by Jeff LaMarche on Sat May 11 2002.
+// �2002 Naked Software. All rights reserved.
+// -----------------------------------------------------------------------------------
+// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
+// -----------------------------------------------------------------------------------
+// You may use and redistribute this source code without limitation
+// -----------------------------------------------------------------------------------
+#import <Foundation/Foundation.h>
+#import "NKDBarcode.h"
+/*!
+ @header NKDCode128Barcode.h
+
+ This concrete subclass of NKDBarcode handles one of the more complex encoding schemes - Code 128, which is
+ capable of encoding the entire ASCII-7 character set. It uses three "code sets" which can be switched
+ between by using control characters.
+
+ Code A allows the encoding of upper-case alphanumeric characters and non-printing characters such as ACK, and ESC,
+ Code B has upper and lower case alphanumerics, and Code C is encodes numeric data packed in two digits per character,
+ making Code 128 a very useful barcode because it both offers a complete character set AND offers a very compact encoding
+ scheme, especially for numeric data.
+ */
+
+/*!
+ @typedef CodeSet
+ @discussion Defines a type of CodeSet (as an Int) to make methods that take one of the precompiler defined set values
+ more readable.
+ */
+typedef int CodeSet;
+/*!
+ @defined SET_A
+ @discussion Used to designate that we are using Code Set A, shifting to B or C if necessary
+ */
+#define SET_A 0
+
+/*!
+ @defined SET_B
+ @discussion Used to designate that we are using Code Set B, shifting to A or C if necessary
+ */
+#define SET_B 1
+
+/*!
+ @defined SET_C
+ @discussion Used to designate that we are using Code Set A. With our current algorithm, we won't be shifting to
+ A or B, but at some point, our initiator routine should look for situations where most (but not all)
+ of the characters are numbers and Set C with shifting to one of the other sets still results in a shorter
+ encoding, however this will involve more than just changing the algorithm to determine the primary set, since
+ SET_C processes two charactes at a time and this framework is primarily focused on the individual encoding of
+ characters. That behavior is not immutable - it is overridden in the Interleaved Two of Five class, but overriding
+ this behavior for part, but not all, of <i>content</i> presents several challenges.
+ */
+#define SET_C 2
+
+/*!
+ @class NKDCode128Barcode
+ @abstract Concrete subclass for creating CODE-128 barcodes.
+ */
+@interface NKDCode128Barcode : NKDBarcode
+{
+ int codeSet;
+}
+/*!
+ @method initWithContent:printsCaption:
+ @abstract Overridden to enforce generation of check digit.
+ */
+-(id)initWithContent: (NSString *)inContent
+ printsCaption: (BOOL)inPrints;
+
+/*!
+ @method codeSet
+ @abstract Returns the primary code set being used to encode content
+ @result SET_A, SET_B, or SET_C
+ */
+-(CodeSet)codeSet;
+
+/*!
+ @method setCodeSet:
+ @abstract Set the primary code set to encode content with
+ @param inSet SET_A, SET_B, or SET_C
+ */
+-(void)setCodeSet:(CodeSet)inSet;
+
+/*!
+ @method generateChecksum
+ @abstract Generates the check digit or checksum for this barcode encoding scheme.
+ @discussion Code 128 has a mandatory check digit calculated by summing the start code
+ value to the product of each character's value (via lookup table), modulus 103.
+*/
+-(void)generateChecksum;
+
+/*!
+ @method initiator
+ @abstract Returns the encoded initiator or alignment bar(s)
+ @discussion This is likely the most complex initator method in the framework. Because there are three code sets to
+ choose from, we have to determine which one is the best choice for our content. Our algorithm will be
+ to check first to see if there are only numbers, then we use set C. If there are other characters, we
+ will sum the number of lower-case letters and the number of non-printing ASCII characters. If there are
+ more lowercase letters than non-printings, we will use set B, otherwise, we will use set C.
+*/
+-(NSString *)initiator;
+
+/*!
+ @method terminator
+ @abstract Returns the encoded te