update
This commit is contained in:
commit
bbb97be6c4
71 files changed
+1738
No files matched your search
@@ -0,0 +1,160 @@
|
||||
#include <amsfontconverter4/amsfontconverter4.hpp>
|
||||
|
||||
namespace ams
|
||||
{
|
||||
namespace font4
|
||||
{
|
||||
|
||||
freetype_fontfaceloader::freetype_fontfaceloader()
|
||||
{
|
||||
bopen = 0;
|
||||
blibinit = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
freetype_fontfaceloader::~freetype_fontfaceloader()
|
||||
{
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
int freetype_fontfaceloader::open(const char *fontfilename)
|
||||
{
|
||||
int ret = 0;
|
||||
int error;
|
||||
|
||||
error = FT_Init_FreeType(&(library));
|
||||
if(!error)
|
||||
{
|
||||
blibinit = 1;
|
||||
|
||||
error = FT_New_Face(library,fontfilename,0,&face);
|
||||
if(!error)
|
||||
{
|
||||
ret = 1;
|
||||
bopen = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = 0;
|
||||
bopen=0;
|
||||
printf("freetype fontfaceloader: Error: Could not load file %s\n",fontfilename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
blibinit = 0;
|
||||
printf("freetype fontfaceloader: Error: FT_Init_FreeType failed.\n");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void freetype_fontfaceloader::close()
|
||||
{
|
||||
if(bopen==1) {FT_Done_Face(face); bopen=0;}
|
||||
if(blibinit==1) {FT_Done_FreeType(library); blibinit=0;}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool freetype_fontfaceloader::hasglyph(uint32_t charind)
|
||||
{
|
||||
bool ret = 0;
|
||||
if(bopen==1)
|
||||
{
|
||||
if(FT_Get_Char_Index(face,charind)==0)
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int freetype_fontfaceloader::getglyph(uint32_t charind, int charheight, amsbitplane *glyph, amsglyphmetrics *metrics)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
FT_GlyphSlot slot;
|
||||
FT_Matrix matrix;
|
||||
FT_Vector pen;
|
||||
FT_Error error;
|
||||
|
||||
int I,J;
|
||||
|
||||
if(bopen)
|
||||
{
|
||||
|
||||
matrix.xx = (FT_Fixed)( cos( 0.0 ) * 0x10000L );
|
||||
matrix.xy = (FT_Fixed)(-sin( 0.0 ) * 0x10000L );
|
||||
matrix.yx = (FT_Fixed)( sin( 0.0 ) * 0x10000L );
|
||||
matrix.yy = (FT_Fixed)( cos( 0.0 ) * 0x10000L );
|
||||
|
||||
pen.x = 0;
|
||||
pen.y = 0;
|
||||
FT_Set_Char_Size(face,charheight*64,0,100,0);
|
||||
FT_Set_Transform(face,&matrix,&pen);
|
||||
if(hasglyph(charind))
|
||||
{
|
||||
ret = 1;
|
||||
FT_Load_Char(face,charind,FT_LOAD_RENDER);
|
||||
slot = face->glyph;
|
||||
|
||||
//metrics->width = face->glyph->metrics.width/64;
|
||||
//metrics->height = face->glyph->metrics.height/64;
|
||||
metrics->width = slot->bitmap.width;
|
||||
metrics->height = slot->bitmap.rows;
|
||||
metrics->xbearing = face->glyph->metrics.horiBearingX/64;
|
||||
metrics->ybearing = face->glyph->metrics.horiBearingY/64;
|
||||
metrics->haschar = 1;
|
||||
|
||||
glyph->resize(metrics->width, metrics->height);
|
||||
glyph->clear();
|
||||
for(I=0;I<metrics->width && I<slot->bitmap.width;I++)
|
||||
{
|
||||
for(J=0;J<metrics->height && J<slot->bitmap.rows;J++)
|
||||
{
|
||||
if(slot->bitmap.buffer[J*slot->bitmap.width+I]!=0)
|
||||
{
|
||||
glyph->at(I,J) = (uint8_t)1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
metrics->haschar = -1;
|
||||
metrics->width = 0;
|
||||
metrics->height = 0;
|
||||
metrics->xbearing = 0;
|
||||
metrics->ybearing = 0;
|
||||
glyph->resize(0,0);
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else //if(bopen)
|
||||
{
|
||||
metrics->haschar = -1;
|
||||
metrics->width = 0;
|
||||
metrics->height = 0;
|
||||
metrics->xbearing = 0;
|
||||
metrics->ybearing = 0;
|
||||
glyph->resize(0,0);
|
||||
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <amsfontconverter4/amsfontconverter4.hpp>
|
||||
|
||||
namespace ams
|
||||
{
|
||||
namespace font4
|
||||
{
|
||||
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <amsfontconverter4/amsfontconverter4.hpp>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
printf("ams fontconverter4 tests.\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in new issue
Block a user