I have a point feature layer with attributes for a text string (call it 'label') and the fontsize in map units (which are meters in my case). Is there a way in Grass to derive polygons from this input information which enclose the label strings when those are used to label the points? For those who know ArcMap: what I mean is exactly what happens when you save Annotations as Shapes in ArcCatalog: you get a polygon layer in which each text string has a polygon hull which fits the height and width, respectively.
It is more tricky than it might seem as exact dimensions depend not
only on font size but also on selected font (see monospace vs
condensed fonts), kerning, styling (bold, italics). Thus final size of
bonding box of a string is a product of all of its properties. Thus
the best option to get the size right is to ask the same rendering
engine to calculate exact dimensions as it will know the size it will
use.
* apart from one used for vector labelling in d.* modules, but that is
not exposed to the enduser. See D_get_text_box from display library.
I have a point feature layer with attributes for a text string (call it 'label') and the fontsize in map units (which are meters in my case). Is there a way in Grass to derive polygons from this input information which enclose the label strings when those are used to label the points? For those who know ArcMap: what I mean is exactly what happens when you save Annotations as Shapes in ArcCatalog: you get a polygon layer in which each text string has a polygon hull which fits the height and width, respectively.
thanks a lot. That is hard tobacco for a user like me. What do you mean 'ask the same rendering engine'?
Is there a chance to get such boxes for a normal user or is it a case for a c++ programmer?
-----Ursprüngliche Nachricht-----
Von: Maris Nartiss [mailto:maris.gis@gmail.com]
Gesendet: Montag, 20. Dezember 2021 08:25
An: Uwe Fischer <gisfisch@t-online.de>
Cc: GRASS user list <grass-user@lists.osgeo.org>
Betreff: Re: [GRASS-user] how to derive polygons from text strings
AFIAK no*
It is more tricky than it might seem as exact dimensions depend not only on font size but also on selected font (see monospace vs condensed fonts), kerning, styling (bold, italics). Thus final size of bonding box of a string is a product of all of its properties. Thus the best option to get the size right is to ask the same rendering engine to calculate exact dimensions as it will know the size it will use.
* apart from one used for vector labelling in d.* modules, but that is not exposed to the enduser. See D_get_text_box from display library.
I have a point feature layer with attributes for a text string (call it 'label') and the fontsize in map units (which are meters in my case). Is there a way in Grass to derive polygons from this input information which enclose the label strings when those are used to label the points? For those who know ArcMap: what I mean is exactly what happens when you save Annotations as Shapes in ArcCatalog: you get a polygon layer in which each text string has a polygon hull which fits the height and width, respectively.
thanks a lot. That is hard tobacco for a user like me. What do you mean 'ask the same rendering engine'?
This depends on how you are planning to use those frames around text.
If as a background for a text, it might not fit well as the exact
width and height of text will depend on the rendering engine used to
draw text. Frames around text in ArcGIS work only as long as text
itself is rendered by ArcGIS. Try to draw text in frames made by
ArcGIS with QGIS and most likely you will not see a perfect fit even
if the same font is in use.
Is there a chance to get such boxes for a normal user or is it a case for a c++ programmer?
You can always go back to scripting. If selected font is monospace,
calculations are easy, if not monospace, it will be hard to get it
right. Thus digging into C code seems to be the best bet.