Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
check
Overview
Overview
Details
Activity
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_web
check
Commits
60e618e4
Commit
60e618e4
authored
May 21, 2015
by
vietdo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#13518 [AAT
1.5]大きさや色を様々なものにしたリッチテキストコンテンツをプレビュー表示すると、オブジェクト上では改行していないのに改行して表示されている
parent
7ea37699
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
20 deletions
+42
-20
abvw/common/js/textObject.js
+42
-20
No files found.
abvw/common/js/textObject.js
View file @
60e618e4
...
@@ -27,20 +27,23 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -27,20 +27,23 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
var
hasUnderLine
=
false
;
// アンダーラインの有無
var
hasUnderLine
=
false
;
// アンダーラインの有無
var
textAlign
=
'left'
;
// テキスト揃え
var
textAlign
=
'left'
;
// テキスト揃え
var
margin
=
2
;
var
margin
=
2
;
var
newLine
=
false
;
var
startPoint
=
0
;
var
flag
=
0
;
var
frontLine
=
0
;
var
startRight
=
0
;
/* remove escape charactor '\' */
/* remove escape charactor '\' */
dataHtml
=
htmlData
.
replace
(
/
\\
/
,
''
);
dataHtml
=
htmlData
.
replace
(
/
\\
/
,
''
);
//dataHtml = dataHtml.toLowerCase();
//dataHtml = dataHtml.toLowerCase();
console
.
log
(
dataHtml
)
//console.log('dataHtml:' + dataHtml);
//console.log('dataHtml:' + dataHtml);
// parse
// parse
HTMLParser
(
dataHtml
,
HTMLParser
(
dataHtml
,
{
{
start
:
function
(
tag
,
attrs
,
unary
)
{
start
:
function
(
tag
,
attrs
,
unary
)
{
console
.
log
(
attrs
);
var
t
=
tag
.
toLowerCase
();
var
t
=
tag
.
toLowerCase
();
/*
/*
* DIVタグ
* DIVタグ
*/
*/
...
@@ -49,8 +52,11 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -49,8 +52,11 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
for
(
var
i
=
0
;
i
<
attrs
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
attrs
.
length
;
i
++
)
{
var
attrName
=
attrs
[
i
].
name
.
toLowerCase
();
var
attrName
=
attrs
[
i
].
name
.
toLowerCase
();
if
(
attrName
==
'align'
)
{
if
(
attrName
==
'align'
)
{
newLine
=
true
;
align
=
attrs
[
i
].
escaped
;
align
=
attrs
[
i
].
escaped
;
textAlign
=
align
;
textAlign
=
align
;
}
else
{
newLine
=
false
;
}
}
}
}
if
(
align
==
'left'
)
{
if
(
align
==
'left'
)
{
...
@@ -64,7 +70,6 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -64,7 +70,6 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
context
.
textAlign
=
'right'
;
context
.
textAlign
=
'right'
;
}
}
}
}
/*
/*
* FONTタグ
* FONTタグ
*/
*/
...
@@ -72,6 +77,7 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -72,6 +77,7 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
var
fontFace
=
'MS Pゴシック'
;
var
fontFace
=
'MS Pゴシック'
;
var
fontSize
=
'11px'
;
var
fontSize
=
'11px'
;
var
fontColor
=
'#000000'
;
var
fontColor
=
'#000000'
;
newLine
=
false
;
for
(
var
i
=
0
;
i
<
attrs
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
attrs
.
length
;
i
++
)
{
var
attrName
=
attrs
[
i
].
name
.
toLowerCase
();
var
attrName
=
attrs
[
i
].
name
.
toLowerCase
();
...
@@ -111,19 +117,27 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -111,19 +117,27 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
if
(
t
==
'br'
)
{
if
(
t
==
'br'
)
{
currentLine
+=
(
nextLinePosition
+
margin
);
currentLine
+=
(
nextLinePosition
+
margin
);
}
}
if
(
newLine
==
true
&&
flag
>
0
)
{
frontLine
=
currentLine
;
currentLine
+=
nextLinePosition
;
}
else
if
(
flag
==
0
){
currentLine
=
20
;
}
flag
++
;
/*
/*
* Uタグ
* Uタグ
*/
*/
if
(
t
==
'u'
)
{
if
(
t
==
'u'
)
{
hasUnderLine
=
true
;
hasUnderLine
=
true
;
}
else
{
hasUnderLine
=
false
;
}
}
},
},
end
:
function
(
tag
)
{
end
:
function
(
tag
)
{
var
t
=
tag
.
toLowerCase
();
var
t
=
tag
.
toLowerCase
();
console
.
log
(
"the"
+
t
);
/*
/*
* Uタグ
* Uタグ
*/
*/
...
@@ -133,7 +147,6 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -133,7 +147,6 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
},
},
chars
:
function
(
text
)
{
chars
:
function
(
text
)
{
// エンティティ文字を置換
// エンティティ文字を置換
// > < & ¥ © ® のみ対応
// > < & ¥ © ® のみ対応
text
=
text
.
replace
(
/ /g
,
' '
);
text
=
text
.
replace
(
/ /g
,
' '
);
...
@@ -143,11 +156,10 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -143,11 +156,10 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
text
=
text
.
replace
(
/©/g
,
'(C)'
);
text
=
text
.
replace
(
/©/g
,
'(C)'
);
text
=
text
.
replace
(
/®/g
,
'(R)'
);
text
=
text
.
replace
(
/®/g
,
'(R)'
);
text
=
text
.
replace
(
/¥/g
,
'
\
\'
);
text
=
text
.
replace
(
/¥/g
,
'
\
\'
);
// 初期描画位置を考慮
// 初期描画位置を考慮
if (currentLine == 0) {
if (currentLine == 0) {
//2014/02 フォントを大きくすると文字の上側が隠れる問題の対応
//2014/02 フォントを大きくすると文字の上側が隠れる問題の対応
//
currentLine += nextLinePosition / 2;
//
currentLine += nextLinePosition / 2;
currentLine += nextLinePosition;
currentLine += nextLinePosition;
}
}
...
@@ -173,7 +185,6 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -173,7 +185,6 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
context.strokeStyle = context.fillStyle;
context.strokeStyle = context.fillStyle;
context.stroke();
context.stroke();
}
}
currentLine += (nextLinePosition + margin);
currentLine += (nextLinePosition + margin);
fillText = text.charAt(i);
fillText = text.charAt(i);
}
}
...
@@ -183,15 +194,25 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -183,15 +194,25 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
// アンダーライン
// アンダーライン
if (hasUnderLine) {
if (hasUnderLine) {
var x1, x2;
var x1, x2;
if(currentLine > frontLine) {
if(newLine == false) {
startPoint = startPosition;
} else {
startPoint = 0;
startPosition = 0;
}
} else {
startPoint = startPosition;
}
if (textAlign == '
left
') {
if (textAlign == '
left
') {
x1 =
0
;
x1 =
startPoint
;
x2 = metrices.width;
x2 =
startPoint +
metrices.width;
} else if (textAlign == '
center
') {
} else if (textAlign == '
center
') {
x1 = startPo
sition
- (metrices.width / 2);
x1 = startPo
int
- (metrices.width / 2);
x2 = startPo
sition
+ (metrices.width / 2);
x2 = startPo
int
+ (metrices.width / 2);
} else if (textAlign =
-
'
right
') {
} else if (textAlign = '
right
') {
x1 =
startPosition
;
x1 =
width
;
x2 =
startPosition
- metrices.width;
x2 =
width
- metrices.width;
}
}
context.beginPath();
context.beginPath();
context.moveTo(x1, currentLine + margin);
context.moveTo(x1, currentLine + margin);
...
@@ -199,12 +220,13 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
...
@@ -199,12 +220,13 @@ TEXTOBJECT.getTextObjectImage = function(width, height, htmlData) {
context.strokeStyle = context.fillStyle;
context.strokeStyle = context.fillStyle;
context.stroke();
context.stroke();
}
}
currentLine += (nextLinePosition + margin);
startPosition +=metrices.width;
//currentLine += (nextLinePosition + margin);
}
}
}
}
}
}
);
);
//context.fillText("helloworld",0, currentLine + margin);
// 描画したイメージを返却する
// 描画したイメージを返却する
var imageUrl = canvas.toDataURL();
var imageUrl = canvas.toDataURL();
return imageUrl;
return imageUrl;
...
...
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