Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

text_size when text ends with a whitspace

Hi all,

I am building an eye-tracking reading experiment, and I am encountering some issues to draw areas of interest. So far, I have been using the text_size function per each area of my sentence (five, in this case). However, it seems that text_size ignores whether there is a whitespace at the end of the word - meaning that, at the end, all my areas of interest are shifted to the left. I have tried:

  • Adding a whitespace after each word in the loop
  • Adding a whitespace via an inline python plugin before calling text_size

Any ideas as to how to go about this? (or even if text_size is the way to go)

Thank you!

Comments

  • Hi Nadia,

    Sounds weird. But if you have the sizes as returned by the text_size function, can't you adapt that variables somewhat? Like, there is a whitespace in the string, shift the values to the right (i.e. adding a few pixels onto the number)?

    Would that work?

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    Thanks for your answer! I did actually try something like that: Create an additional text that is just space, get its width, and then add it to the areas of interest calculation but it didn't quite work (maybe I did something wrong!).

    I just came back from the lab and I used .rect instead of text_size and this time it worked (I don't discard having made additional changes that were the issue in my first post that I was unaware of)-- the new additional problem is that the space between words that are in different areas of interest is not as "big" as that of within areas of interest (in the picture below, the first space is between areas of interest, the second is within). Any suggestion for this? Thank you again for your response!


  • edited June 18

    Hi @nadia27 and @eduard ,

    A cheap trick to include spaces that have a fixed size is by using a visible character, and then give this character the color of the background. For example, the text string below would appear as though there is a space between 'Word' and 'Another word', but really it's an underscore that's not visible because it has the background color. The main reason to do this is to avoid the space from not being taken into account when calculating the text size.

    Word<span style="color:{background};">_</span>Another word
    

    — Sebastiaan

  • Hi @sebastiaan,


    Just saw this now - thank you! I just tried it out and noticed something: does Text() add a tiny bit of space at the end of the text? I noticed that the gap between words was bigger than the space taken by an underscore, so I printed it with colour and noticed there was space between the words (see example below, where I changed the underscore for an 'i')


  • @nadia27 I see what you mean, yes. It seems the span element is flanked by whitespace. Maybe you can use an empty span instead? This is regular HTML formatting, so you can play around using all the tools available in HTML.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games