FontExists: t1
| t2 |
t2 _ UnicodePlugin getFontList.
(t2 includes: t1)
ifTrue: [^ true].
^ false(t1 is a String argument.)
Basically what this code does is call getFontList to t2, making t2 an array containing string names of every font on the computer. Then, if t1 is part of that array, it reports true. Otherwise, false.
The Problem:
It will always return false. And, interestingly, if you replace the t1 in (t2 includes: t1) with 'Arial', it works. Same if put this in the code part in the workspace, define t1 as a temporary variable instead, and set it to 'Arial'. But as it is above, it doesn't work.
I tested this extensively and can't figure it out. If someone can fix this block, I'll share it at the Block Library with credit to me as creator and credit to whoever discovered the solution as an improvement. Please help!

Offline
Please, I could really use the help!

Offline
I think it has to do with whether t1 is being recognized as a string or not.
Offline
scratcher7_13 wrote:
I think it has to do with whether t1 is being recognized as a string or not.
I already tried that. Originally it was (t2 includes: t1 asString) and it still glitched.

Offline
Convert the strings of fonts to UFT8 strings, since the input will be a UTF8 string too, then make the comparison:
fontExists: t1
| t2 |
t2 _ UnicodePlugin getFontList collect: [:f | f asUTF8].
^ (t2 includes: t1)Offline
Baderous wrote:
Convert the strings of fonts to UFT8 strings, since the input will be a UTF8 string too, then make the comparison:
Code:
fontExists: t1 | t2 | t2 _ UnicodePlugin getFontList collect: [:f | f asUTF8]. ^ (t2 includes: t1)
OK, but I'm away from home and using a 3DS. I'll test it if I can tonight, though maybe tomorrow.
I did try UTF8, but I was trying to convert t1 to UTF8.
Assuming this works, thanks so much!

Offline
Baderous wrote:
This works, I tested it.
Oh. Thanks so much again!!!

Offline
OK, but I'm away from home and using a 3DS.
3DS HAS INTERNET!?!?
I HAVE GOTTA GET ONE!!!!!

Offline