<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Legend creation - space character issue in 2.6 in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1002068#M5747</link>
    <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I have code dynamically generate the legend.&lt;/P&gt;&lt;P&gt;Working well with 2.5&lt;/P&gt;&lt;P&gt;In 2.6, the spacing seem to be issue.&lt;/P&gt;&lt;P&gt;What is the changes in 2.6 related to layout tool legend objects?&lt;/P&gt;&lt;P&gt;I am using usual approach like create legend and changing font from the CIMLegend from definition.&lt;/P&gt;&lt;P&gt;Legend resultLegend = LayoutElementFactory.Instance.CreateLegend(activeLayoutView.Layout, leg_env, activedMapFrame);&lt;/P&gt;&lt;P&gt;Below is the screenshot, left is 2.6, right is 2.5&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Left legend is 2.6, Right Legend is 2.5" style="width: 417px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/294i39624A30E91E41C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2020-11-17 095757 (3).jpg" alt="Left legend is 2.6, Right Legend is 2.5" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Left legend is 2.6, Right Legend is 2.5&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Idea?&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/9021"&gt;@UmaHarano&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12882"&gt;@Wolf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2020 07:15:33 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-11-17T07:15:33Z</dc:date>
    <item>
      <title>Legend creation - space character issue in 2.6</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1002068#M5747</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I have code dynamically generate the legend.&lt;/P&gt;&lt;P&gt;Working well with 2.5&lt;/P&gt;&lt;P&gt;In 2.6, the spacing seem to be issue.&lt;/P&gt;&lt;P&gt;What is the changes in 2.6 related to layout tool legend objects?&lt;/P&gt;&lt;P&gt;I am using usual approach like create legend and changing font from the CIMLegend from definition.&lt;/P&gt;&lt;P&gt;Legend resultLegend = LayoutElementFactory.Instance.CreateLegend(activeLayoutView.Layout, leg_env, activedMapFrame);&lt;/P&gt;&lt;P&gt;Below is the screenshot, left is 2.6, right is 2.5&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Left legend is 2.6, Right Legend is 2.5" style="width: 417px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/294i39624A30E91E41C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2020-11-17 095757 (3).jpg" alt="Left legend is 2.6, Right Legend is 2.5" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Left legend is 2.6, Right Legend is 2.5&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Idea?&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/9021"&gt;@UmaHarano&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12882"&gt;@Wolf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 07:15:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1002068#M5747</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-17T07:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Legend creation - space character issue in 2.6</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1014172#M5928</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I managed to solve this issue.&lt;/P&gt;&lt;P&gt;The problem is at generating the text symbol.&lt;/P&gt;&lt;P&gt;Have to add the following properties to make spacing work properly in 2.6 and 2.7.&lt;/P&gt;&lt;P&gt;destinationTextSymbol.LetterWidth = 100;&lt;BR /&gt;destinationTextSymbol.WordSpacing = 100;&lt;BR /&gt;destinationTextSymbol.Kerning = true;&lt;BR /&gt;destinationTextSymbol.Ligatures = true;&lt;BR /&gt;destinationTextSymbol.FontType = FontType.TTOpenType;&lt;BR /&gt;destinationTextSymbol.ExtrapolateBaselines = true;&lt;BR /&gt;destinationTextSymbol.HaloSize = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Than&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 02:45:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1014172#M5928</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-06T02:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Legend creation - space character issue in 2.6</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1031044#M6271</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also trying to customize my legend. Your solution is to use&amp;nbsp;&lt;SPAN&gt;&lt;FONT color="#800080"&gt;&lt;STRONG&gt;destinationTextSymbol&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;in controlling the text properties in the legend. Can you please elaborate a bit on this solution?&lt;BR /&gt;&lt;BR /&gt;The following is my code for creating a legend. But after that, I am confused on HOW and WHERE to insert &lt;STRONG&gt;&lt;FONT color="#008080"&gt;CIMTextSymbol &lt;/FONT&gt;&lt;/STRONG&gt;reference such as your&amp;nbsp;&lt;FONT color="#800080"&gt;&lt;STRONG&gt;destinationTextSymbol&lt;/STRONG&gt;&lt;/FONT&gt;. Can you please help me with that? Thanks.&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Coordinate2D llLegend = new Coordinate2D(10, 10);
Coordinate2D urLegend = new Coordinate2D(100, 50);
Envelope leg_env = EnvelopeBuilder.CreateEnvelope(llLegend, urLegend);	
LayoutElementFactory.Instance.CreateLegend(layout, leg_env, mfElm);&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 17:16:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1031044#M6271</guid>
      <dc:creator>GyanendraGurung</dc:creator>
      <dc:date>2021-02-26T17:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Legend creation - space character issue in 2.6</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1040920#M6388</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/19301"&gt;@GyanendraGurung&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code snippet, the destinationTextSymbol is the variable actually,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, I didn't post full set of code earlier.&lt;/P&gt;&lt;P&gt;Let me know when you got issue,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//Separate method
