minor fixes to prevent crashing on linux and eliminate error msgs about kern tables

This commit is contained in:
Randall O'Reilly 2018-08-16 01:05:50 -06:00
parent e2365dfdc4
commit e21dad5cc8
5 changed files with 16 additions and 10 deletions

View file

@ -6,15 +6,15 @@
// The freetype package provides a convenient API to draw text onto an image.
// Use the freetype/raster and freetype/truetype packages for lower level
// control over rasterization and TrueType parsing.
package freetype // import "github.com/golang/freetype"
package freetype
import (
"errors"
"image"
"image/draw"
"github.com/golang/freetype/raster"
"github.com/golang/freetype/truetype"
"github.com/goki/freetype/raster"
"github.com/goki/freetype/truetype"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)

View file

@ -13,7 +13,7 @@
// the Freetype "smooth" module, and the Anti-Grain Geometry library. A
// description of the area/coverage algorithm is at
// http://projects.tuxee.net/cl-vectors/section-the-cl-aa-algorithm
package raster // import "github.com/golang/freetype/raster"
package raster
import (
"strconv"

View file

@ -9,7 +9,7 @@ import (
"image"
"math"
"github.com/golang/freetype/raster"
"github.com/goki/freetype/raster"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)

View file

@ -175,6 +175,9 @@ func (g *GlyphBuf) load(recursion uint32, i Index, useMyMetrics bool) (err error
if recursion >= 32 {
return UnsupportedError("excessive compound glyph recursion")
}
if g.font.loca == nil {
return UnsupportedError("no glyph location data")
}
// Find the relevant slice of g.font.glyf.
var g0, g1 uint32
if g.font.locaOffsetFormat == locaOffsetFormatShort {

View file

@ -15,7 +15,7 @@
//
// To measure a TrueType font in ideal FUnit space, use scale equal to
// font.FUnitsPerEm().
package truetype // import "github.com/golang/freetype/truetype"
package truetype
import (
"fmt"
@ -312,9 +312,10 @@ func (f *Font) parseKern() error {
// Since we expect that almost all fonts aim to be Windows-compatible, we only parse the "older" format,
// just like the C Freetype implementation.
if len(f.kern) == 0 {
if f.nKern != 0 {
return FormatError("bad kern table length")
}
// if f.nKern != 0 {
// return FormatError("bad kern table length")
// }
f.nKern = 0 // just reset and move on
return nil
}
if len(f.kern) < 18 {
@ -346,7 +347,9 @@ func (f *Font) parseKern() error {
}
f.nKern, offset = int(u16(f.kern, offset)), offset+2
if 6*f.nKern != length-14 {
return FormatError("bad kern table length")
f.nKern = 0
return nil
// return FormatError("bad kern table length")
}
return nil
}