This is an incredibly complex problem, even though it may seem simple on the surface. In order to make it appear like you are entering text directly on the page, I am dynamically inserting a text edit control on the page, but I make it's background transparent and I try to position it exactly where it should be to enter text based on the insertion point. However, the text component behavior is not something I have complete control over, and there are considerations with the font metrics, line spacing, typeface, etc when trying to figure out the exact position to place it. When the finger is lifted, I hide the text edit control and revert back to just rendering the text on the page using the skia graphics library on Android. However, there is scaling that has to happen - the annotation is stored relative to the raw PDF page size, not the scaled size, in order to ensure it scales properly across different devices, orientations, scale settings, etc. So while the text font size was just set to "12" while you were entering the text with the edit control, for example, it might be saved as 3.49 relative to the PDF page, but then it's scaled up by the page scaling factor, and it might be something close to 12 but not exactly (the scaling also occurs with the coordinates of the text). So it's hard to know if the offset position is due to something happening internally in the edit control where it's padding the insertion point or doing some other processing that places it offset from the insertion point, or if it's due to the scaling causing it to be offset a little bit. It could also be caused by the way Android handles text measurements with different fonts, causing some small discrepancies there.
I'll have to revisit this to see if I can improve it at all, but in order to get things working fairly well with the default font (sans serif), I had to add some small offsets at different font sizes to get it to all line up properly when going between editing a text annotation and displaying it normally. This is obviously not working as well with serif for some reason. This capability has been a real pain to deal with.
Mike
I'll have to revisit this to see if I can improve it at all, but in order to get things working fairly well with the default font (sans serif), I had to add some small offsets at different font sizes to get it to all line up properly when going between editing a text annotation and displaying it normally. This is obviously not working as well with serif for some reason. This capability has been a real pain to deal with.
Mike