Commit Graph

23 Commits

Author SHA1 Message Date
Elias Naur
cc896f830c font/sfnt,font/opentype: correct font height computation
According to https://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html
the line spacing of a font is computed as

line space = ascent - descent + linegap

Use that formula to compute the Height field of a Font's Metrics.

Change-Id: I1c44eca9f662e0aae68716cd8859670fe0b394d7
Reviewed-on: https://go-review.googlesource.com/120815
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2018-06-28 06:20:38 +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
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
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
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
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
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
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
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
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
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
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
Nigel Tao
83686c5479 font/sfnt: parse the glyf table.
Change-Id: Ib7ff75d99d3641f68f621db4ba2279cc1bda8c3a
Reviewed-on: https://go-review.googlesource.com/35271
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-01-19 08:01:09 +00:00
Nigel Tao
2d771d3c32 font/sfnt: add a Font.Name method.
Also make all of the Buffer fields non-exported. LoadGlyph now returns
the segments instead of setting Buffer.Segments for the caller to use.

Change-Id: I3f87070da5e8f014f88dbca70b62a4cd30e3fd66
Reviewed-on: https://go-review.googlesource.com/34532
Reviewed-by: Dave Day <djd@golang.org>
2016-12-20 10:23:14 +00:00
Nigel Tao
ed90ab82a8 font/sfnt: add a comment about contour ordering.
Change-Id: I591c735cc1c3108aa806b0a7be6c54152fe2029e
Reviewed-on: https://go-review.googlesource.com/34174
Reviewed-by: Dave Day <djd@golang.org>
2016-12-15 04:48:35 +00:00
Nigel Tao
88b013251f font/sfnt: implement rrcurveto.
Change-Id: I2e24293568b296dd916b2ef6a9c1113ffd5f9253
Reviewed-on: https://go-review.googlesource.com/34171
Reviewed-by: Dave Day <djd@golang.org>
2016-12-12 04:37:57 +00:00
Nigel Tao
ce50dba65c font/sfnt: parse Type 2 Charstrings.
Change-Id: I61beec4611612800a519045e2552c513eb83c3f8
Reviewed-on: https://go-review.googlesource.com/33932
Reviewed-by: Dave Day <djd@golang.org>
2016-12-09 07:38:38 +00:00
Nigel Tao
5286ed5c2a font/sfnt: parse the CFF table.
Parsing the per-glyph Charstrings will be a follow-up commit.

Change-Id: I52f849a77dd7fa14b6e07420820bdfb4347c2438
Reviewed-on: https://go-review.googlesource.com/33593
Reviewed-by: Dave Day <djd@golang.org>
2016-12-01 07:43:55 +00:00
Nigel Tao
c39d899a5b font/sfnt: new package for parsing SFNT fonts.
Updates golang/go#16904

Change-Id: Ic4c55865741b712f7d82448276fc357f2edf9b45
Reviewed-on: https://go-review.googlesource.com/33417
Reviewed-by: Dave Day <djd@golang.org>
2016-11-23 02:01:16 +00:00