Different custom fonts paired with stimuli
Hi everyone,
First, thank you for this great program. I am very new to it; so nowadays I am bothering the forum a lot, and it really helps, thank you for that too. But I still have some struggles...
So I went through all the documentation and discussions I could find for the custom fonts. I have two fonts that I want to use, they are in the file pool and I am able to pull one off for one condition. However, I need to present two different fonts for two different conditions. The thing is:
My sketchpad is able to take a picture paired with one font. In the other condition, it takes the different picture as it should, but the font doesn't change. I couldn't figure out how to tell the sketchpad and make it pull a "font" variable from the trial_sequence table. Can I do that? Ah, I also want to do the same thing with different colors. Also, this is going to be online experiment, so these fonts should be somehow embedded into it, so that everyone can see in their own computer... Would it work?
Best,
Hülya

Comments
Hi Hülya,
Not sure why the sketchpad wouldn't be able to adjust the font on a trial by trial basis. Perhaps it helps if you embed the text that you want to show in html syntax? Normally this is more powerful and flexible that the standard Opensesame commands. See here for more info: https://osdoc.cogsci.nl/3.3/manual/stimuli/text/
Eduard
Hi Eduard,
Thank you so much for your answer!
I am trying the HTML solutions in the link you sent...but probably since I am too new to that too, seems like I am doing something wrong. The code goes as follows: (I am trying to take that "font" variable from my loop table...)
set duration 0
set description "Displays stimuli"
draw textline center=1 color="#000000" font_bold=no font_family="[font]" font_italic=no font_size=24 html=yes show_if=always text="[Intro]" x=-13 y=84 z_index=0
<span style='font-family:"[font]";'>Font style</span>
But then, when I say "apply" the span tag that I am trying to add magically disappears like I did no change at all (without giving an error). Probably I am doing something wrong while typing it...I would be very happy for the help!
Best,
Hülya
Hi,
the line
<span style='font-family:"[font]";'>Font style</span>has to be embedded in text, you can't just drop it in the script part of the sketchpad. So, if you replace the ">Font Style<" with ">[Intro]<" and copy then the entire line as value to the text keyword, it could work. Something like this:draw textline center=1 color="#000000" font_bold=no font_family="[font]" font_italic=no font_size=24 html=yes show_if=always text="<span style='font-family:"[font]";'>[Intro]</span>" x=-13 y=84 z_index=0EduardHi,
Oh. Sorry that I needed to make you explain a very silly thing :')
However now I am doing the exact same thing you suggested, and still no change. Might it be caused by my font files? They are .ttf , and they are both defined in the table with their extensions under their title. They are also in the file pool...
NOOOO I did it!! I don't know how to delete the comment so I am editing it - Ok. Apparently I shouldn't have written their extensions in the table! I thought they would work like an image. Now it works! Thank you a bunch Eduard!
Best,
Hülya
Great! Cool.
Hi Eduard,
Sorry to revive this. I am just having a simple problem: when running in browser, my colors or fonts does not work. They run smoothly in OpenSesame though. Should I translate the HTMLs to JavaScript somehow?
Best,
Hülya
Hi Hülya,
Mh, that is annoying. Do you have an error message that goes with this? I doubt that you would need to translate html to javascript. My guess would be that the fonts are for some reason not available or something? If you have an error message or can provide more details on your experience, we might be able to pinpoint the issue.
Eduard
Hi Eduard,
Sorry for unresponsiveness!
I was not getting any error... though yes you were right, I did not need to translate anything. I tried writing them again as variables and such and somehow it was fixed: maybe some kind of a typing error I have made.
Thanks a lot,
H
Hi Eduard,
Sorry to revive. I am not sure if I should have asked this in JATOS title but the problem is with the fonts again. While they work in my computer, either with the JATOS link, or "Run in browser", or OpenSesame itself - they do not work in other computers. We checked one console and we have this error:
"Refused to execute script from '.....' because its MIME type ('application/js') is not executable, and strict MIME type checking is enabled"
I did a little bit of research and it seems like this might be due to browsers? I am not sure, I really don't know anything about HTMLs or JavaScripts. Can I do something about it beforehand, like an inline_java or something in the beginning?
Best,
H
Hi Hülya,
I unfortunately don't know much about HTML or Javascript myself, but if this is browser specific, could you not require your participants to use specific browsers? @kri Have you seen this error before? Is it something that Jatos settings can help with?
Thanks,
Eduard
Hi Hülya, Hi Eduard,
From how I understand the error message (and from what Google tells me) it means that you try to load and run a file that has a MIME type that is actually not executable. I'm not an expert in MIME types, but according to this list here (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) 'application/js' seems to not exist. I assume you want to run a JavaScript file and this should have the MIME type 'text/javascript'. Is this possible? Do you somewhere specify 'application/js'?
Best,
Kristian
Hi,
Wow, @kri
I honestly have no idea. I nenver specified any such thing in the experiment, and all the custom fonts I had were .ttf from Google Fonts. All the other kind of texts were written in sketchpad item, sometimes with HTML tags but as simple as a <br>. So honestly there is nothing I am trying to run as a js file, there is only one inline_javascript but this error comes when we tried with the fonts, and without them we didn't get any.
@eduard , I don't think it is browser specific because we tried in many and couldn't succeed...
Anyway, at last, I decided to get rid of the fonts but I thought you might be interested in such an error or things like that for future issues maybe...
Thank you both!
Best,
H