Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="output"></div>
<div id="hello"></div>
<br>
<div id="world"></div>

              
            
!

CSS

              
                  svg text.sym-line {
    font-family: "SignWriting 2010";
    -moz-font-feature-settings: "liga=1";
    -ms-font-feature-settings: "liga";
    -webkit-font-feature-settings: "liga";
    -o-font-feature-settings: "liga";
    font-feature-settings: "liga";
    fill: black;
    font-size: 30px;
  }
  svg text.sym-fill {
    font-family: "SignWriting 2010 Filling";
    -moz-font-feature-settings: "liga=1";
    -ms-font-feature-settings: "liga";
    -webkit-font-feature-settings: "liga";
    -o-font-feature-settings: "liga";
    font-feature-settings: "liga";
    fill: white;
    font-size: 30px;
  }
              
            
!

JS

              
                function key2code(key){
  code = 0x100000 + ((parseInt(key.slice(1,4),16) - 256) * 96) + ((parseInt(key.slice(4,5),16))*16) + parseInt(key.slice(5,6),16) + 1;
  return String.fromCharCode(0xD800 + ((code - 0x10000) >> 10), 0xDC00 + ((code - 0x10000) & 0x3FF));
}

function getSymSize(key) {
  var count = 0;
  var zoom = 2;
  var bound = 76 * zoom;
  var plus = 3 * zoom;
  var canvas = getSymSize.canvas || (getSymSize.canvas = document.createElement("canvas"));
  canvas.width = bound;
  canvas.height = bound;
  var context = canvas.getContext("2d");
  context.clearRect(0, 0, bound, bound);

  context.font = (30*zoom) + "px 'SignWriting 2010'";
  //context.imageSmoothingEnabled= false;
  context.fillText(key2code(key),0,0);
  var detect = function(x,y,w,h){
    count += 1;
    var line=false;
    try {
	    imgData = context.getImageData(x,y,w,h)
	}
	catch(e){
	  return
	}
    data = imgData.data
    for (var i=data.length; i--;) {
      if (data[i]){ line = true; break; }
    }
    return line;
  }

  var min,max,current,found,foundPlus,width,height;
  min=0;
  max=bound;
  while(min!=(max-1)){ 
    current=parseInt((max+min)/2)
    found = detect(current,0,1,bound);
    foundPlus = detect(current + plus,0,1,bound)
    if (found ){
      min = current
    } else if (foundPlus) {
      min = current+plus;
      if (max<=min) max=min+1;
    } else {
      max = parseInt((max+max+current)/3);
    }
  }
  width = min;

  min=0;
  max=bound;
  while(min!=(max-1)){
    current=parseInt((max+min)/2)
    found = detect(0,current,width,1);
    foundPlus = detect(0,(current + plus),width,1)
    if (found ){
      min = current
    } else if (foundPlus) {
      min = current+plus;
      if (max<=min) max=min+1;
    } else {
      max = parseInt((max+max+current)/3);
    }
  }
  height = max;

  width= '' + (500 + Math.ceil(width/zoom));
  height= '' + (500 + Math.ceil(height/zoom));
  //rounding error appears in chrome, could be FontForge, Potrace, or TrueType based
  if ('S1710d S1711d S1712d S17311 S17321 S17733 S1773f S17743 S1774f S17753 S1775f '.indexOf(key)>-1){
    width = '520';
  }
  size = width + 'x' + height;
  if (size=='500x501') return
  return size;
}

function getSignSvg(fsw,laned){
  var r, rsym, rcoord, sym, syms, coords, o;
  r = /(A(S[123][0-9a-f]{2}[0-5][0-9a-f])+)?[BLMR]([0-9]{3}x[0-9]{3})(S[123][0-9a-f]{2}[0-5][0-9a-f][0-9]{3}x[0-9]{3})*|S38[7-9ab][0-5][0-9a-f][0-9]{3}x[0-9]{3}/g;
  rsym = /S[123][0-9a-f]{2}[0-5][0-9a-f][0-9]{3}x[0-9]{3}/g;
  rcoord = /[0-9]{3}x[0-9]{3}/g;
  o = {};
  o.L = -1;
  o.R = 1;
  var x, x1 = 500,
    x2 = 500,
    y, y1 = 500,
    y2 = 500,
    k, w, h, l;

  k = fsw.charAt(0);
  coords = fsw.match(rcoord);
  for (var i=0; i < coords.length; i++) {
    x = parseInt(coords[i].slice(0, 3));
    y = parseInt(coords[i].slice(4, 7));
    x1 = Math.min(x1, x);
    x2 = Math.max(x2, x);
    y1 = Math.min(y1, y);
    y2 = Math.max(y2, y);
  }
  syms = fsw.match(rsym);
  for (var i=0; i < syms.length; i++) {
    sym = syms[i].slice(0,6)
    x = syms[i].slice(6, 9);
    y = syms[i].slice(10, 13);
    syms[i] = '<g transform="translate(' + x + ',' + y + ')" ><text class="sym-fill">' + sym + '</text><text class="sym-line">' + sym + '</text></g>';
  }
  if (k == 'S') {
    x2 = 1000 - x1;
    y2 = 1000 - y1;
  }
  w = x2 - x1;
  h = y2 - y1;
  l = o[k] || 0;
  l = l * 75 + x1 - 400;
  //font-size = "12">
//            <tspan x = "10" dy = "20" font-family = "serif">
  var svg = '<svg width="' + w + '" height="' + h + '" viewBox="' + x1 + ' ' + y1 + ' ' + w + ' ' + h + '">' + syms.join('') + "</svg>";
  if (laned){
    svg = '<div style="padding:10px;position:relative;width:' + w + 'px;height:' + h + 'px;left:' + l + 'px;">' + svg + '</div>';
  }
  return svg
}

function fontInstall(){
  var report = '<h2>SignWriting 2010 Font not installed!</h2>\n';
  report += '<p>Please download and install the SignWriting 2010 Fonts:';
  report += fontLinks();
  return report;
}

function fontRefresh(){
  var report = '<h2>SignWriting 2010 Font have been installed!</h2>\n';
  report += '<p>TrueType font source links:';
  report += fontLinks();
  return report;
}

function fontLinks(){
  var report = '<ul><li><a href="https://github.com/Slevinski/signwriting_2010_fonts/raw/master/fonts/SignWriting%202010.ttf">SignWriting 2010</a>';
  report += '<li><a href="https://github.com/Slevinski/signwriting_2010_fonts/raw/master/fonts/SignWriting%202010%20Filling.ttf">SignWriting 2010 Filling</a>';
  return report;
}

if (!getSymSize('S10000')){
  document.getElementById("output").innerHTML = fontInstall(); 
} else {
  document.getElementById("output").innerHTML = fontRefresh(); 
  document.getElementById("hello").innerHTML = getSignSvg("M518x529S14c20481x471S27106503x489");  document.getElementById("world").innerHTML = getSignSvg("M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468");
  
}

              
            
!
999px

Console