Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小雨青年
freetype
提交
5cb0a99d
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看板
提交
5cb0a99d
编写于
11月 30, 2013
作者:
N
Nigel Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
freetype/truetype: fix Super45 rounding.
R=bsiegert CC=golang-dev, remyoudompheng
https://codereview.appspot.com/34790045
上级
1f97ea5d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
6 deletion
+27
-6
freetype/truetype/hint.go
freetype/truetype/hint.go
+26
-5
freetype/truetype/truetype_test.go
freetype/truetype/truetype_test.go
+1
-1
未找到文件。
freetype/truetype/hint.go
浏览文件 @
5cb0a99d
...
...
@@ -81,6 +81,7 @@ type graphicsState struct {
loop
int32
// Rounding policy.
roundPeriod
,
roundPhase
,
roundThreshold
f26dot6
roundSuper45
bool
// Auto-flip.
autoFlip
bool
}
...
...
@@ -97,6 +98,7 @@ var globalDefaultGS = graphicsState{
loop
:
1
,
roundPeriod
:
1
<<
6
,
// 1 as an f26dot6.
roundThreshold
:
1
<<
5
,
// 1/2 as an f26dot6.
roundSuper45
:
false
,
autoFlip
:
true
,
}
...
...
@@ -350,11 +352,13 @@ func (h *Hinter) run(program []byte, pCurrent, pUnhinted, pInFontUnits []Point,
h
.
gs
.
roundPeriod
=
1
<<
6
h
.
gs
.
roundPhase
=
0
h
.
gs
.
roundThreshold
=
1
<<
5
h
.
gs
.
roundSuper45
=
false
case
opRTHG
:
h
.
gs
.
roundPeriod
=
1
<<
6
h
.
gs
.
roundPhase
=
1
<<
5
h
.
gs
.
roundThreshold
=
1
<<
5
h
.
gs
.
roundSuper45
=
false
case
opSMD
:
top
--
...
...
@@ -683,6 +687,7 @@ func (h *Hinter) run(program []byte, pCurrent, pUnhinted, pInFontUnits []Point,
h
.
gs
.
roundPeriod
=
1
<<
5
h
.
gs
.
roundPhase
=
0
h
.
gs
.
roundThreshold
=
1
<<
4
h
.
gs
.
roundSuper45
=
false
case
opMIAP0
,
opMIAP1
:
top
-=
2
...
...
@@ -905,7 +910,8 @@ func (h *Hinter) run(program []byte, pCurrent, pUnhinted, pInFontUnits []Point,
case
2
:
h
.
gs
.
roundPeriod
=
1
<<
7
}
if
opcode
==
opS45ROUND
{
h
.
gs
.
roundSuper45
=
opcode
==
opS45ROUND
if
h
.
gs
.
roundSuper45
{
// The spec says to multiply by √2, but the C Freetype code says 1/√2.
// We go with 1/√2.
h
.
gs
.
roundPeriod
*=
46341
...
...
@@ -936,16 +942,19 @@ func (h *Hinter) run(program []byte, pCurrent, pUnhinted, pInFontUnits []Point,
h
.
gs
.
roundPeriod
=
0
h
.
gs
.
roundPhase
=
0
h
.
gs
.
roundThreshold
=
0
h
.
gs
.
roundSuper45
=
false
case
opRUTG
:
h
.
gs
.
roundPeriod
=
1
<<
6
h
.
gs
.
roundPhase
=
0
h
.
gs
.
roundThreshold
=
1
<<
6
-
1
h
.
gs
.
roundSuper45
=
false
case
opRDTG
:
h
.
gs
.
roundPeriod
=
1
<<
6
h
.
gs
.
roundPhase
=
0
h
.
gs
.
roundThreshold
=
0
h
.
gs
.
roundSuper45
=
false
case
opSANGW
,
opAA
:
// These ops are "anachronistic" and no longer used.
...
...
@@ -1686,17 +1695,29 @@ func (h *Hinter) round(x f26dot6) f26dot6 {
return
x
}
if
x
>=
0
{
ret
:=
(
x
-
h
.
gs
.
roundPhase
+
h
.
gs
.
roundThreshold
)
&
-
h
.
gs
.
roundPeriod
ret
:=
x
-
h
.
gs
.
roundPhase
+
h
.
gs
.
roundThreshold
if
h
.
gs
.
roundSuper45
{
ret
/=
h
.
gs
.
roundPeriod
ret
*=
h
.
gs
.
roundPeriod
}
else
{
ret
&=
-
h
.
gs
.
roundPeriod
}
if
x
!=
0
&&
ret
<
0
{
ret
=
0
}
return
ret
+
h
.
gs
.
roundPhase
}
ret
:=
-
((
-
x
-
h
.
gs
.
roundPhase
+
h
.
gs
.
roundThreshold
)
&
-
h
.
gs
.
roundPeriod
)
if
ret
>
0
{
ret
:=
-
x
-
h
.
gs
.
roundPhase
+
h
.
gs
.
roundThreshold
if
h
.
gs
.
roundSuper45
{
ret
/=
h
.
gs
.
roundPeriod
ret
*=
h
.
gs
.
roundPeriod
}
else
{
ret
&=
-
h
.
gs
.
roundPeriod
}
if
ret
<
0
{
ret
=
0
}
return
ret
-
h
.
gs
.
roundPhase
return
-
ret
-
h
.
gs
.
roundPhase
}
func
bool2int32
(
b
bool
)
int32
{
...
...
freetype/truetype/truetype_test.go
浏览文件 @
5cb0a99d
...
...
@@ -255,7 +255,7 @@ var scalingTestCases = []struct {
hintingBrokenAt
int
}{
{
"luxisr"
,
12
,
-
1
},
{
"x-arial-bold"
,
11
,
2
38
},
{
"x-arial-bold"
,
11
,
2
74
},
{
"x-deja-vu-sans-oblique"
,
17
,
-
1
},
{
"x-droid-sans-japanese"
,
9
,
0
},
{
"x-times-new-roman"
,
13
,
0
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录