Note that there are some explanatory texts on larger screens.

plurals
  1. POFont Rendering with Glyph information
    text
    copied!<p>I call "GetCharABCWidthsFloatW" to get the width information for a character. With this I will get the leftside bearing, right side bearing and the advanced width.</p> <p>For positioning each characters, I will start with a "xPlacement" variables that will begin at zero. I will first adjust the xPlacement variable by subtracting the "left side bearing". After the character is drawn, I will then advance it by the width of the character( I will show the calculation for this later). I will then move the xPlacement variable by adding the "right side bearing" information from the current "xPlacement".</p> <p>This, in my opinion is all that should be code for character placement, correct?</p> <p>An important thing is to correct the width of the characters. The width will be calculated by taking the advancedWidth, plus the POSITIVE version of the left side bearing and the POSITIVE version of the right side bearing. I will convert this values to positive, if they are negative so I can have the total width of the character.</p> <p>Here is some pseudo code about how it is generated.</p> <pre><code>float xPlacement = 0.0f; for(int i = 0; i &lt; strlen(text); ++i) { char charValue = text[i]; GetCharWidthABC(.., .., charInfo); float posLeft = charInfo.leftSideBearing; if(charInfo.leftSideBearing &lt; 0) posLeft = -charInfo.leftSideBearing; float posRight = charInfo.rightSideBearing; if(posRight &lt; 0) posRight = -charInfo.rightSideBearing; float posWidth = posRight + posRight + charInfo.advancedWidth; float letterWidth = posWidth; xPlacement -= charInfo.leftSideBearing; /* generated some vertex coordinates, using the xPlacement variable and letterWidth */ xPlacement += letterWidth; xPlacement += charInfo.rightSideBearing } </code></pre> <p>Does this appear to be the correct way to do this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload