Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
d50c99df
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d50c99df
编写于
7月 29, 2014
作者:
B
Behdad Esfahbod
提交者:
Android (Google) Code Review
7月 27, 2014
浏览文件
操作
浏览文件
下载
差异文件
Merge "Remove CSS string doLayout entrypoint and supporting code" into lmp-dev
上级
83d5a3c5
c924dd12
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
0 addition
and
369 deletion
+0
-369
include/minikin/CssParse.h
include/minikin/CssParse.h
+0
-108
include/minikin/Layout.h
include/minikin/Layout.h
+0
-5
libs/minikin/Android.mk
libs/minikin/Android.mk
+0
-1
libs/minikin/CssParse.cpp
libs/minikin/CssParse.cpp
+0
-210
libs/minikin/Layout.cpp
libs/minikin/Layout.cpp
+0
-45
未找到文件。
include/minikin/CssParse.h
已删除
100644 → 0
浏览文件 @
83d5a3c5
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MINIKIN_CSS_PARSE_H
#define MINIKIN_CSS_PARSE_H
#include <map>
#include <string>
namespace
android
{
enum
CssTag
{
unknown
,
fontScaleX
,
fontSize
,
fontSkewX
,
fontStyle
,
fontWeight
,
cssLang
,
letterSpacing
,
minikinBidi
,
minikinHinting
,
minikinVariant
,
paintFlags
,
};
const
std
::
string
cssTagNames
[]
=
{
"unknown"
,
"font-scale-x"
,
"font-size"
,
"font-skew-x"
,
"font-style"
,
"font-weight"
,
"lang"
,
"letter-spacing"
,
"-minikin-bidi"
,
"-minikin-hinting"
,
"-minikin-variant"
,
"-paint-flags"
,
};
class
CssValue
{
public:
enum
Type
{
UNKNOWN
,
DOUBLE
,
STRING
};
enum
Units
{
SCALAR
,
PERCENT
,
PX
,
EM
};
CssValue
()
:
mType
(
UNKNOWN
)
{
}
explicit
CssValue
(
double
v
)
:
mType
(
DOUBLE
),
doubleValue
(
v
),
mUnits
(
SCALAR
)
{
}
Type
getType
()
const
{
return
mType
;
}
double
getDoubleValue
()
const
{
return
doubleValue
;
}
int32_t
getIntValue
()
const
{
return
doubleValue
;
}
uint32_t
getUintValue
()
const
{
return
doubleValue
;
}
std
::
string
getStringValue
()
const
{
return
stringValue
;
}
std
::
string
toString
(
CssTag
tag
)
const
;
void
setDoubleValue
(
double
v
)
{
mType
=
DOUBLE
;
doubleValue
=
v
;
}
void
setStringValue
(
const
std
::
string
&
v
)
{
mType
=
STRING
;
stringValue
=
v
;
}
private:
Type
mType
;
double
doubleValue
;
std
::
string
stringValue
;
Units
mUnits
;
};
class
CssProperties
{
public:
bool
parse
(
const
std
::
string
&
str
);
bool
hasTag
(
CssTag
tag
)
const
;
CssValue
value
(
CssTag
tag
)
const
;
// primarily for debugging
std
::
string
toString
()
const
;
private:
// We'll use STL map for now but can replace it with something
// more efficient if needed
std
::
map
<
CssTag
,
CssValue
>
mMap
;
};
}
// namespace android
#endif // MINIKIN_CSS_PARSE_H
include/minikin/Layout.h
浏览文件 @
d50c99df
...
...
@@ -21,7 +21,6 @@
#include <vector>
#include <minikin/CssParse.h>
#include <minikin/FontCollection.h>
#include <minikin/MinikinFontFreeType.h>
...
...
@@ -68,10 +67,6 @@ public:
void
dump
()
const
;
void
setFontCollection
(
const
FontCollection
*
collection
);
// Deprecated. Will be removed.
void
doLayout
(
const
uint16_t
*
buf
,
size_t
start
,
size_t
count
,
size_t
bufSize
,
const
std
::
string
&
css
);
void
doLayout
(
const
uint16_t
*
buf
,
size_t
start
,
size_t
count
,
size_t
bufSize
,
int
bidiFlags
,
const
FontStyle
&
style
,
const
MinikinPaint
&
paint
);
...
...
libs/minikin/Android.mk
浏览文件 @
d50c99df
...
...
@@ -20,7 +20,6 @@ include external/stlport/libstlport.mk
LOCAL_SRC_FILES
:=
\
AnalyzeStyle.cpp
\
CmapCoverage.cpp
\
CssParse.cpp
\
FontCollection.cpp
\
FontFamily.cpp
\
GraphemeBreak.cpp
\
...
...
libs/minikin/CssParse.cpp
已删除
100644 → 0
浏览文件 @
83d5a3c5
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string>
#include <cstdlib>
#include <cstring>
#include <cstdio> // for sprintf - for debugging
#include <minikin/CssParse.h>
#include <minikin/FontFamily.h>
using
std
::
map
;
using
std
::
pair
;
using
std
::
string
;
namespace
android
{
static
bool
strEqC
(
const
string
str
,
size_t
off
,
size_t
len
,
const
char
*
str2
)
{
if
(
len
!=
strlen
(
str2
))
return
false
;
return
!
memcmp
(
str
.
data
()
+
off
,
str2
,
len
);
}
static
CssTag
parseTag
(
const
string
str
,
size_t
off
,
size_t
len
)
{
if
(
len
==
0
)
return
unknown
;
char
c
=
str
[
off
];
if
(
c
==
'f'
)
{
if
(
strEqC
(
str
,
off
,
len
,
"font-scale-x"
))
return
fontScaleX
;
if
(
strEqC
(
str
,
off
,
len
,
"font-size"
))
return
fontSize
;
if
(
strEqC
(
str
,
off
,
len
,
"font-skew-x"
))
return
fontSkewX
;
if
(
strEqC
(
str
,
off
,
len
,
"font-weight"
))
return
fontWeight
;
if
(
strEqC
(
str
,
off
,
len
,
"font-style"
))
return
fontStyle
;
}
else
if
(
c
==
'l'
)
{
if
(
strEqC
(
str
,
off
,
len
,
"lang"
))
return
cssLang
;
if
(
strEqC
(
str
,
off
,
len
,
"letter-spacing"
))
return
letterSpacing
;
}
else
if
(
c
==
'-'
)
{
if
(
strEqC
(
str
,
off
,
len
,
"-minikin-bidi"
))
return
minikinBidi
;
if
(
strEqC
(
str
,
off
,
len
,
"-minikin-hinting"
))
return
minikinHinting
;
if
(
strEqC
(
str
,
off
,
len
,
"-minikin-variant"
))
return
minikinVariant
;
if
(
strEqC
(
str
,
off
,
len
,
"-paint-flags"
))
return
paintFlags
;
}
return
unknown
;
}
static
bool
parseStringValue
(
const
string
&
str
,
size_t
*
off
,
size_t
len
,
CssTag
tag
,
CssValue
*
v
)
{
const
char
*
data
=
str
.
data
();
size_t
beg
=
*
off
;
if
(
beg
==
len
)
return
false
;
char
first
=
data
[
beg
];
bool
quoted
=
false
;
if
(
first
==
'\''
||
first
==
'\"'
)
{
quoted
=
true
;
beg
++
;
}
size_t
end
;
for
(
end
=
beg
;
end
<
len
;
end
++
)
{
char
c
=
data
[
end
];
if
(
quoted
&&
c
==
first
)
{
v
->
setStringValue
(
std
::
string
(
str
,
beg
,
end
-
beg
));
*
off
=
end
+
1
;
return
true
;
}
else
if
(
!
quoted
&&
(
c
==
';'
||
c
==
' '
))
{
break
;
}
// TODO: deal with backslash escape, but only important for real strings
}
v
->
setStringValue
(
std
::
string
(
str
,
beg
,
end
-
beg
));
*
off
=
end
;
return
true
;
}
static
bool
parseValue
(
const
string
&
str
,
size_t
*
off
,
size_t
len
,
CssTag
tag
,
CssValue
*
v
)
{
if
(
tag
==
cssLang
)
{
return
parseStringValue
(
str
,
off
,
len
,
tag
,
v
);
}
const
char
*
data
=
str
.
data
();
char
*
endptr
;
double
fv
=
strtod
(
data
+
*
off
,
&
endptr
);
if
(
endptr
==
data
+
*
off
)
{
// No numeric value, try tag-specific idents
size_t
end
;
for
(
end
=
*
off
;
end
<
len
;
end
++
)
{
char
c
=
data
[
end
];
if
(
c
!=
'-'
&&
!
(
c
>=
'a'
&&
c
<=
'z'
)
&&
!
(
c
>=
'0'
&&
c
<=
'9'
))
break
;
}
size_t
taglen
=
end
-
*
off
;
endptr
+=
taglen
;
if
(
tag
==
fontStyle
)
{
if
(
strEqC
(
str
,
*
off
,
taglen
,
"normal"
))
{
fv
=
0
;
}
else
if
(
strEqC
(
str
,
*
off
,
taglen
,
"italic"
))
{
fv
=
1
;
// TODO: oblique, but who really cares?
}
else
{
return
false
;
}
}
else
if
(
tag
==
fontWeight
)
{
if
(
strEqC
(
str
,
*
off
,
taglen
,
"normal"
))
{
fv
=
400
;
}
else
if
(
strEqC
(
str
,
*
off
,
taglen
,
"bold"
))
{
fv
=
700
;
}
else
{
return
false
;
}
}
else
if
(
tag
==
minikinVariant
)
{
if
(
strEqC
(
str
,
*
off
,
taglen
,
"compact"
))
{
fv
=
VARIANT_COMPACT
;
}
else
if
(
strEqC
(
str
,
*
off
,
taglen
,
"elegant"
))
{
fv
=
VARIANT_ELEGANT
;
}
}
else
{
return
false
;
}
}
v
->
setDoubleValue
(
fv
);
*
off
=
endptr
-
data
;
return
true
;
}
string
CssValue
::
toString
(
CssTag
tag
)
const
{
if
(
mType
==
DOUBLE
)
{
if
(
tag
==
fontStyle
)
{
return
doubleValue
?
"italic"
:
"normal"
;
}
else
if
(
tag
==
minikinVariant
)
{
if
(
doubleValue
==
VARIANT_COMPACT
)
return
"compact"
;
if
(
doubleValue
==
VARIANT_ELEGANT
)
return
"elegant"
;
}
char
buf
[
64
];
sprintf
(
buf
,
"%g"
,
doubleValue
);
return
string
(
buf
);
}
else
if
(
mType
==
STRING
)
{
return
stringValue
;
// should probably quote
}
return
""
;
}
bool
CssProperties
::
parse
(
const
string
&
str
)
{
size_t
len
=
str
.
size
();
size_t
i
=
0
;
while
(
true
)
{
size_t
j
=
i
;
while
(
j
<
len
&&
str
[
j
]
==
' '
)
j
++
;
if
(
j
==
len
)
break
;
size_t
k
=
str
.
find_first_of
(
':'
,
j
);
if
(
k
==
string
::
npos
)
{
return
false
;
// error: junk after end
}
CssTag
tag
=
parseTag
(
str
,
j
,
k
-
j
);
#ifdef VERBOSE
printf
(
"parseTag result %d, ijk %lu %lu %lu
\n
"
,
tag
,
i
,
j
,
k
);
#endif
if
(
tag
==
unknown
)
return
false
;
// error: unknown tag
k
++
;
// skip over colon
while
(
k
<
len
&&
str
[
k
]
==
' '
)
k
++
;
if
(
k
==
len
)
return
false
;
// error: missing value
CssValue
v
;
if
(
!
parseValue
(
str
,
&
k
,
len
,
tag
,
&
v
))
break
;
#ifdef VERBOSE
printf
(
"parseValue ok
\n
"
);
#endif
mMap
.
insert
(
pair
<
CssTag
,
CssValue
>
(
tag
,
v
));
while
(
k
<
len
&&
str
[
k
]
==
' '
)
k
++
;
if
(
k
<
len
)
{
if
(
str
[
k
]
!=
';'
)
return
false
;
k
++
;
}
i
=
k
;
}
return
true
;
}
bool
CssProperties
::
hasTag
(
CssTag
tag
)
const
{
return
(
mMap
.
find
(
tag
)
!=
mMap
.
end
());
}
CssValue
CssProperties
::
value
(
CssTag
tag
)
const
{
map
<
CssTag
,
CssValue
>::
const_iterator
it
=
mMap
.
find
(
tag
);
if
(
it
==
mMap
.
end
())
{
CssValue
unknown
;
return
unknown
;
}
else
{
return
it
->
second
;
}
}
string
CssProperties
::
toString
()
const
{
string
result
;
for
(
map
<
CssTag
,
CssValue
>::
const_iterator
it
=
mMap
.
begin
();
it
!=
mMap
.
end
();
it
++
)
{
result
+=
cssTagNames
[
it
->
first
];
result
+=
": "
;
result
+=
it
->
second
.
toString
(
it
->
first
);
result
+=
";
\n
"
;
}
return
result
;
}
}
// namespace android
libs/minikin/Layout.cpp
浏览文件 @
d50c99df
...
...
@@ -354,27 +354,6 @@ int Layout::findFace(FakedFont face, LayoutContext* ctx) {
return
ix
;
}
static
FontStyle
styleFromCss
(
const
CssProperties
&
props
)
{
int
weight
=
4
;
if
(
props
.
hasTag
(
fontWeight
))
{
weight
=
props
.
value
(
fontWeight
).
getIntValue
()
/
100
;
}
bool
italic
=
false
;
if
(
props
.
hasTag
(
fontStyle
))
{
italic
=
props
.
value
(
fontStyle
).
getIntValue
()
!=
0
;
}
FontLanguage
lang
;
if
(
props
.
hasTag
(
cssLang
))
{
string
langStr
=
props
.
value
(
cssLang
).
getStringValue
();
lang
=
FontLanguage
(
langStr
.
c_str
(),
langStr
.
size
());
}
int
variant
=
0
;
if
(
props
.
hasTag
(
minikinVariant
))
{
variant
=
props
.
value
(
minikinVariant
).
getIntValue
();
}
return
FontStyle
(
lang
,
variant
,
weight
,
italic
);
}
static
hb_script_t
codePointToScript
(
hb_codepoint_t
codepoint
)
{
static
hb_unicode_funcs_t
*
u
=
0
;
if
(
!
u
)
{
...
...
@@ -495,30 +474,6 @@ static void clearHbFonts(LayoutContext* ctx) {
ctx
->
hbFonts
.
clear
();
}
void
Layout
::
doLayout
(
const
uint16_t
*
buf
,
size_t
start
,
size_t
count
,
size_t
bufSize
,
const
string
&
css
)
{
CssProperties
props
;
props
.
parse
(
css
);
FontStyle
style
=
styleFromCss
(
props
);
MinikinPaint
paint
;
paint
.
size
=
props
.
value
(
fontSize
).
getDoubleValue
();
paint
.
scaleX
=
props
.
hasTag
(
fontScaleX
)
?
props
.
value
(
fontScaleX
).
getDoubleValue
()
:
1
;
paint
.
skewX
=
props
.
hasTag
(
fontSkewX
)
?
props
.
value
(
fontSkewX
).
getDoubleValue
()
:
0
;
paint
.
letterSpacing
=
props
.
hasTag
(
letterSpacing
)
?
props
.
value
(
letterSpacing
).
getDoubleValue
()
:
0
;
paint
.
paintFlags
=
props
.
hasTag
(
paintFlags
)
?
props
.
value
(
paintFlags
).
getUintValue
()
:
0
;
int
bidiFlags
=
props
.
hasTag
(
minikinBidi
)
?
props
.
value
(
minikinBidi
).
getIntValue
()
:
0
;
doLayout
(
buf
,
start
,
count
,
bufSize
,
bidiFlags
,
style
,
paint
);
}
void
Layout
::
doLayout
(
const
uint16_t
*
buf
,
size_t
start
,
size_t
count
,
size_t
bufSize
,
int
bidiFlags
,
const
FontStyle
&
style
,
const
MinikinPaint
&
paint
)
{
AutoMutex
_l
(
gMinikinLock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录