Skip to content

Commit 6fed110

Browse files
authored
Merge branch 'master' into sd/geometrybasics
2 parents 64968ad + 44e0df5 commit 6fed110

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ julia:
77

88
notifications:
99
email: false
10+
11+
after_success:
12+
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1111

1212
[compat]
1313
ColorVectorSpace = "0.8"
14-
Colors = "0.11"
15-
FreeType = "2, 3"
1614
GeometryBasics = "0.2"
15+
Colors = "0.11, 0.12"
16+
FreeType = "3"
1717
StaticArrays = "0.12"
1818
julia = "1"
1919

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![codecov](https://codecov.io/gh/JuliaGraphics/FreeTypeAbstraction.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaGraphics/FreeTypeAbstraction.jl)
2+
[![Build Status](https://travis-ci.org/JuliaGraphics/FreeTypeAbstraction.jl.svg?branch=master)](https://travis-ci.org/JuliaGraphics/FreeTypeAbstraction.jl)
13
# FreeTypeAbstraction
24

35
Draw text into a Matrix.
@@ -7,7 +9,7 @@ Draw text into a Matrix.
79
using FreeTypeAbstraction
810

911
# load a font
10-
face = newface("hack_regular.ttf")
12+
face = FTFont("hack_regular.ttf")
1113

1214
# render a character
1315
img, metric = renderface(face, 'C')

src/FreeTypeAbstraction.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ include("findfonts.jl")
1010
include("layout.jl")
1111
include("rendering.jl")
1212

13+
export FTFont
1314
export newface
1415
export renderface
1516
export FontExtent

src/layout.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function iterate_extents(f, line::AbstractString, fonts, scales)
3232
iterator = zip(line, iter_or_array(scales), iter_or_array(fonts))
3333
lastpos = 0.0
3434
for (char, scale, font) in iterator
35-
extent, glyph_box = metrics_bb(char, font, scale)
36-
mini = minimimum(glyph_box) .+ Vec2f0(lastpos, 0.0)
35+
glyph_box, extent = metrics_bb(char, font, scale)
36+
mini = minimum(glyph_box) .+ Vec2f0(lastpos, 0.0)
3737
glyph_box = Rect2D(mini, widths(glyph_box))
3838
glyph_advance = Point2f0(extent.advance)
3939
lastpos += glyph_advance[1]
@@ -51,5 +51,5 @@ function glyph_rects(line::AbstractString, fonts, scales)
5151
end
5252

5353
function boundingbox(line::AbstractString, fonts, scales)
54-
reduce(union, glyph_rects(lines, fonts, scales))
54+
return reduce(union, glyph_rects(line, fonts, scales))
5555
end

src/types.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ function Base.getproperty(font::FTFont, fieldname::Symbol)
156156
end
157157
end
158158

159+
# Allow broadcasting over fonts
160+
Base.Broadcast.broadcastable(ft::FTFont) = Ref(ft)
161+
159162
get_pixelsize(face::FTFont) = getfield(face, :current_pixelsize)[]
160163

161164
function set_pixelsize(face::FTFont, size::Integer)

test/runtests.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
using FreeTypeAbstraction, Colors, ColorVectorSpace, GeometryBasics
22
using Test
3-
using FreeTypeAbstraction: Vec, glyph_rects, get_extent, FTFont, kerning
3+
using FreeTypeAbstraction: boundingbox, Vec, glyph_rects, get_extent, FTFont, kerning
44
using FreeType
55

66
face = FreeTypeAbstraction.findfont("hack"; additional_fonts=@__DIR__)
77

8+
bb = boundingbox("asdasd", face, 1.0)
9+
@test bb == Rect(4.0, -1.0, 224.0, 50.0)
10+
811
FA = FreeTypeAbstraction
912

1013
FA.set_pixelsize(face, 64) # should be the default

0 commit comments

Comments
 (0)