Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
It's true. I have no clue whyI tried to embed three fonts. Its showing different fonts however.
Location: Netherlands
Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
Location: Netherlands
Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
![]() |
Source code |
1 2 3 4 |
@font-face { font-family:Fira; src: url(fonts/FiraSans-Light.ttf); } |
![]() |
Source code |
1 2 3 4 5 6 |
<action name="add_web_fonts" autorun="preinit" type="Javascript" devices="html5"><![CDATA[ var styleNode = document.createElement("style"); styleNode.type = "text/css"; styleNode.textContent = "@font-face{ font-family:Fira; src:url('" + krpano.parsepath("tests/FiraSans-Light.ttf") + "'); }"; document.head.appendChild(styleNode); ]]></action> |
![]() |
Source code |
1 2 3 4 5 6 7 8 |
<action name="add_web_fonts" autorun="preinit" type="Javascript" devices="html5"><![CDATA[ setTimeout( function(){ var styleNode = document.createElement("style"); styleNode.type = "text/css"; styleNode.textContent = "@font-face{ font-family:Fira; src:url('" + krpano.parsepath("tests/FiraSans-Light.ttf") + "'); }"; document.head.appendChild(styleNode); },3000); ]]></action> |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<action name="check_for_web_fonts_loading" autorun="preinit" type="Javascript" devices="html5"><![CDATA[ function new_fonts_loaded() { var layers = krpano.get("layer").getArray(); var hotspots = krpano.get("hotspot").getArray(); var i; for (i=0; i < layers.length; i++) { if (layers[i].type == "text") { // force an update by changing the vcenter setting two times layers[i].vcenter = !layers[i].vcenter; layers[i].vcenter = !layers[i].vcenter; } } for (i=0; i < hotspots.length; i++) { if (hotspots[i].type == "text") { // force an update by changing the vcenter setting two times hotspots[i].vcenter = !hotspots[i].vcenter; hotspots[i].vcenter = !hotspots[i].vcenter; } } } if (document.fonts) { document.fonts.addEventListener("loadingdone", new_fonts_loaded, true); } ]]></action> |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
<action name="load_web_fonts" autorun="preinit" type="Javascript" devices="html5"><![CDATA[ if (window.FontFace) { // the browser has FontFace support // load the font var fontFace = new FontFace("Fira", "url('tests/FiraSans-Light.ttf')"); fontFace.load().then( function(loadedFontFace) { // when loaded, add it document.fonts.add(loadedFontFace); // and update all textfields to make sure the resize and align correctly update_textfields(); }); } function update_textfields() { var layers = krpano.get("layer").getArray(); var hotspots = krpano.get("hotspot").getArray(); var i; for (i=0; i < layers.length; i++) { if (layers[i]._istextfield) { // force an update by changing the vcenter setting two times layers[i].vcenter = !layers[i].vcenter; layers[i].vcenter = !layers[i].vcenter; } } for (i=0; i < hotspots.length; i++) { if (hotspots[i]._istextfield) { // force an update by changing the vcenter setting two times hotspots[i].vcenter = !hotspots[i].vcenter; hotspots[i].vcenter = !hotspots[i].vcenter; } } } ]]></action> |
Location: Netherlands
Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
![]() |
Source code |
1 |
hotspots.vcenter = ![color=#ff0000]layers[/color][i].vcenter; |
Location: Netherlands
Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
That's because the internal layer itself is already at 0, it's the further internal text layer that changes its size and the other layer doesn't know about the font changes.I changed the first example a bit.
You can now also click the first red box. Then it will set x to 0 again (not happening) but the code thinks it does.
Here the:Here an 3th example with the last code implemented.
http://www.virtualtuur.com/krpano/font-align-safaribug/3/
![]() |
Source code |
1 2 3 4 |
@font-face { font-family:Fira; src: url(fonts/FiraSans-Light.ttf); } |
Location: Netherlands
Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
<action name="load_web_fonts" autorun="preinit" type="Javascript" devices="html5"><![CDATA[ // load the font FIRA if (window.FontFace) { // the browser has FontFace support var fontFace = new FontFace("Fira", "url('fonts/FiraSans-Light.ttf')"); fontFace.load().then( function(loadedFontFace) { // when loaded, add it document.fonts.add(loadedFontFace); // and update all textfields to make sure the resize and align correctly update_textfields(); }); } // load the font JULIUS if (window.FontFace) { var fontFace = new FontFace("Julius", "url('fonts/JuliusSansOne-Regular.ttf')"); fontFace.load().then( function(loadedFontFace) { document.fonts.add(loadedFontFace); update_textfields(); }); } function update_textfields() { var layers = krpano.get("layer").getArray(); var hotspots = krpano.get("hotspot").getArray(); var i; for (i=0; i < layers.length; i++) { if (layers[i]._istextfield) { layers[i].vcenter = !layers[i].vcenter; layers[i].vcenter = !layers[i].vcenter; } } for (i=0; i < hotspots.length; i++) { if (hotspots[i]._istextfield) { hotspots[i].vcenter = !hotspots[i].vcenter; hotspots[i].vcenter = !hotspots[i].vcenter; } } } ]]></action> |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
if (window.FontFace) { var fonts_to_load = []; fonts_to_load.push( (new FontFace("Fira", "url('fonts/FiraSans-Light.ttf')")).load() ); fonts_to_load.push( (new FontFace("Julius", "url('fonts/JuliusSansOne-Regular.ttf')")).load() ); fonts_to_load.push( (new FontFace("Font3", "url('...')")).load() ); // ... Promise.all( fonts_to_load ).then( function(loaded_fonts) { loaded_fonts.forEach( function(font){ document.fonts.add(font); } ); update_textfields(); }); } |
Location: Netherlands
Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
Location: Netherlands
Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer
![]() |
Source code |
1 2 3 4 5 6 7 8 |
@font-face { font-family: 'myfont'; src: url('fonts/myfont.eot'); /* IE9 Compat Modes */ src: url('fonts/myfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('fonts/myfont.woff') format('woff'), /* Pretty Modern Browsers */ url('fonts/myfont.ttf') format('truetype'), /* Safari, Android, iOS */ url('fonts/myfont.svg#svgFontName') format('svg'); /* Legacy iOS */ } |
![]() |
Source code |
1 2 3 |
<action name="setFonts" autorun="preinit" > set(font-bold, 'Roboto-Bold'); </action> |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
embedpano({ swf:"tour.swf", id:"krpanoviewer", xml:"tour.xml", target:"pano", html5:"prefer+webgl+preservedrawingbuffer", consolelog:"true", initvars:{ newvar:"123456", oldvar:"abcde" }, passQueryParameters:true, mwheel:true, focus:true }); |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<action name="skin_deeplinking_update_url_process"> copy(adr, browser.location); indexoftxt(qi, get(adr), '?'); if(qi GT 0, subtxt(adr, adr, 0, get(qi))); copy(si, scene[get(xml.scene)].index); copy(h, view.hlookat); copy(v, view.vlookat); copy(f, view.fov); copy(d, view.distortion); copy(a, view.architectural); clamp(d, 0.0, 1.0); clamp(a, 0.0, 1.0); set(pp, calc(f LT 10 ? 6 : 2)); roundval(h, get(pp)); roundval(v, get(pp)); roundval(f, get(pp)); roundval(d, 2); roundval(a, 1); set(adr, calc(adr + '?' + newvar + '&startscene=' + si + '&startactions=lookat('+h+','+v+','+f+','+d+','+a+');')); js( history.replaceState(null, document.title, get(adr)); ); </action> |