Commit d6afd57d by ramdayalmunda

custom line fixes

parent a91248d9
......@@ -10,7 +10,7 @@ var ADocEditor = function (customConfig) {
element: "",
pageSetup: {
width: 210,
height: 140,
height: 110,
},
format: {
background: "#fff",
......@@ -19,7 +19,7 @@ var ADocEditor = function (customConfig) {
fontSize: 10,
},
style: {
fontSize: 70,
fontSize: 30,
fontFamily: 'Arial',
bold: false,
italic: false,
......@@ -136,6 +136,8 @@ var ADocEditor = function (customConfig) {
})
reRenderPages(dataSet)
removeStyles(dataSet)
}
function reRenderPages(dataList) {
......@@ -163,13 +165,44 @@ var ADocEditor = function (customConfig) {
renderText(canvas, dataList[i])
}
function renderText(canvas, dataBlock) {
console.log('to render text', dataBlock)
let ctx = canvas.getContext('2d', { willReadFrequently: true })
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
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()
......@@ -334,6 +367,15 @@ var ADocEditor = function (customConfig) {
}
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