Commit Graph

255 Commits

Author SHA1 Message Date
Paul Jolly
af66defab9 README: fix go get instructions
Currently the instructions tell the user to:

go get -u golang.org/x/image

However, this is not valid because golang.org/x/image contains no Go
files.

Instead it should read:

go get -u golang.org/x/image/...

Fixes golang/go#25618.

Change-Id: I465fac26afdca52878518e4c01d46cf9d12930b9
Reviewed-on: https://go-review.googlesource.com/115675
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-01 11:54:56 +00:00
monkeybutter
f315e44030 tiff: fixes problem with decoding tiled uint16 tiff files.
The proposed fix updates the x axis offset variable in case the tile
surpasses the limits of the destination image.

Fixes golang/go#24657

Change-Id: I6bc52274a05dc41b058f6a6f1d0a304f1b20152d
Reviewed-on: https://go-review.googlesource.com/104295
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-03 16:11:27 +00:00
Andrew Bonventre
f3a9b89b59 CONTRIBUTING.md: remove note about not accepting Pull Requests
Updates golang/go#24185

Change-Id: I9a3a920ec803ee612775aebfeaedb162d2266aa8
Reviewed-on: https://go-review.googlesource.com/100683
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-14 18:02:48 +00:00
Jiulong Wang
12117c17ca draw: fix crash caused by Scale by Copy shortcut
When DstMask is not nil, this shortcut causes stack overflow because
Copy function in turn will call Scale with same dr and sr.

Fixes golang/go#23107

Change-Id: I8ccadbd9b7f16363ac17b6114308527d6fa9456e
Reviewed-on: https://go-review.googlesource.com/83537
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-12-14 22:51:56 +00:00
Sebastien Binet
e5db4c4663 font/opentype: implement font.Face interface
This CL adds the type Face that implements the font.Face interface.
This CL also adds tests using gofont/goregular as an input font, using
github.com/golang/freetype/truetype as reference values.

Updates golang/go#22451.

