Skip to content

Commit a54d6d5

Browse files
committed
Release 0.1.0
2 parents 673badd + b0d02e9 commit a54d6d5

File tree

122 files changed

+25677
-2292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+25677
-2292
lines changed

.codebeatsettings

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"SWIFT": {
3+
"TOO_MANY_FUNCTIONS": [40, 60, 80, 100],
4+
"TOTAL_LOC": [300, 600, 900, 1500],
5+
"ARITY": [7, 8, 9, 11]
6+
}
7+
}

.travis.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
language: generic
2-
os:
3-
- osx
4-
- linux
52

6-
sudo: required
7-
dist: trusty
8-
osx_image: xcode8
3+
matrix:
4+
include:
5+
- os: osx
6+
osx_image: xcode8
7+
env: RUN_TESTS="NO" POD_LINT="YES"
8+
- os: osx
9+
osx_image: xcode8
10+
env: RUN_TESTS="YES" POD_LINT="NO"
11+
- os: linux
12+
sudo: required
13+
dist: trusty
14+
env: RUN_TESTS="YES" POD_LINT="NO"
915

1016
script:
11-
- Scripts/ci.sh
17+
- if [[ $POD_LINT == "YES" ]]; then
18+
gem install cocoapods && pod lib lint --allow-warnings;
19+
fi
20+
- if [[ $RUN_TESTS == "YES" ]]; then
21+
eval Scripts/ci.sh;
22+
fi
1223

