Daniel Harrison's Personal Blog

Personal blog for daniel harrison

links for 2010-03-30 March 31, 2010

Filed under: Uncategorized — danielharrison @ 2:03 am
 

Ruling canvas out for text editing March 30, 2010

Filed under: Uncategorized — danielharrison @ 9:23 pm
Tags:

Wrote a quick prototype using canvas as a text editor but have now abandoned it in favour of a contenteditable block with canvas overlays.

The problem for non fixed width fonts is that there’s no way of measuring where each character starts and ends. Due to kerning, aliasing etc. eg {measureText(and again) != measuretext(an) + measureText(d again)} which would be expected. But there’s no way of getting the character offsets of ctx.fillText call. I wrote a quick and dirty manual measure by getting the canvas as an image and finding the start and end pixel of characters but it felt like too much work and contenteditable was just there.

The thing stopping me using contenteditable in the first place was obtaining the screen co-ordinates for the selection is not possible at the moment as far as I can tell. IE has boundingWidth … but firefox or the w3c std doesn’t seem to support this. I’m interested in word selection, not multiparagraphs. As a workaround I clone the contents, surround the word with a div and calculate it’s location and then replace with the original content again, reselecting the original selection. Seems to work ok in both firefox and webkit browsers.

 

links for 2010-03-29

Filed under: Uncategorized — danielharrison @ 2:02 am
 

feedback March 29, 2010

Filed under: Uncategorized — danielharrison @ 11:05 pm
Tags:

Javascript, scala and web applications. I don’t think it’s possible to understate the velocity it’s possible to have when there’s less in the way.

 

links for 2010-03-28

Filed under: Uncategorized — danielharrison @ 2:02 am
 

links for 2010-03-25 March 26, 2010

Filed under: Uncategorized — danielharrison @ 2:01 am
 

links for 2010-03-24 March 25, 2010

Filed under: Uncategorized — danielharrison @ 2:03 am