Change-Id: I2a6945309331b251ec2ddec95b6e809ad10aa116
Reviewed-on: https://go-review.googlesource.com/73870
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-12-08 23:31:33 +00:00
Elias Naur
f7e31b4ea2 font/sfnt: add Metrics to Font
Change-Id: I4bfcf264e5ee7e4f3ddf89e289d730f230095401
Reviewed-on: https://go-review.googlesource.com/67330
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-10-13 01:36:00 +00:00
Kevin Burke
334384d9e1 README: add more description
Move the README to README.md so Gerrit can render it; currently
Gerrit only renders files named exactly "README.md" (for example at
https://go.googlesource.com/go).

Add more links to the README explaining how to file issues,
how to submit code changes, where to download the code to and
how to get it. Hopefully this should help people who go to
https://go.googlesource.com/image or https://github.com/golang/image
figure out how to get started with development.

Change-Id: I390d4bd84c9fd7d0bd3f3f56f63ea8482d03a725
Reviewed-on: https://go-review.googlesource.com/49830
Reviewed-by: Kevin Burke <kev@inburke.com>
2017-09-27 05:35:55 +00:00
Michael Munday
e20db36d77 vector: prevent fused multiply-add being used in floatingLineTo
The test code now produces bit-identical results across platforms.

Fixes golang/go#21460.

Change-Id: I58b72dacf3c7930e2804b4e37bd3ccd9ef3dc2f0
Reviewed-on: https://go-review.googlesource.com/61024
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-09-07 23:27:51 +00:00
Nigel Tao
d1087bc575 vector: benchmark the floating point code path.
Specifically, this commit adds Benchmark.*1024.* functions, and then
gofmt's some other Benchmark functions.

There are existing floating point benchmarks in acc_test.go, but they
have narrower scope. The benchmarks in vector_test.go are closer to
end-to-end benchmarks for the package.

Change-Id: I5b4770bcefa9aa3ed4d4823f78993df7b80c7d87
Reviewed-on: https://go-review.googlesource.com/62130
Reviewed-by: David Symonds <dsymonds@golang.org>
2017-09-07 00:02:32 +00:00
Nigel Tao
426cfd8eeb font/sfnt: implement hflex and hflex1.
Change-Id: I288a014a5b6c54e54ffa69b76a8b12fa7fdbc708
Reviewed-on: https://go-review.googlesource.com/43474
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-05-23 02:19:15 +00:00
Nigel Tao
d835a09709 font/sfnt: add ErrColoredGlyph.
Also add tests for the Noto proprietary fonts. Prior to this commit,
NotoColorEmoji.ttf was unsupported. It's still not well supported, but
the error message returned is now more informative.

Change-Id: I61a3301d7f2458a4b838eb1de7a73d6472e3486f
Reviewed-on: https://go-review.googlesource.com/43694
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-05-23 02:17:49 +00:00
Nigel Tao
f483456c9f font/sfnt: don't reject multiple kern subtables.
A future commit will actually use subtables past the first one, but for
now, ignore them instead of failing on their presence.

Also add tests for the DejaVu proprietary fonts. Prior to this commit,
DejaVuSans-ExtraLight.ttf was unsupported.

Change-Id: Ic78a59c5ab30e4091efa2a04b89b12cb786157db
Reviewed-on: https://go-review.googlesource.com/42192
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-05-04 00:22:41 +00:00
Nigel Tao
d442804300 tiff/lzw: sync with the stdlib compress/lzw.
As noted at the top of reader.go, this package is a fork of the standard
library's LZW package, due to an "off by one" in the TIFF format. Grep
for "NOTE" in the Go code for more details.

This commit picks up an upstream change:
https://go-review.googlesource.com/14410 "tidy up some flush calls"

Picking up the more recent change:
https://go-review.googlesource.com/42032 "fix hi code overflow"
will be a follow-up commit, separate from this straightforward commit,
since it has a non-trivial interaction with that off by one.

Change-Id: Iaf795d11590b3e3e0891e3ea3f04b696de4243c9
Reviewed-on: https://go-review.googlesource.com/42191
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-30 11:58:49 +00:00
Nigel Tao
3210c0296b font/sfnt: support .dfont files.
Change-Id: Id7aa18c48c65586c688cee230ce87f4d88dae9b5
Reviewed-on: https://go-review.googlesource.com/40893
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-04-21 22:58:11 +00:00
kim yongbin
a74d51e6d3 tiff: remove InternalError which is not used anywhere.
Change-Id: I92fd800bafd380797651e158c9385dcf3d3578da
Reviewed-on: https://go-review.googlesource.com/40892
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-16 14:51:06 +00:00
Nigel Tao
7c3fafc74f font/sfnt: explicitly close glyph contours.
Change-Id: I4a59167cfe5d84f0ef6732711cca9b46a52b445c
Reviewed-on: https://go-review.googlesource.com/39930
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-04-10 07:42:48 +00:00
Nigel Tao
1de9a5bb2a font/sfnt: implement Font.Bounds.
Change-Id: I24ab4cfa74a791ebb8223b38e5d6624c74caa9f8
Reviewed-on: https://go-review.googlesource.com/39670
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-04-10 07:35:26 +00:00
Nigel Tao
84a6511894 font/sfnt: use charmap EncodeRune API.
Change-Id: I91d850d1816b43748580f6f8a8f19151472750d0
Reviewed-on: https://go-review.googlesource.com/39070
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-05 22:33:02 +00:00
Nigel Tao
10ed294205 font/sfnt: implement Font.GlyphAdvance.
Change-Id: I3e15c6e634d858a87e73221bd9d5a9e3979d674a
Reviewed-on: https://go-review.googlesource.com/39250
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-04-05 22:26:46 +00:00
Nigel Tao
ce0faa1867 font/sfnt: flip the Y axis for LoadGlyph's Segments.
The underlying font format's Y axis increases up. The Go standard
graphics libraries' Y axis increases down. This change makes the Go API
consistent with the other Go libraries.

Also change Segment.Args from [6]fixed.Int26_6 to [3]fixed.Point26_6 to
emphasize that the Args are consistent with other fixed.Point26_6 use.

Change-Id: Idd7b89eb4d86890dea477ac2ef96ff8f6b1dee8d
Reviewed-on: https://go-review.googlesource.com/39072
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-31 23:39:16 +00:00
Nigel Tao
f36ba34967 font/sfnt: implement Font Dict Select.
Change-Id: I8c463b41421a35455701847520367add4727cbe3
Reviewed-on: https://go-review.googlesource.com/38871
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-30 23:40:04 +00:00
Nigel Tao
59d151bf14 font/sfnt: implement implicit vstem before hintmask.
Change-Id: I811bcf94b518dabcfbebd085ad3c6a47c17ef38e
Reviewed-on: https://go-review.googlesource.com/38288
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-30 01:47:42 +00:00
Nigel Tao
ecc1a9abb6 font/sfnt: fix argStack size check for moveto ops.
The *moveto ops don't take multiple args or arg pairs. For example, in
http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5177.Type2.pdf
page 16, the rmoveto args are listed as:
dx1 dy1
which is not the same as rlineto's args, which can be repeated:
{dxa dya}+

Change-Id: I5d13f686e604955909eb0b7e52f20ce5f0522c5d
Reviewed-on: https://go-review.googlesource.com/38289
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-30 01:44:25 +00:00
Nigel Tao
f03a046406 font/gofont: new Smallcaps; update other Go Fonts.
Bigelow & Holmes have prepared new versions of the Go Fonts. The version
numbers have changed from 2.004 to 2.008. ChangeLog:

* New! 2 new fonts, bringing the total to 12: Go Smallcaps and Go
  Smallcaps Italic.
* New! U+FFFD REPLACEMENT CHARACTER glyph added.
* U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE ring tweaked.
* U+00F0 LATIN SMALL LETTER ETH glyph lightened.
* Superfluous U+0005 <control> glyph removed.
* Split integral, chart draw, block, shade and related glyphs now span
  the full height and have fewer seams when tiled.
* Raised most capital letter diacritics and some lowercase diacritics.
* Mono character widths fixed to be uniform.
* Underline position adjusted.
* SFNT glyph order and cmap table optimized.
* SFNT glyph names (post table) regularized, consistent with the AGLFN.
* ttfautohint upgraded to the latest version, from 1.5 to 1.6.

Change-Id: I0985f07d58b984010199dd723ccdf5892ee59c78
Reviewed-on: https://go-review.googlesource.com/38870
Reviewed-by: Rob Pike <r@golang.org>
2017-03-30 00:58:26 +00:00
Nigel Tao
c0851fbc5b font/sfnt: support PostScript compound glyphs (subroutines).
Change-Id: I8aa10150aa004b1bc1128bf0b3d5c14b74ee089c
Reviewed-on: https://go-review.googlesource.com/38280
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-22 22:20:00 +00:00
Nigel Tao
2e35bd52b4 font/sfnt: increase proprietary_test coverage.
Recent commits (probably 792d36e1 "support TrueType compound glyphs" and
1995ed1a "support TrueType glyph transformations") let us decode all the
glyphs in the Adobe TrueType fonts, but I forgot to update the test
coverage in those commits.

Change-Id: I7b135005cd67082f84aee16d296debdedcc9488e
Reviewed-on: https://go-review.googlesource.com/38281
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-22 21:47:50 +00:00
Nigel Tao
2c9074b9aa font/sfnt: implement flagWeHaveATwoByTwo.
Change-Id: I9f4577b57f25a85ef0639c34215adf40df61c5ab
Reviewed-on: https://go-review.googlesource.com/38274
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-22 21:43:44 +00:00
Nigel Tao
fb59e5ba10 font/sfnt: rename a "stack" field to "argStack".
This will lessen the diff in a subsequent commit, which introduces a
call stack.

Change-Id: I478857675f47b53e6bd3ee270087a00b9d1d4d34
Reviewed-on: https://go-review.googlesource.com/38279
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-03-19 05:24:11 +00:00
Nigel Tao
88e2d806a0 font/sfnt: ignore version 1 kern tables.
The format is relatively complicated but rarely seen. It doesn't seem
worth the effort. Ignoring it is what Microsoft Windows and FreeType do.

Change-Id: I4415bd591c832650066de1d4e035b20a7230a4da
Reviewed-on: https://go-review.googlesource.com/38273
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-18 23:50:03 +00:00
Nigel Tao
6847effb9b font/sfnt: support font collections (.ttc and .otc files).
Also add tests for Apple proprietary fonts.

Change-Id: I5ce8efa2397bb01c5255d956a77c955ba1383105
Reviewed-on: https://go-review.googlesource.com/38272
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-18 07:04:21 +00:00
Nigel Tao
1995ed1a25 font/sfnt: support TrueType glyph transformations.
Change-Id: Iea2387b5e30dd0fff53e2808b25599c3be5b1cdb
Reviewed-on: https://go-review.googlesource.com/38210
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-18 06:57:45 +00:00
Nigel Tao
792d36e11d font/sfnt: support TrueType compound glyphs.
Change-Id: I129e3f7894ad0edccc9e8ca4a21fc9e60e23105b
Reviewed-on: https://go-review.googlesource.com/38111
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-15 23:27:06 +00:00
Nigel Tao
c1a19c11c3 font/sfnt: implement rcurveline and rlinecurve.
Change-Id: I563f9e4a76a5c91d2ef2b6ffccc78550ab582d08
Reviewed-on: https://go-review.googlesource.com/38110
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-15 23:13:12 +00:00
Nigel Tao
793f3be7da font/sfnt: implement {hh,vv}curveto.
Change-Id: I873f8b273d2fe9f39df7d333c36976f1b45239a0
Reviewed-on: https://go-review.googlesource.com/37917
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-12 00:23:23 +00:00
Nigel Tao
069db1da13 font/sfnt: make parseXxx dependencies explicit.
Change-Id: Ib0b76c48cd0b4288700458407077aae4e5911233
Reviewed-on: https://go-review.googlesource.com/37553
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-03-07 07:36:15 +00:00
Russ Cox
e6cbe778da draw: use type aliases for go1.8.typealias builds too
go1.8.typealias is the build tag defined by the unreleased
"Go 1.8 + type aliases" variant in the Go repo's dev.typealias branch.

Change-Id: Iff2566249ecc9a6788b78199743d2005708f1cd7
Reviewed-on: https://go-review.googlesource.com/37511
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-27 16:05:05 +00:00
Nigel Tao
c8ae36c95e font/sfnt: implement Font.Kern.
Change-Id: I9ffb93dd3ee08b8871dadf5bc36578710b800199
Reviewed-on: https://go-review.googlesource.com/37410
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-24 09:00:53 +00:00
Nigel Tao
b952c941a6 font/sfnt: check the versions of proprietary fonts.
Change-Id: If8d104f5d0e60b6270e7f6a0762432dfe66cfe48
Reviewed-on: https://go-review.googlesource.com/37174
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-22 03:10:26 +00:00
Nigel Tao
ed91dc314e font/sfnt: add a ppem arg to Font.LoadGlyph.
This lets us load a glyph at e.g. 12 pixels per em.

Change-Id: I048b3db89af8670782953a8361afe0e6373df9b0
Reviewed-on: https://go-review.googlesource.com/37175
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-22 03:05:44 +00:00
Nigel Tao
791b615328 font/sfnt: update test for adobe/SourceSansPro-Regular.ttf.
The latest version of that TTF file fixes the inconsistency between the
TTF and OTF versions.

Change-Id: I0b86f6ddc3f0326e538bdd18fe097be9ad8533ae
Reviewed-on: https://go-review.googlesource.com/37173
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-17 22:17:21 +00:00
Nigel Tao
8491f88afc font/sfnt: implement Font.GlyphName.
This is based on the post table in the sfnt file.

Change-Id: I11f7a9bd9024cfc8f92adc5abb4d5356521f0df7
Reviewed-on: https://go-review.googlesource.com/36972
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-17 10:37:04 +00:00
Nigel Tao
153d857a8f font/sfnt: support Symbol fonts such as MS Webdings.
Change-Id: I1297246dad6288345b4b87b885fbeda06a6516ff
Reviewed-on: https://go-review.googlesource.com/37031
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-17 10:20:08 +00:00
Nigel Tao
306b829431 draw: alias the standard library's image/draw's exported types.
This relies on type aliases, a language feature new in Go 1.9.

The package documentation, in draw.go, explicitly gives the intent of
this package:

    This package is a superset of and a drop-in replacement for the
    image/draw package in the standard library.

Drop-in replacement means that I can replace all of my "image/draw"
imports with "golang.org/x/image/draw", to access additional features in
this package, and no further changes are required. That's mostly true,
but not completely true unless we use type aliases.

Without type aliases, users might need to import both "image/draw" and
"golang.org/x/image/draw" in order to convert from two conceptually
equivalent but different (from the compiler's point of view) types, such
as from one draw.Op type to another draw.Op type, to satisfy some other
interface or function signature.

Change-Id: Ice6d000d49b019c2d8761739a904232e9cd01cae
Reviewed-on: https://go-review.googlesource.com/36730
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-02-15 00:37:23 +00:00
Nigel Tao
df2aa51d44 draw: tweak the YCbCr to RGBA conversion formula again.
This is the golang.org/x equivalent of the golang.org/cl/36732 change to
the standard library.

Change-Id: I71c09a72e24c8e1c013769a6fed8f9a031724d9d
Reviewed-on: https://go-review.googlesource.com/36733
Run-TryBot: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-02-10 23:08:06 +00:00
Nigel Tao
05f0a469d9 font/sfnt: support non-zero offsets in format-4 cmap tables.
Change-Id: I52592fcde96ce2f3b7700a29169b517a813f9f3c
Reviewed-on: https://go-review.googlesource.com/36371
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-07 21:45:33 +00:00
Nigel Tao
993cf229e6 font/sfnt: fix proprietary fonts and cmap format 12.
Two recent commits ("proprietary fonts" and "cmap format 12") each
passed all of its own tests, but the combination wasn't tested until
both were submitted.

Change-Id: Ic4c2ae8deb1e4623ca5543672dc46d55bfce91a4
Reviewed-on: https://go-review.googlesource.com/36372
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-07 21:42:49 +00:00
Nigel Tao
28d9a8b4a3 font/sfnt: add tests for proprietary fonts.
Change-Id: I1886e24f726598654d2474f0219a8046ba184a9f
Reviewed-on: https://go-review.googlesource.com/36370
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-04 04:20:41 +00:00
Nigel Tao
c8ab450c16 font/sfnt: support cmap format 12.
Change-Id: I2791f5aec860bbb16c6c6945703827afd55c11dc
Reviewed-on: https://go-review.googlesource.com/36291
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-04 03:42:56 +00:00
Nigel Tao
55ae12acc9 font/sfnt: use ../testdata/cmapTest.ttf.
The index numbers can be verified by running ttx over the ttf file:

<GlyphOrder>
<!-- The 'id' attribute is only for humans; it is ignored when parsed. -->
<GlyphID id="0" name=".notdef"/>
<GlyphID id="1" name=".null"/>
<GlyphID id="2" name="nonmarkingreturn"/>
<GlyphID id="3" name="zero"/>
<GlyphID id="4" name="one"/>
<GlyphID id="5" name="two"/>
<GlyphID id="6" name="A"/>
<GlyphID id="7" name="B"/>
<GlyphID id="8" name="a"/>
<GlyphID id="9" name="ydieresis"/>
<GlyphID id="10" name="Amacron"/>
<GlyphID id="11" name="amacron"/>
<GlyphID id="12" name="uni4E2D"/>
<GlyphID id="13" name="u1F0A1"/>
<GlyphID id="14" name="u1F0B1"/>
<GlyphID id="15" name="u1F0B2"/>
</GlyphOrder>

Change-Id: I8c3b3f09ca25c14d92725d121481287cf57d0d01
Reviewed-on: https://go-review.googlesource.com/36080
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-03 07:45:48 +00:00
Nigel Tao
69afd001f7 font/sfnt: parse the cmap table.
Change-Id: I757d42c9caf419f549696543f0f156cfe3dbfe1a
Reviewed-on: https://go-review.googlesource.com/35512
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-02-02 02:23:30 +00:00