سؤال

I have a character's glyph data from the glyf table in a TrueType font file.
This data is represented as a block of decimal numbers.

Example: character 'a' in Calibri 11pt (Glyph Index 258)

0209225523736332020510640176643215663166476631192352121217752161317752241117752161516176521841247641403939150112016151770581842552401791217758184255232179131775818425523217911177581842552321801516176581842864201723197052165225919252105215252466542184127641520834134344292344674612201277404763237632371857479323717185747931139493237147225434343431964394935747162254343434350574948949337206635343838535366353446253526225151535246235341423534462535262451503022173534142212022515054553631628272631145914581711158145621161681051242249785761977349128129472766861025297136843816414168100663189806511161241212661212906370377010265761127437705280532729352981625152529263529194485126841962345634170836668

What are the possibilities to draw this character on a screen?

هل كانت مفيدة؟

المحلول

Short answer: don't do this yourself. Use a font rendering library such as freetype, or if you are on a platform that already has a font renderer, use that. There are also a number of commercial rendering libraries available.

Long answer: the data specification for decoding the glyph data into curves (plus, optionally, instructions) can be found here. So you can start with that. But you'll need much, much more...You'll also minimally need to parse the 'head' and 'hhea' tables to know where to place things and how to scale design units into the drawing space. Then you'll need to parse the 'fpgm', 'cvt ', and 'prep' tables which contain "global" (font-wide) instructions (sometimes referred to as "hints"). Then you'll need to parse the instructions that are present in each glyph, then develop a fill routine to use all of this information to place the individual pixels. Good luck! This is not for the faint-hearted nor those looking for a quick solution. Use a library.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top