用了FreeType2,字体位图倒是得到了,可是显示的位置有问题

灼眼的超哥 2011-10-30 06:42:57
如题,不知道这个问题该提在哪,还是提在C语言这个版块了;

用C语言写了个图形UI库,终于能显示字体了,用的是FreeType2提供的API获取字体库文件里的字体的,可是,字体是得到了,显示的位置却不正常,具体,可参考我贴的图片。

图中所示的是用我写的图形UI库的一个测试程序,创建一个窗口,标题栏上测试显示字体,窗口内显示指定图片。


上图使用的是华文细黑字体。
你会发现,字母都是处于同一条底线的 ,这些字母的位置需要调整;
数字呢,有的大有的小;
而汉字,还比较理想,之前用微软雅黑字体,在电脑上的ubuntu系统中测试时(安装了最新版的FreeType2),结果正常,字体完整,没有缺失;
而在学习机里测试,汉字被剃头了,像“应”、”序“这样的字,上面的一点没了。



上图使用的是微软雅黑字体。
数字正常,有的符号位置不正确。
难道FreeType只给出字体字形,不给出字体放置的位置吗?


windows中的字体预览程序(如下图所示),是如何让字体在正确的位置显示?
...全文
291 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2011-11-07
  • 打赏
  • 举报
回复
C:\MSVC20\SAMPLES\win32\gridfont\http://download.csdn.net/detail/zhao4zhong1/3253384

C:\Microsoft SDK\samples\multimedia\Gdi\Fonts\GridFont\
赵4老师 2011-11-07
  • 打赏
  • 举报
回复
mk:@MSITStore:C:\MSDN98\98VS\2052\vcsample.chm::/html/vcsmpgridfont.htm
GridFont: Displaying Font Codepoints

Click to open or copy the files for the GridFont sample.

The GridFont sample, written in C++, displays a grid containing Unicode codepoints. The user is able to select a font, and then see which codepoints are covered by the font.

Note There is a font distributed with the Win32® SDK that covers more than 1,000 Unicode characters. In order to use this application to its full potential, install that font by using Fonts in the Control Panel. The font is named l_10646.TTF.

Building SDK Samples

This sample uses the following keywords:

_alias; _block; _bxf; _canvas; _cblock; _ccol; _char; _code; _cols; _crow; _cx; _cy; _fontalias; _fontblock; _fontctype; _fpagemode; _fuformat; _hdc; _hdevnames; _hinst; _hwnd; _icol; _ipage; _irow; _line; _macpage; _pf; _pt; _size; abortproc; alertbox; alpha; brush; buttondown; buttonup; bxf; cancelled; cannextpage; cannextsection; canprevpage; canprevsection; canvas; cblackpen; cblockformat; cblockframe; cbox; cboxformat; cbrush; ccanvas; ccharblock; cchargrid; ccodegrid; cctypeset; cfont; cfontselect; cfontset; cframeformat; cgridit; char; choose; choosefont; circle; clinegrid; cmodel; code; col; combining; command; countucsegments; cpage; cpageformat; cpoint; cprintcanvas; cprintrequest; create; createbrushindirect; createfont; createfontindirect; createpen; cscrollableview; ctextfield; ctextgrid; ctype; cview; cwindow; cx; cy; decomp; deletedc; deleteobject; destroy; dialogbox; done; dptolp; draw; drawelement; enddialog; enddoc; endpage; endpaint; error; fillrect; foldstring; fontdecomp; freeprocinstance; fs; getclientrect; getdevicecaps; getextent; getfont; getfontdata; getformat; getlinesize; getmaxpage; getmaxsection; getmenu; getobject; getpage; getpagedata; getpagemode; getrect; getscale; getscrollpos; getsize; getstockbrush; getstringtypeex; getstringtypew; gettextextentpoint; globalfree; hdc; hfont; hittest; hscroll; hwnd; in; initpage; invalidate; invalidaterect; ismodelpageused; ispageused; it; job; keydown; keyup; line; loadstring; localalloc; localfree; localhandle; lptodp; lstrcpy; lstrlen; makeprocinstance; max; memset; min; muldiv; nextpage; nextsection; offsetrect; page; paint; pen; postquitmessage; prevpage; prevsection; print; printdlg; rctext; rectangle; releasecapture; rgb; row; scale; scanvas; scroll; scrollwindow; selectbrush; selectfont; selectpen; senddlgitemmessage; setabortproc; setchartable; setcset; setfont; setfontrange; setformat; sethscrollpos; setpage; setpagemode; setscale; setscrollpos; setscrollrange; setsize; setstyle; settextalign; settextcolor; settextorg; setvscrollpos; setweight; setwindoworgex; size; startpage; switch; text; textalign; update; updatewindow; view; vscroll; wsprintf
ryfdizuo 2011-11-07
  • 打赏
  • 举报
回复
ft我曾经用过,lz用opengl绘制字体的?
灼眼的超哥 2011-11-07
  • 打赏
  • 举报
回复
散分!我还是自己看文档。
来人接分!
灼眼的超哥 2011-10-31
  • 打赏
  • 举报
回复
木有人?

69,381

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