Commit d6afd57d by ramdayalmunda

custom line fixes

parent a91248d9
...@@ -10,7 +10,7 @@ var ADocEditor = function (customConfig) { ...@@ -10,7 +10,7 @@ var ADocEditor = function (customConfig) {
element: "", element: "",
pageSetup: { pageSetup: {
width: 210, width: 210,
height: 140, height: 110,
}, },
format: { format: {
background: "#fff", background: "#fff",
...@@ -19,7 +19,7 @@ var ADocEditor = function (customConfig) { ...@@ -19,7 +19,7 @@ var ADocEditor = function (customConfig) {
fontSize: 10, fontSize: 10,
}, },
style: { style: {
fontSize: 70, fontSize: 30,
fontFamily: 'Arial', fontFamily: 'Arial',
bold: false, bold: false,
italic: false, italic: false,
...@@ -136,6 +136,8 @@ var ADocEditor = function (customConfig) { ...@@ -136,6 +136,8 @@ var ADocEditor = function (customConfig) {
}) })
reRenderPages(dataSet) reRenderPages(dataSet)
removeStyles(dataSet)
} }
function reRenderPages(dataList) { function reRenderPages(dataList) {
...@@ -163,13 +165,44 @@ var ADocEditor = function (customConfig) { ...@@ -163,13 +165,44 @@ var ADocEditor = function (customConfig) {
renderText(canvas, dataList[i]) renderText(canvas, dataList[i])
} }
function renderText(canvas, dataBlock) { function renderText(canvas, dataBlock) {
console.log('to render text', dataBlock)
let ctx = canvas.getContext('2d', { willReadFrequently: true }) let ctx = canvas.getContext('2d', { willReadFrequently: true })
ctx.save() ctx.save()
ctx.font = `${config.style.fontSize}px ${config.style.fontFamily}`; ctx.fillStyle = "#0006"; ctx.fillText("A", x,y+config.style.fontSize)
// to calculate the lines // to calculate the lines
let dataLineArr = []
let wordsArr = dataBlock.plainContent.split(/\s/);
dataBlock.formatedText = []
let lineObj = {
x: 0,
y: 0,
plainContent: "",
formatedText: [], // { x: 10, y: 25 }, // bold,italic, fontSize, can be pulled from "dataSet"
style: { maxFontSize: 30 }
}
let charIndex = 0
for (let i=0; i<wordsArr.length; i++){
if (i!=0){
charIndex++;
}
// this is to add style on original dataSet
for (let j=0; j<wordsArr[i].length; j++){
// console.log('char:', i, j, wordsArr[i][j], charIndex)
charIndex++
}
}
ctx.fillText( dataBlock.plainContent, 0, 70 )
ctx.restore() ctx.restore()
...@@ -334,6 +367,15 @@ var ADocEditor = function (customConfig) { ...@@ -334,6 +367,15 @@ var ADocEditor = function (customConfig) {
} }
renderInProgress = false renderInProgress = false
} }
function removeStyles(dataList){
for (let i=0; i<dataList.length; i++){
console.log(i, dataList[i])
for(let j=0; j<dataList[i].plainContent.length; j++){
dataList[i].formatedText.push( JSON.parse( JSON.stringify( config.style ) ) )
}
}
console.log('removedStyles',dataList)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment