jDrawingView Text measurement lazarus / 43-Android ---------------------------------------------------------------------- CC · 2017-11-02 23:30 Hi, One important piece seem to be missing from  jDrawingView. Before Drawing a text to place it properly it is important to know the  place it would occupy in both direction. ---------------------------------------------------------------------- jmpessoa · 2017-11-02 23:47 Ok. I will try implement text measurement! Thank you! ---------------------------------------------------------------------- CC · 2017-11-03 00:33 jmpessoa There is an other issue with DrawText: it is not anti-aliased, which makes it unusable. I am testing jView+jCanvas which has very similar functionality and DrawText is anti-aliased here. So it would be better to implement Text measurement for jCanvas if you can. ---------------------------------------------------------------------- CC · 2017-11-03 01:14 Bold fonts seem to be missing as well. ---------------------------------------------------------------------- CC · 2017-11-03 08:36 A  higher level solution would be to add horizontal end vertical  alignment parameters to the DrawText function. If the Android API has no published functionality for this I can help you to create it on the pascal side. ---------------------------------------------------------------------- CC · 2017-11-05 22:57 This solution is working for me to align a text in a rectangle. Add these to the source files: ....\lamw\java\lamwdesigner\jCanvas.java Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         public  void drawTextAligned(String text, float _left, float _top, float _right, float _bottom, float _alignhorizontal , float _alignvertical ) {                Rect bounds = new Rect();              paint.getTextBounds(text, 0, text.length(), bounds);              float x = _left + (_right - _left  - bounds.width()) * _alignhorizontal;                float y = _top + (_bottom - _top  - bounds.height()) * _alignvertical + bounds.height();                canvas.drawText(text,x,y,paint);                        } ....\lamw\android_bridges\And_jni_Bridge.pas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure jCanvas_drawTextAligned(env: PJNIEnv; Canv: jObject; const text: string;  _left, _top, _right, _bottom, _alignhorizontal , _alignvertical: single);var  _jMethod : jMethodID = nil;  _jParams : Array[0..6] of jValue;  cls: jClass; begin  _jParams[0].l := env^.NewStringUTF(env, pchar(text) );  _jParams[1].F := _left;  _jParams[2].F := _top;  _jParams[3].F := _right;  _jParams[4].F := _bottom;  _jParams[5].F := _alignhorizontal;  _jParams[6].F := _alignvertical;  cls := env^.GetObjectClass(env, Canv);  _jMethod:= env^.GetMethodID(env, cls, 'drawTextAligned', '(Ljava/lang/String;FFFFFF)V');  env^.CallVoidMethodA(env,Canv,_jMethod,@_jParams);  env^.DeleteLocalRef(env,_jParams[0].l);  env^.DeleteLocalRef(env, cls);end;  ....\lamw\android_bridges\Laz_And_Controls.pas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure jCanvas.drawTextAligned(Text: string; _left, _top, _right,  _bottom, _alignhorizontal, _alignvertical: single);begin  if FInitialized then    jCanvas_drawTextAligned(FjEnv, FjObject, Text, _left, _top, _right,     _bottom, _alignhorizontal, _alignvertical );end;  alignhorizontal / alignvertical  0    : align left / top  0.5  :to the middle  1     :align right / bottom ---------------------------------------------------------------------- jmpessoa · 2017-11-06 00:07 Great! I will add to git repo! Thank you! ---------------------------------------------------------------------- jmpessoa · 2017-11-07 04:36 Done! Added  DrawTextAligned  to  jCanvas and jDrawingView and fixed  jDrawingView anti alias. Note: Method signature changed to DrawTextAligned(_text: string; _left, _top, _right, _bottom: single;                            _alignHorizontal:  TTextAlignHorizontal;                            _alignVertical: TTextAlignVertical); where:   TTextAlignHorizontal = (thLeft, thRight, thCenter);  TTextAlignVertical = (tvTop, tvBottom, tvCenter); Thank you! ---------------------------------------------------------------------- CC · 2017-11-11 18:14 Thank you!