Commit graph

152 commits

Author SHA1 Message Date
Nigel Tao
62e59645ee Quantize sub-pixel glyph rendering.
This is in anticipation of caching glyph images. Quantization means that cache
hits are more likely.

Also make NewFace take an *Options instead of an Options.
2015-08-25 22:34:31 +10:00
Nigel Tao
a021a5f23e Rename Kerning to Kern. 2015-08-24 16:17:16 +10:00
Nigel Tao
db77c6a161 Delete some unnecessary fixed.Int26_6 conversions. 2015-08-24 15:57:20 +10:00
Nigel Tao
24265d1c91 Implement GlyphBounds and GlyphAdvance. 2015-08-24 15:51:50 +10:00
Nigel Tao
9c46b87503 Make face.Glyph not allocate a new mask each time.
benchmark                 old ns/op     new ns/op     delta
BenchmarkDrawString-4     96914389      88683659      -8.49%

benchmark                 old allocs     new allocs     delta
BenchmarkDrawString-4     32287          0              -100.00%

benchmark                 old bytes     new bytes     delta
BenchmarkDrawString-4     1929619       156           -99.99%
2015-08-23 21:11:02 +10:00
Nigel Tao
2d84b72ff6 Add a DrawString benchmark. 2015-08-23 20:45:19 +10:00
Nigel Tao
d8618774be Fix some comment typos.
These comments weren't updated when we went from 24.8 to 26.6.
2015-08-22 14:48:07 +10:00
Nigel Tao
6deea24143 Add a truetype.Face type.
Its implementation is mostly a copy/paste of the freetype.Context type.
Follow-up commits will make it more efficient.

Also add an example that uses a truetype.Face and the
golang.org/x/exp/shiny/font package to draw text.
2015-08-22 14:46:12 +10:00
Nigel Tao
7166253831 Fix rounding up for 26.6 fixed point, not 24.8. 2015-08-21 14:00:51 +10:00
Nigel Tao
071d96ed47 Update BenchmarkDrawString testdata dir. 2015-08-20 16:09:11 +10:00
Nigel Tao
f42630ca7a Use the common golang.org/x/exp/shiny/font.Hinting type. 2015-08-20 16:07:51 +10:00
Nigel Tao
7e2154db58 Delete the f26dot6 type in favor of fixed.Int26_6. 2015-08-18 16:47:46 +10:00
Nigel Tao
43fc220ebd Make f26dot6 methods prefix, not infix.
This is in anticipation of removing the f26dot6 type entirely. Instead,
we will use the fixed.Int26_6 type from golang.org/x/image/math/fixed.
2015-08-18 16:36:59 +10:00
Nigel Tao
e8121e3c7d Don't use backtick quotes in the comments. 2015-08-18 16:33:14 +10:00
Nigel Tao
2a5cbfd47e Use the fixed.Int26_6 type in package truetype. 2015-08-18 16:30:37 +10:00
Nigel Tao
a9554eda48 Fix example/freetype for the s/Fix32/fixed.Int26_6/ change. 2015-08-18 16:08:44 +10:00
Nigel Tao
856a70c395 Use the fixed.Int26_6 and fixed.Point26_6 types. 2015-08-17 10:26:09 +10:00
Nigel Tao
d91c1d6844 Remove Point methods other than Add, Sub, Mul.
This is in anticipation of removing the Point type entirely. Instead, we will
use the fixed.Point26_6 type from golang.org/x/image/math/fixed.
2015-08-13 21:17:25 +10:00
Nigel Tao
84ba7fbd7a Add "+build ignore" tags to the examples. 2015-08-12 14:41:46 +10:00
Nigel Tao
5193f9f147 Add canonical import paths. 2015-08-12 14:34:19 +10:00
Nigel Tao
d1c460896e Fix testdata paths after moving files up one level. 2015-08-12 14:32:40 +10:00
Nigel Tao
bf25f8ce0e Move files up one level. 2015-08-12 14:30:01 +10:00
Nigel Tao
2f0c939b0a Delete hg related detritus.
We use git and github now, not hg and code.google.com.
2015-08-11 14:38:11 +10:00
Nigel Tao
160e1d6137 freetype: fix drawContour when the first point is off the curve.
Fixes issue 16.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews, philipz
https://codereview.appspot.com/209280043
2015-03-09 11:32:30 +11:00
Nigel Tao
78edcde0f3 freetype/raster: fix some style nits.
This code dates from before Go 1.0.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://codereview.appspot.com/206860043
2015-02-24 10:52:08 +11:00
Nigel Tao
cf94cb9b43 freetype/truetype: update the golden tests for Ubuntu 14.04's version
of standard fonts like Deja Vu Sans Oblique.

LGTM=bsiegert
R=bsiegert
CC=golang-codereviews
https://codereview.appspot.com/164660043
2014-11-07 09:38:15 +11:00
Nigel Tao
c3ec330230 freetype/truetype: fix some typos in hint.go.
Fixes issue 12.
Fixes issue 13.

LGTM=bsiegert
R=bsiegert
CC=golang-codereviews
https://codereview.appspot.com/164650043
2014-11-07 09:37:26 +11:00
Nigel Tao
e009753234 freetype/truetype: support symbol fonts such as Webdings.
LGTM=bsiegert
R=bsiegert
CC=golang-codereviews
https://codereview.appspot.com/60380043
2014-02-06 10:38:58 +11:00
Nigel Tao
49fa4a4de0 freetype: add a Hinting enum in the top-level freetype package, and
hide the Hinter implementation in the freetype/truetype package.

