Commit Graph

279 Commits

Author SHA1 Message Date
Nigel Tao
746988e7a2 vector: add SIMD versions of xxxAccumulateOpSrc.
name                         old time/op  new time/op  delta
GlyphAlpha16Src-8            3.37µs ± 0%  3.07µs ± 1%   -8.86%    (p=0.000 n=9+9)
GlyphAlpha32Src-8            6.01µs ± 1%  4.55µs ± 0%  -24.28%   (p=0.000 n=10+9)
GlyphAlpha64Src-8            13.2µs ± 0%   8.1µs ± 0%  -38.69%   (p=0.000 n=10+9)
GlyphAlpha128Src-8           32.9µs ± 0%  16.9µs ± 0%  -48.85%   (p=0.000 n=10+9)
GlyphAlpha256Src-8           98.0µs ± 0%  43.6µs ± 1%  -55.50%  (p=0.000 n=10+10)

A comparison of the non-SIMD and SIMD versions:

name                             time/op
FixedAccumulateOpSrc16-8          368ns ± 0%
FixedAccumulateOpSrcSIMD16-8     86.8ns ± 1%
FloatingAccumulateOpSrc16-8       434ns ± 0%
FloatingAccumulateOpSrcSIMD16-8   119ns ± 0%
FixedAccumulateOpSrc64-8         6.12µs ± 0%
FixedAccumulateOpSrcSIMD64-8     1.17µs ± 0%
FloatingAccumulateOpSrc64-8      7.15µs ± 0%
FloatingAccumulateOpSrcSIMD64-8  1.68µs ± 1%

Change-Id: I58e5c7a3ecd12e536aab8e765e94275453d0eac8
Reviewed-on: https://go-review.googlesource.com/30431
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-10 07:32:32 +00:00
Nigel Tao
dc590effac vector: add some accumulate tests.
Change-Id: I199e1637698572e36b4a3bb83d652baf0d76717f
Reviewed-on: https://go-review.googlesource.com/30110
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-05 23:42:26 +00:00
Benny Siegert
1be1b0af35 tiff: reject TIFF images with unsorted IFD tags.
The spec says that these images are invalid. Add a test with an invalid
tiff generated by go-fuzz.

Fixes golang/go#10549

Change-Id: I3fd3ae5e607202b41735a2d930f55cb7997f7a9b
Reviewed-on: https://go-review.googlesource.com/9377
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-04 16:59:28 +00:00
Nigel Tao
72141d56a2 vector: re-order some functions.
There are no code changes, just a re-ordering so that these files are
consistent with others in this package: OpOver, OpSrc, Mask.

Change-Id: Ib1d46a8e912dae0c760af655e919b77023688189
Reviewed-on: https://go-review.googlesource.com/30111
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-02 02:10:30 +00:00
Nigel Tao
992afa5d48 vector: add a fixed point math implementation.
name                      old time/op  new time/op  delta

GlyphAlpha16Over-8        4.48µs ± 1%  3.56µs ± 0%  -20.70%   (p=0.000 n=9+10)
GlyphAlpha16Src-8         4.17µs ± 0%  3.38µs ± 1%  -19.09%  (p=0.000 n=10+10)
GlyphAlpha32Over-8        9.03µs ± 0%  6.74µs ± 0%  -25.33%   (p=0.000 n=9+10)
GlyphAlpha32Src-8         7.46µs ± 1%  5.98µs ± 0%  -19.80%   (p=0.000 n=10+9)
GlyphAlpha64Over-8        21.3µs ± 0%  16.4µs ± 0%  -22.84%  (p=0.000 n=10+10)
GlyphAlpha64Src-8         16.2µs ± 1%  13.1µs ± 0%  -19.33%  (p=0.000 n=10+10)
GlyphAlpha128Over-8       59.8µs ± 0%  47.2µs ± 0%  -21.11%    (p=0.000 n=9+9)
GlyphAlpha128Src-8        41.3µs ± 1%  33.0µs ± 0%  -20.26%   (p=0.000 n=9+10)
GlyphAlpha256Over-8        197µs ± 0%   158µs ± 0%  -19.44%   (p=0.000 n=9+10)
GlyphAlpha256Src-8         124µs ± 0%    98µs ± 0%  -21.17%    (p=0.000 n=9+9)

