Not much doing aesthetics wise with todayโs improvements on yesterdayโs Local Fonts Revisited Application Tutorial. Itโs more a shoring up of the logic of that div contenteditable=true user defined field and incorporating two new ideas or concepts, those being โฆ
- a decision for the divโs onblur and onchange event logics to start with a scenario where innerHTML is equivalent to (innerText || contentWindow || contentDocument) before building all the imagery needed for the whole div content (ie. like changing from an SQL UPDATE idea to a DELETE/INSERT paradigm) โฆ and for this we developed methodologies whereby โฆ
- the img (local font) insertions can be converted back to either โฆ
- โspanizedโ form (ie. as span element) โฆor โฆ
- straight text
โฆ either of which can then get you back to โstraight textโ with the โฆ
var outsidec=('' + (divo.innerText || divo.contentWindow || divo.contentDocument));
โฆ again
At first we thought Javascript [String].split(โ<imgโ) thoughts, but soon realized what would be much neater (and cuter) would be to โinfuseโ into the img elements onclick logic to self destruct. We like this because โฆ
- the onclick event has the scope to know about its title property or a global data attributes โdata-indexโ we start using today (and access via [divObject].getAttribute(โdata-indexโ)) โฆ as well as the fact that โฆ
- the onclick event can be accessed programmatically via the [imgObject].click() Javascript functionality โฆ and so lends itself to โฆ
- a sequence of [imgObject].click() calls โdo a procedure maketh for (var ijh=0; ijh<imgids.length; ijh++) { selfdestruct(ijh,โ); }โ (like up where we wanted to help with โimg (local font) insertions can be converted backโ)
Hereโs the img element onclick logic function โฆ
function selfdestruct(indx,ititle) {
var issa=[];
if (imgids.length > indx) {
var inc=imgids[indx].split(String.fromCharCode(9))[0];
var parid=imgids[indx].split(String.fromCharCode(9))[1];
var csid=imgids[indx].split(String.fromCharCode(9))[2];
var atti=imgids[indx].split(String.fromCharCode(9))[3];
var ih=String.fromCharCode(eval('' + inc.replace('ximage','').replace('image','')));
var intag='img';
if (1 == 3 && document.getElementsByClassName) {
issa=document.getElementsByClassName(inc);
var iil=0; //for (var iil=0; iil<issa.length; iil++) {
if (ititle != '') {
for (iil=0; iil<issa.length; iil++) {
if (issa[iil].outerHTML.indexOf(' data-index=') != -1) {
if (ititle == issa[iil].getAttribute('data-index')) {
document.getElementById(parid).innerHTML=document.getElementById(parid).innerHTML.replace(issa[iil].outerHTML, '<span class="' + csid + '">' + ih + '</span>');
}
} else {
if (ititle == issa[iil].title) {
document.getElementById(parid).innerHTML=document.getElementById(parid).innerHTML.replace(issa[iil].outerHTML, '<span class="' + csid + '">' + ih + '</span>');
}
}
}
} else if (issa.length > 0) {
document.getElementById(parid).innerHTML=document.getElementById(parid).innerHTML.replace(issa[iil].outerHTML, '<span class="' + csid + '">' + ih + '</span>');
}
} else {
var ijl;
var huhs=document.getElementsByTagName(intag);
for (ijl=0; ijl<huhs.length; ijl++) {
if (huhs[ijl].className.indexOf(inc) != -1) {
issa.push(huhs[ijl]);
}
}
var il=0; //for (var il=0; il<issa.length; il++) {
if (ititle != '') {
for (il=0; il<issa.length; il++) {
if (issa[il].outerHTML.indexOf(' data-index=') != -1) {
if (ititle == issa[il].getAttribute('data-index')) {
document.getElementById(parid).innerHTML=document.getElementById(parid).innerHTML.replace(issa[il].outerHTML, '<span class="' + csid + '">' + ih + '</span>');
}
} else {
if (ititle == issa[il].title) {
document.getElementById(parid).innerHTML=document.getElementById(parid).innerHTML.replace(issa[il].outerHTML, '<span class="' + csid + '">' + ih + '</span>');
}
}
}
} else if (issa.length > 0) {
document.getElementById(parid).innerHTML=document.getElementById(parid).innerHTML.replace(issa[il].outerHTML, '<span class="' + csid + '">' + ih + '</span>');
}
}
}
}
โฆ instigated in the changed calling arrangement (for that div contenteditable=true red bordered element) โฆ
imgids.push('ximage' + ic + String.fromCharCode(9) + 'arialdiv' + String.fromCharCode(9) + 'span' + outsidec.substring(ii, eval(1 + ii)) + String.fromCharCode(9) + eval(-1 + imgids.length));
dcs=docgetclasssub('span' + outsidec.substring(ii, eval(1 + ii)).charCodeAt(), 'span', document.getElementById('ximage' + ic).outerHTML.replace(' id=', ' class=').replace('<img','<img title="Click to reveal original font character" data-index="' + eval(-1 + imgids.length) + '" onclick="selfdestruct(' + eval(-1 + imgids.length) + ',' + eval(-1 + imgids.length) + ');"'));
for (var idcs=1; idcs<dcs.length; idcs++) {
imgids.push('ximage' + ic + String.fromCharCode(9) + 'arialdiv' + String.fromCharCode(9) + 'span' + outsidec.substring(ii, eval(1 + ii)) + String.fromCharCode(9) + eval(-1 + imgids.length));
}
To see these ideas in play, you can see this idea play out at thechanged under_local_fonthtmlโs live
run link.
Previous relevant Local Fonts Revisited Application Tutorial is shown below.
Itโs going to take a while to โbed this inโ, the web application of yesterdayโs Local Fonts Revisited Recall Tutorial involving local font management, and now thinking about โapplyingโ local fonts digitized by the user.
We want to explore alternative ideas to โฆ
- character by character traversal of an HTML element (with innerHTML โฆ the raw textual wording of which can be gleaned via code like (for HTML element object โdivoโ)) โฆ
var outsidec=('' + (divo.innerText || divo.contentWindow || divo.contentDocument));
โฆ for chances of โfont character imageโ substitution to the innerHTML content โฆ because it can be slow (though we think we can improve on that slowness, in future code releases) โฆ so today we look to โฆ - idea of applying a โbackground image strip version of the textual contentโ brought to the fore (which can mean retract whatโs there to the back) only where a user defined font character exists โฆ alas, we discovered (without a lot more effort (we may yet do)) this only suits monospaced fonts such as Courier New (going back to that decision we made that the digitizing canvas should be 70 x 70)
At first we tried that linear gradient thought that a background might โglow aboveโ the foreground (tee hee, but seriously, this technique does suit sometimes, as with Javascript and PHP Base64 Media Tutorial). But then we saw sense and to โretract whatโs there to the backโ we could set the existant element CSS property color:transparent, opening the door to the plan below.
The plan we have going forward with this approach goes like โฆ
- find text elements with defined innerHTML โฆ that โฆ
- have a defined โIDโ โฆ and โฆ
- apart from <br> and > and < and & and if innerHTML is equivalent to (innerText || contentWindow || contentDocument) โฆ we โฆ
- CSS (via Javascript DOM) โฆ
- document.getElementById(โarial_spanโ).style.color = โtransparentโ;
- document.getElementById(โarial_spanโ).style.backgroundRepeat = โno-repeatโ;
- document.getElementById(โarial_spanโ).style.backgroundSize=โ105% 100%โ;
- letsomethrough( document.getElementById(โarial_spanโ) ).style.backgroundImage = โURL(โโ + document.getElementById(โifsrcโ).src.replace(โ?ipinto=yโ, document.getElementById(โipintoโ).value) + โโ)โ;
- โspanizeโ the parent text element as above via that Javascript function letsomethrough by nesting all โlonelyโ (find in code later below where var outside is true) text characters within a โฆ
- span element (why span? โฆ because it is CSS display:inline) โฆ that if for a letter (as per the โwโ of below) digitized by the user โฆ
- will inherit its colour from the parent (ie. be transparent, and allow the background imagery to โshine throughโ, via <span>w</span>) โฆ whereas if for a letter not digitized by the user โฆ
- we define the colour to be black, overriding transparent, via <span style=โcolor:black;โ>w</span>
As you can see, this is ongoing, and we hope to iron out some of the restrictiveness and get to cross browser issues and โapplyโ to real world data, such as this blog contents, perhaps.
In the meantime, see this idea play out at thechanged under_local_fonthtmlโs live
run link.
You can also see this play out at WordPress 4.1.1โs Local Fonts Revisited Application Tutorial.
Previous relevant Local Fonts Revisited Recall Tutorial is shown below.
Onto yesterdayโs Local Fonts Revisited Primer Tutorial Local Fonts web application start, weโve progressed today with some โrecallโ work.
In this respect we had to decide a mechanism by which a user could recall their work. Our decision is to โฆ
- be saving user defined font characters into a long โcanvasโ strip element โฆ and โฆ
- allow a โSaveโ button be pressed โฆ to โฆ
- convert that โcanvasโ strip element to data URI and subsequently to a web server image file (via PHP) โฆ that has a filename whereby โฆ
- on web application rerun if such a Local Fonts web server image file is found (via PHP) โฆ this triggers โฆ
- a select (dropdown) element appears in the h1 heading element allowing the user to โrecallโ that Local Font work โฆin which case โฆ
- a long โcanvasโ strip element appears with these Local Font characters โฆ and tomorrow โฆ
โฆ leaving tomorrowโs work to โmeldโ that recall data into the natural workflow of that previous work.
Itโs best you view thechanged under_local_fonthtmlโs live
run link to see what we mean here, getting the [canvasContext].drawImage() functionality to be able to draw multiple images into a single canvas element, the curiosity being that we needed to โฆ
function athy() {
var xid='';
if (lastcid != cid) {
lastcid=cid;
compcanv=document.getElementById('compositeimages');
compcanvc=compcanv.getContext('2d');
var isd=docgetclass('athy', 'img');
for (var jsd=0; jsd<isd.length; jsd++) {
xid=String.fromCharCode(eval('' + isd[jsd].id.replace('image','')));
curx=eval(70 * eval('' + origlist.indexOf(xid)));
compcanvc.drawImage(document.getElementById(isd[jsd].id),0,0,70,70,curx,cury,70,70);
}
}
}
โฆ a form of verbosity we were not expecting but required because the canvas would clear in between Local Font character definitions.
Previous relevant Local Fonts Revisited Primer Tutorial is shown below.
Working off our work on the Textarea Pointing web application of the series of blog postings ending with Textarea Pointing Local Font Canvas Overlay Deletes Tutorial today weโre starting out on a Local Fonts web application journey.
At this early stage weโre missing a bit of accountability and recall but we have worked a way to combine โฆ
- proper web font text characters โฆ with โฆ
- tailored canvas drawn โscribbleโ Local Font alternatives โฆ within a grandchild child iframe element โฆ the in between child iframe called via the srcdoc content mode of populating
The user can see these characters โinfiltrateโ text strings there on the webpage, one โฆ
- a list of the ascii characters weโre dealing with using these Local Fonts โฆ and the other โฆ
- a user controllable HTML div contenteditable=true text string that dynamically changes appropriately as the user defines their Local Font characters
Like the idea? Well, follow the journey in the days to follow todayโs โproof of conceptโ under_local_fonthtml live
run link.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.