Text Objects - Determining Text Size

388 views
Skip to first unread message

Alex Eastwood

unread,
Apr 17, 2015, 10:46:26 AM4/17/15
to mapi...@googlegroups.com
Hi,

I am trying to find a way of extracting the font size from an existing Text object. There is no direct way to do this via the ObjectInfo() function, so as a workaround I have tried something like this:

Dim oObj,oMBR as Object
Dim Top,Bottom,TextHeight as Float

oObj = Selection.Obj
Alter Object oObj Geography OBJ_GEO_TEXTANGLE,0 'make it horizontal
Update Selection Set Obj = oObj
oMBR - MBR(oObj) [MinimumBoundingRectangle]
Top = ObjectGeography(oMBR,OBJ_GEO_MAXX)
Bottom = ObjectGeography(oMBR,OBJ_GEO_MINX)
TextHeight = Top - Bottom

The problem with this is that the text objects are often not horizontal (which they need to be for 'Top' and 'Bottom' to be correct), hence Alter Object...TextAngle, but this Alter Object statement also modifies the size of the text object for some reason. So when you then define the MBR after you've rotated the text object the size won't be correct.

When you are making text objects there is of course the Font clause where one can specify size, style etc. so the information I need must be stored somewhere, but I can't find a way to extract from an existing object.

Hope all the above is clear, many thanks in advance for any help/suggestions!

Alex


GIS Software Developer, Buchanan Computing
London, UK

Thomas Bacon

unread,
Apr 17, 2015, 10:53:18 AM4/17/15
to mapi...@googlegroups.com

Alex,

 

I stumbled upon this problem recently and deduced that this was due to the fact that any font size would only be correct at 1 specific map zoom as the font scales with the zoom. I guess using the object bounds as you’ve done would be the only way to get a size for the text. If there is another way I’d be interested to hear it too!

 

Cheers,

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



            

Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX.  The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. 

Thomas Bacon

unread,
Apr 17, 2015, 10:59:58 AM4/17/15
to mapi...@googlegroups.com

“The problem with this is that the text objects are often not horizontal (which they need to be for 'Top' and 'Bottom' to be correct), hence Alter Object...TextAngle, but this Alter Object statement also modifies the size of the text object for some reason. So when you then define the MBR after you've rotated the text object the size won't be correct.”

 

I guess the text size must be defined by its MBR so rotating the text would affect the way it fits inside the bounding rectangle and hence the size of the text. I’m not sure how you’d calculate the height and width in this case!

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

 

From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of Alex Eastwood
Sent: 17 April 2015 14:48
To: mapi...@googlegroups.com
Subject: [MI-L] Text Objects - Determining Text Size

 

Hi,

--

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tony Pilkington

unread,
Apr 17, 2015, 11:21:45 AM4/17/15
to mapi...@googlegroups.com
You need to read up using the Set Style statement before calling CreateText( ) and the difference between CreateText and Create Text. Then look at styleattr(...). It is not straight forward.

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2014.0.4800 / Virus Database: 4311/9558 - Release Date: 04/17/15

Alex Eastwood

unread,
Apr 17, 2015, 11:30:10 AM4/17/15
to mapi...@googlegroups.com
Thanks Tom,

I see what you mean regarding the different font size at different map scales, that would explain why there is no function for extracting the font size from text objects. For the data I'm using the size is actually fixed - not that that brings us any further in this case.

My colleague has been in touch with Pitney Bowes regarding this, but unfortunately they haven't provided us with a magical solution (yet...?)!

I also found that if you select a Text Object and rotate it manually (ie with the mouse by clicking on the rotation node) as opposed to rotating it via the MapBasic command the size is preserved...

We'll be trying to come up with a workaround for this so I'll keep you posted!

Cheers,

Alex


Alex Eastwood

unread,
Apr 17, 2015, 11:46:18 AM4/17/15
to mapi...@googlegroups.com, a.j.pil...@talk21.com
Yeah I had hopes for that but:

FONT_POINTSIZE:

Integer indicating the Font size, in points.

Note: If the Text object is in a mappable table (as opposed to a Layout window), the point size is returned as zero, and the text height is dictated by the Map window's current zoom.

Text height for this data is fixed, not sure how I would use the current zoom level to extract the text height...? Bearing in mind I have 400k objects I'm trying to do this with so this all needs to be automated and wouldn't actually be displayed in a map window or otherwise!

Cheers,

Alex

Greg

unread,
Apr 17, 2015, 12:30:52 PM4/17/15
to mapi...@googlegroups.com
Have you looked at using the TEXTSIZE() function? I've used this in the past to find the point size of text objects (MasterMap text) in a map window.

Many years ago, Jacques Paris investigated text objects and produced an informative document, which included some MapBasic functions to find text size etc. He also covered the use of the MBR() to find the size and how it changes if the text object has been rotated. I may have a copy, if it can't be found on-line.

Greg

Bill Thoen

unread,
Apr 17, 2015, 1:03:58 PM4/17/15
to mapi...@googlegroups.com

Bo Victor Thomsen

unread,
Apr 17, 2015, 1:19:11 PM4/17/15
to mapi...@googlegroups.com
The works of Jacques Paris can be found at :

http://georezo.net/jparis/

The specific document about text size in MapInfo is here:

http://georezo.net/jparis/d_a/textobjects/MI_Text_Objects.zip

AFAIK It's still relevant :-/ The representation of text in MapInfo in
still slightly zany

Regards

Bo Victor Thomsen
AestasGIS
Denmark

Greg

unread,
Apr 17, 2015, 1:20:39 PM4/17/15
to mapi...@googlegroups.com
That's the one, thanks Bill. Wow, written in 2003....

Greg

Bill Thoen

unread,
Apr 17, 2015, 3:06:48 PM4/17/15
to mapi...@googlegroups.com


> That's the one, thanks Bill. Wow, written in 2003....
>
> Greg
>
That's been a problem for a long time! I think the answer is to use the Windows GDI library and get the font metrics directly from the functions. I don't know how hard it is in 64-bit machines, but it was easy to call a 32-bit dll from within MapBasic, once you figured out what was needed.

Alex Eastwood

unread,
Apr 20, 2015, 6:50:39 AM4/20/15
to mapi...@googlegroups.com
Thanks all for your advice!

I'm going to give the TextSize() function a go, but I'm not sure if this will work for this particular purpose.

Otherwise I might write a function based on that document by Jacques Paris where you can calculate the size of a non-horizontal text bounding rectangle (page 7).

I'll let youse know how I get on!

Thanks again,

Alex

Eric Blasenheim

unread,
Apr 20, 2015, 9:51:30 PM4/20/15
to mapi...@googlegroups.com
I think Alex said "Text height for this data is fixed." In a MapInfo Text object from a table, there is no such thing and the point size we use to tell Windows to render text is a fairly complicated calculation that happens on the fly, every time you draw. This is important to understand what text objects are.

It is not possible to say for a text object in a table, what point size is this text.  A text object only has a point size when put in a particular map and at any particular location, projection and zoom, a point size is generated.  When you go to edit it, the size you see is that calculation.  

Jacques' work was done with some help from us years ago to understand and document this and I believe he did a reasonably good job with what MapBasic can tell you.

As for some of Alex's particular questions,  I will try as best I can annotating his code.

oObj = Selection.Obj   
Alter Object oObj Geography OBJ_GEO_TEXTANGLE,0 'make it horizontal     ' A text object has an internal size that represents the unrotated height of the text in table units (the units of the coordinate system).  When you change the angle, the height is not changed, so you have essentially changed the bounding box as we rotate the text keeping the size.
Update Selection Set Obj = oObj    ' note that this operation could change things if the coordinate system of oObj and the table are not the same because a coordinate system transformation would occur.
oMBR - MBR(oObj) [MinimumBoundingRectangle]
Top = ObjectGeography(oMBR,OBJ_GEO_MAXX)
Bottom = ObjectGeography(oMBR,OBJ_GEO_MINX)
TextHeight = Top - Bottom    ' This will be in map units and is the overall MBR height, not the height of the text. There could be spacing (multi-line) and there is padding. 


In the end, I am not sure what you are trying to accomplish.  The text size in point is not a part of a text object.  Note that the function that lets you create a text object based on a current map window  (CreateText() I think() was a MapBasic helper function I added to the product back in 1996, because the Create Text statement was way too difficult to get right.  The function uses the text size in points in the specified window to create a text object. But once it is created, all knowledge of that size is lost.

If you want further proof, you can create two text objects (use different characters ) at the same small text size and via zooming in you can find where their text sizes are no longer the same.

This is why we created labels which solves some but not all problems.

Eric Blasenheim
Pitney Bowes Software
 

Alex Eastwood

unread,
Apr 21, 2015, 12:53:38 PM4/21/15
to mapi...@googlegroups.com
Hi Eric,

thanks for your response. Regarding what I said about the text size being fixed, what I mean is that once the text object has been drawn on a map, its size in distance units is fixed, i.e. when you zoom out the text becomes too small to read. This as opposed to labels for example, where the size stays constant regardless of the zoom level.

In terms of what I am trying to achieve:

We have map data where road names, building names etc are stored as text objects. These data are being uploaded to the web via a series of tiles, which are rendered on the fly as the user pans the map. The problem we are having is that if a text object spreads across 2 adjacent tiles the text is truncated, so we have written a program that converts each letter of a text object into a region, combines the regions into a word and then adds these to the map. This way the regions don't get truncated between neighbouring map tiles.
We have had 1 dataset where the text size in distance units was indicated as part of the data, and we created our text regions based on this height. For all other data, this is not the case, hence why we are using MBRs around the text object to try and get an idea of how large the text is, so that our region text can be similar in size. But since most of the text objects are not horizontal, the height derived from the MBR is not correct until we have rotated it to horizontal, which is when we found that doing this via the method described above changes the height of the object.

We have been trying various methods based on Jacques Paris's TextBoxSize function, and have made some progress. I'll post an update on this tomorrow since I'm leaving the office now.

Thanks again,


Alex




Eric Blasenheim

unread,
Apr 21, 2015, 10:00:21 PM4/21/15
to mapi...@googlegroups.com
Alex,
I am impressed by the undertaking to say the least. I am guessing the software you are using for creating tiles cannot read or does not read text objects correctly? For tiles I would expect the multiple pieces of text to display seamlessly across tiles.
Regards,
Eric

On Friday, April 17, 2015 at 10:46:26 AM UTC-4, Alex Eastwood wrote:

Alex Eastwood

unread,
Apr 22, 2015, 5:31:09 AM4/22/15
to mapi...@googlegroups.com
Hi,

we are using Open Layers 3 for this, it does read the text objects but clearly doesn't handle them very well. I think we're stuck with it now so will have to find ways to deal with it! But I'm not in a position to judge, I've just been tasked with processing data for uploading to the web.

Anyway we've almost got something usable, I'll keep everyone posted.

Cheers,

Alex


Alex Eastwood

unread,
May 12, 2015, 10:28:13 AM5/12/15
to mapi...@googlegroups.com
Hi everyone,

have been busy with other stuff over the last few weeks, but thought I should post an update for everyone who offered to help:

I ended up using a very slightly TextBoxSize() function, which can be found via this link http://georezo.net/jparis/d_a/textobjects/text_objects.htm  (Thanks Jacques!). This works reasonably well, except for text rotated at 45°. This is probably stated somewhere in Jacques' text so might not be a great revelation to anyone, however we did try getting around it by nominally adding/subtracting a few 0.1°s to/from the text angle if this was 45°. Jacques does something similar (subtracts 0.00001 from the text angle) when the text angle is a multiple of 45, and both his and our method work well enough, except where the angle is actually 45 (not a multiple). If I remember correctly anything with an angle between 44.1° and 45.8° would produce strange/unusable results, so we decided to skip everything with these angles, and resize the text to a nominal value. It is interesting that a couple of tenths of a degree can make a big difference, in some cases text rotated at 44° would come out fine, whereas text of a similar length & height rotated at 44.2° would come out completely wrong. But I for one am unable to explain why this happens.

So, unfortunately there is no happy ending to this story, no 'happily ever after', no Prince Charming who came to the rescue. We had a crack at it and failed, but we live to code another day.

Thanks again to everyone for your suggestions and interest, if I have a 'hallelujah moment' I'll let youse all know.

Cheers,

Alex


Thomas Bacon

unread,
May 13, 2015, 5:55:21 AM5/13/15
to mapi...@googlegroups.com

Thanks for the update Alex, and also the link. Good to have this reference as I’m sure I’ll end up trying to do similar at some point!

 

Cheers,

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

 

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Crossley

unread,
May 13, 2015, 6:42:06 AM5/13/15
to mapi...@googlegroups.com

Thomas,

 

I was looking at this problem a while ago as I wanted to store text objects in SQL Server by storing their properties separately to the object, and then recreating the text object from those properties.  Unfortunately, there was one property that couldn’t be accessed from MapBasic, something like the unrotated height.

 

So I pass my test program to you to see if you can make any more progress than I.  The code has lost its formatting I am afraid.  Good luck.

 

Rob.

 

 

Sub Main

 

                                Create Table "TestTextObj" (ID Integer) File ApplicationDirectory$() + "TestTextObj.tab"

                                Create Map For TestTextObj CoordSys Earth Projection 1,104

                               

                                fFont = MakeFont("Arial", 1, 12, BLACK, -1)

                               

                                Create Text Into Variable oTextObj

                                                "Looooooooooong Test String 0"

                                                (153,-24) (153.1, -24.1)

                                                Font fFont

                                                Angle 0

                                Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)

                                Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))

                               

                                Create Text Into Variable oTextObj

                                                "Looooooooooong Test String 30"

                                                (153,-25) (153.1, -25.1)

                                                Font fFont

                                Alter Object oTextObj Geography OBJ_GEO_TEXTANGLE, 30

                                Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)

                                Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))

                               

                                Create Text Into Variable oTextObj

                                                "Looooooooooong Test String 225"

                                                (154,-25) (154.1, -25.1)

                                                Font fFont

                                Alter Object oTextObj Geography OBJ_GEO_TEXTANGLE, 225

                                Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)

                                Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))

                               

                                Create Text Into Variable oTextObj

                                                "Looooooooooong Test String 90"

                                                (154.5,-25) (154.6, -25.1)

                                                Font fFont

                                Alter Object oTextObj Geography OBJ_GEO_TEXTANGLE, 90

                                Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)

                                Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))

                               

                                Create Text Into Variable oTextObj

                                                "Looooooooooong Test String 125"

                                                (155,-25) (155.1, -25.1)

                                                Font fFont

                                Alter Object oTextObj Geography OBJ_GEO_TEXTANGLE, 125

                                Insert Into TestTextObj (ID, Obj) Values (-1, oTextObj)

                                Insert Into TestTextObj (ID, Obj) Values (0, MBR(oTextObj))

                               

                                Commit Table TestTextObj

                                Close Table TestTextObj

                                Open Table ApplicationDirectory$() + "TestTextObj.tab"

                               

                                Map From TestTextObj

                                Set Map Window FrontWindow() Zoom Entire

                               

                                Create Menu "Test Object Functions" As

                                                "Do Text Operations" Calling TransformText

                                               

                                Alter Menu Bar Add "Test Object Functions"

 

