Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小雨青年
freetype
提交
db77c6a1
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看板
提交
db77c6a1
编写于
8月 24, 2015
作者:
N
Nigel Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete some unnecessary fixed.Int26_6 conversions.
上级
24265d1c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
21 deletion
+21
-21
freetype.go
freetype.go
+14
-14
truetype/face.go
truetype/face.go
+7
-7
未找到文件。
freetype.go
浏览文件 @
db77c6a1
...
...
@@ -98,16 +98,16 @@ func (c *Context) drawContour(ps []truetype.Point, dx, dy fixed.Int26_6) {
// upwards. start is the same thing measured in fixed point units and
// positive Y going downwards, and offset by (dx, dy).
start
:=
fixed
.
Point26_6
{
X
:
dx
+
fixed
.
Int26_6
(
ps
[
0
]
.
X
)
,
Y
:
dy
-
fixed
.
Int26_6
(
ps
[
0
]
.
Y
)
,
X
:
dx
+
ps
[
0
]
.
X
,
Y
:
dy
-
ps
[
0
]
.
Y
,
}
others
:=
[]
truetype
.
Point
(
nil
)
if
ps
[
0
]
.
Flags
&
0x01
!=
0
{
others
=
ps
[
1
:
]
}
else
{
last
:=
fixed
.
Point26_6
{
X
:
dx
+
fixed
.
Int26_6
(
ps
[
len
(
ps
)
-
1
]
.
X
)
,
Y
:
dy
-
fixed
.
Int26_6
(
ps
[
len
(
ps
)
-
1
]
.
Y
)
,
X
:
dx
+
ps
[
len
(
ps
)
-
1
]
.
X
,
Y
:
dy
-
ps
[
len
(
ps
)
-
1
]
.
Y
,
}
if
ps
[
len
(
ps
)
-
1
]
.
Flags
&
0x01
!=
0
{
start
=
last
...
...
@@ -124,8 +124,8 @@ func (c *Context) drawContour(ps []truetype.Point, dx, dy fixed.Int26_6) {
q0
,
on0
:=
start
,
true
for
_
,
p
:=
range
others
{
q
:=
fixed
.
Point26_6
{
X
:
dx
+
fixed
.
Int26_6
(
p
.
X
)
,
Y
:
dy
-
fixed
.
Int26_6
(
p
.
Y
)
,
X
:
dx
+
p
.
X
,
Y
:
dy
-
p
.
Y
,
}
on
:=
p
.
Flags
&
0x01
!=
0
if
on
{
...
...
@@ -165,10 +165,10 @@ func (c *Context) rasterize(glyph truetype.Index, fx, fy fixed.Int26_6) (
return
0
,
nil
,
image
.
Point
{},
err
}
// Calculate the integer-pixel bounds for the glyph.
xmin
:=
int
(
fx
+
fixed
.
Int26_6
(
c
.
glyphBuf
.
B
.
XMin
)
)
>>
6
ymin
:=
int
(
fy
-
fixed
.
Int26_6
(
c
.
glyphBuf
.
B
.
YMax
)
)
>>
6
xmax
:=
int
(
fx
+
fixed
.
Int26_6
(
c
.
glyphBuf
.
B
.
XMax
)
+
0x3f
)
>>
6
ymax
:=
int
(
fy
-
fixed
.
Int26_6
(
c
.
glyphBuf
.
B
.
YMin
)
+
0x3f
)
>>
6
xmin
:=
int
(
fx
+
c
.
glyphBuf
.
B
.
XMin
)
>>
6
ymin
:=
int
(
fy
-
c
.
glyphBuf
.
B
.
YMax
)
>>
6
xmax
:=
int
(
fx
+
c
.
glyphBuf
.
B
.
XMax
+
0x3f
)
>>
6
ymax
:=
int
(
fy
-
c
.
glyphBuf
.
B
.
YMin
+
0x3f
)
>>
6
if
xmin
>
xmax
||
ymin
>
ymax
{
return
0
,
nil
,
image
.
Point
{},
errors
.
New
(
"freetype: negative sized glyph"
)
}
...
...
@@ -177,8 +177,8 @@ func (c *Context) rasterize(glyph truetype.Index, fx, fy fixed.Int26_6) (
// the pixel offsets, based on the font's FUnit metrics, that let a
// negative co-ordinate in TrueType space be non-negative in rasterizer
// space. xmin and ymin are typically <= 0.
fx
+=
fixed
.
Int26_6
(
-
xmin
<<
6
)
fy
+=
fixed
.
Int26_6
(
-
ymin
<<
6
)
fx
-=
fixed
.
Int26_6
(
xmin
<<
6
)
fy
-=
fixed
.
Int26_6
(
ymin
<<
6
)
// Rasterize the glyph's vectors.
c
.
r
.
Clear
()
e0
:=
0
...
...
@@ -188,7 +188,7 @@ func (c *Context) rasterize(glyph truetype.Index, fx, fy fixed.Int26_6) (
}
a
:=
image
.
NewAlpha
(
image
.
Rect
(
0
,
0
,
xmax
-
xmin
,
ymax
-
ymin
))
c
.
r
.
Rasterize
(
raster
.
NewAlphaSrcPainter
(
a
))
return
fixed
.
Int26_6
(
c
.
glyphBuf
.
AdvanceWidth
)
,
a
,
image
.
Point
{
xmin
,
ymin
},
nil
return
c
.
glyphBuf
.
AdvanceWidth
,
a
,
image
.
Point
{
xmin
,
ymin
},
nil
}
// glyph returns the advance width, glyph mask and integer-pixel offset to
...
...
@@ -235,7 +235,7 @@ func (c *Context) DrawString(s string, p fixed.Point26_6) (fixed.Point26_6, erro
for
_
,
rune
:=
range
s
{
index
:=
c
.
f
.
Index
(
rune
)
if
hasPrev
{
kern
:=
fixed
.
Int26_6
(
c
.
f
.
Kerning
(
c
.
scale
,
prev
,
index
)
)
kern
:=
c
.
f
.
Kerning
(
c
.
scale
,
prev
,
index
)
if
c
.
hinting
!=
font
.
HintingNone
{
kern
=
(
kern
+
32
)
&^
63
}
...
...
truetype/face.go
浏览文件 @
db77c6a1
...
...
@@ -98,7 +98,7 @@ func (a *face) Close() error { return nil }
func
(
a
*
face
)
Kern
(
r0
,
r1
rune
)
fixed
.
Int26_6
{
i0
:=
a
.
f
.
Index
(
r0
)
i1
:=
a
.
f
.
Index
(
r1
)
kern
:=
fixed
.
Int26_6
(
a
.
f
.
Kerning
(
a
.
scale
,
i0
,
i1
)
)
kern
:=
a
.
f
.
Kerning
(
a
.
scale
,
i0
,
i1
)
if
a
.
hinting
!=
font
.
HintingNone
{
kern
=
(
kern
+
32
)
&^
63
}
...
...
@@ -222,16 +222,16 @@ func (a *face) drawContour(ps []Point, dx, dy fixed.Int26_6) {
// upwards. start is the same thing measured in fixed point units and
// positive Y going downwards, and offset by (dx, dy).
start
:=
fixed
.
Point26_6
{
X
:
dx
+
fixed
.
Int26_6
(
ps
[
0
]
.
X
)
,
Y
:
dy
-
fixed
.
Int26_6
(
ps
[
0
]
.
Y
)
,
X
:
dx
+
ps
[
0
]
.
X
,
Y
:
dy
-
ps
[
0
]
.
Y
,
}
var
others
[]
Point
if
ps
[
0
]
.
Flags
&
0x01
!=
0
{
others
=
ps
[
1
:
]
}
else
{
last
:=
fixed
.
Point26_6
{
X
:
dx
+
fixed
.
Int26_6
(
ps
[
len
(
ps
)
-
1
]
.
X
)
,
Y
:
dy
-
fixed
.
Int26_6
(
ps
[
len
(
ps
)
-
1
]
.
Y
)
,
X
:
dx
+
ps
[
len
(
ps
)
-
1
]
.
X
,
Y
:
dy
-
ps
[
len
(
ps
)
-
1
]
.
Y
,
}
if
ps
[
len
(
ps
)
-
1
]
.
Flags
&
0x01
!=
0
{
start
=
last
...
...
@@ -248,8 +248,8 @@ func (a *face) drawContour(ps []Point, dx, dy fixed.Int26_6) {
q0
,
on0
:=
start
,
true
for
_
,
p
:=
range
others
{
q
:=
fixed
.
Point26_6
{
X
:
dx
+
fixed
.
Int26_6
(
p
.
X
)
,
Y
:
dy
-
fixed
.
Int26_6
(
p
.
Y
)
,
X
:
dx
+
p
.
X
,
Y
:
dy
-
p
.
Y
,
}
on
:=
p
.
Flags
&
0x01
!=
0
if
on
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录