Freetype-Go: truetype parser initial check-in.
Parsing a malformed TTF may result in an index out-of-bounds panic,
rather than guaranteeing to return an error. This may be tightened
in the future.
http://codereview.appspot.com/940044/diff/2001/3001 File example/truetype/main.go (right): http://codereview.appspot.com/940044/diff/2001/3001#newcode17 example/truetype/main.go:17: var fontfile *string = flag.String("fontfile", "/usr/share/fonts/truetype/msttcorefonts/arial.ttf", "filename of the ...
14 years, 7 months ago
(2010-04-23 17:23:51 UTC)
#2
http://codereview.appspot.com/940044/diff/2001/3001
File example/truetype/main.go (right):
http://codereview.appspot.com/940044/diff/2001/3001#newcode17
example/truetype/main.go:17: var fontfile *string = flag.String("fontfile",
"/usr/share/fonts/truetype/msttcorefonts/arial.ttf", "filename of the ttf font")
can we not use arial as the example? whatever font you use here will be the
likeliest one for people to use and therefore to deploy. i'd rather not
encourage an overused microsoft knockoff of a weak and overused font.
lucida? lucida sans? i don't know what the other options are for linux users.
http://codereview.appspot.com/940044/diff/2001/3001#newcode30
example/truetype/main.go:30: fmt.Print(" on \n")
why space before newline?
http://codereview.appspot.com/940044/diff/2001/3003
File freetype/truetype/truetype.go (right):
http://codereview.appspot.com/940044/diff/2001/3003#newcode20
freetype/truetype/truetype.go:20: // A GlyphIndex is a Font's encoding of a
Unicode character.
encoding doesn't seem like the right word here.
http://codereview.appspot.com/940044/diff/2001/3003#newcode23
freetype/truetype/truetype.go:23: // A Bounds holds the range of one or more
glyphs. The endpoints are inclusive.
range of what? coordinates?
http://codereview.appspot.com/940044/diff/2001/3003#newcode136
freetype/truetype/truetype.go:136: for i, x := 0, 14; i < segCount; i, x = i+1,
x+2 {
i think this would be clearer if x was defined outside the loops so we see it
just walks along the data. it took me a while to figure that out.
another option that might work well is to define readU16 and readU32 as methods
on a *[]byte type. you could then grab a copy of the slice into a value of that
type and just read it out. no xs or offsets or magic numbers then.
http://codereview.appspot.com/940044/diff/2001/3003#newcode136
freetype/truetype/truetype.go:136: for i, x := 0, 14; i < segCount; i, x = i+1,
x+2 {
later: as i read further through the code i became confident that approach would
be good
http://codereview.appspot.com/940044/diff/2001/3003#newcode360
freetype/truetype/truetype.go:360: // A Point is a co-ordinate pair plus whether
it is `on' a contour or an
don't use this style of quotes. they look crappy in many fonts. just "" is fine.
> http://codereview.appspot.com/940044/diff/2001/3001#newcode17 > example/truetype/main.go:17: var fontfile *string = > flag.String("fontfile", > "/usr/share/fonts/truetype/msttcorefonts/arial.ttf", "filename of the ...
14 years, 7 months ago
(2010-04-23 17:29:20 UTC)
#3
> http://codereview.appspot.com/940044/diff/2001/3001#newcode17
> example/truetype/main.go:17: var fontfile *string =
> flag.String("fontfile",
> "/usr/share/fonts/truetype/msttcorefonts/arial.ttf", "filename of the
> ttf font")
> can we not use arial as the example? whatever font you use here will be
> the likeliest one for people to use and therefore to deploy. i'd rather
> not encourage an overused microsoft knockoff of a weak and overused
> font.
>
> lucida? lucida sans? i don't know what the other options are for linux
> users.
Also what about non-Linux users?
It would be fine to include a copy of one or all of the Luxi fonts in
http://xorg.freedesktop.org/releases/individual/font/font-bh-ttf-1.0.0.tar.bz2
They have a non-restrictive license and are good quality
Bigelow & Holmes fonts.
I use them in Plan 9 from User Space because I can't
distribute the Lucida fonts.
Russ
http://codereview.appspot.com/940044/diff/2001/3001 File example/truetype/main.go (right): http://codereview.appspot.com/940044/diff/2001/3001#newcode17 example/truetype/main.go:17: var fontfile *string = flag.String("fontfile", "/usr/share/fonts/truetype/msttcorefonts/arial.ttf", "filename of the ...
14 years, 7 months ago
(2010-04-29 01:58:14 UTC)
#4
http://codereview.appspot.com/940044/diff/2001/3001
File example/truetype/main.go (right):
http://codereview.appspot.com/940044/diff/2001/3001#newcode17
example/truetype/main.go:17: var fontfile *string = flag.String("fontfile",
"/usr/share/fonts/truetype/msttcorefonts/arial.ttf", "filename of the ttf font")
On 2010/04/23 17:23:51, r wrote:
> can we not use arial as the example? whatever font you use here will be the
> likeliest one for people to use and therefore to deploy. i'd rather not
> encourage an overused microsoft knockoff of a weak and overused font.
>
> lucida? lucida sans? i don't know what the other options are for linux users.
>
Changed from Arial to the included Luxi fonts.
http://codereview.appspot.com/940044/diff/2001/3001#newcode30
example/truetype/main.go:30: fmt.Print(" on \n")
On 2010/04/23 17:23:51, r wrote:
> why space before newline?
Typo. Fixed.
http://codereview.appspot.com/940044/diff/2001/3003
File freetype/truetype/truetype.go (right):
http://codereview.appspot.com/940044/diff/2001/3003#newcode20
freetype/truetype/truetype.go:20: // A GlyphIndex is a Font's encoding of a
Unicode character.
On 2010/04/23 17:23:51, r wrote:
> encoding doesn't seem like the right word here.
I've changed "encoding" to "index", and the type from GlyphIndex to just Index.
http://codereview.appspot.com/940044/diff/2001/3003#newcode23
freetype/truetype/truetype.go:23: // A Bounds holds the range of one or more
glyphs. The endpoints are inclusive.
On 2010/04/23 17:23:51, r wrote:
> range of what? coordinates?
Done.
http://codereview.appspot.com/940044/diff/2001/3003#newcode136
freetype/truetype/truetype.go:136: for i, x := 0, 14; i < segCount; i, x = i+1,
x+2 {
On 2010/04/23 17:23:51, r wrote:
> later: as i read further through the code i became confident that approach
would
> be good
This segment has been rewritten to use read16Slice. I think it is much clearer.
http://codereview.appspot.com/940044/diff/2001/3003#newcode360
freetype/truetype/truetype.go:360: // A Point is a co-ordinate pair plus whether
it is `on' a contour or an
On 2010/04/23 17:23:51, r wrote:
> don't use this style of quotes. they look crappy in many fonts. just "" is
fine.
Done.
> http://codereview.appspot.com/940044/diff/2001/3003#newcode360 > freetype/truetype/truetype.go:360: // A Point is a co-ordinate pair plus > whether it ...
14 years, 7 months ago
(2010-04-29 02:43:45 UTC)
#5
> http://codereview.appspot.com/940044/diff/2001/3003#newcode360
> freetype/truetype/truetype.go:360: // A Point is a co-ordinate pair plus
> whether it is `on' a contour or an
> On 2010/04/23 17:23:51, r wrote:
>>
>> don't use this style of quotes. they look crappy in many fonts. just
>
> "" is fine.
Sorry to contradict, but please do use `` '' in doc comments.
They get turned into nice quotation marks in the HTML output
and could get turned into " " if necessary in the text output.
http://golang.org/pkg/math/#NaN is an example.
Russ
http://codereview.appspot.com/940044/diff/14001/15001 File example/truetype/main.go (right): http://codereview.appspot.com/940044/diff/14001/15001#newcode17 example/truetype/main.go:17: var fontfile *string = flag.String("fontfile", "../../luxi-fonts/luxisr.ttf", "filename of the ...
14 years, 6 months ago
(2010-04-30 01:12:09 UTC)
#8
http://codereview.appspot.com/940044/diff/14001/15001
File example/truetype/main.go (right):
http://codereview.appspot.com/940044/diff/14001/15001#newcode17
example/truetype/main.go:17: var fontfile *string = flag.String("fontfile",
"../../luxi-fonts/luxisr.ttf", "filename of the ttf font")
On 2010/04/30 00:15:17, r wrote:
> s/\*string //
Done.
http://codereview.appspot.com/940044/diff/14001/15003
File freetype/truetype/truetype.go (right):
http://codereview.appspot.com/940044/diff/14001/15003#newcode21
freetype/truetype/truetype.go:21: // An Index is a Font's index of a Unicode
character.
On 2010/04/30 00:15:17, r wrote:
> s/character/code point/ ? i'm actually not sure
I've gone with "code point".
http://codereview.appspot.com/940044/diff/14001/15003#newcode163
freetype/truetype/truetype.go:163: readU16Slice(f.cmapOffset,
data[16+6*segCount:])
On 2010/04/30 00:15:17, r wrote:
> this is better and fine if you really want it this way but i would have used a
> few read methods on the slice. the offsets in this code could be handled
> completely automatically.
>
> similarly with almost all the other slice offset stuff in this program.
I'll leave it as is. If I get the itch I might try it your way and send out a
change if it looks better.
On 2010/05/02 15:38:43, r wrote: > LGTM but i still think you should try my ...
14 years, 6 months ago
(2010-05-03 14:42:34 UTC)
#12
On 2010/05/02 15:38:43, r wrote:
> LGTM but i still think you should try my suggestion with methods on a slice
type
> for the unpacking.
Done. PTAL.
(Russ' comments are also all Done.)
Issue 940044: code review 940044: Freetype-Go: truetype parser initial check-in.
(Closed)
Created 14 years, 7 months ago by nigeltao
Modified 14 years, 6 months ago
Reviewers:
Base URL:
Comments: 26