GlyphAlphaLoose16Over-8   4.73µs ± 0%  3.97µs ± 1%  -16.06%  (p=0.000 n=10+10)
GlyphAlphaLoose16Src-8    4.41µs ± 0%  3.64µs ± 1%  -17.50%  (p=0.000 n=10+10)
GlyphAlphaLoose32Over-8   9.62µs ± 0%  8.47µs ± 0%  -11.95%  (p=0.000 n=10+10)
GlyphAlphaLoose32Src-8    8.25µs ± 0%  7.19µs ± 0%  -12.88%    (p=0.000 n=9+9)
GlyphAlphaLoose64Over-8   25.6µs ± 0%  22.2µs ± 0%  -13.01%    (p=0.000 n=9+9)
GlyphAlphaLoose64Src-8    20.2µs ± 0%  17.2µs ± 1%  -14.98%  (p=0.000 n=10+10)
GlyphAlphaLoose128Over-8  83.4µs ± 1%  68.2µs ± 0%  -18.27%  (p=0.000 n=10+10)
GlyphAlphaLoose128Src-8   59.8µs ± 0%  47.4µs ± 0%  -20.77%   (p=0.000 n=10+9)
GlyphAlphaLoose256Over-8   273µs ± 1%   239µs ± 0%  -12.52%   (p=0.000 n=10+9)
GlyphAlphaLoose256Src-8    187µs ± 0%   155µs ± 1%  -16.91%   (p=0.000 n=9+10)

GlyphRGBA16Over-8         5.99µs ± 0%  5.24µs ± 1%  -12.60%   (p=0.000 n=9+10)
GlyphRGBA16Src-8          5.48µs ± 0%  4.68µs ± 0%  -14.68%   (p=0.000 n=9+10)
GlyphRGBA32Over-8         14.6µs ± 0%  13.5µs ± 0%   -7.60%    (p=0.000 n=9+9)
GlyphRGBA32Src-8          12.6µs ± 0%  11.4µs ± 0%   -9.62%    (p=0.000 n=9+9)
GlyphRGBA64Over-8         44.8µs ± 0%  42.2µs ± 0%   -5.69%    (p=0.000 n=9+9)
GlyphRGBA64Src-8          36.6µs ± 1%  33.5µs ± 1%   -8.55%    (p=0.000 n=9+9)
GlyphRGBA128Over-8         162µs ± 0%   148µs ± 1%   -8.85%   (p=0.000 n=10+9)
GlyphRGBA128Src-8          129µs ± 1%   114µs ± 0%  -11.61%   (p=0.000 n=9+10)
GlyphRGBA256Over-8         588µs ± 0%   573µs ± 0%   -2.53%   (p=0.000 n=9+10)
GlyphRGBA256Src-8          455µs ± 0%   426µs ± 1%   -6.51%   (p=0.000 n=9+10)

GlyphNRGBA16Over-8        27.0µs ± 4%  26.3µs ± 2%   -2.65%   (p=0.001 n=9+10)
GlyphNRGBA16Src-8         19.4µs ± 3%  18.6µs ± 1%   -4.35%   (p=0.000 n=9+10)
GlyphNRGBA32Over-8        97.4µs ± 3%  96.8µs ± 2%     ~      (p=0.447 n=9+10)
GlyphNRGBA32Src-8         66.6µs ± 3%  64.5µs ± 1%   -3.21%   (p=0.000 n=10+9)
GlyphNRGBA64Over-8         372µs ± 3%   368µs ± 1%     ~     (p=0.105 n=10+10)
GlyphNRGBA64Src-8          235µs ± 1%   234µs ± 1%     ~       (p=0.130 n=8+8)
GlyphNRGBA128Over-8       1.45ms ± 2%  1.48ms ± 3%   +2.06%    (p=0.014 n=9+9)
GlyphNRGBA128Src-8         926µs ± 3%   937µs ± 1%     ~      (p=0.113 n=10+9)
GlyphNRGBA256Over-8       5.76ms ± 2%  5.90ms ± 3%   +2.29%   (p=0.001 n=9+10)
GlyphNRGBA256Src-8        3.59ms ± 1%  3.86ms ± 1%   +7.46%   (p=0.000 n=9+10)