End Sub

 

Sub TransformText

'-----------------------

'Subroutine:       Main

'Called By:                           None

'Description:       This subroutine calls other subs to sets up the menus and initial variables.

'-----------------------

 

'Set up general error handler

ONERROR GOTO ErrorHandler

Dim  oOrigTextObject, oMBROrigTextObject, oMBRotatedTextObj, oNewTextObj As Object

Dim oObjProp As tObjProperties

'Dim oMBROrigText As tObjMBX

Dim RotationAngle As Float

Dim  arraysize  As Integer

 

Select * From TestTextObj Where ID > 0 Into SelText

Delete From SelText

 

Select * From TestTextObj Where ID <= 0 Into SelText

 

If TableIsOpen("TmpObjects") Then

                Drop Table TmpObjects

End If

 

Create Table "TmpObjects" (TextRotation Float) File ApplicationDirectory$() + "TmpObjects.tab"

Create Map For TmpObjects CoordSys Earth Projection 1,104

Select * From TestTextObj Where Obj Into SelTemp

Select * From SelTemp Where Int(ObjectInfo(Obj, OBJ_INFO_TYPE)) = OBJ_TYPE_TEXT Into SelTempText

If SelectionInfo(SEL_INFO_NROWS) > 0 Then

                Insert Into TmpObjects (TextRotation, Obj) Select ObjectGeography(Obj, OBJ_GEO_TEXTANGLE), Obj From SelTempText

End If

Select * From SelTemp Where Int(ObjectInfo(Obj, OBJ_INFO_TYPE)) <> OBJ_TYPE_TEXT Into SelTempNotText

If SelectionInfo(SEL_INFO_NROWS) > 0 Then

                Insert Into TmpObjects (TextRotation, Obj) Select 0, Obj From SelTempNotText

End If

 

Select * From TmpObjects Into SelTemp

