Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions font/font_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,12 @@ func TestGDEFBlocklist(t *testing.T) {
tu.AssertNoErr(t, err)
tu.Assert(t, ft.GDEF.GlyphClassDef == nil)
}

func TestBitmapExtents(t *testing.T) {
ld := readFontFile(t, "bitmap/cherry-10-r.otb")
ft, err := NewFont(ld)
tu.AssertNoErr(t, err)
face := NewFace(ft)
extents, ok := face.GlyphExtents(41)
tu.Assert(t, ok && extents.Width == 819.2 && extents.Height == -1433.6)
}
8 changes: 4 additions & 4 deletions font/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,18 +402,18 @@ func (f *Face) glyphExtentsRaw(glyph GID) (GlyphExtents, bool) {
if ok {
return out, ok
}
out, ok = f.getExtentsFromGlyf(gID(glyph))
out, ok = f.getExtentsFromBitmap(gID(glyph), f.xPpem, f.yPpem)
if ok {
return out, ok
}
out, ok = f.getExtentsFromCff2(gID(glyph))
out, ok = f.getExtentsFromGlyf(gID(glyph))
if ok {
return out, ok
}
out, ok = f.getExtentsFromCff1(gID(glyph))
out, ok = f.getExtentsFromCff2(gID(glyph))
if ok {
return out, ok
}
out, ok = f.getExtentsFromBitmap(gID(glyph), f.xPpem, f.yPpem)
out, ok = f.getExtentsFromCff1(gID(glyph))
return out, ok
}
4 changes: 4 additions & 0 deletions shaping/wrapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,10 @@ func (l *LineWrapper) postProcessLine(finalLine Line, done bool) (WrappedLine, b
//
// See also [WrapNextLineF] which supports a decimal [maxWidth].
func (l *LineWrapper) WrapNextLine(maxWidth int) (out WrappedLine, done bool) {
maxFixed := math.MaxInt32 >> 6
if maxWidth > maxFixed {
maxWidth = maxFixed
}
return l.WrapNextLineF(fixed.I(maxWidth))
}

Expand Down
5 changes: 4 additions & 1 deletion shaping/wrapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,6 @@ func TestMaxWidthRouding(t *testing.T) {
}

func TestWrapping_oneLine_overflow_bug(t *testing.T) {

maxWidth := math.MaxInt

textInput := []rune("Lorem ipsum") // a simple input that fits on one line
Expand Down Expand Up @@ -3619,4 +3618,8 @@ func TestWrapping_oneLine_overflow_bug(t *testing.T) {
if len(outs) != 0 {
t.Errorf("expected no line, got %d", len(outs))
}

l.Prepare(WrapConfig{BreakPolicy: Never}, textInput, NewSliceIterator(out))
_, done := l.WrapNextLine(maxWidth)
tu.Assert(t, done)
}