├── .gitignore ├── .gitmodules ├── Pork.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── Pork.xcscheme ├── Pork ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── Column.swift ├── Diacriticals.swift ├── Document.swift ├── File.swift ├── Hyphenation.swift ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── Line.swift ├── NSRange.swift ├── PDFViewController.swift ├── Page.swift ├── Paragraph.swift ├── Pork-Info.plist ├── SplitViewController.swift ├── TextViewController.swift └── en.lproj │ ├── Credits.rtf │ └── InfoPlist.strings ├── PorkTests ├── HyphenationTests.swift └── Info.plist └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build 3 | xcuserdata 4 | *.mode* 5 | *.pbxuser 6 | *.xcuserdatad 7 | *.xccheckout 8 | xcuserdata 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "External/Reducers"] 2 | path = External/Reducers 3 | url = https://github.com/robrix/Reducers.git 4 | [submodule "External/Lagrangian"] 5 | path = External/Lagrangian 6 | url = https://github.com/robrix/Lagrangian.git 7 | -------------------------------------------------------------------------------- /Pork.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D4C9AB881A5706ED00CB61FB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9AB871A5706ED00CB61FB /* AppDelegate.swift */; }; 11 | D4C9AB8C1A5706ED00CB61FB /* Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9AB8B1A5706ED00CB61FB /* Document.swift */; }; 12 | D4C9AB8E1A5706ED00CB61FB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D4C9AB8D1A5706ED00CB61FB /* Images.xcassets */; }; 13 | D4C9AB911A5706ED00CB61FB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D4C9AB8F1A5706ED00CB61FB /* Main.storyboard */; }; 14 | D4C9ABA41A57070F00CB61FB /* Hyphenation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9AB6B1A5705A500CB61FB /* Hyphenation.swift */; }; 15 | D4C9ABA51A57070F00CB61FB /* Page.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9AB631A57044100CB61FB /* Page.swift */; }; 16 | D4C9ABA61A57070F00CB61FB /* Column.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9AB651A57046000CB61FB /* Column.swift */; }; 17 | D4C9ABA71A57070F00CB61FB /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9AB671A57048800CB61FB /* Line.swift */; }; 18 | D4C9ABA81A57071C00CB61FB /* HyphenationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9AB6D1A57060100CB61FB /* HyphenationTests.swift */; }; 19 | D4C9ABAC1A570C1100CB61FB /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9ABAB1A570C1100CB61FB /* File.swift */; }; 20 | D4C9ABAE1A57109F00CB61FB /* PDFViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9ABAD1A57109F00CB61FB /* PDFViewController.swift */; }; 21 | D4C9ABB01A57118F00CB61FB /* SplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9ABAF1A57118F00CB61FB /* SplitViewController.swift */; }; 22 | D4C9ABB21A57126200CB61FB /* TextViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9ABB11A57126200CB61FB /* TextViewController.swift */; }; 23 | D4C9ABB41A571D2A00CB61FB /* Paragraph.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4C9ABB31A571D2A00CB61FB /* Paragraph.swift */; }; 24 | D4EE11AB1B04CA71002D9D9A /* NSRange.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EE11AA1B04CA71002D9D9A /* NSRange.swift */; }; 25 | D4EE11AD1B04CC92002D9D9A /* Diacriticals.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EE11AC1B04CC92002D9D9A /* Diacriticals.swift */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | D4C9AB971A5706ED00CB61FB /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = D45F1AB618E5AB2A005CE515 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = D4C9AB821A5706ED00CB61FB; 34 | remoteInfo = Pork; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | D45F1AC118E5AB2A005CE515 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 40 | D45F1AD418E5AB4D005CE515 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 41 | D45F1AD718E5AB4D005CE515 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 42 | D45F1AD818E5AB4D005CE515 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 43 | D45F1AD918E5AB4D005CE515 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 44 | D45F1B3018E5ADF9005CE515 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; }; 45 | D45F1B5318E5BF5C005CE515 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 46 | D4C9AB631A57044100CB61FB /* Page.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Page.swift; sourceTree = ""; }; 47 | D4C9AB651A57046000CB61FB /* Column.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Column.swift; sourceTree = ""; }; 48 | D4C9AB671A57048800CB61FB /* Line.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; 49 | D4C9AB6B1A5705A500CB61FB /* Hyphenation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Hyphenation.swift; sourceTree = ""; }; 50 | D4C9AB6D1A57060100CB61FB /* HyphenationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HyphenationTests.swift; sourceTree = ""; }; 51 | D4C9AB761A57067200CB61FB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | D4C9AB831A5706ED00CB61FB /* Pork.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pork.app; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | D4C9AB861A5706ED00CB61FB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | D4C9AB871A5706ED00CB61FB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 55 | D4C9AB8B1A5706ED00CB61FB /* Document.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Document.swift; sourceTree = ""; }; 56 | D4C9AB8D1A5706ED00CB61FB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 57 | D4C9AB901A5706ED00CB61FB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 58 | D4C9AB961A5706ED00CB61FB /* PorkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PorkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | D4C9ABAB1A570C1100CB61FB /* File.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = ""; }; 60 | D4C9ABAD1A57109F00CB61FB /* PDFViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFViewController.swift; sourceTree = ""; }; 61 | D4C9ABAF1A57118F00CB61FB /* SplitViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplitViewController.swift; sourceTree = ""; }; 62 | D4C9ABB11A57126200CB61FB /* TextViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextViewController.swift; sourceTree = ""; }; 63 | D4C9ABB31A571D2A00CB61FB /* Paragraph.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Paragraph.swift; sourceTree = ""; }; 64 | D4EE11AA1B04CA71002D9D9A /* NSRange.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSRange.swift; sourceTree = ""; }; 65 | D4EE11AC1B04CC92002D9D9A /* Diacriticals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Diacriticals.swift; sourceTree = ""; }; 66 | /* End PBXFileReference section */ 67 | 68 | /* Begin PBXFrameworksBuildPhase section */ 69 | D4C9AB801A5706ED00CB61FB /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | D4C9AB931A5706ED00CB61FB /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | D45F1AB518E5AB2A005CE515 = { 87 | isa = PBXGroup; 88 | children = ( 89 | D4C9AB841A5706ED00CB61FB /* Pork */, 90 | D4C9AB741A57067200CB61FB /* PorkTests */, 91 | D45F1AC018E5AB2A005CE515 /* Frameworks */, 92 | D45F1ABF18E5AB2A005CE515 /* Products */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | D45F1ABF18E5AB2A005CE515 /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | D4C9AB831A5706ED00CB61FB /* Pork.app */, 100 | D4C9AB961A5706ED00CB61FB /* PorkTests.xctest */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | D45F1AC018E5AB2A005CE515 /* Frameworks */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | D45F1B5318E5BF5C005CE515 /* XCTest.framework */, 109 | D45F1B3018E5ADF9005CE515 /* Quartz.framework */, 110 | D45F1AC118E5AB2A005CE515 /* Foundation.framework */, 111 | D45F1AD418E5AB4D005CE515 /* Cocoa.framework */, 112 | D45F1AD618E5AB4D005CE515 /* Other Frameworks */, 113 | ); 114 | name = Frameworks; 115 | sourceTree = ""; 116 | }; 117 | D45F1AD618E5AB4D005CE515 /* Other Frameworks */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | D45F1AD718E5AB4D005CE515 /* Foundation.framework */, 121 | D45F1AD818E5AB4D005CE515 /* CoreData.framework */, 122 | D45F1AD918E5AB4D005CE515 /* AppKit.framework */, 123 | ); 124 | name = "Other Frameworks"; 125 | sourceTree = ""; 126 | }; 127 | D4C9AB741A57067200CB61FB /* PorkTests */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | D4C9AB6D1A57060100CB61FB /* HyphenationTests.swift */, 131 | D4C9AB751A57067200CB61FB /* Supporting Files */, 132 | ); 133 | path = PorkTests; 134 | sourceTree = ""; 135 | }; 136 | D4C9AB751A57067200CB61FB /* Supporting Files */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | D4C9AB761A57067200CB61FB /* Info.plist */, 140 | ); 141 | name = "Supporting Files"; 142 | sourceTree = ""; 143 | }; 144 | D4C9AB841A5706ED00CB61FB /* Pork */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | D4C9AB871A5706ED00CB61FB /* AppDelegate.swift */, 148 | D4C9AB8B1A5706ED00CB61FB /* Document.swift */, 149 | D4C9ABAB1A570C1100CB61FB /* File.swift */, 150 | D4C9AB6B1A5705A500CB61FB /* Hyphenation.swift */, 151 | D4EE11AC1B04CC92002D9D9A /* Diacriticals.swift */, 152 | D4C9AB631A57044100CB61FB /* Page.swift */, 153 | D4C9AB651A57046000CB61FB /* Column.swift */, 154 | D4C9ABB31A571D2A00CB61FB /* Paragraph.swift */, 155 | D4C9AB671A57048800CB61FB /* Line.swift */, 156 | D4C9ABAD1A57109F00CB61FB /* PDFViewController.swift */, 157 | D4C9ABAF1A57118F00CB61FB /* SplitViewController.swift */, 158 | D4C9ABB11A57126200CB61FB /* TextViewController.swift */, 159 | D4C9AB8D1A5706ED00CB61FB /* Images.xcassets */, 160 | D4C9AB8F1A5706ED00CB61FB /* Main.storyboard */, 161 | D4C9AB851A5706ED00CB61FB /* Supporting Files */, 162 | ); 163 | path = Pork; 164 | sourceTree = ""; 165 | }; 166 | D4C9AB851A5706ED00CB61FB /* Supporting Files */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | D4C9AB861A5706ED00CB61FB /* Info.plist */, 170 | D4EE11AA1B04CA71002D9D9A /* NSRange.swift */, 171 | ); 172 | name = "Supporting Files"; 173 | sourceTree = ""; 174 | }; 175 | /* End PBXGroup section */ 176 | 177 | /* Begin PBXNativeTarget section */ 178 | D4C9AB821A5706ED00CB61FB /* Pork */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = D4C9AB9E1A5706ED00CB61FB /* Build configuration list for PBXNativeTarget "Pork" */; 181 | buildPhases = ( 182 | D4C9AB7F1A5706ED00CB61FB /* Sources */, 183 | D4C9AB801A5706ED00CB61FB /* Frameworks */, 184 | D4C9AB811A5706ED00CB61FB /* Resources */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | ); 190 | name = Pork; 191 | productName = Pork; 192 | productReference = D4C9AB831A5706ED00CB61FB /* Pork.app */; 193 | productType = "com.apple.product-type.application"; 194 | }; 195 | D4C9AB951A5706ED00CB61FB /* PorkTests */ = { 196 | isa = PBXNativeTarget; 197 | buildConfigurationList = D4C9ABA11A5706ED00CB61FB /* Build configuration list for PBXNativeTarget "PorkTests" */; 198 | buildPhases = ( 199 | D4C9AB921A5706ED00CB61FB /* Sources */, 200 | D4C9AB931A5706ED00CB61FB /* Frameworks */, 201 | D4C9AB941A5706ED00CB61FB /* Resources */, 202 | ); 203 | buildRules = ( 204 | ); 205 | dependencies = ( 206 | D4C9AB981A5706ED00CB61FB /* PBXTargetDependency */, 207 | ); 208 | name = PorkTests; 209 | productName = PorkTests; 210 | productReference = D4C9AB961A5706ED00CB61FB /* PorkTests.xctest */; 211 | productType = "com.apple.product-type.bundle.unit-test"; 212 | }; 213 | /* End PBXNativeTarget section */ 214 | 215 | /* Begin PBXProject section */ 216 | D45F1AB618E5AB2A005CE515 /* Project object */ = { 217 | isa = PBXProject; 218 | attributes = { 219 | LastUpgradeCheck = 0510; 220 | ORGANIZATIONNAME = "Rob Rix"; 221 | TargetAttributes = { 222 | D4C9AB821A5706ED00CB61FB = { 223 | CreatedOnToolsVersion = 6.1.1; 224 | }; 225 | D4C9AB951A5706ED00CB61FB = { 226 | CreatedOnToolsVersion = 6.1.1; 227 | TestTargetID = D4C9AB821A5706ED00CB61FB; 228 | }; 229 | }; 230 | }; 231 | buildConfigurationList = D45F1AB918E5AB2A005CE515 /* Build configuration list for PBXProject "Pork" */; 232 | compatibilityVersion = "Xcode 3.2"; 233 | developmentRegion = English; 234 | hasScannedForEncodings = 0; 235 | knownRegions = ( 236 | en, 237 | Base, 238 | ); 239 | mainGroup = D45F1AB518E5AB2A005CE515; 240 | productRefGroup = D45F1ABF18E5AB2A005CE515 /* Products */; 241 | projectDirPath = ""; 242 | projectRoot = ""; 243 | targets = ( 244 | D4C9AB821A5706ED00CB61FB /* Pork */, 245 | D4C9AB951A5706ED00CB61FB /* PorkTests */, 246 | ); 247 | }; 248 | /* End PBXProject section */ 249 | 250 | /* Begin PBXResourcesBuildPhase section */ 251 | D4C9AB811A5706ED00CB61FB /* Resources */ = { 252 | isa = PBXResourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | D4C9AB8E1A5706ED00CB61FB /* Images.xcassets in Resources */, 256 | D4C9AB911A5706ED00CB61FB /* Main.storyboard in Resources */, 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | D4C9AB941A5706ED00CB61FB /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | /* End PBXResourcesBuildPhase section */ 268 | 269 | /* Begin PBXSourcesBuildPhase section */ 270 | D4C9AB7F1A5706ED00CB61FB /* Sources */ = { 271 | isa = PBXSourcesBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | D4C9AB881A5706ED00CB61FB /* AppDelegate.swift in Sources */, 275 | D4C9AB8C1A5706ED00CB61FB /* Document.swift in Sources */, 276 | D4C9ABB41A571D2A00CB61FB /* Paragraph.swift in Sources */, 277 | D4C9ABAC1A570C1100CB61FB /* File.swift in Sources */, 278 | D4EE11AD1B04CC92002D9D9A /* Diacriticals.swift in Sources */, 279 | D4C9ABAE1A57109F00CB61FB /* PDFViewController.swift in Sources */, 280 | D4C9ABA41A57070F00CB61FB /* Hyphenation.swift in Sources */, 281 | D4C9ABB21A57126200CB61FB /* TextViewController.swift in Sources */, 282 | D4C9ABB01A57118F00CB61FB /* SplitViewController.swift in Sources */, 283 | D4C9ABA51A57070F00CB61FB /* Page.swift in Sources */, 284 | D4C9ABA71A57070F00CB61FB /* Line.swift in Sources */, 285 | D4EE11AB1B04CA71002D9D9A /* NSRange.swift in Sources */, 286 | D4C9ABA61A57070F00CB61FB /* Column.swift in Sources */, 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | D4C9AB921A5706ED00CB61FB /* Sources */ = { 291 | isa = PBXSourcesBuildPhase; 292 | buildActionMask = 2147483647; 293 | files = ( 294 | D4C9ABA81A57071C00CB61FB /* HyphenationTests.swift in Sources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | /* End PBXSourcesBuildPhase section */ 299 | 300 | /* Begin PBXTargetDependency section */ 301 | D4C9AB981A5706ED00CB61FB /* PBXTargetDependency */ = { 302 | isa = PBXTargetDependency; 303 | target = D4C9AB821A5706ED00CB61FB /* Pork */; 304 | targetProxy = D4C9AB971A5706ED00CB61FB /* PBXContainerItemProxy */; 305 | }; 306 | /* End PBXTargetDependency section */ 307 | 308 | /* Begin PBXVariantGroup section */ 309 | D4C9AB8F1A5706ED00CB61FB /* Main.storyboard */ = { 310 | isa = PBXVariantGroup; 311 | children = ( 312 | D4C9AB901A5706ED00CB61FB /* Base */, 313 | ); 314 | name = Main.storyboard; 315 | sourceTree = ""; 316 | }; 317 | /* End PBXVariantGroup section */ 318 | 319 | /* Begin XCBuildConfiguration section */ 320 | D45F1ACA18E5AB2A005CE515 /* Debug */ = { 321 | isa = XCBuildConfiguration; 322 | buildSettings = { 323 | ALWAYS_SEARCH_USER_PATHS = NO; 324 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 325 | CLANG_CXX_LIBRARY = "libc++"; 326 | CLANG_ENABLE_MODULES = YES; 327 | CLANG_ENABLE_OBJC_ARC = YES; 328 | CLANG_WARN_BOOL_CONVERSION = YES; 329 | CLANG_WARN_CONSTANT_CONVERSION = YES; 330 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 331 | CLANG_WARN_EMPTY_BODY = YES; 332 | CLANG_WARN_ENUM_CONVERSION = YES; 333 | CLANG_WARN_INT_CONVERSION = YES; 334 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 335 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 336 | COPY_PHASE_STRIP = NO; 337 | GCC_C_LANGUAGE_STANDARD = gnu99; 338 | GCC_DYNAMIC_NO_PIC = NO; 339 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 340 | GCC_OPTIMIZATION_LEVEL = 0; 341 | GCC_PREPROCESSOR_DEFINITIONS = ( 342 | "DEBUG=1", 343 | "$(inherited)", 344 | ); 345 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 346 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 347 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 348 | GCC_WARN_UNDECLARED_SELECTOR = YES; 349 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 350 | GCC_WARN_UNUSED_FUNCTION = YES; 351 | GCC_WARN_UNUSED_VARIABLE = YES; 352 | MACOSX_DEPLOYMENT_TARGET = 10.10; 353 | ONLY_ACTIVE_ARCH = YES; 354 | SDKROOT = macosx; 355 | }; 356 | name = Debug; 357 | }; 358 | D45F1ACB18E5AB2A005CE515 /* Release */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | ALWAYS_SEARCH_USER_PATHS = NO; 362 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 363 | CLANG_CXX_LIBRARY = "libc++"; 364 | CLANG_ENABLE_MODULES = YES; 365 | CLANG_ENABLE_OBJC_ARC = YES; 366 | CLANG_WARN_BOOL_CONVERSION = YES; 367 | CLANG_WARN_CONSTANT_CONVERSION = YES; 368 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 369 | CLANG_WARN_EMPTY_BODY = YES; 370 | CLANG_WARN_ENUM_CONVERSION = YES; 371 | CLANG_WARN_INT_CONVERSION = YES; 372 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 373 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 374 | COPY_PHASE_STRIP = YES; 375 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 376 | ENABLE_NS_ASSERTIONS = NO; 377 | GCC_C_LANGUAGE_STANDARD = gnu99; 378 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 379 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 380 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 381 | GCC_WARN_UNDECLARED_SELECTOR = YES; 382 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 383 | GCC_WARN_UNUSED_FUNCTION = YES; 384 | GCC_WARN_UNUSED_VARIABLE = YES; 385 | MACOSX_DEPLOYMENT_TARGET = 10.10; 386 | SDKROOT = macosx; 387 | }; 388 | name = Release; 389 | }; 390 | D4C9AB9F1A5706ED00CB61FB /* Debug */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 394 | CLANG_WARN_UNREACHABLE_CODE = YES; 395 | CODE_SIGN_IDENTITY = "-"; 396 | COMBINE_HIDPI_IMAGES = YES; 397 | ENABLE_STRICT_OBJC_MSGSEND = YES; 398 | GCC_PREPROCESSOR_DEFINITIONS = ( 399 | "DEBUG=1", 400 | "$(inherited)", 401 | ); 402 | INFOPLIST_FILE = Pork/Info.plist; 403 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 404 | MACOSX_DEPLOYMENT_TARGET = 10.10; 405 | MTL_ENABLE_DEBUG_INFO = YES; 406 | PRODUCT_NAME = "$(TARGET_NAME)"; 407 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 408 | }; 409 | name = Debug; 410 | }; 411 | D4C9ABA01A5706ED00CB61FB /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 415 | CLANG_WARN_UNREACHABLE_CODE = YES; 416 | CODE_SIGN_IDENTITY = "-"; 417 | COMBINE_HIDPI_IMAGES = YES; 418 | ENABLE_STRICT_OBJC_MSGSEND = YES; 419 | INFOPLIST_FILE = Pork/Info.plist; 420 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 421 | MACOSX_DEPLOYMENT_TARGET = 10.10; 422 | MTL_ENABLE_DEBUG_INFO = NO; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | }; 425 | name = Release; 426 | }; 427 | D4C9ABA21A5706ED00CB61FB /* Debug */ = { 428 | isa = XCBuildConfiguration; 429 | buildSettings = { 430 | BUNDLE_LOADER = "$(TEST_HOST)"; 431 | CLANG_WARN_UNREACHABLE_CODE = YES; 432 | COMBINE_HIDPI_IMAGES = YES; 433 | ENABLE_STRICT_OBJC_MSGSEND = YES; 434 | FRAMEWORK_SEARCH_PATHS = ( 435 | "$(DEVELOPER_FRAMEWORKS_DIR)", 436 | "$(inherited)", 437 | ); 438 | GCC_PREPROCESSOR_DEFINITIONS = ( 439 | "DEBUG=1", 440 | "$(inherited)", 441 | ); 442 | INFOPLIST_FILE = PorkTests/Info.plist; 443 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 444 | MACOSX_DEPLOYMENT_TARGET = 10.10; 445 | MTL_ENABLE_DEBUG_INFO = YES; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Pork.app/Contents/MacOS/Pork"; 448 | }; 449 | name = Debug; 450 | }; 451 | D4C9ABA31A5706ED00CB61FB /* Release */ = { 452 | isa = XCBuildConfiguration; 453 | buildSettings = { 454 | BUNDLE_LOADER = "$(TEST_HOST)"; 455 | CLANG_WARN_UNREACHABLE_CODE = YES; 456 | COMBINE_HIDPI_IMAGES = YES; 457 | ENABLE_STRICT_OBJC_MSGSEND = YES; 458 | FRAMEWORK_SEARCH_PATHS = ( 459 | "$(DEVELOPER_FRAMEWORKS_DIR)", 460 | "$(inherited)", 461 | ); 462 | INFOPLIST_FILE = PorkTests/Info.plist; 463 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 464 | MACOSX_DEPLOYMENT_TARGET = 10.10; 465 | MTL_ENABLE_DEBUG_INFO = NO; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Pork.app/Contents/MacOS/Pork"; 468 | }; 469 | name = Release; 470 | }; 471 | /* End XCBuildConfiguration section */ 472 | 473 | /* Begin XCConfigurationList section */ 474 | D45F1AB918E5AB2A005CE515 /* Build configuration list for PBXProject "Pork" */ = { 475 | isa = XCConfigurationList; 476 | buildConfigurations = ( 477 | D45F1ACA18E5AB2A005CE515 /* Debug */, 478 | D45F1ACB18E5AB2A005CE515 /* Release */, 479 | ); 480 | defaultConfigurationIsVisible = 0; 481 | defaultConfigurationName = Release; 482 | }; 483 | D4C9AB9E1A5706ED00CB61FB /* Build configuration list for PBXNativeTarget "Pork" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | D4C9AB9F1A5706ED00CB61FB /* Debug */, 487 | D4C9ABA01A5706ED00CB61FB /* Release */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | D4C9ABA11A5706ED00CB61FB /* Build configuration list for PBXNativeTarget "PorkTests" */ = { 493 | isa = XCConfigurationList; 494 | buildConfigurations = ( 495 | D4C9ABA21A5706ED00CB61FB /* Debug */, 496 | D4C9ABA31A5706ED00CB61FB /* Release */, 497 | ); 498 | defaultConfigurationIsVisible = 0; 499 | defaultConfigurationName = Release; 500 | }; 501 | /* End XCConfigurationList section */ 502 | }; 503 | rootObject = D45F1AB618E5AB2A005CE515 /* Project object */; 504 | } 505 | -------------------------------------------------------------------------------- /Pork.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Pork.xcodeproj/xcshareddata/xcschemes/Pork.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 57 | 63 | 64 | 65 | 66 | 67 | 73 | 74 | 75 | 76 | 85 | 86 | 92 | 93 | 94 | 95 | 96 | 97 | 103 | 104 | 110 | 111 | 112 | 113 | 115 | 116 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /Pork/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | @NSApplicationMain 4 | class AppDelegate: NSObject, NSApplicationDelegate {} 5 | 6 | 7 | // MARK: - Imports 8 | 9 | import Cocoa 10 | -------------------------------------------------------------------------------- /Pork/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | Default 511 | 512 | 513 | 514 | 515 | 516 | 517 | Left to Right 518 | 519 | 520 | 521 | 522 | 523 | 524 | Right to Left 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | Default 536 | 537 | 538 | 539 | 540 | 541 | 542 | Left to Right 543 | 544 | 545 | 546 | 547 | 548 | 549 | Right to Left 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 730 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | -------------------------------------------------------------------------------- /Pork/Column.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | public struct Column: Comparable { 4 | var lines: [Line] = [] 5 | 6 | var bounds: CGRect { 7 | return reduce(map(lines) { $0.bounds }, CGRect.nullRect) { 8 | $0.rectByUnion($1) 9 | } 10 | } 11 | } 12 | 13 | public func == (left: Column, right: Column) -> Bool { 14 | return left.lines == right.lines 15 | } 16 | 17 | public func < (left: Column, right: Column) -> Bool { 18 | if left.bounds.minX == right.bounds.minX { 19 | return left.bounds.maxY > right.bounds.minY 20 | } else { 21 | return left.bounds.maxX < right.bounds.minX 22 | } 23 | } 24 | 25 | 26 | // MARK: - Imports 27 | 28 | import Quartz 29 | -------------------------------------------------------------------------------- /Pork/Diacriticals.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | public func readjoinDecomposedDiacriticals(string: NSAttributedString) -> NSAttributedString { 4 | let string = string.mutableCopy() as! NSMutableAttributedString 5 | separatedDiacriticalExpression?.enumerateMatchesInString(string.string, options: nil, range: NSRange(string)) { result, _, _ in 6 | if result.rangeAtIndex(2).length > 0 { 7 | string.replaceCharactersInRange(result.rangeAtIndex(2), withString: (string.string as NSString).substringWithRange(result.rangeAtIndex(2)) + "\u{0308}") 8 | string.replaceCharactersInRange(result.rangeAtIndex(1), withString: "") 9 | } else { 10 | string.replaceCharactersInRange(result.range, withString: "\u{0308}") 11 | } 12 | } 13 | return string 14 | } 15 | 16 | 17 | let separatedDiacriticalExpression = NSRegularExpression(pattern: "(\u{0020}[\u{0300}-\u{036f}])([aeiouAEIOU])?", options: nil, error: nil) 18 | 19 | 20 | import Cocoa 21 | -------------------------------------------------------------------------------- /Pork/Document.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | final class Document: NSDocument { 4 | var document: PDFDocument? 5 | var file: File? 6 | 7 | override func makeWindowControllers() { 8 | let storyboard = NSStoryboard(name: "Main", bundle: nil)! 9 | let windowController = storyboard.instantiateControllerWithIdentifier("Document Window Controller") as! NSWindowController 10 | windowController.contentViewController?.representedObject = self 11 | addWindowController(windowController) 12 | } 13 | 14 | override func readFromURL(url: NSURL, ofType typeName: String, error outError: NSErrorPointer) -> Bool { 15 | document = PDFDocument(URL: url) 16 | file = document.map { File(document: $0) } 17 | 18 | return document != nil 19 | } 20 | } 21 | 22 | 23 | // MARK: - Imports 24 | 25 | import Quartz 26 | -------------------------------------------------------------------------------- /Pork/File.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | struct File { 4 | init(document: PDFDocument) { 5 | self.document = document 6 | pages = map(0.. 0 { $0.appendAttributedString(separator) } 59 | $0.appendAttributedString($1.attributedString) 60 | return $0 61 | } 62 | } 63 | } 64 | 65 | 66 | func split(elements: S, contiguous: (S.Generator.Element, S.Generator.Element) -> Bool) -> [S.SubSlice] { 67 | if isEmpty(elements) { return [] } 68 | for index in elements.startIndex.successor().. NSMutableAttributedString { 4 | if string.string.hasSuffix("-") { 5 | if isDictionaryWord(wordInString(string.string, backwards: true)) && isDictionaryWord(wordInString(line.string, backwards: false)) { 6 | string.appendAttributedString(line) 7 | } else { 8 | string.replaceCharactersInRange(NSRange(location: string.length - 1, length: 1), withAttributedString: line) 9 | } 10 | } else if string.length > 0 { 11 | string.appendAttributedString(NSAttributedString(string: " ")) 12 | string.appendAttributedString(line) 13 | } else { 14 | string.appendAttributedString(line) 15 | } 16 | return string 17 | } 18 | 19 | public func isDictionaryWord(word: String) -> Bool { 20 | return dictionaryWords.containsObject(word) 21 | } 22 | 23 | public func wordInString(string: String, #backwards: Bool) -> String { 24 | if var range = string.rangeOfCharacterFromSet(NSCharacterSet.whitespaceAndNewlineCharacterSet(), options: backwards ? .BackwardsSearch : NSStringCompareOptions(0)) { 25 | if distance(range.startIndex, range.endIndex) == 0 { 26 | range = string.startIndex..<(backwards ? string.startIndex : string.endIndex) 27 | } 28 | 29 | return backwards ? 30 | string.substringWithRange(range.endIndex.. 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | pdf 13 | 14 | CFBundleTypeIconFile 15 | 16 | CFBundleTypeName 17 | DocumentType 18 | CFBundleTypeOSTypes 19 | 20 | ???? 21 | 22 | CFBundleTypeRole 23 | Editor 24 | NSDocumentClass 25 | $(PRODUCT_MODULE_NAME).Document 26 | 27 | 28 | CFBundleExecutable 29 | $(EXECUTABLE_NAME) 30 | CFBundleIconFile 31 | 32 | CFBundleIdentifier 33 | com.antitypical.$(PRODUCT_NAME:rfc1034identifier) 34 | CFBundleInfoDictionaryVersion 35 | 6.0 36 | CFBundleName 37 | $(PRODUCT_NAME) 38 | CFBundlePackageType 39 | APPL 40 | CFBundleShortVersionString 41 | 1.0 42 | CFBundleSignature 43 | ???? 44 | CFBundleVersion 45 | 1 46 | LSMinimumSystemVersion 47 | $(MACOSX_DEPLOYMENT_TARGET) 48 | NSHumanReadableCopyright 49 | Copyright © 2015 Rob Rix. All rights reserved. 50 | NSMainStoryboardFile 51 | Main 52 | NSPrincipalClass 53 | NSApplication 54 | 55 | 56 | -------------------------------------------------------------------------------- /Pork/Line.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | public struct Line: Comparable { 4 | init(_ selection: PDFSelection, _ defaultAttributes: [String: NSObject]) { 5 | let string = selection.attributedString().mutableCopy() as! NSMutableAttributedString 6 | string.addAttributes(defaultAttributes, range: NSRange(string)) 7 | self.selection = selection 8 | self.attributedString = string 9 | self.bounds = selection.boundsForPage(selection.pages().first as! PDFPage) 10 | } 11 | 12 | let selection: PDFSelection 13 | let attributedString: NSAttributedString 14 | let bounds: CGRect 15 | 16 | var complete: Bool { 17 | return attributedString.string.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).hasSuffix(".") 18 | } 19 | } 20 | 21 | public func == (left: Line, right: Line) -> Bool { 22 | return left.bounds == right.bounds 23 | } 24 | 25 | public func < (left: Line, right: Line) -> Bool { 26 | return left.bounds.minY > right.bounds.minY 27 | } 28 | 29 | 30 | let maximalProximity: CGSize = CGSize(width: 20, height: 10) 31 | 32 | typealias LineContext = (column: (index: Int, element: Column), line: (index: Int, element: Line)) 33 | 34 | func verticallyProximal(line1: LineContext, line2: LineContext) -> Bool { 35 | let proximity = max(lineHeight(line1.line.element), lineHeight(line2.line.element), maximalProximity.height) 36 | return 37 | CGFloat.abs(line1.line.element.bounds.minY - line2.line.element.bounds.maxY) < proximity 38 | || (!line1.line.element.complete && inSuccessiveColumns(line1, line2) && atEndOfColumn(line1) && atStartOfColumn(line2)) 39 | } 40 | 41 | func horizontallyCoincident(line1: LineContext, line2: LineContext) -> Bool { 42 | return 43 | CGFloat.abs(line1.column.element.bounds.width - line2.column.element.bounds.width) < maximalProximity.width 44 | && CGFloat.abs(line1.column.element.bounds.width - line1.line.element.bounds.width) < maximalProximity.width 45 | && CGFloat.abs(line2.column.element.bounds.width - line2.line.element.bounds.width) < maximalProximity.width 46 | } 47 | 48 | func alignedAtLeft(line1: Line, line2: Line) -> Bool { 49 | return CGFloat.abs(line1.bounds.minX - line2.bounds.minX) < maximalProximity.width 50 | } 51 | 52 | func nonJustifiedTerminalLine(line1: Line, line2: Line) -> Bool { 53 | return alignedAtLeft(line1, line2) && line1.bounds.width > (line2.bounds.width + maximalProximity.width) 54 | } 55 | 56 | func lineHeight(line: Line) -> CGFloat { 57 | var size = line.bounds.height 58 | line.attributedString.enumerateAttributesInRange(NSRange(line.attributedString), options: nil) { attributes, _, _ in 59 | let fontSize: CGFloat? = ((attributes[NSFontSizeAttribute] as? NSNumber)?.doubleValue).map { CGFloat($0) } 60 | let font = attributes[NSFontAttributeName] as? NSFont 61 | if let s = fontSize ?? font?.pointSize { size = max(size, s) } 62 | } 63 | return round(size) 64 | } 65 | 66 | func sameLineHeight(line1: Line, line2: Line) -> Bool { 67 | let (size1, size2) = (lineHeight(line1), lineHeight(line2)) 68 | return abs(size1 - size2) < 5 69 | } 70 | 71 | func inSuccessiveColumns(line1: LineContext, line2: LineContext) -> Bool { 72 | return line1.column.index + 1 == line2.column.index 73 | } 74 | 75 | func atEndOfColumn(line: LineContext) -> Bool { 76 | return line.line.index + 1 == line.column.element.lines.count 77 | } 78 | 79 | func atStartOfColumn(line: LineContext) -> Bool { 80 | return line.line.index == 0 81 | } 82 | 83 | func centred(line: LineContext) -> Bool { 84 | let (columnBounds, lineBounds) = (line.column.element.bounds, line.line.element.bounds) 85 | let centred = 86 | CGFloat.abs(columnBounds.width - lineBounds.width) > maximalProximity.width 87 | && CGFloat.abs(columnBounds.midX - lineBounds.midX) < maximalProximity.width 88 | return centred 89 | } 90 | 91 | func contiguous(line1: LineContext, line2: LineContext) -> Bool { 92 | if !verticallyProximal(line1, line2) { return false } 93 | if !sameLineHeight(line1.line.element, line2.line.element) { return false } 94 | return 95 | horizontallyCoincident(line1, line2) 96 | || centred(line1) && centred(line2) 97 | || nonJustifiedTerminalLine(line1.line.element, line2.line.element) 98 | } 99 | 100 | 101 | import Quartz 102 | -------------------------------------------------------------------------------- /Pork/NSRange.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | extension NSRange { 4 | init(_ string: NSAttributedString) { 5 | self.init(location: 0, length: string.length) 6 | } 7 | } 8 | 9 | 10 | import Cocoa 11 | -------------------------------------------------------------------------------- /Pork/PDFViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | final class PDFViewController: NSViewController { 4 | var pdfView: PDFView { 5 | return view as! PDFView 6 | } 7 | 8 | override var representedObject: AnyObject? { 9 | didSet { 10 | if let document = representedObject as? Document, pdfDocument = document.document, file = document.file { 11 | pdfView.setDocument(pdfDocument) 12 | 13 | var pageIndex = 0 14 | let pdfPages = GeneratorOf { 15 | pageIndex < pdfDocument.pageCount() ? pdfDocument.pageAtIndex(pageIndex++) : nil 16 | } 17 | 18 | for (pdfPage, page) in zip(pdfPages, file.pages) { 19 | for column in page.columns { 20 | let annotation = PDFAnnotationSquare(bounds: column.bounds) 21 | annotation.setColor(NSColor.greenColor()) 22 | pdfPage.addAnnotation(annotation) 23 | } 24 | } 25 | 26 | for paragraph in file.paragraphs { 27 | if let selection = paragraph.selection { 28 | for page in selection.pages() as! [PDFPage] { 29 | let annotation = PDFAnnotationSquare(bounds: selection.boundsForPage(page)) 30 | annotation.setColor(NSColor.blueColor()) 31 | page.addAnnotation(annotation) 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | } 39 | 40 | 41 | // MARK: - Imports 42 | 43 | import Quartz 44 | -------------------------------------------------------------------------------- /Pork/Page.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | public struct Page { 4 | init(page: PDFPage) { 5 | self.page = page 6 | } 7 | 8 | var columns: [Column] = [] 9 | 10 | private mutating func columnForLine(line: Line) -> Array.Index? { 11 | return columnForLine(byLeftEdge: line) ?? columnForLine(byCentre: line) 12 | } 13 | 14 | private func columnForLine(byLeftEdge line: Line) -> Array.Index? { 15 | return bestColumnForLine(line, 20) { 16 | CGFloat.abs($0.bounds.minX - line.bounds.minX) 17 | } 18 | } 19 | 20 | private func columnForLine(byCentre line: Line) -> Array.Index? { 21 | return bestColumnForLine(line, 10) { 22 | CGFloat.abs($0.bounds.midX - line.bounds.midX) 23 | } 24 | } 25 | 26 | private func bestColumnForLine(line: Line, _ maxAllowableDistance: CGFloat, _ metric: Column -> CGFloat) -> Array.Index? { 27 | var bestDistance = CGFloat.infinity 28 | return reduce(enumerate(columns), nil) { 29 | if CGFloat.abs($1.element.bounds.minY - line.bounds.maxY) > maxAllowableDistance { return $0 } 30 | let distance = metric($1.element) 31 | if distance < min(maxAllowableDistance, bestDistance) { 32 | bestDistance = distance 33 | return $1.index 34 | } 35 | return $0 36 | } 37 | } 38 | 39 | 40 | var lines: [Line] { 41 | return reduce(columns, []) { $0 + $1.lines } 42 | } 43 | 44 | mutating func addLine(line: Line) { 45 | if let index = columnForLine(line) { 46 | columns[index].lines.append(line) 47 | } else { 48 | var column = Column() 49 | column.lines.append(line) 50 | columns.append(column) 51 | } 52 | } 53 | 54 | 55 | // MARK: Private 56 | 57 | private let page: PDFPage 58 | } 59 | 60 | 61 | // MARK: - Imports 62 | 63 | import Quartz 64 | -------------------------------------------------------------------------------- /Pork/Paragraph.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | struct Paragraph { 4 | var lines: [Line] = [] 5 | 6 | var attributedString: NSAttributedString { 7 | return reduce(lines, NSMutableAttributedString(string: "")) { 8 | dehyphenateLine(readjoinDecomposedDiacriticals($1.attributedString), intoAttributedString: $0) 9 | } 10 | } 11 | 12 | var selection: PDFSelection? { 13 | let selections = lazy(lines).map { $0.selection } 14 | if let document = (selections.first?.pages() as? [PDFPage])?.first?.document() { 15 | let selection = PDFSelection(document: document) 16 | selection.addSelections(selections.array) 17 | return selection 18 | } 19 | return nil 20 | } 21 | } 22 | 23 | 24 | import Cocoa 25 | import Quartz 26 | -------------------------------------------------------------------------------- /Pork/Pork-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.antitypical.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2014 Rob Rix. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /Pork/SplitViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | final class SplitViewController: NSSplitViewController { 4 | override var representedObject: AnyObject? { 5 | didSet { 6 | for each in childViewControllers as! [NSViewController] { 7 | each.representedObject = representedObject 8 | } 9 | } 10 | } 11 | } 12 | 13 | 14 | // MARK: - Imports 15 | 16 | import Cocoa 17 | -------------------------------------------------------------------------------- /Pork/TextViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | final class TextViewController: NSViewController { 4 | var scrollView: NSScrollView { 5 | return view as! NSScrollView 6 | } 7 | 8 | var textView: NSTextView { 9 | return scrollView.documentView as! NSTextView 10 | } 11 | 12 | override var representedObject: AnyObject? { 13 | didSet { 14 | let s = (representedObject as? Document)?.file?.attributedString 15 | let f = textView.textStorage?.setAttributedString 16 | f.flatMap { s.map($0) } 17 | } 18 | } 19 | 20 | override func viewDidLoad() { 21 | textView.textContainerInset = NSSize(width: 50, height: 50) 22 | } 23 | } 24 | 25 | 26 | import Cocoa 27 | -------------------------------------------------------------------------------- /Pork/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Pork/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /PorkTests/HyphenationTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | import Pork 4 | import XCTest 5 | 6 | final class HyphenationTests: XCTestCase { 7 | func testDictionaryWords() { 8 | XCTAssertTrue(isDictionaryWord("context")) 9 | XCTAssertTrue(isDictionaryWord("free")) 10 | XCTAssertFalse(isDictionaryWord("hyph")) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /PorkTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.antitypical.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pork 2 | 3 | *All the good names were already taken.* 4 | 5 | Pork is a PDF-to-text converter. It’s only a little clever right now, but it will learn. 6 | --------------------------------------------------------------------------------