How to set text on specific size in mm?


Author
Message
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
To clarify, there are so-called "fixed-width" aka. "monospaced" fonts (Consolas, Courier New, etc.), meaning that each letter's bounding rectangle takes up the same amount of horizontal space. The effect is that the string "IIII" takes up the same amount of horizontal space as the string "OOOO", which is not the case for "normal" fonts:

<trial mytrial>
/ stimulusframes = [1=fixedwidth, notfixedwidth]
/ validresponse = (57)
</trial>

<text fixedwidth>
/ items = ("OOOO~nIIII")
/ fontstyle = ("Courier New", 5%)
/ position = (40%, 50%)
</text>

<text notfixedwidth>
/ items = ("OOOO~nIIII")
/ fontstyle = ("Verdana", 5%)
/ position = (60%, 50%)
</text>

https://www.millisecond.com/forums/uploads/images/91c6a374-805d-4342-87dc-9f40.png

But something like a "fixed-height" font does not exist (to the best of my knowledge). Even in monospaced fonts, vertical space typically differs between letters due to shape:

https://www.millisecond.com/forums/uploads/images/7ea132ec-dc2c-49bb-9749-8578.png
Edited 9 Years Ago by Dave
kulajw
kulajw
Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)
Group: Forum Members
Posts: 51, Visits: 256
Thanks, a lot Dave.

You are right, it looks like there is no fixed font size
So in this situation, It is good idea to use picture instead of fonts.

Thanks for advice :)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
Your calibration logic is fine. You can see this by displaying e.g. a rectangle sized according to expressions.letters on-screen and measuring its dimensions (it's the desired 12mm on my system and should be on yours as well):


<<<<this script should always shows letter 12mm height, regardless of participants computer display properties>>>
<values calibration>
/ cal_mm = 0mm
/ cal_px = 500px
/ letters = 12mm
</values>

<expressions>
/ mmtopx = values.cal_mm/values.cal_px
/ letters = 1px*round((values.letters/expressions.mmtopx))
</expressions>

<openended calibrate>
/ stimulusframes = [1= line]
/ position = (50%, 80%)
/ validresponse = (anyresponse)
/ monkeyresponse = ("195")
/ mask = positiveinteger
/ ontrialend = [values.cal_mm=openended.calibrate.response]
/ ontrialbegin = [openended.calibrate.buttonlabel= "Save results (in mm)"]
</openended>

<shape line>
/ shape = rectangle
/ color = (black)
/ erase = (250,250,250)
/ size = (values.cal_px,10px)
/ position = (50%, 50%)
/ halign = center
</shape>

<text Letters>
/ items = ("F","P","Q","J","H","K","T","S","N","R","Y","L")
/ fontstyle = ("Verdana", expressions.letters, true)
/ erase = true(silver)
</text>

<trial trial_A>
/stimulustimes = [0=letters, myshape]
/ validresponse = (57)
</trial>

<shape myshape>
/ shape = rectangle
/ size = (expressions.letters, expressions.letters)
/ position = (50%, 25%)
/ color = red
</shape>

<block calibrate>
/trials = [1=calibrate]
</block>

<block block_trial_A>
/trials = [1-10=trial_A]
</block>

<expt >
/blocks = [1=calibrate;2=block_trial_A]
</expt>

The problem with your approach is that fonts just don't work that way. To the best of my knowledge, there is no such thing as a "fixed-height" font, i.e. letters *will* necessarily vary in height due to their natural shape. For example, the letter Q requires more vertical space than the letter P (the red square is 12mm x 12mm):
https://www.millisecond.com/forums/uploads/images/00b872ea-e527-4ca4-be8a-4bf9.png
If you measure the height of the Q, you'll find it to be relatively close to 12mm (also note that there's typically some amount of empty space around letters in a font).

If you really want all your letters to have identical, fixed height you will have to resort to a different approach. E.g. don't use fonts, but prepare images displaying the letters, with each letter sized according to your needs.

kulajw
kulajw
Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)Guru (5.9K reputation)
Group: Forum Members
Posts: 51, Visits: 256
Hello all ;),
I would like to create text element - letter stimulus on 12mm height regardless of participants computer screen settings.
To do this I prepared some calibrations as follows:
I create reference line (RL) 500px long, I measured it with ruler and put measurement (M) result in mm into open ended element.
for my computer i have M=130mm
Next using <expressions> I divide M by RL so i have 130mm/500px=0,26mm/px
Then I divided my target height 12mm by 0,26mm/px so I have about 46px in my case

But there is some problem, if I measure my stimulus using ruler on computer screen I have 9mm not 12mm ;/

Can anyone help me?
Thanks in advance for any help.

I attach my script





Attachments
calibration_to_12_mm.iqx (247 views, 1.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search