Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小雨青年
freetype
提交
e8121e3c
F
freetype
项目概览
小雨青年
/
freetype
通知
14
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
freetype
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e8121e3c
编写于
8月 18, 2015
作者:
N
Nigel Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't use backtick quotes in the comments.
上级
2a5cbfd4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
15 deletion
+21
-15
example/raster/main.go
example/raster/main.go
+1
-1
freetype.go
freetype.go
+2
-2
raster/raster.go
raster/raster.go
+15
-9
truetype/glyph.go
truetype/glyph.go
+3
-3
未找到文件。
example/raster/main.go
浏览文件 @
e8121e3c
...
...
@@ -28,7 +28,7 @@ type node struct {
x
,
y
,
degree
int
}
// These contours "outside" and "inside" are from the
`
A' glyph from the Droid
// These contours "outside" and "inside" are from the
'
A' glyph from the Droid
// Serif Regular font.
var
outside
=
[]
node
{
...
...
freetype.go
浏览文件 @
e8121e3c
...
...
@@ -84,7 +84,7 @@ type Context struct {
cache
[
nGlyphs
*
nXFractions
*
nYFractions
]
cacheEntry
}
// PointToFixed converts the given number of points (as in
``a 12 point font''
)
// PointToFixed converts the given number of points (as in
"a 12 point font"
)
// into a 26.6 fixed point number of pixels.
func
(
c
*
Context
)
PointToFixed
(
x
float64
)
fixed
.
Int26_6
{
return
fixed
.
Int26_6
(
x
*
float64
(
c
.
dpi
)
*
(
64.0
/
72.0
))
...
...
@@ -304,7 +304,7 @@ func (c *Context) SetFont(font *truetype.Font) {
c
.
recalc
()
}
// SetFontSize sets the font size in points (as in
``a 12 point font''
).
// SetFontSize sets the font size in points (as in
"a 12 point font"
).
func
(
c
*
Context
)
SetFontSize
(
fontSize
float64
)
{
if
c
.
fontSize
==
fontSize
{
return
...
...
raster/raster.go
浏览文件 @
e8121e3c
...
...
@@ -304,7 +304,7 @@ func (r *Rasterizer) Add1(b fixed.Point26_6) {
// Add2 adds a quadratic segment to the current curve.
func
(
r
*
Rasterizer
)
Add2
(
b
,
c
fixed
.
Point26_6
)
{
// Calculate nSplit (the number of recursive decompositions) based on how
//
`
curvy' it is. Specifically, how much the middle point b deviates from
//
'
curvy' it is. Specifically, how much the middle point b deviates from
// (a+c)/2.
dev
:=
maxAbs
(
r
.
a
.
X
-
2
*
b
.
X
+
c
.
X
,
r
.
a
.
Y
-
2
*
b
.
Y
+
c
.
Y
)
/
fixed
.
Int26_6
(
r
.
splitScale2
)
nsplit
:=
0
...
...
@@ -312,7 +312,8 @@ func (r *Rasterizer) Add2(b, c fixed.Point26_6) {
dev
/=
4
nsplit
++
}
// dev is 32-bit, and nsplit++ every time we shift off 2 bits, so maxNsplit is 16.
// dev is 32-bit, and nsplit++ every time we shift off 2 bits, so maxNsplit
// is 16.
const
maxNsplit
=
16
if
nsplit
>
maxNsplit
{
panic
(
"freetype/raster: Add2 nsplit too large: "
+
strconv
.
Itoa
(
nsplit
))
...
...
@@ -331,8 +332,9 @@ func (r *Rasterizer) Add2(b, c fixed.Point26_6) {
s
:=
sStack
[
i
]
p
:=
pStack
[
2
*
i
:
]
if
s
>
0
{
// Split the quadratic curve p[:3] into an equivalent set of two shorter curves:
// p[:3] and p[2:5]. The new p[4] is the old p[2], and p[0] is unchanged.
// Split the quadratic curve p[:3] into an equivalent set of two
// shorter curves: p[:3] and p[2:5]. The new p[4] is the old p[2],
// and p[0] is unchanged.
mx
:=
p
[
1
]
.
X
p
[
4
]
.
X
=
p
[
2
]
.
X
p
[
3
]
.
X
=
(
p
[
4
]
.
X
+
mx
)
/
2
...
...
@@ -348,7 +350,8 @@ func (r *Rasterizer) Add2(b, c fixed.Point26_6) {
sStack
[
i
+
1
]
=
s
-
1
i
++
}
else
{
// Replace the level-0 quadratic with a two-linear-piece approximation.
// Replace the level-0 quadratic with a two-linear-piece
// approximation.
midx
:=
(
p
[
0
]
.
X
+
2
*
p
[
1
]
.
X
+
p
[
2
]
.
X
)
/
4
midy
:=
(
p
[
0
]
.
Y
+
2
*
p
[
1
]
.
Y
+
p
[
2
]
.
Y
)
/
4
r
.
Add1
(
fixed
.
Point26_6
{
midx
,
midy
})
...
...
@@ -360,7 +363,8 @@ func (r *Rasterizer) Add2(b, c fixed.Point26_6) {
// Add3 adds a cubic segment to the current curve.
func
(
r
*
Rasterizer
)
Add3
(
b
,
c
,
d
fixed
.
Point26_6
)
{
// Calculate nSplit (the number of recursive decompositions) based on how `curvy' it is.
// Calculate nSplit (the number of recursive decompositions) based on how
// 'curvy' it is.
dev2
:=
maxAbs
(
r
.
a
.
X
-
3
*
(
b
.
X
+
c
.
X
)
+
d
.
X
,
r
.
a
.
Y
-
3
*
(
b
.
Y
+
c
.
Y
)
+
d
.
Y
)
/
fixed
.
Int26_6
(
r
.
splitScale2
)
dev3
:=
maxAbs
(
r
.
a
.
X
-
2
*
b
.
X
+
d
.
X
,
r
.
a
.
Y
-
2
*
b
.
Y
+
d
.
Y
)
/
fixed
.
Int26_6
(
r
.
splitScale3
)
nsplit
:=
0
...
...
@@ -369,7 +373,8 @@ func (r *Rasterizer) Add3(b, c, d fixed.Point26_6) {
dev3
/=
4
nsplit
++
}
// devN is 32-bit, and nsplit++ every time we shift off 2 bits, so maxNsplit is 16.
// devN is 32-bit, and nsplit++ every time we shift off 2 bits, so
// maxNsplit is 16.
const
maxNsplit
=
16
if
nsplit
>
maxNsplit
{
panic
(
"freetype/raster: Add3 nsplit too large: "
+
strconv
.
Itoa
(
nsplit
))
...
...
@@ -389,8 +394,9 @@ func (r *Rasterizer) Add3(b, c, d fixed.Point26_6) {
s
:=
sStack
[
i
]
p
:=
pStack
[
3
*
i
:
]
if
s
>
0
{
// Split the cubic curve p[:4] into an equivalent set of two shorter curves:
// p[:4] and p[3:7]. The new p[6] is the old p[3], and p[0] is unchanged.
// Split the cubic curve p[:4] into an equivalent set of two
// shorter curves: p[:4] and p[3:7]. The new p[6] is the old p[3],
// and p[0] is unchanged.
m01x
:=
(
p
[
0
]
.
X
+
p
[
1
]
.
X
)
/
2
m12x
:=
(
p
[
1
]
.
X
+
p
[
2
]
.
X
)
/
2
m23x
:=
(
p
[
2
]
.
X
+
p
[
3
]
.
X
)
/
2
...
...
truetype/glyph.go
浏览文件 @
e8121e3c
...
...
@@ -21,11 +21,11 @@ const (
// TODO: implement VerticalHinting.
)
// A Point is a co-ordinate pair plus whether it is
``on'' a contour or an
//
``off''
control point.
// A Point is a co-ordinate pair plus whether it is
'on' a contour or an 'off'
// control point.
type
Point
struct
{
X
,
Y
fixed
.
Int26_6
// The Flags' LSB means whether or not this Point is
``on'
' the contour.
// The Flags' LSB means whether or not this Point is
'on
' the contour.
// Other bits are reserved for internal use.
Flags
uint32
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录