public void FormatDefaultArialTextSymbol(CIMTextSymbol sourceTextSymbol, CIMTextSymbol destinationTextSymbol, string FontStyleName, double fontSize, double height)
        {
            destinationTextSymbol.CopyFrom(sourceTextSymbol);
            destinationTextSymbol.FontStyleName = FontStyleName;
            destinationTextSymbol.FontFamilyName = "Arial";
            
            destinationTextSymbol.Height = height;
            destinationTextSymbol.SetSize(fontSize);
            destinationTextSymbol.ExtrapolateBaselines = false;           
            destinationTextSymbol.VerticalAlignment = VerticalAlignment.Center;           
            destinationTextSymbol.BillboardMode3D = BillboardMode.None;
            destinationTextSymbol.Symbol3DProperties = new CIM3DSymbolProperties()
            {
                DominantSizeAxis3D = DominantSizeAxis.Z,
                ScaleY = 0,
                ScaleZ = 0,
                RotationOrder3D = RotationOrder.XYZ
            };
            //from 2.6 - word spacing and letter width are required to set and ,need to be 100
            destinationTextSymbol.LetterWidth = 100;
            destinationTextSymbol.WordSpacing = 100;
            destinationTextSymbol.Kerning = true;
            destinationTextSymbol.Ligatures = true;
            destinationTextSymbol.FontType = FontType.TTOpenType;
            destinationTextSymbol.ExtrapolateBaselines = true;
            destinationTextSymbol.HaloSize = 1;

        }


/// actual code
//Get layout and map frame first
 LayoutView activeLayoutView = LayoutView.Active;
            
 MapFrame activedMapFrame = activeLayoutView.ActiveMapFrame;

ProgressorSource ps = new ProgressorSource("Adding Legend...");
                    QueuedTask.Run(() =&amp;gt;
                    {
                        Console.WriteLine("Create legend area");
                        //Search for a style project item by name
                        StyleProjectItem arcgis_2dStyle = Project.Current.GetItems&amp;lt;StyleProjectItem&amp;gt;().First(si =&amp;gt; si.Name == "ArcGIS 2D");
                        Envelope mapFrameExtent = (activedMapFrame.GetDefinition() as CIMMapFrame).Frame.Extent;
                        double xmin = mapFrameExtent.XMax - (mapFrameExtent.Width / 4);
                        double bufferX = mapFrameExtent.Width * 0.01;
                        double bufferY = mapFrameExtent.Height * 0.01;//1%
                        double xmax = mapFrameExtent.XMax - bufferX;
                        double ymax = mapFrameExtent.YMax - bufferY;
                        double ymin = mapFrameExtent.YMin + bufferY;
                        Envelope leg_env = EnvelopeBuilder.CreateEnvelope(xmin, ymin, xmax, ymax);
                        Legend resultLegend = LayoutElementFactory.Instance.CreateLegend(activeLayoutView.Layout, leg_env, activedMapFrame);

                        CIMLegend legendDef = resultLegend.GetDefinition() as CIMLegend;
                        legendDef.Title = "Legend";
                        legendDef.ShowTitle = true;
                        SymbolStyleItem paragraph = arcgis_2dStyle.SearchSymbols(StyleItemType.TextSymbol, "Paragraph").FirstOrDefault();
                        CIMTextSymbol aParaSymbol = paragraph.Symbol as CIMTextSymbol;

                        FormatDefaultArialTextSymbol(aParaSymbol, (legendDef.TitleSymbol.Symbol as CIMTextSymbol), "Bold",12,8);

                        legendDef.AutoAdd = true;
                        legendDef.AutoFonts = true;
                        legendDef.AutoVisibility = true;
                        legendDef.FittingStrategy = LegendFittingStrategy.AdjustColumnsAndSize;
                        ps.Message = "Adding Legend - Formatting Text";
                        foreach (CIMLegendItem legItem in legendDef.Items)
                        {
                            FormatDefaultArialTextSymbol(aParaSymbol, (legItem.HeadingSymbol.Symbol as CIMTextSymbol), "Regular",8, 8);
                            FormatDefaultArialTextSymbol(aParaSymbol, (legItem.LabelSymbol.Symbol as CIMTextSymbol), "Regular",8, 8);
                            FormatDefaultArialTextSymbol(aParaSymbol, (legItem.DescriptionSymbol.Symbol as CIMTextSymbol), "Regular",8, 8);
                            FormatDefaultArialTextSymbol(aParaSymbol, (legItem.LayerNameSymbol.Symbol as CIMTextSymbol), "Bold", 9, 8);
                            FormatDefaultArialTextSymbol(aParaSymbol, (legItem.GroupLayerNameSymbol.Symbol as CIMTextSymbol), "Bold", 9, 8);
                           
                            legItem.AutoVisibility = true;
                        }
                     
                        resultLegend.SetName("Legend");

                        resultLegend.SetDefinition(legendDef);
                    }, ps.Progressor);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 02:59:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/legend-creation-space-character-issue-in-2-6/m-p/1040920#M6388</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-26T02:59:26Z</dc:date>
    </item>
  </channel>
</rss>

