File: main-cpp.cpp

package info (click to toggle)
libucimf 2.3.7-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,912 kB
  • ctags: 708
  • sloc: sh: 10,568; cpp: 3,769; ansic: 789; makefile: 63
file content (45 lines) | stat: -rw-r--r-- 1,070 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "font.h"
#include <iostream>

using namespace std;

int main()
{
	Font::instance()->setInfo("細明體", 16, 0 ); // 字型取自 fc-list 的列表
	//Font::instance()->showInfo(true);

	u16 code = 0x4e2d; // 0x4e2d => "中"
	Font::Glyph *glyph = (Font::Glyph *)Font::instance()->getGlyph(code);

	cout << "glyph->pitch: " << glyph->pitch << endl;
	cout << "glyph->width: " << glyph->width << endl;
	cout << "glyph->height: " << glyph->height << endl;
	cout << "glyph->left: " << glyph->left << endl;
	cout << "glyph->top: " << glyph->top << endl;

	for ( int y = glyph->height; y > 0 ; y-- )
	{
		for ( int x = 0; x < glyph->width ; x++ )
		{
			// Dump bitwise data
			/*
			int n = glyph->pixmap[ (glyph->height - y) * glyph->pitch + x ];
			for (int i=8; i>=0; i--) {                                                                  
				int bit = ((n >> i) & 1);
				cout << bit;
			}  
			*/

			if ( glyph->pixmap[ (glyph->height - y) * glyph->pitch + x ] ) {
				cout << "O" ;
			}
			else {
				cout << "_" ;

			}
		}
		cout << endl;
	}

	return 0;
}