Update SelTemp Set Obj = fUnRotateText(Obj)

 

 

If SelectionInfo(SEL_INFO_NROWS) > 0 Then

                Fetch First From SelTemp

                Do Until EOT(SelTemp)

                                If fGetObjProperties(SelTemp.Obj, oObjProp) = FALSE Then

                                                Note "Failed to extract properties from text object."

                                Else

                                                oOrigTextObject = SelTemp.Obj

                                                oObjProp.iTextAngle = SelTemp.TextRotation

                                                'RotationAngle = ObjectGeography(oOrigTextObject, OBJ_GEO_TEXTANGLE)

                                                'oMBROrigTextObject = MBR(oOrigTextObject)

                                                'Insert Into TestTextObj (ID, Obj) Values (1, oMBROrigTextObject)

                                               

                                                oNewTextObj = fCreateObjFromProperties(oObjProp.iObjectType,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.cTextString,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.cFontName,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.IfontStyle,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.IfontSize,

                                                                                                                                                                                                                                                                                                                                                                RED,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.IfontbackColor,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.iTextSpacing,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.iTextJustIfy,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.iTextLineType,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.cTextLinePen,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.fTextLineX,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.fTextLineY,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.iTextAngle,

                                                                                                                                                                                                                                                                                                                                                                oObjProp.oObj)

                               

                                                Insert Into TestTextObj (ID, Obj) Values (3, oNewTextObj)

                                End If

                                Fetch Next From SelTemp

                Loop

End If

 

Exit Sub

ErrorHandler:

                Note Error$()

End Sub

 

 

Function fUnRotateText(ByVal oObj As Object) As Object

'-----------------------

'Subroutine:       Main

'Called By:                           None

'Description:       This subroutine calls other subs to sets up the menus and initial variables.

'-----------------------

 

'Set up general error handler

ONERROR GOTO ErrorHandler

Dim oUnRotObj As Object

Dim iTextAngle, iObjectType As Integer

 

 

iObjectType = ObjectInfo(oObj, OBJ_INFO_TYPE)

Do Case iObjectType

                Case OBJ_TYPE_TEXT

                                iTextAngle = ObjectGeography(oObj,OBJ_GEO_TEXTANGLE)

                                If iTextAngle <> 0 Then

                                                Alter Object oObj Geography OBJ_GEO_TEXTANGLE, 0

                                End If

                Case Else

                                fUnRotateText = oObj

End Case

 

Exit Function

ErrorHandler:

                CALL ErrorMessage("fUnRotateText")

END Function 'fUnRotateText

 

Function fCreateObjFromProperties(ByVal iObjectType As SmallInt,

                                                                                                                                                                                                                                ByVal                cTextString As String,

                                                                                                                                                                                                                                ByVal cFontName As String,

                                                                                                                                                                                                                                ByVal iFontStyle As Integer,   

                                                                                                                                                                                                                                ByVal iFontSize As Integer,

                                                                                                                                                                                                                                ByVal iFontForeColor As Integer,

                                                                                                                                                                                                                                ByVal iFontbackColor As Integer,

                                                                                                                                                                                                                                ByVal fTextSpacing As Float,

                                                                                                                                                                                                                                ByVal iTextJustify As SmallInt,

                                                                                                                                                                                                                                ByVal iTextLineType As SmallInt,

                                                                                                                                                                                                                                ByVal cTextLinePen As String,

                                                                                                                                                                                                                                ByVal fTextLineX As Float,

                                                                                                                                                                                                                                ByVal fTextLineY As Float,

                                                                                                                                                                                                                                ByVal iTextAngle As Integer,

                                                                                                                                                                                                                                ByVal oObj As Object) As Object

                                                                                                                                                                                                                               

 

'-----------------------

'Subroutine:       Main

'Called By:                           None

'Description:       This subroutine calls other subs to sets up the menus and initial variables.

'-----------------------

 

'Set up general error handler

ONERROR GOTO ErrorHandler

Dim oText As Object

Dim fFont As Font

Dim UnRotText As Object

Dim oMBRUnRotText As Object

Dim Xi As Float

Dim Hi As Float

Dim Xr As Float

Dim Hr As Float

Dim K As Float

Dim a As Float

Dim b As Float

Dim Discriminant As Float

 

'  ------------

'  |       / /|

'  |      / / |

'  |     / /  |

'  |    / /Xi |

