You are not logged in.

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.

1

Saturday, April 28th 2018, 7:09am

Autosize doesn't work using custom font?

Dear Klaus,

we've looked at the possibility of using some custom fonts for our textfield based plugins (layers), so far we've only been using Arial. Thing is, it seems the onautosized event isn't always working properly. Here's the code that sets the css for the layer in question:

Source code

1
menuItem.css = "font-family:Armata,sans-serif;font-size:13px;color:#FFFFFF;text-align:center";


The text appears and displays fine, but (with a certain html string) it sets itself to a width of 111px, when in reality it's more like 128. If I find the corresponding table element in the devtools, it correctly displays the height of 128x40px.



Yet the following code

Source code

1
menuItem.onautosized = "trace(width)";


traces 111 around 9 times out of 10. Yet on the 10th reload it traces 128 correctly.

Any idea what might be causing this? As long as we've only used Arial, it was always working perfectly...

2

Wednesday, September 5th 2018, 11:26am

Hi,

the autosizing of the textfields works that way:
- it waits until the browser provides a valid size for internal html element of the textfield - that typically means a size larger than 0
- once it got the size, the onautosize event will be sent

But it doesn't wait for any external resources (e.g. custom font files) that the browser eventually might load and add later.

See here a for manual solution by tracking the loading state of the custom fonts and forcing krpano to refresh the textfields:
Embeddded fonts in HTML5?

Best regards,
Klaus

3

Saturday, September 8th 2018, 6:06am

Cheers!