Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
fe6bef23
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fe6bef23
编写于
2月 02, 2020
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stb_truetype: clean up svg support
上级
ade80f46
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
15 deletion
+25
-15
stb_truetype.h
stb_truetype.h
+25
-15
未找到文件。
stb_truetype.h
浏览文件 @
fe6bef23
...
...
@@ -833,7 +833,7 @@ STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertice
STBTT_DEF
int
stbtt_GetCodepointSVG
(
const
stbtt_fontinfo
*
info
,
int
unicode_codepoint
,
const
char
**
svg
);
STBTT_DEF
int
stbtt_GetGlyphSVG
(
const
stbtt_fontinfo
*
info
,
int
gl
,
const
char
**
svg
);
// fills svg with the
font
's SVG data.
// fills svg with the
character
's SVG data.
// returns data size or 0 if SVG not found.
//////////////////////////////////////////////////////////////////////////////
...
...
@@ -1337,6 +1337,22 @@ static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict)
return
stbtt__cff_get_index
(
&
cff
);
}
// since most people won't use this, find this table the first time it's needed
static
int
stbtt__get_svg
(
stbtt_fontinfo
*
info
)
{
stbtt_uint32
t
;
if
(
info
->
svg
<
0
)
{
t
=
stbtt__find_table
(
info
->
data
,
info
->
fontstart
,
"SVG "
);
if
(
t
)
{
stbtt_uint32
offset
=
ttULONG
(
info
->
data
+
t
+
2
);
info
->
svg
=
t
+
offset
;
}
else
{
info
->
svg
=
0
;
}
}
return
info
->
svg
;
}
static
int
stbtt_InitFont_internal
(
stbtt_fontinfo
*
info
,
unsigned
char
*
data
,
int
fontstart
)
{
stbtt_uint32
cmap
,
t
;
...
...
@@ -1416,14 +1432,8 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in
else
info
->
numGlyphs
=
0xffff
;
t
=
stbtt__find_table
(
data
,
fontstart
,
"SVG "
);
if
(
t
)
{
stbtt_uint32
offset
=
ttULONG
(
data
+
t
+
2
);
info
->
svg
=
t
+
offset
;
}
else
{
info
->
svg
=
0
;
}
info
->
svg
=
-
1
;
// find a cmap encoding table we understand *now* to avoid searching
// later. (todo: could make this installable)
// the same regardless of glyph.
...
...
@@ -2618,17 +2628,17 @@ STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
STBTT_DEF
stbtt_uint8
*
stbtt_FindSVGDoc
(
const
stbtt_fontinfo
*
info
,
int
gl
)
{
int
i
;
stbtt_uint8
*
data
=
info
->
data
;
stbtt_uint8
*
svg_doc_list
=
data
+
info
->
svg
;
stbtt_uint8
*
svg_doc_list
=
data
+
stbtt__get_svg
((
stbtt_fontinfo
*
)
info
)
;
int
numEntries
=
ttUSHORT
(
svg_doc_list
);
stbtt_uint8
*
svg_docs
=
svg_doc_list
+
2
;
for
(
i
nt
i
=
0
;
i
<
numEntries
;
i
++
)
{
for
(
i
=
0
;
i
<
numEntries
;
i
++
)
{
stbtt_uint8
*
svg_doc
=
svg_docs
+
(
12
*
i
);
printf
(
"%lx - %lx - %lx %lx
\n
"
,
ttUSHORT
(
svg_doc
),
ttUSHORT
(
svg_doc
+
2
),
ttULONG
(
svg_doc
+
4
),
ttULONG
(
svg_doc
+
8
));
if
((
gl
>=
ttUSHORT
(
svg_doc
))
&&
(
gl
<=
ttUSHORT
(
svg_doc
+
2
)))
return
svg_doc
;
if
((
gl
>=
ttUSHORT
(
svg_doc
))
&&
(
gl
<=
ttUSHORT
(
svg_doc
+
2
)))
return
svg_doc
;
}
return
0
;
}
...
...
@@ -2642,7 +2652,7 @@ STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char *
return
0
;
if
(
svg_doc
=
stbtt_FindSVGDoc
(
info
,
gl
))
{
*
svg
=
(
void
*
)
data
+
info
->
svg
+
ttULONG
(
svg_doc
+
4
);
*
svg
=
(
char
*
)
data
+
info
->
svg
+
ttULONG
(
svg_doc
+
4
);
return
ttULONG
(
svg_doc
+
8
);
}
else
{
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录