'  |   / /    |

'  |  /Hi/     |

'  ------------

'  a       b

'      Xr

     

If iFontSize = 0 Then

                iFontSize = 100

End If

 

If iObjectType <> OBJ_TYPE_TEXT Then

                fCreateObjFromProperties = oObj

                Exit Function

Else

                fCreateObjFromProperties = oObj

                fFont = MakeFont(cFontName, iFontStyle, iFontSize, iFontForeColor, iFontbackColor)

                If iTextAngle = 0 Then

                                Print "Found a ext object with a text andgle of 0"

                                Create Text Into Variable oText

                                                cTextString

                                                (ObjectGeography(oObj, OBJ_GEO_MINX), ObjectGeography(oObj, OBJ_GEO_MINY)) (ObjectGeography(oObj, OBJ_GEO_MAXX), ObjectGeography(oObj, OBJ_GEO_MAXY))

                                                Font fFont

                                                Spacing fTextSpacing

                Else

                                Print "Found a ext object with a text andgle of " + iTextAngle

                               

                                Create Text Into Variable UnRotText

                                                cTextString

                                                (ObjectGeography(oObj, OBJ_GEO_MINX), ObjectGeography(oObj, OBJ_GEO_MINY)) (ObjectGeography(oObj, OBJ_GEO_MAXX), ObjectGeography(oObj, OBJ_GEO_MAXY))

                                                Font fFont

                                                Spacing fTextSpacing

                                'Get proportion of hieght to base on text object.

                                oMBRUnRotText = MBR(UnRotText)

                                K = (ObjectGeography(oMBRUnRotText, OBJ_GEO_MAXX)- ObjectGeography(oMBRUnRotText, OBJ_GEO_MINX))/ (ObjectGeography(oMBRUnRotText, OBJ_GEO_MAXY) - ObjectGeography(oMBRUnRotText, OBJ_GEO_MINY))

                                Print "K Len/ Height of Unrotated Text = " + K

                                Xr = ObjectGeography(oObj, OBJ_GEO_MAXX) - ObjectGeography(oObj, OBJ_GEO_MINX)

                                Print "Xr= " + Xr

                                Hi =  Xr / (Sin(iTextAngle*DEG_2_RAD) + (K * Cos(iTextAngle*DEG_2_RAD)))

'                               Discriminant = (Xr ^ 2) - (4 * Sin(-1*iTextAngle*DEG_2_RAD) * K * Cos(iTextAngle*DEG_2_RAD))

'                               Print "Discriminant= " + Discriminant

'                               Hi = ((-1 * Xr) + Sqr(Discriminant)) / (-2 * Sin(iTextAngle*DEG_2_RAD))

'                               Hi = ObjectGeography(oMBRUnRotText, OBJ_GEO_MAXY) - ObjectGeography(oMBRUnRotText, OBJ_GEO_MINY)

                                Print "Hi= " + Hi

                                Create Text Into Variable oText

                                                cTextString

                                                (ObjectGeography(oObj, OBJ_GEO_MINX), ObjectGeography(oObj, OBJ_GEO_MINY)) (ObjectGeography(oObj, OBJ_GEO_MAXX), ObjectGeography(oObj, OBJ_GEO_MAXY))

'                                               (ObjectGeography(oObj, OBJ_GEO_MINX), ObjectGeography(oObj, OBJ_GEO_MINY)) (ObjectGeography(oObj, OBJ_GEO_MAXX), ObjectGeography(oObj, OBJ_GEO_MINY)+Hi)

                                                Font fFont

                                                Spacing fTextSpacing

                                                Angle iTextAngle

                                                               

                End If

                If iTextLineType In(0,1,2) Then

                                                Alter Object oText Info OBJ_INFO_TEXTARROW, iTextLineType

                End If

                If fTextLineX > 0 Then

                                Alter Object oText Geography OBJ_GEO_TEXTLINEX,  fTextLineX

                End If

                If fTextLineY > 0 Then

                                Alter Object oText Geography OBJ_GEO_TEXTLINEY,  fTextLineY

                End If

                fCreateObjFromProperties = oText

End If

 

Exit Function

ErrorHandler:

                CALL ErrorMessage("fCreateObjFromProperties")

END Function 'fCreateObjFromProperties

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of Thomas Bacon


Sent: Wednesday, 13 May 2015 7:54 PM
To: mapi...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages