Raster font rendering and kerning

I am trying to create a bitmap font rendering, however I am having problems displaying the actual placements of individual letters.

I will get font character information through GetCharABCWidthsFloat and GetTextMetricsW, however I'm not sure how to use ABC width correctly ... or do I need more information for this?

I do not want to use FreeType or any other libraries for this, I am trying to do this with standard functions available through C ++ \ Windows.

Without kerning information, the letters will not display correctly. For example, take a look at β€œTimes new roman” when β€œf” and β€œt” are next to each other. Without the correct spacing between letters, they will look too far apart. Algorithm Example ---

float letterBottomLeftX = 0.0f;
float letterHeight = 1.0f;
float letterWidth = 1.0f;

float scale = 1.0f;
for(U32 c = 0; c < numberOfCharacters; ++c)
{
    fon->GetCharcterInfo(charValue, charInfo);
    //float advancedWith = (charInfo.A * scale) + (charInfo.B * scale) + (charInfo.C * scale);

    letterWidth = charInfo.B * scale;
    letterHeight = textMetrics.Height * scale;

    if(c == 0)
    {
        letterBottomLeftX = -(charInfo.A * scale);
    }


    // vertex placement, beginning at letterBottomLeftX

    // texture placement

    // index placement

    letterBottomLeftX += (charInfo.A + charInfo.B + charInfo.C) * scale;
}

, , . ( UV, , ).

http://img88.imageshack.us/img88/4015/njpjp2.png

+3
2

KERNINGPAIR . , wFirst wSecond, iKernAmount , .

std::map<std::pair<wchar_t,wchar_t>,int> GetKerningPairs . , GetKerningPairs . , , . , , .

, SetMapMode(hdc,MM_TEXT), .

+2

. , "Ti" , MN. , .

0

Source: https://habr.com/ru/post/1783154/


All Articles