Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
8939b245
Commit
8939b245
authored
Sep 08, 2015
by
张博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solved the compatibility of browsers
parent
6452c694
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
125 additions
and
10 deletions
+125
-10
text.js
src/module/text.js
+125
-10
No files found.
src/module/text.js
View file @
8939b245
...
...
@@ -7,10 +7,109 @@ define(function(require, exports, module) {
var
Command
=
require
(
'../core/command'
);
var
Module
=
require
(
'../core/module'
);
var
Renderer
=
require
(
'../core/render'
);
/**
* 针对不同系统、不同浏览器、不同字体做居中兼容性处理
* 暂时未增加Linux的处理
*/
var
FONT_ADJUST
=
{
'微软雅黑,Microsoft YaHei'
:
-
0.15
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.15
'safari'
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.17
,
'楷体,楷体_GB2312,SimKai'
:
-
0.1
,
'隶书, SimLi'
:
-
0.1
,
'comic sans ms'
:
-
0.23
,
'impact,chicago'
:
-
0.15
,
'times new roman'
:
-
0.1
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.15
},
'ie'
:
{
10
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.17
,
'comic sans ms'
:
-
0.17
,
'impact,chicago'
:
-
0.08
,
'times new roman'
:
0.04
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.15
},
11
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.17
,
'arial,helvetica,sans-serif'
:
-
0.17
,
'comic sans ms'
:
-
0.17
,
'impact,chicago'
:
-
0.08
,
'times new roman'
:
0.04
,
'sans-serif'
:
-
0.16
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.15
}
},
'edge'
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.15
,
'arial,helvetica,sans-serif'
:
-
0.17
,
'comic sans ms'
:
-
0.17
,
'impact,chicago'
:
-
0.08
,
'sans-serif'
:
-
0.16
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.15
},
'sg'
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.15
,
'arial,helvetica,sans-serif'
:
-
0.05
,
'comic sans ms'
:
-
0.22
,
'impact,chicago'
:
-
0.16
,
'times new roman'
:
-
0.03
,
'arial black,avant garde'
:
-
0.22
,
'default'
:
-
0.15
},
'chrome'
:
{
'Mac'
:
{
'andale mono'
:
-
0.05
,
'comic sans ms'
:
-
0.3
,
'impact,chicago'
:
-
0.13
,
'times new roman'
:
-
0.1
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
0
},
'Win'
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.15
,
'arial,helvetica,sans-serif'
:
-
0.02
,
'arial black,avant garde'
:
-
0.2
,
'comic sans ms'
:
-
0.2
,
'impact,chicago'
:
-
0.12
,
'times new roman'
:
-
0.02
,
'default'
:
-
0.15
},
'Lux'
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.15
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.15
}
},
'firefox'
:
{
'Mac'
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.2
,
'宋体,SimSun'
:
-
0.15
,
'comic sans ms'
:
-
0.2
,
'impact,chicago'
:
-
0.15
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.15
},
'Win'
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.16
,
'andale mono'
:
-
0.17
,
'arial,helvetica,sans-serif'
:
-
0.17
,
'comic sans ms'
:
-
0.22
,
'impact,chicago'
:
-
0.23
,
'times new roman'
:
-
0.22
,
'sans-serif'
:
-
0.22
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.16
},
'Lux'
:
{
'微软雅黑,Microsoft YaHei'
:
-
0.15
,
'arial black,avant garde'
:
-
0.17
,
'default'
:
-
0.15
}
}
};
var
TextRenderer
=
kity
.
createClass
(
'TextRenderer'
,
{
...
...
@@ -36,12 +135,28 @@ define(function(require, exports, module) {
var
height
=
(
lineHeight
*
fontSize
)
*
textArr
.
length
-
(
lineHeight
-
1
)
*
fontSize
;
var
yStart
=
-
height
/
2
;
if
(
kity
.
Browser
.
ie
)
{
var
adjust
=
FONT_ADJUST
[
fontFamily
]
||
0
;
textGroup
.
setTranslate
(
0
,
adjust
*
fontSize
);
var
Browser
=
kity
.
Browser
;
var
adjust
;
if
(
Browser
.
chrome
||
Browser
.
opera
||
Browser
.
bd
||
Browser
.
lb
===
"chrome"
)
{
adjust
=
FONT_ADJUST
[
'chrome'
][
Browser
.
platform
][
fontFamily
];
}
else
if
(
Browser
.
gecko
)
{
adjust
=
FONT_ADJUST
[
'firefox'
][
Browser
.
platform
][
fontFamily
];
}
else
if
(
Browser
.
sg
)
{
adjust
=
FONT_ADJUST
[
'sg'
][
fontFamily
];
}
else
if
(
Browser
.
safari
)
{
adjust
=
FONT_ADJUST
[
'safari'
][
fontFamily
];
}
else
if
(
Browser
.
ie
)
{
adjust
=
FONT_ADJUST
[
'ie'
][
Browser
.
version
][
fontFamily
];
}
else
if
(
Browser
.
edge
)
{
adjust
=
FONT_ADJUST
[
'edge'
][
fontFamily
];
}
else
if
(
Browser
.
lb
)
{
// 猎豹浏览器的ie内核兼容性模式下
adjust
=
0.9
;
}
textGroup
.
setTranslate
(
0
,
(
adjust
||
0
)
*
fontSize
);
var
rBox
=
new
kity
.
Box
(),
r
=
Math
.
round
;
...
...
@@ -62,7 +177,7 @@ define(function(require, exports, module) {
while
(
growth
--
)
{
textShape
=
new
kity
.
Text
()
.
setAttr
(
'text-rendering'
,
'inherit'
);
if
(
kity
.
Browser
.
ie
)
{
if
(
kity
.
Browser
.
ie
||
kity
.
Browser
.
edge
)
{
textShape
.
setVerticalAlign
(
'top'
);
}
else
{
textShape
.
setAttr
(
'dominant-baseline'
,
'text-before-edge'
);
...
...
@@ -72,9 +187,9 @@ define(function(require, exports, module) {
}
for
(
i
=
0
,
text
,
textShape
;
(
text
=
textArr
[
i
],
textShape
=
textGroup
.
getItem
(
i
));
i
++
)
{
(
text
=
textArr
[
i
],
textShape
=
textGroup
.
getItem
(
i
));
i
++
)
{
textShape
.
setContent
(
text
);
if
(
kity
.
Browser
.
ie
)
{
if
(
kity
.
Browser
.
ie
||
kity
.
Browser
.
edge
)
{
textShape
.
fixPosition
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment