freetype 2 로 ascii - art 중국어 표시
#include
<ft2build.h>
#include
FT_FREETYPE_H
int
main
(int
argc
, char
**argv
){
int
psize
;
FT_Library
library
;
FT_Face
face
;
unsigned
int
ucode
;
FT_UInt
glyph_index
;
int
row
, pixel
;
if
(argc != 4){
return
10;
}
ucode = strtol(argv[2], NULL
, 16);
psize = strtol(argv[3], NULL
, 10);
printf("unicode +%X size %d/n"
, ucode, psize);
if
(FT_Init_FreeType(&library)
|| FT_New_Face(library,
argv[1],
0,
&face)
|| FT_Set_Pixel_Sizes(face,
psize,
0)){
return
1;
}
glyph_index = FT_Get_Char_Index(face, ucode);
if
(glyph_index == 0){
return
2;
}
if
(FT_Load_Glyph(face,
glyph_index,
FT_LOAD_DEFAULT)){
return
3;
}
if
(FT_Render_Glyph(face->glyph,
FT_RENDER_MODE_MONO)){
return
4;
}
printf("bitmap_left=%d/n"
"bitmap_top=%d/n"
"bitmap.rows=%d/n"
"bitmap.width=%d/n"
"bitmap.pitch=%d/n"
"bitmap.pixel_mode=%d/n"
,
face->glyph->bitmap_left,
face->glyph->bitmap_top,
face->glyph->bitmap.rows,
face->glyph->bitmap.width,
face->glyph->bitmap.pitch,
face->glyph->bitmap.pixel_mode);
printf("/n/n"
);
for
(row = 0;
row < (face->glyph->bitmap.rows - face->glyph->bitmap_top);
++row){
for
(pixel = 0; pixel < face->glyph->bitmap.width; ++pixel){
printf("_"
);
}
printf("/n"
);
}
for
(row = 0; row < face->glyph->bitmap.rows; ++row){
for
(pixel = 0; pixel < face->glyph->bitmap_left; ++pixel)
printf("_"
);
for
(pixel = 0; pixel < face->glyph->bitmap.width; ++pixel){
printf("%c"
, (face->glyph->bitmap.buffer
[row * face->glyph->bitmap.pitch +
pixel/8] & (0xC0 >> (pixel % 8)))?'O'
:'_'
);
}
printf("/n"
);
}
return
0;
}
Makefile
all
: getbitmap
getbitmap.o
: getbitmap.c
gcc $(CXXFLAGS
) -c `pkg-config freetype2 --cflags`
$<
-o $
@
getbitmap
: getbitmap.o
gcc $(CXXFLAGS
) `pkg-config freetype2 --libs`
-lm $<
-o $
@
clean
:
rm -f *.o getbitmap
실행 효과:
hellwolf
@
cocteau
#
pts/1
%
J0S2
:
getbitmap
$
./getbitmap /usr/share/fonts/chinese/True
Type/uming.ttf $(mygetunicode ) 12
unicode +6C38 size 12
bitmap_left=0
bitmap_top=10
bitmap.rows=11
bitmap.width=11
bitmap.pitch=2
bitmap.pixel_mode=1
___________
____OOO____
______OO___
__OOOOO____
_____OO_OO_
OOOOOOO_O__
___OOOOO___
___OOOOO___
__OO_OO_O__
_OOOOOO_OO_
OO__OOO_OOO
O___OO___OO
hellwolf
@
cocteau
#
pts/1
%
J0S2
:
getbitmap
$
./getbitmap /usr/share/fonts/chinese/True
Type/uming.ttf $(mygetunicode ) 16
unicode +6C38 size 16
bitmap_left=1
bitmap_top=14
bitmap.rows=15
bitmap.width=14
bitmap.pitch=2
bitmap.pixel_mode=1
______________
_____OO________
______OOO______
_______OO______
_______________
__OOOOOOO__OOO_
_______OO__OO__
____OO_OO_OO___
_OOOOOOOOOO____
____OO_OOO_____
___OO__OOOO____
___OO__OOOO____
__OO___OO_OO___
_OO_OO_OO__OOO_
_O___OOOO___OOO
______OO_____OO
hellwolf
@
cocteau
#
pts/1
%
J0S2
:
getbitmap
$
./getbitmap /usr/share/fonts/chinese/True
Type/uming.ttf $(mygetunicode ) 20
unicode +6C38 size 20
bitmap_left=0
bitmap_top=18
bitmap.rows=20
bitmap.width=20
bitmap.pitch=4
bitmap.pixel_mode=1
____________________
____________________
____________________
________OOO_________
_________OOO________
____________________
_________OO_________
____OOOOOOOO____O___
_________OO___OOOO__
_________OOO__OO____
OOOOOOOO_OOO_OO_____
_____OOO_OOOOO______
_____OO__OOOO_______
_____OO__OOOO_______
____OOO__OO_OO______
____OO___OO__OO_____
___OO____OO__OOO____
___OO____OO___OOO___
__OO_____OO_____OOOO
_OO______OO_________
OO______OOO_________
____________________
hellwolf
@
cocteau
#
pts/1
%
J0S2
:
getbitmap
$
./getbitmap /usr/share/fonts/chinese/True
Type/uming.ttf $(mygetunicode ) 16
unicode +4E2D size 16
bitmap_left=1
bitmap_top=14
bitmap.rows=15
bitmap.width=14
bitmap.pitch=2
bitmap.pixel_mode=1
______________
______OOO______
______OO_______
______OO_______
______OO____OO_
_OOOOOOOOOOOOOO
_O____OO____OO_
_O____OO____OO_
_O____OO____OO_
_OOOOOOOOOOOOO_
_O____OO____OO_
______OO_______
______OO_______
______OO_______
______OO_______
______OO_______
hellwolf
@
cocteau
#
pts/1
%
J0S2
:
getbitmap
$
./getbitmap /usr/share/fonts/chinese/True
Type/uming.ttf $(mygetunicode ) 32
unicode +4E2D size 32
bitmap_left=4
bitmap_top=28
bitmap.rows=32
bitmap.width=26
bitmap.pitch=4
bitmap.pixel_mode=1
__________________________
__________________________
__________________________
__________________________
______________OO______________
______________OOOO____________
______________OOO_____________
______________OOO_____________
______________OOO_____________
______________OOO_____________
____O_________OOO________OOO__
____OOOOOOOOOOOOOOOOOOOOOOOOO_
____OO________OOO________OOO__
____OO________OOO________OOO__
____OO________OOO________OOO__
____OO________OOO________OOO__
____OO________OOO________OOO__
____OO________OOO________OOO__
____OO________OOO________OOO__
____OO________OOO________OOO__
____OO________OOO________OOO__
____OOOOOOOOOOOOOOOOOOOOOOOO__
____OO________OOO________OOO__
____OO________OOO________OOO__
____O_________OOO________OO___
______________OOO_____________
______________OOO_____________
______________OOO_____________
______________OOO_____________
______________OOO_____________
______________OOO_____________
______________OOO_____________
______________OOO_____________
______________OOO_____________
______________OO______________
______________________________
hellwolf
@
cocteau
#
pts/1
%
J0S2
:
getbitmap
$
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Docker를 사용한 React 및 .NET Core 6.0 샘플 프로젝트 - 1부이 기사에서는 Entity Framework Core Code First 접근 방식을 사용하는 ASP.NET Core 6.0 WEP API의 CRUD(만들기, 읽기, 업데이트 및 삭제) 작업에 대해 설명합니다. 웹 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.