none
Need help to calculate advance width from indices in XPS RRS feed

  • Question

  • Hi,

    I need a help which is already present in the XPS Specification.

    I am lack in english, so i need to post this forum.

    I am rendering XPS file to PDF, so while rendering Glyphs i came across Advance width calculated from indices.

    I have read the definition form XPS Specification, but these lines i cant able to understand "So that rounding errors do not accumulate, the advance MUST be calculated as the exact unrounded origin of the subsequent glyph minus the sum of the calculated (that is, rounded) advance widths of the preceding glyphs [M5.6].".

    I have removed the indices present in the Glyphs and tried rendering it works fine, but while the indices is present the text overlap with the subsequent text.

    Here is a example.

    UnicodeString="Karthikeyan needs a help...." Indices=",25;,50;,58;,25;,92;,25;,25;....."

    How should i calculate the advance width, is it depends on next glyphs.

    My present code to draw glyphs is:

    {..............

                                      // Get the advance width.
                                        int index = int.Parse(charSplit[i]);                //eg 25 or 50 or 58 or 25.....

                                        // It is specified in percentage of em.
                                        round = (float)(index * glyphs.FontRenderingEmSize / 100);

                                        // Convert to points. This should be the width of the current glyph.(since i am drawing in pdf)
                                        round = ConvertToPoints(round);
                                    }
                                    if (round > 0 && round > font.GetCharWidth(glyphs.UnicodeString[i], stringFormat))
                                        result = elem.Draw(m_page, location, round); //m_page is the Graphics, location is the starting location, round in the character width
                                    else
                                        result = elem.Draw(m_page, location);

    Thanks in Advance

    Wednesday, May 8, 2013 6:19 AM

Answers