1324
after_success:
14-
- Scripts/coverage.sh
25+
- if [[ $RUN_TESTS == "YES" ]]; then
26+
eval Scripts/coverage.sh;
27+
fi

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Change Log
2+
3+
## [0.1.0](https://github.com/WeirdMath/SwiftyHaru/tree/0.1.0) (2016-11-02)
4+
**Closed issues:**
5+
6+
- Add CocoaPods support [\#4](https://github.com/WeirdMath/SwiftyHaru/issues/4)
7+
8+
**Implemented features:**
9+
10+
- Creating PDF documents
11+
- Saving a document's contents into binary `Data`
12+
- Appending and inserting pages to documents
13+
- Setting a page's layout
14+
- Adding labels to pages
15+
- Loading TrueType fonts from file
16+
- Setting a page's size
17+
- Rotating a page
18+
- Measuring a width of a specified text
19+
- Path construction
20+
- Path painting
21+
- Setting a font
22+
- Setting a font size
23+
- Setting a line width
24+
- Setting a line cap
25+
- Setting a line join
26+
- Setting a miter limit
27+
- Setting a dash style
28+
- Setting a text leading
29+
- Setting a stroke and fill color and color space
30+
- Placing a text on a page

CLibHaru.podspec

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'CLibHaru'
3+
s.version = '0.1.0'
4+
s.summary = 'libharu - free PDF library'
5+
6+
s.homepage = 'http://libharu.org'
7+
s.license = { :type => 'ZLIB/LIBPNG', :text => <<-LICENSE
8+
Copyright (C) 1999-2006 Takeshi Kanno
9+
Copyright (C) 2007-2009 Antony Dovgal
10+
11+
This software is provided 'as-is', without any express or implied warranty.
12+
13+
In no event will the authors be held liable for any damages arising from the
14+
use of this software.
15+
16+
Permission is granted to anyone to use this software for any purpose,including
17+
commercial applications, and to alter it and redistribute it freely, subject
18+
to the following restrictions:
19+
20+
1. The origin of this software must not be misrepresented; you must not claim
21+
that you wrote the original software. If you use this software in a
22+
product, an acknowledgment in the product documentation would be
23+
appreciated but is not required.
24+
2. Altered source versions must be plainly marked as such, and must not be
25+
misrepresented as being the original software.
26+
3. This notice may not be removed or altered from any source distribution.
27+
LICENSE
28+
}
29+
s.author = 'Takeshi Kanno', 'Antony Dovgal'
30+
s.source = { :git => 'https://github.com/WeirdMath/SwiftyHaru.git', :tag => s.version.to_s }
31+
32+
s.ios.deployment_target = '8.0'
33+
s.osx.deployment_target = '10.9'
34+
s.tvos.deployment_target = '9.0'
35+
s.watchos.deployment_target = '2.0'
36+
37+
s.dependency 'CLibPNG', '~> 0.1'
38+
39+
s.source_files = 'Sources/CLibHaru/**/*.{h,c}'
40+
s.libraries = 'z'
41+
s.module_map = 'Sources/CLibHaru/module.modulemap'
42+
end

CLibPNG.podspec

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'CLibPNG'
3+
s.version = '0.1.0'
4+
s.summary = 'libpng is the official PNG reference library.'
5+
6+
s.homepage = 'http://www.libpng.org'
7+
s.license = { :type => 'libpng', :text => <<-LICENSE
8+
This copy of the libpng notices is provided for your convenience. In case of
9+
any discrepancy between this copy and the notices in the file png.h that is
10+
included in the libpng distribution, the latter shall prevail.
11+
12+
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
13+
14+
If you modify libpng you may insert additional notices immediately following
15+
this sentence.
16+
17+
This code is released under the libpng license.
18+
19+
libpng versions 1.0.7, July 1, 2000 through 1.6.27beta01, October 28, 2016 are
20+
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
21+
derived from libpng-1.0.6, and are distributed according to the same
22+
disclaimer and license as libpng-1.0.6 with the following individuals
23+
added to the list of Contributing Authors:
24+
25+
Simon-Pierre Cadieux
26+
Eric S. Raymond
27+
Mans Rullgard
28+
Cosmin Truta
29+
Gilles Vollant
30+
James Yu
31+
32+
and with the following additions to the disclaimer:
33+
34+
There is no warranty against interference with your enjoyment of the
35+
library or against infringement. There is no warranty that our
36+
efforts or the library will fulfill any of your particular purposes
37+
or needs. This library is provided with all faults, and the entire
38+
risk of satisfactory quality, performance, accuracy, and effort is with
39+
the user.
40+
41+
Some files in the "contrib" directory and some configure-generated
42+
files that are distributed with libpng have other copyright owners and
43+
are released under other open source licenses.
44+
45+
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
46+
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
47+
libpng-0.96, and are distributed according to the same disclaimer and
48+
license as libpng-0.96, with the following individuals added to the list
49+
of Contributing Authors:
50+
51+
Tom Lane
52+
Glenn Randers-Pehrson
53+
Willem van Schaik
54+
55+
libpng versions 0.89, June 1996, through 0.96, May 1997, are
56+
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
57+
and are distributed according to the same disclaimer and license as
58+
libpng-0.88, with the following individuals added to the list of
59+
Contributing Authors:
60+
61+
John Bowler
62+
Kevin Bracey
63+
Sam Bushell
64+
Magnus Holmgren
65+
Greg Roelofs
66+
Tom Tanner
67+
68+
Some files in the "scripts" directory have other copyright owners
69+
but are released under this license.
70+
71+
libpng versions 0.5, May 1995, through 0.88, January 1996, are
72+
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
73+
74+
For the purposes of this copyright and license, "Contributing Authors"
75+
is defined as the following set of individuals:
76+
77+
Andreas Dilger
78+
Dave Martindale
79+
Guy Eric Schalnat
80+
Paul Schmidt
81+
Tim Wegner
82+
83+
The PNG Reference Library is supplied "AS IS". The Contributing Authors
84+
and Group 42, Inc. disclaim all warranties, expressed or implied,
85+
including, without limitation, the warranties of merchantability and of
86+
fitness for any purpose. The Contributing Authors and Group 42, Inc.
87+
assume no liability for direct, indirect, incidental, special, exemplary,
88+
or consequential damages, which may result from the use of the PNG
89+
Reference Library, even if advised of the possibility of such damage.
90+
91+
Permission is hereby granted to use, copy, modify, and distribute this
92+
source code, or portions hereof, for any purpose, without fee, subject
93+
to the following restrictions:
94+
95+
1. The origin of this source code must not be misrepresented.
96+
97+
2. Altered versions must be plainly marked as such and must not
98+
be misrepresented as being the original source.
99+
100+
3. This Copyright notice may not be removed or altered from any
101+
source or altered source distribution.
102+
103+
The Contributing Authors and Group 42, Inc. specifically permit, without
104+
fee, and encourage the use of this source code as a component to
105+
supporting the PNG file format in commercial products. If you use this
106+
source code in a product, acknowledgment is not required but would be
107+
appreciated.
108+
109+
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
110+
111+
TRADEMARK:
112+
113+
The name "libpng" has not been registered by the Copyright owner
114+
as a trademark in any jurisdiction. However, because libpng has
115+
been distributed and maintained world-wide, continually since 1995,
116+
the Copyright owner claims "common-law trademark protection" in any
117+
jurisdiction where common-law trademark is recognized.
118+
119+
OSI CERTIFICATION:
120+
121+
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
122+
a certification mark of the Open Source Initiative. OSI has not addressed
123+
the additional disclaimers inserted at version 1.0.7.
124+
125+
EXPORT CONTROL:
126+
127+
The Copyright owner believes that the Export Control Classification
128+
Number (ECCN) for libpng is EAR99, which means not subject to export
129+
controls or International Traffic in Arms Regulations (ITAR) because
130+
it is open source, publicly available software, that does not contain
131+
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
132+
734.7(b).
133+
134+
Glenn Randers-Pehrson
135+
glennrp at users.sourceforge.net
136+
October 28, 2016
137+
LICENSE
138+
}
139+
s.author = 'Greg Roelofs'
140+
s.source = { :git => 'https://github.com/WeirdMath/SwiftyHaru.git', :tag => s.version.to_s }
141+
142+
s.ios.deployment_target = '8.0'
143+
s.osx.deployment_target = '10.9'
144+
s.tvos.deployment_target = '9.0'
145+
s.watchos.deployment_target = '2.0'
146+
147+
s.source_files = 'Sources/CLibPNG/**/*.{h,c}'
148+
s.libraries = 'z'
149+
s.module_map = 'Sources/CLibPNG/module.modulemap'
150+
end
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import SwiftyHaru
2+
3+
let fontList: [Font] = [
4+
.courier,
5+
.courierBold,
6+
.courierOblique,
7+
.courierBoldOblique,
8+
.helvetica,
9+
.helveticaBold,
10+
.helveticaOblique,
11+
.helveticaBoldOblique,
12+
.timesRoman,
13+
.timesBold,
14+
.timesItalic,
15+
.timesBoldItalic,
16+
.symbol,
17+
.zapfDingbats
18+
]
19+
20+
let document = PDFDocument()
21+
let page = document.addPage()
22+
let pageTitle = "Font Demo"
23+
24+
page.draw { context in
25+
26+
// Print the lines of the page.
27+
let rectangle = Path()
28+
.appendingRectangle(x: 50,
29+
y: 50,
30+
width: page.width - 100,
31+
height: page.height - 110)
32+
33+
context.stroke(rectangle)
34+
35+
// Print the title of the page (with positioning center).
36+
context.fontSize = 24
37+
let textWidth = context.textWidth(for: pageTitle)
38+
context.show(text: pageTitle,
39+
atX: (page.width - textWidth) / 2,
40+
y: page.height - 50)
41+
}
42+
43+
// Output subtitle.
44+
page.draw { context in
45+
46+
context.fontSize = 16
47+
context.show(text: "<Standerd Type1 fonts samples>",
48+
atX: 60,
49+
y: page.height - 80)
50+
}
51+
52+
page.draw { context in
53+
54+
var textPosition = Point(x: 60, y: page.height - 105)
55+
56+
let sampleText = "abcdefgABCDEFG12345!#$%&+-@?"
57+
58+
for font in fontList {
59+
60+
context.fontSize = 9
61+
context.font = .helvetica
62+
context.show(text: font.name, atPosition: textPosition)
63+
textPosition = textPosition + Vector(x: 0, y: -18)
64+
65+
context.fontSize = 20
66+
context.font = font
67+
context.show(text: sampleText, atPosition: textPosition)
68+
textPosition = textPosition + Vector(x: 0, y: -20)
69+
}
70+
}
71+
72+
document.display()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Quartz
2+
import PlaygroundSupport
3+
import SwiftyHaru
4+
5+
public extension SwiftyHaru.PDFDocument {
6+
7+
public func display() {
8+
9+
let view = PDFView(frame: NSRect(x: 0, y: 0, width: 480, height: 640))
10+
11+
view.document = PDFDocument(data: getData())
12+
13+
view.scaleFactor = 0.75
14+
15+
PlaygroundPage.current.liveView = view
16+
}
17+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='macos'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

0 commit comments

Comments
 (0)