This does for x/image what
https://go-review.googlesource.com/c/go/+/45111/ did for the standard
library's compress/lzw.
The x variant is a fork of the stdlib, with an extra, explicit tweak
because the TIFF format is "off by one" - a mistake (not Go specific)
somebody introduced decades ago and that we can never fix, given all the
existing TIFF files out there in the wild.
When previously patching the stdlib variant, I was supposed to also
patch the x variant, but forgot.
Updates golang/go#11386
Change-Id: Ic74f9014d2d048ee12cdd151332db62b76f1cde2
Reviewed-on: https://go-review.googlesource.com/c/image/+/191221
Reviewed-by: Bryan C. Mills <bcmills@google.com>
The PSHUFB instruction is also used by the floating-point
implementation, not just the fixed-point one.
Fixesgolang/go#32835
Change-Id: I21f204319b28b664c862a7e3d938ba9366c74116
Reviewed-on: https://go-review.googlesource.com/c/image/+/184898
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The go tool kept inserting "go 1.13" so I'm adding an explicit line so
it stops modifying my local files when I'm working on other changes.
Change-Id: Ib430e058d2551d8e3746f32bf8ffbdb2fb74c330
Reviewed-on: https://go-review.googlesource.com/c/image/+/182220
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Upcoming commits will also implement an encoder, not just a decoder, and
they might want to generate fooEncodeTable vars.
Change-Id: Ib02548a912a7354f00dace580151fbcfc405be8f
Reviewed-on: https://go-review.googlesource.com/c/image/+/178417
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This initial commit only provides a decoder that generates modes and run
lengths from a bit stream. Future commits will add more features.
Updates golang/go#19443
Change-Id: I7bba1226a69a83e636e407e4d72ffd5630562e6b
Reviewed-on: https://go-review.googlesource.com/c/image/+/174979
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
On wasm, calculations on float32 values are done with 64 bit precision.
This is allowed by the Go specification, only explicit conversions to
float32 have to round to 32 bit precision. The difference caused by the
additional precision accumulates over several calculations and causes
the test results to not fully match the expectations. Account for this
by giving a 0.1% tolerance.
Fixesgolang/go#31281.
Change-Id: I843788f912015600a18ff3d5cf5520c60403b534
Reviewed-on: https://go-review.googlesource.com/c/image/+/171257
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This change adds a sample Fuzz test function to package tiff, under
the gofuzz build tag. The function is based on the tiff/tiff.go code,
from github.com/dvyukov/go-fuzz-corpus.
Fixesgolang/go#30719
Updates golang/go#19109
Change-Id: I78771e9a1bd01651ba6ca421ba41f0c0e95d0c53
Reviewed-on: https://go-review.googlesource.com/c/image/+/167097
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: thepudds <thepudds1460@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
The subtable length from the kern table is only uint16. Fonts like
Cambria, Calibri or Corbel have more then 10k kerning pairs and the
encoded length is truncated to uint16. Validate length with truncated
values as well.
Change-Id: I788b709e913790b936d928e7b1e92f628b9c0adf
Reviewed-on: https://go-review.googlesource.com/c/159637
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This change adds a go.mod and go.sum file to this repo, following the
requirements stated in bcmills's comment here:
https://golang.org/issue/28136#issuecomment-462971974. It's
important to note that we will not be
adding versions to the repo for now.
The change was generated by running "go mod init" and "go mod tidy" using Go
1.11.5 in the top-level directory of the repository.
Updates golang/go#28136
Change-Id: I837a30c514e23ddab0404a2d8ab66eaa6ad82961
Reviewed-on: https://go-review.googlesource.com/c/162912
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This CL adds support for reading kerning information from GPOS tables.
Most modern fonts like Noto or Roboto do not provide a kern table.
Instead they use the GPOS table for kerning.
This CL is limited to horizontal kerning and latin scripts.
The proprietary_test was extended to check all supported variations.
gpos.go has full test coverage (excluding error conditions).
Additionally, the new TestBulkKern (opt-in) can be used to check parsing
of large font collection.
Fixes: golang/go#29528
Change-Id: I9f1ae142c9e26170dd836ccaca1526bbefe9698a
Reviewed-on: https://go-review.googlesource.com/c/159638
Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library provides support for CMap formats 2, 4 and 12, but
does not support CMap format 6.
CL adds support for CMap format 6 (trimmed table mapping).
Change-Id: I40657c4805c14017367af17596023da96b2c7483
Reviewed-on: https://go-review.googlesource.com/c/146079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Previously, it was a float32, which obviously has 32 bits of state. Not
all of that 32 bit state space is meaningful, since NaN has multiple bit
representations. The underlying file format field (of type "Fixed" or
16.16 fixed point) is also 32 bits of state
(https://docs.microsoft.com/en-us/typography/opentype/spec/post).
Therefore, converting from 32 bit fixed point to 32 bit floating point
can be lossy. Instead, use 64 bit floating point. 53 significand bits
can losslessly represent all possible 16.16 fixed point values.
Using float64 is also arguably more Go-like, as the default type for the
ideal constant 0.5 is float64, not float32.
Change-Id: I5abe7979a020af2ac4784d6c2723ab8e39e38e34
Reviewed-on: https://go-review.googlesource.com/c/149837
Reviewed-by: Denys Smirnov <denis.smirnov.91@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Currently the library only parses the version in PostScript table.
However use cases such as PDF document processing requires this
information to be exposed.
CL parses a minimal set of the fields from the PostScript table
and exposes it via new PostTable method.
Change-Id: Ia86eecea9f5aaf557c7e4737f2474966aa30cff2
Reviewed-on: https://go-review.googlesource.com/c/145797
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This change renames the example to follow correct naming convention,
as documented at https://godoc.org/testing#hdr-Examples. As a result,
it shows up in godoc.
This issue was caught and reported by vet:
$ go vet golang.org/x/image/font/sfnt
# golang.org/x/image/font/sfnt_test
font/sfnt/example_test.go:19: ExampleRasterizeGlyph refers to unknown identifier: RasterizeGlyph
Fixesgolang/go#28684
Change-Id: I2749c638c5f3ed15e4db0448bc7a5e2c12c056e5
Reviewed-on: https://go-review.googlesource.com/c/148576
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Each span of unindented non-blank lines is converted into a
single paragraph. This isn't desired here. Indent the matrix,
so that it's converted into a <pre> block. That also prevents
the previous line from being interpreted as a heading.
Reference: https://godoc.org/go/doc#ToHTMLFixesgolang/go#28683
Change-Id: Ibc5488d5cc66fe3a5f2bbe2fe23628dd08276037
Reviewed-on: https://go-review.googlesource.com/c/148573
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This change removes support for Go 1.8 and older, as they're no longer
supported per release policy¹.
This brings back a simpler file layout that was here prior to CL 36730,
but keeps using type aliases for the exported names from the standard
library's image/draw package.
Don't keep the comment motivating type alias use, since that feature is
no longer new, and commonly understood by now.
¹ https://tip.golang.org/doc/devel/release.html#policy
Change-Id: I5fab71162cf6daa5985a048ed06011efacddf886
Reviewed-on: https://go-review.googlesource.com/c/148567
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This is a revert of CL 24945 and CL 24954, since we no longer need to
support Go 1.5.
No need to explicitly specify which Go version is required. Instead,
rely on the implicit requirement based on the release support policy¹.
This is simpler and consistent with how it was before CL 24954.
¹ https://tip.golang.org/doc/devel/release.html#policy
Change-Id: I3cfef1bef120f702d5859dad10a76803544cc869
Reviewed-on: https://go-review.googlesource.com/c/148569
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This change reverts CL 32132. We no longer have to worry about
Go 1.5 support. This results in slightly simpler build constraints.
Change-Id: I021936646a6e9a82462a885b256894027fb58aeb
Reviewed-on: https://go-review.googlesource.com/c/148568
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This package has been deprecated since Go 1.6, which is long ago.
There's a warning printed whenever this package is imported, which
helped people migrate away from it by now. Delete it since it's
unused and unsupported.
Change-Id: If84b631ebff6530cdb955af34fa7b84d50130166
Reviewed-on: https://go-review.googlesource.com/c/148570
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
The Scalable Vector Graphics (SVG) 1.1 specification URL has changed.
The old URL, https://www.w3.org/TR/SVG/, now hosts the SVG 2 spec.
SVG 1.1 spec has moved to https://www.w3.org/TR/SVG11/.
This change makes this package go generate successfully with no diff.
Change-Id: Ifa788b1bb47748610b3adc0ac96692c00bcb3158
Reviewed-on: https://go-review.googlesource.com/c/148566
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Currently, the library produces a parsing error when the font
contains a PostScript table of version 1.0.
CL adds this version to the validation code and implements a glyph
name lookup for it.
Change-Id: Id4999d8b252e5c2d8e897f637ba31270336cfe9a
Reviewed-on: https://go-review.googlesource.com/c/146080
Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm,
which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described
in the spec. However, fonts seen in the wild sometimes omit the
second term (left side bearings), making validation to fail.
CL fixes the validation code by allowing to omit the second term.
Fixesgolang/go#28379
Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3
Reviewed-on: https://go-review.googlesource.com/c/144080
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Library assumes that OS/2 header size is at least 96 bytes,
which is not the case for fonts with OS/2 table version <= 1.
This CL adds a version test and handles the legacy header.
Fixesgolang/go#28339
Change-Id: I79bd8f8bbf262c1caaf4e66888446159b5e4fb43
Reviewed-on: https://go-review.googlesource.com/c/144079
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Decode BITMAPV4INFOHEADER and BITMAPV5INFOHEADER in addition to
BITMAPINFOHEADER and check if any of their features are used. If this is
not the case, the bmp can be decoded as if it had the BITMAPINFOHEADER.
Otherwise an ErrUnsupported is returned.
The colormap.bmp and yellow_rose-small-v5.bmp files were generated using
imagemagick using the following conversions:
convert video-001.bmp -depth 8 -palette colormap.bmp
convert yellow_rose-small.bmp -format BMP5 yellow_rose-small-v5.bmp
The corresponding png files were created using imagemagick convert
without any arguments.
Fixesgolang/go#27767
Change-Id: I5c0138b231c68132d39a29c71b61faa546921511
Reviewed-on: https://go-review.googlesource.com/c/141799
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This also fixes the writer test to actually compare the decoded images,
so as to make sure it is decoded properly.
Implements golang/go#25945.
Change-Id: I606887baa11b7664018313cf7d5800b2dc7622cf
Reviewed-on: https://go-review.googlesource.com/120095
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
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/...
Fixesgolang/go#25618.
Change-Id: I465fac26afdca52878518e4c01d46cf9d12930b9
Reviewed-on: https://go-review.googlesource.com/115675
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
The proposed fix updates the x axis offset variable in case the tile
surpasses the limits of the destination image.
Fixesgolang/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>
When DstMask is not nil, this shortcut causes stack overflow because
Copy function in turn will call Scale with same dr and sr.
Fixesgolang/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>
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>
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>