Hello experts
I need to render mathematical formulae in my LiveCode cross-platform app. I tried going the MathML way with a browser but it just won't work consistently, so now I'm trying to write my own math rendering library. I ran into what seems to be a brick wall because I can't find a way to determine the baseline of text in a field. LC will let me find the height and line spacing, but it does no good in my quest for the baseline, which is crucial for lining up the math symbols with other formulae text.
Can anyone here help me out?
Thank you so much
Cairoo
Is there a way to determine the baseline of text in a field?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Is there a way to determine the baseline of text in a fi
Hi Cairoo, maybe you could solve the problem by setting the textShift of the chunk expression of the text instead of changing a property of the field, for example:
Please, see the attached stack.
Code: Select all
on mouseUp
set the textShift of word 1 to -1 of field myField to "-12" -- this example works well in a list field
end mouseUp
- Attachments
-
- Shift.livecode.zip
- (1.44 KiB) Downloaded 248 times
Re: Is there a way to determine the baseline of text in a fi
If you only need to do this for a single field (or several fields with the same text settings) then the easiest way is to keep changing the textshift of the text chunk until it looks right, then just hard-code that number into your script as a constant. Your script would set the textshift of the formula text to that number.
If you need to dynamically determine the textshift for fields of different textheights, then use the above method to find a good textshift number, and calculate what percentage of the textheight that number is. Store the percentage as a constant in the script. At run time, calculate the textshift by multiplying the textheight by that percentage. That should get you pretty close.
If you need to dynamically determine the textshift for fields of different textheights, then use the above method to find a good textshift number, and calculate what percentage of the textheight that number is. Store the percentage as a constant in the script. At run time, calculate the textshift by multiplying the textheight by that percentage. That should get you pretty close.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com