Change-Id: I72f25193b5be4e57af09e9eea4eee50545a34cbf
Reviewed-on: https://go-review.googlesource.com/29972
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-30 06:47:22 +00:00
Nigel Tao
8a20735b0e vector: sort benchmarks from slowest to fastest.
Change-Id: Ia6047f225c7ba4407fe831a49f90d4c74d203651
Reviewed-on: https://go-review.googlesource.com/29973
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-30 06:02:01 +00:00
Nigel Tao
14bbbc8017 vector: add a fast path for RGBA dst images.
name                      old time/op  new time/op  delta
GlyphRGBA16Over-8         25.1µs ± 2%   6.0µs ± 0%  -76.09%  (p=0.000 n=10+10)
GlyphRGBA16Src-8          17.3µs ± 2%   5.4µs ± 0%  -68.68%  (p=0.000 n=10+10)
GlyphRGBA32Over-8         93.2µs ± 2%  14.5µs ± 0%  -84.41%  (p=0.000 n=10+10)
GlyphRGBA32Src-8          59.3µs ± 2%  12.4µs ± 0%  -79.04%    (p=0.000 n=9+9)
GlyphRGBA64Over-8          350µs ± 2%    45µs ± 0%  -87.21%    (p=0.000 n=9+9)
GlyphRGBA64Src-8           223µs ± 2%    37µs ± 0%  -83.58%    (p=0.000 n=9+9)
GlyphRGBA128Over-8        1.37ms ± 2%  0.16ms ± 1%  -88.19%   (p=0.000 n=9+10)
GlyphRGBA128Src-8          868µs ± 2%   128µs ± 0%  -85.21%   (p=0.000 n=10+9)
GlyphRGBA256Over-8        5.50ms ± 3%  0.59ms ± 0%  -89.31%  (p=0.000 n=10+10)
GlyphRGBA256Src-8         3.47ms ± 2%  0.45ms ± 0%  -86.91%   (p=0.000 n=9+10)

Change-Id: I3df60e6b7147872367715361c9d1ed52951b22e0
Reviewed-on: https://go-review.googlesource.com/29699
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-27 04:00:57 +00:00
Nigel Tao
0080ac3d2c vector: add some more tests.
These tests are copied from the github.com/google/font-go prototype.

Change-Id: I4523193bd3453974633cbef0576c1203eb013a7d
Reviewed-on: https://go-review.googlesource.com/29697
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-25 03:45:43 +00:00
Nigel Tao
7ea36498ac vector: allow dst and mask to have different strides.
Change-Id: If244dba2c681b11122a7a26b352f9411135f123f
Reviewed-on: https://go-review.googlesource.com/29696
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-25 02:48:45 +00:00
Nigel Tao
b077ed42b3 vector: implement arbitrary dst and src image types.
Change-Id: Ib0d0961c69cabc3bb01d7b1d244796f0f713b819
Reviewed-on: https://go-review.googlesource.com/29691
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-24 05:40:50 +00:00
Nigel Tao
50ce1ebf58 vector: add benchmarks.
Change-Id: I4946ccc3a915c7e9365cd5fe860da673a2270fbb
Reviewed-on: https://go-review.googlesource.com/29631
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-23 02:06:24 +00:00
Nigel Tao
cd8486aac9 vector: implement DrawOp == draw.Over.
Some "TODO: the general case" lines remain.

Change-Id: If66e484a00d5ea3fce9db37d4ee493739648daa3
Reviewed-on: https://go-review.googlesource.com/29495
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-23 01:58:13 +00:00
Nigel Tao
bb355ba442 vector: add CubeTo.
Change-Id: Ia64b5b077172303981538de99cc14c5bcc99a3e4
Reviewed-on: https://go-review.googlesource.com/28489
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-08 11:11:11 +00:00
Nigel Tao
714f2e47f7 vector: new package for rasterizing 2-D graphics.
Updates golang/go#16904

Change-Id: I4e11e4e859c007c3444655a227ac935c27f3f784
Reviewed-on: https://go-review.googlesource.com/28347
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-04 08:48:55 +00:00
Nigel Tao
112f996332 math/fixed: add Mul methods.
Change-Id: Id6f9f5825527b311b5b1aa4ae0923c9551fa076b
Reviewed-on: https://go-review.googlesource.com/27413
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-25 00:04:48 +00:00
Nigel Tao
9f8d0d4587 font/plan9font: look for subfont ".0" suffixes.
Change-Id: Id8aadd846311fd621b47912d7b426d6a2d17a594
Reviewed-on: https://go-review.googlesource.com/25560
Reviewed-by: Rob Pike <r@golang.org>
2016-08-07 01:57:26 +00:00
Nigel Tao
c348254d65 webp: make a placeholder package for Go 1.5 and earlier.
This lets programs that underscore import this package build on Go 1.5.

Change-Id: Icd977b16eb44389f8ee4640c2ab57e4b6791b1f4
Reviewed-on: https://go-review.googlesource.com/24954
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-16 05:04:44 +00:00
Brad Fitzpatrick
81315f0c68 webp: mark package as requiring Go 1.6 for NYCbCrA
See https://build.golang.org/log/1e0572f27630c3a896f17722d89b6cc35d9f52d8

Updates golang/go#11811

Change-Id: I0db67f2c8586b1c36608c6131c803eb26fb87751
Reviewed-on: https://go-review.googlesource.com/24945
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-15 18:42:21 +00:00
Nigel Tao
a21e5be7b4 riff: fix some short chunk data bugs.
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-07 05:37:58 +00:00
Nigel Tao
8550bb5380 font/inconsolata: new package.
Fixes golang/go#16185

Change-Id: Ic7d64428b39be6b39a965fddf8753a2ce36d262c
Reviewed-on: https://go-review.googlesource.com/24482
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-30 01:20:08 +00:00
Nigel Tao
c4226c0d9c font/basicfont: add Descent and Left fields.
A face's glyph height (the height of the glyph image) isn't necessarily
the inter-line spacing: f.Ascent + f.Descent isn't always f.Height.

Similarly, a face's glyph image's left side isn't always dot.X.

Change-Id: I86594c52b8d31bf652ac34a695e9270ac635a5bc
Reviewed-on: https://go-review.googlesource.com/24481
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-30 00:32:31 +00:00
Nigel Tao
97680175a5 font: add a []byte flavor of string methods.
Change-Id: I2506067ba6ac12c275b65c3a52cb38579d4b9dca
Reviewed-on: https://go-review.googlesource.com/23464
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-27 00:37:06 +00:00
Nigel Tao
51ddfee6f3 colornames: export variables such as Darkred.
Change-Id: I1507d510ffa0ee3c899af652e0d1ab9d42a650d3
Reviewed-on: https://go-review.googlesource.com/23463
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-27 00:36:51 +00:00
Nigel Tao
f551d3a6b7 font/plan9font: derive the example's ascent from the metrics.
The Face.Metrics method is relatively new.

Also pick up the unicode.7x13.font fix from the upstream plan9port:
https://plan9port-review.googlesource.com/#/c/1490/

Change-Id: Ia6e0feec4ea3c9a35e19d38aa634ca9eb6b2ffa0
Reviewed-on: https://go-review.googlesource.com/21699
Reviewed-by: Rob Pike <r@golang.org>
2016-04-23 08:08:30 +00:00
Nigel Tao
14f8673644 font: add a MeasureString function, not just a method.
It can be useful to measure some text without having to set up a Drawer.

Change-Id: I18b7b1fecc32ca69b7644d598ed21462e7c41edd
Reviewed-on: https://go-review.googlesource.com/21785
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-12 11:16:26 +00:00
Nigel Tao
4cff43048f example/font: use an "example" build tag instead of "ignore".
The golang-dev discussion is at
https://groups.google.com/d/topic/golang-dev/qKpxZiNABcY/discussion

Change-Id: I55d626fd9b4c5585d11c585a8553fb5184d0ace7
Reviewed-on: https://go-review.googlesource.com/21788
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-12 11:14:18 +00:00
Nigel Tao
c4e9f1b429 math/fixed: have Floor, Round and Ceil return int, not Int26_6.
Change-Id: I1714bfbaf355771fb5d01508ac1dfe11c3db927a
Reviewed-on: https://go-review.googlesource.com/21787
Reviewed-by: Rob Pike <r@golang.org>
2016-04-10 05:23:37 +00:00
Nigel Tao
0991244d9d math/fixed: add Floor, Round and Ceil methods.
Change-Id: I7ed8c79a9098f45b38db947b5d99d021358e4e96
Reviewed-on: https://go-review.googlesource.com/21700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-10 01:36:18 +00:00
Nigel Tao
22f1b5f81b font/plan9font: optimize the conversion to image.Alpha.
Also remove the dependency on the image/draw package. That package will
give the right answer for arbitrary source images, including those of
type plan9Image, but doing the conversion directly avoids bouncing uint8
or color.Alpha values through the general-purpose draw.Image,
image.Image and color.Color interfaces.

