Font ScanString & ConverttoOS queries
Martin Avison (27) 1494 posts |
Using Font_ScanString to determine the bounding box for some text, I noticed an oddity which has caused some problems, and I am not sure if it a problem with FontManager or my code. I use This works fine when text$ contains some characters, but when it is null then the returned bounding box is &20000000,&20000000,&E0000000,&E0000000 When passed through Font_ConverttoOS all these become -1342178 and it was this bounding box which caused problems. Should scans of null strings be avoided? I can see no mention that it does not work but is seems likely. Should Font_ConverttoOS return the same value for different inputs? |
Chris Hall (132) 3558 posts |
Not sure what text$="" and then SYS “Font_ScanString”,handle%,text$, … would actually do so how exactly do you obtain rep%+36? |
Jeffrey Lee (213) 6048 posts |
Probably, yeah. It looks like it’s just returning the default values it initialises the bounding box to.
Yes, Font_ConvertToOS should return the same value for some differing inputs (all it really does is a couple of integer divisions, so there are many inputs which will map to the same outputs). But in this case it looks like you’ve breached the upper limit for the input range in which Font_ConvertToOS will work correctly. Looking at the source, it looks like it shifts the input values left two bits prior to the division so that it can calculate the sub-pixel position. So your upper and lower bounds both end up getting converted to &80000000. |
Martin Avison (27) 1494 posts |
@Chris: The exact code is @Jeffrey: Thanks – I will investigate why null strings are being scanned, and avoid! Perhaps there should be some notes added to both SWIs documentation about these restrictions? |