相关疑难解决方法(0)

字体渲染与字形信息

我调用"GetCharABCWidthsFloatW"来获取角色的宽度信息.有了这个,我将获得左侧轴承,右侧轴承和先进的宽度.

为了定位每个字符,我将从一个从零开始的"xPlacement"变量开始.我将首先通过减去"左侧轴承"来调整xPlacement变量.绘制完角色后,我会按角色的宽度前进(我稍后会显示计算结果).然后,我将通过添加当前"xPlacement"中的"右侧方位"信息来移动xPlacement变量.

在我看来,这应该是字符放置的代码,对吗?

重要的是要纠正字符的宽度.宽度将通过采用advancedWidth,左侧轴承的POSITIVE版本和右侧轴承的POSITIVE版本来计算.我会将这些值转换为正值,如果它们是负数,那么我可以得到字符的总宽度.

这是一些关于如何生成的伪代码.

float xPlacement = 0.0f;
for(int i = 0; i < strlen(text); ++i)
{
 char charValue = text[i];
 GetCharWidthABC(.., .., charInfo);

 float posLeft = charInfo.leftSideBearing;
 if(charInfo.leftSideBearing < 0)
  posLeft = -charInfo.leftSideBearing;

 float posRight = charInfo.rightSideBearing;
 if(posRight < 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
}
Run Code Online (Sandbox Code Playgroud)

这似乎是正确的方法吗?

c# c++ algorithm fonts rendering

6
推荐指数
1
解决办法
5688
查看次数

Java方法getGlyphOutline在C#中是否有等价物?

我正在将一些Java代码转换为C#.此代码使用GlyphVector中的getGlyphOutline.有没有想过在C#或.NET中是否有相同的东西?

.net c# java

1
推荐指数
1
解决办法
542
查看次数

标签 统计

c# ×2

.net ×1

algorithm ×1

c++ ×1

fonts ×1

java ×1

rendering ×1