It is possible to optimize this even further, but this will do for now.

benchmark                   old ns/op     new ns/op     delta
BenchmarkParseSubfont-8     2298492       492443        -78.58%

Change-Id: Iea9436bffa097a1ba0052dbabf21516bce8b61e0
Reviewed-on: https://go-review.googlesource.com/21693
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-04-10 01:11:56 +00:00
Ethan Burns
7a320489ae plan9font: use image.Alpha for subface images.
image.Alpha is fast-pathed in draw.Draw, plan9Image is not.

Change-Id: I5ed8fc4d310bb5c6ec2cffdd0ba4295dae2274cf
Reviewed-on: https://go-review.googlesource.com/21453
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-04-07 03:46:29 +00:00
Nigel Tao
8b5ac8f8e5 image/font: make a zero Weight mean a normal weight.
Change-Id: I2000bdf1c49174b9eaefe1c680138392e3434ace
Reviewed-on: https://go-review.googlesource.com/21440
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-02 04:27:04 +00:00
Nigel Tao
0ebebfd658 webp: fix tests for webp/nycbcra deprecation.
The previous commit (00fe24ef "webp/nycbcra: deprecate package") was
incomplete.

Change-Id: I6af5e1633b9c291e72b02877b308eae6e5624ef5
Reviewed-on: https://go-review.googlesource.com/21441
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-04-02 01:02:22 +00:00
Nigel Tao
00fe24ef7b webp/nycbcra: deprecate package.
The standard image and image/color packages have NYCbCrA support, as of Go 1.6.

Change-Id: I3ed2a502b3b9fe720968ac21901115e20a11456a
Reviewed-on: https://go-review.googlesource.com/21066
Reviewed-by: Rob Pike <r@golang.org>
2016-03-27 23:18:01 +00:00
Nigel Tao
f1e9747265 font: add Metrics.Descent.
Change-Id: Id38e7e54264e0e77a28afd8e10cf574610b47336
Reviewed-on: https://go-review.googlesource.com/21019
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-23 23:23:04 +00:00
Ethan Burns
7b1c29e1d6 font: add Face.Metrics.
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-03-23 23:05:57 +00:00
Nigel Tao
7c492694a6 cmd/webp-manual-test: blacklist some versions of the dwebp binary.
In particular, the 0.4.0 version of /usr/bin/dwebp that comes with
Ubuntu 14.04 LTS "Trusty", is known to be bad.

As per https://chromium.googlesource.com/webm/libwebp/+/master/NEWS
(grep for 239), versions 0.4.1 and 0.4.2 are also bad.

The alpha_color_cache.webp test file that triggers the discrepancy
between the (correct) Go implementation and the (buggy) libwebp C
implementation was added on 2015-01-23 in
f64fb2da01
in response to https://bugs.chromium.org/p/webp/issues/detail?id=239

Change-Id: Ifee19be0af634b9bf36ff0e16957648e05be840a
Reviewed-on: https://go-review.googlesource.com/18186
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-01-07 22:46:02 +00:00
Nigel Tao
baddd3465a font/basicfont: new package for a basic font face.
The key feature is that its data is entirely self-contained and does not
require loading from separate files.

Change-Id: I4ef72b52cde93597be89dcfd55659f418c6cab23
Reviewed-on: https://go-review.googlesource.com/14486
Reviewed-by: Rob Pike <r@golang.org>
2015-09-16 11:25:57 +00:00
Nigel Tao
2dc9880a10 colornames: fix copyright year.
These files were added in 2015:
https://go-review.googlesource.com/#/c/13181/

Presumably they were copy/pasted from something written in 2011.

Change-Id: I3defb4e02d03beb835e8a16c89bcae44c292e914
Reviewed-on: https://go-review.googlesource.com/14487
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-11 03:52:25 +00:00
Nigel Tao
b3d8467d91 font: fix up some old x/exp/shiny references.
Also add canonical import paths for the newly merged packages.

Change-Id: I96fe3a964ba08e718fc9163c980ef7ea9da551fe
Reviewed-on: https://go-review.googlesource.com/14148
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-09-01 05:21:00 +00:00
Nigel Tao
00f88f596f Merge x/exp/shiny/font to x/image/font. 2015-09-01 14:51:18 +10:00
Nigel Tao
b53870fbcf shiny/font/plan9font: add an example test.
The testdata/fixed font files come from the Plan 9 Port, and were all
marked as public domain. The total size of the new testdata is 112K.