LGTM=bsiegert
R=bsiegert
CC=golang-codereviews
https://codereview.appspot.com/58940043
2014-02-01 14:12:48 +11:00
Nigel Tao
51c4a7ede4 freetype/truetype: merge the deltap and deltac code.
LGTM=bsiegert
R=bsiegert
CC=golang-codereviews
https://codereview.appspot.com/54730043
2014-01-30 13:07:29 +11:00
Nigel Tao
c3fc397167 freetype/truetype: refactor dispatch for high opcodes.
Also delete "q means that that opcode is not yet implemented", as all
valid opcodes are now implemented.

R=bsiegert
CC=golang-codereviews
https://codereview.appspot.com/53050044
2014-01-21 09:31:51 +11:00
Nigel Tao
39b0167875 freetype/truetype: implement the remaining opcodes.
R=bsiegert
CC=golang-codereviews
https://codereview.appspot.com/51760043
2014-01-20 14:33:40 +11:00
Nigel Tao
10cb3b4280 freetype/truetype: calculate advance widths correctly.
The logic is a little clunky, but as before, let's get it right first,
then get it clean once we have a full battery of tests.

R=bsiegert
CC=golang-codereviews
https://codereview.appspot.com/50910043
2014-01-14 09:58:07 +11:00
Nigel Tao
897255e610 freetype/truetype: fix bounding box calculation.
R=bsiegert
CC=golang-codereviews, remyoudompheng
https://codereview.appspot.com/39440045
2013-12-21 10:03:04 +11:00
Russ Cox
5ed83878d0 codereview: switch defaultcc to golang-codereviews
See this thread for background:
https://groups.google.com/forum/#!topic/golang-dev/xG7vPi21r8g

R=golang-codereviews, r
CC=golang-codereviews
https://codereview.appspot.com/36380046
2013-12-20 10:59:27 -05:00
Nigel Tao
9fd1f2aca9 freetype/truetype: add testdata for advance widths and bounding boxes.
R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/40690045
2013-12-16 13:47:21 +11:00
Nigel Tao
f3eade8b5f freetype/truetype: fix MD0/MD1 opcodes and f26dot6 multiplication
rounding.

Pass all the hinting tests. Hooray! Removing the hintingBrokenAt field
will be a follow-up CL.

R=bsiegert, remyoudompheng, jeremyjackins
CC=golang-dev
https://codereview.appspot.com/36880043
2013-12-05 09:09:03 +11:00
Nigel Tao
4c33bd09f5 freetype/truetype: implement SCFS, FLIPPT, FLIPRGON, FLIPRGOFF opcodes.
R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/36300043
2013-12-04 10:04:19 +11:00
Nigel Tao
25cb1e119f freetype/truetype: fix SHC opcode.
R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/36220043
2013-12-03 10:57:02 +11:00
Nigel Tao
11bef13aa5 freetype/truetype: track phantom points across compound glyphs.
The very subtle pp1x versus phantomPoints[0].X distinction is pretty
ugly code, but let's get all the tests passing first, so that we can
refactor with confidence.

R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/35850043
2013-12-03 08:21:05 +11:00
Nigel Tao
5cb0a99dcd freetype/truetype: fix Super45 rounding.
R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/34790045
2013-11-30 15:19:12 +11:00
Nigel Tao
1f97ea5d8e freetype/truetype: apply the pp1x adjustment to the unhinted points
*before* hinting.

R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/35070044
2013-11-29 22:12:55 +11:00
Nigel Tao
114d43ecfe freetype/truetype: load vertical metrics from the OS/2 table.
R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/34700043
2013-11-29 10:33:11 +11:00
Nigel Tao
1c0c5a1f9a freetype/truetype: upgrade testdata to C Freetype 2.5.1.
R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/33650044
2013-11-28 14:02:28 +11:00
Nigel Tao
02a88bab17 freetype/truetype: fix SHC, MIRP opcodes.
R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/33750043
2013-11-27 20:09:54 +11:00
Nigel Tao
5a5d117404 freetype/truetype: normalize and set dual vector for SPVFS and SFVFS
opcodes. Calculate dot product with 32-bit math to match C Freetype's
rounding.

R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/32740043
2013-11-27 17:48:57 +11:00
Nigel Tao
cce54f9bf8 freetype/truetype: fix order of 1st phantom point adjustment and
2nd / 4th phantom point rounding.

R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/32040043
2013-11-26 20:06:51 +11:00
Nigel Tao
cef9ca89c7 freetype/truetype: implement ISECT, SHC, WCVTF, DELTAC and SDPVTL
opcodes.

R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/29510043
2013-11-21 08:51:09 +11:00
Nigel Tao
f6106a9f8b freetype/truetype: adjust ends slice when hinting a compound glyph.
Successfully hint all of DejaVu Sans Oblique, barring 4 exceptions
that are errors in the upstream C Freetype project. See
http://lists.nongnu.org/archive/html/freetype/2013-11/msg00004.html
for details.

R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/21580044
2013-11-07 08:53:15 +11:00
Nigel Tao
cdaff3c716 freetype/truetype: run compound glyph hinting instructions.
Also add API for vertical metrics.

R=bsiegert
CC=golang-dev, remyoudompheng
https://codereview.appspot.com/21330043
2013-11-05 09:58:40 +11:00