2013-10-13 4 views
1

내부적으로 채우기가없는 외곽선 테두리 만 포함하는 글리프 비트 맵을 만들려고합니다. 이것을 위해 FreeType 라이브러리를 사용합니다. 그 결과FreeType : 채워지지 않은 외곽선을 래스터 화하는 방법

Spans outlineSpans; 
FT_Stroker stroker; 
FT_Stroker_New(ft, &stroker); 
FT_Stroker_Set(stroker, outlineWidth, round ? FT_STROKER_LINECAP_ROUND : FT_STROKER_LINECAP_SQUARE, round ? FT_STROKER_LINEJOIN_ROUND : FT_STROKER_LINEJOIN_BEVEL, 0); 

FT_Glyph g; 
FT_Get_Glyph(currentFace->glyph, &g); 
FT_Glyph_StrokeBorder(&g, stroker, 0, 1); 

FT_Raster_Params params; 
memset(&params, 0, sizeof(params)); 
params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT; 
params.gray_spans = RasterCallback; 
params.user = &outlineSpans; 
outlineSpans.clear(); 
FT_Outline *o = &reinterpret_cast<FT_OutlineGlyph>(g)->outline; 
int err = FT_Outline_Render(ft, o, &params); 

FT_Stroker_Done(stroker); 
FT_Done_Glyph(g); 

내가 전체 글리프 이미지 스팬 가득 outlineSpans 벡터를 얻을 수 있지만, 난 단지 "테두리"래스터 화 될 필요가 : 여기에 FreeType에서 참조에서 예 2 코드와 유사한 내 코드입니다. CurrentFace->glyph에는 내가로드 한 글리프가 포함되어 있습니다. FT_Load_Char(currentFace, *ch, FT_LOAD_NO_BITMAP)) 무엇이 잘못 되었나요? 어떤 도움을 주셔서 감사합니다, 그물에 FreeType에 대한 많은 문서/예제가 없습니다.

답변

0

윤곽선 글꼴로 어떻게 작업 할 수 있는지 솔루션을 통해 공유합니다. 그 글꼴 만 사용하면 도움이 될 것입니다.

 FT_OutlineGlyph _oGlyph; 
     struct Point{ 
      int x; 
      int y; 
     }; 

     vector<std::pair<int, int>> pointsPairVector; 

     pointCount = _oGlyph->outline.n_points; 

     for(int i = 0; i < pointCount; i++) 
     { 
      point.first = _oGlyph->outline.points[i].x; 
      point.second = _oGlyph->outline.points[i].y; 
      pointsPairVector.push_back(point) 
     } 
     //use Cairo to connect points in pointsPairVector 
관련 문제