Change-Id: I8cf5de4e5abd1aec7e6550d330271f2acdc12402
Reviewed-on: https://go-review.googlesource.com/13888
Reviewed-by: Rob Pike <r@golang.org>
2015-09-01 04:36:16 +00:00
Nigel Tao
5ae59125bf shiny/font: have Face.Glyph return an advance width, not a new dot.
This is consistent with Face.GlyphBounds and Face.GlyphAdvance.

Change-Id: I9da6b4f2fdb8f093fc9567c717e8fbbecc624e30
Reviewed-on: https://go-review.googlesource.com/14090
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-08-31 01:31:05 +00:00
Nigel Tao
627898392a shiny/font: add per-glyph metrics.
Change-Id: Ie5c7e29b4eb7bd87b8e99de941f2f94b042e268f
Reviewed-on: https://go-review.googlesource.com/13827
Reviewed-by: Rob Pike <r@golang.org>
2015-08-24 05:53:06 +00:00
Nigel Tao
8ab1ac6834 math/fixed: add rectangle types and the R function.
Change-Id: Ibb3785bcd57f13c7b6f1dc37526f65e44b4ac695
Reviewed-on: https://go-review.googlesource.com/13823
Reviewed-by: Rob Pike <r@golang.org>
2015-08-24 01:31:27 +00:00
Nigel Tao
ab08d42a8a shiny/font: add Hinting, Stretch, Style and Weight option types.
These will be used by other vector font packages, such as the truetype
package, to select specific faces.

Change-Id: I3db8c97335089c2076811e8f85d9a8868fc900bd
Reviewed-on: https://go-review.googlesource.com/13714
Reviewed-by: Rob Pike <r@golang.org>
2015-08-20 02:16:59 +00:00
Nigel Tao
e87ffe258c shiny/font/plan9font: implement ParseFont.
Also delete font.MultiFace. We can resurrect a font.MultiFace type if we
need it in the future, but for now, it's simpler if it lives in the
plan9font package.

Change-Id: I1493b47696c323424e7d91cb7fac15505bfdd023
Reviewed-on: https://go-review.googlesource.com/13520
Reviewed-by: Rob Pike <r@golang.org>
2015-08-19 04:10:22 +00:00
Nigel Tao
d9c0088098 math/fixed: add I and P helper functions.
The P function is especially common in e.g. Freetype code that works
with both the integer-pixel (X,Y) coordinates used by the stdlib image
package and sub-pixel (X,Y) coordinates used by its raster package.

Change-Id: I68be8ca71ceb24f40277ecc39a0896323f6671f5
Reviewed-on: https://go-review.googlesource.com/13652
Reviewed-by: Rob Pike <r@golang.org>
2015-08-17 07:17:06 +00:00
Hariharan Srinath
b137518d47 colornames: new package for named colors
This package provides named colors as defined in the SVG 1.1 spec.
Named colors are parsed from the SVG 1.1 spec web page at
http://www.w3.org/TR/SVG/types.html and written using go generate

fixes golang/go#11734

Change-Id: Ia75a166b3714a36a07be64c7d331231b5b2d0cf2
Reviewed-on: https://go-review.googlesource.com/13181
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-08-16 00:08:16 +00:00
Nigel Tao
b96af5338f math/fixed: add Point methods (Add, Sub, Mul, Div).
These mirror the image.Point methods in the standard library.

Change-Id: I7309af308a8182e325af20b47341f72703cbc95a
Reviewed-on: https://go-review.googlesource.com/13603
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-13 13:30:46 +00:00
Nigel Tao
eecb4e626f shiny/font: new package for drawing text on an image.
Package font defines an interface for font faces.

Other packages provide font face implementations. For example, a
truetype package (not part of this CL) would provide one based on .ttf
font files.

This CL also introduces the golang.org/x/exp/shiny/font/plan9font
package, a concrete implementation of the font.Face interface for the
Plan 9 bitmap font format.

Change-Id: Iead8914caaa58c7562b18a86b45002ae47486903
Reviewed-on: https://go-review.googlesource.com/13463
Reviewed-by: Rob Pike <r@golang.org>
2015-08-11 05:46:15 +00:00