weird version clashes

This commit is contained in:
madrocketsci committed 2025-06-14 09:51:24 -04:00
1 parent 34df3bd7c7
commit ca5265fc9e
16 files changed
+154 -17

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -55,19 +55,18 @@ namespace font4
};
int ft_load_glyphrange(
const char *fname,
int charheight,
uint32_t charindmin,
uint32_t charindmax,
amsglyphrange *glyphrange_out
);
///////////
// Tests //
///////////
void test_printglyph(amsbitplane *glyph);
void test_getglyph1();
void test_getglyph2();
void test_facemetrics();
void test_glyphrange_load();
};
};
#include <amsfontconverter4/amsfontconverter4_tests.hpp>
#endif
@@ -0,0 +1,24 @@
#ifndef __AMSFONTCONVERTER4_TESTS_HPP__
#define __AMSFONTCONVERTER4_TESTS_HPP__
namespace ams
{
namespace font4
{
///////////
// Tests //
///////////
void test_printglyph(amsbitplane *glyph);
void test_getglyph1();
void test_getglyph2();
void test_facemetrics();
void test_glyphrange_load();
void test_load_fontfamily1();
};
};
#endif
@@ -21,7 +21,7 @@ freetype_fontfaceloader::~freetype_fontfaceloader()
int freetype_fontfaceloader::open(const char *fontfilename)
{
int ret = 0;
int ret = fontconverter4_failure;
int error;
error = FT_Init_FreeType(&(library));
@@ -32,21 +32,22 @@ int freetype_fontfaceloader::open(const char *fontfilename)
error = FT_New_Face(library,fontfilename,0,&face);
if(!error)
{
ret = 1;
ret = fontconverter4_success;
bopen = 1;
}
else
{
ret = 0;
ret = fontconverter4_failure;
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;
ret = fontconverter4_failure;
}
return ret;
@@ -235,8 +236,8 @@ int freetype_fontfaceloader::load_glyphrange(
getglyph(
(uint32_t) I,
charheight,
&(glyphrange_out->glyphs[I]),
&(glyphrange_out->metrics[I])
&(glyphrange_out->glyphs[I-charindmin]),
&(glyphrange_out->metrics[I-charindmin])
);
}
@@ -251,5 +252,62 @@ int freetype_fontfaceloader::load_glyphrange(
return ret;
}
int ft_load_glyphrange(
const char *fname,
int charheight,
uint32_t charindmin,
uint32_t charindmax,
amsglyphrange *glyphrange_out
)
{
long I;
int ret = fontconverter4_success;
int res;
freetype_fontfaceloader ftloader;
if(glyphrange_out==NULL)
{
ret = fontconverter4_failure;
return ret;
}
res = ftloader.open(fname);
if(ftloader.bopen==0)
{
ret = fontconverter4_failure;
return ret;
}
*glyphrange_out = amsglyphrange();
charindmax = (charindmax<charindmin) ? charindmin : charindmax;
glyphrange_out->charheight = charheight;
glyphrange_out->charindmin = charindmin;
glyphrange_out->charindmax = charindmax;
glyphrange_out->fontfacemetrics = ftloader.getfacemetrics(charheight);
glyphrange_out->metrics.resize(charindmax-charindmin);
glyphrange_out->glyphs.resize(charindmax-charindmin);
for(I=charindmin;I<charindmax;I++)
{
ftloader.getglyph(
(uint32_t) I,
charheight,
&(glyphrange_out->glyphs[I-charindmin]),
&(glyphrange_out->metrics[I-charindmin])
);
}
glyphrange_out->docalculations();
ftloader.close();
return ret;
}
};
};
@@ -121,5 +121,57 @@ void test_glyphrange_load()
return;
}
void test_load_fontfamily1()
{
printf("Test loading a font family.\n");
int res;
int I;
int charheight = 30;
amsglyphrange gr;
amsfontfamily amsff;
const char *nfont = "../inputfonts/FreeMono.ttf";
const char *bfont = "../inputfonts/FreeMonoBold.ttf";
const char *ifont = "../inputfonts/FreeMonoOblique.ttf";
const char *bifont = "../inputfonts/FreeMonoBoldOblique.ttf";
res = ft_load_glyphrange(nfont,charheight,0,256,&gr);
gr.typefacetype = typefacetype_normal;
amsff.addrange(gr);
res = ft_load_glyphrange(bfont,charheight,0,256,&gr);
gr.typefacetype = typefacetype_bold;
amsff.addrange(gr);
res = ft_load_glyphrange(ifont,charheight,0,256,&gr);
gr.typefacetype = typefacetype_italic;
amsff.addrange(gr);
res = ft_load_glyphrange(bifont,charheight,0,256,&gr);
gr.typefacetype = typefacetype_bolditalic;
amsff.addrange(gr);
res = ft_load_glyphrange(bifont,charheight,256,512,&gr);
gr.typefacetype = typefacetype_bolditalic;
amsff.addrange(gr);
res = ft_load_glyphrange(nfont,charheight,256,512,&gr);
gr.typefacetype = typefacetype_normal;
amsff.addrange(gr);
amsff.print();
return;
}
};
};
+5 -1
View File
@@ -1,5 +1,7 @@
#include <amsfontconverter4/amsfontconverter4.hpp>
using namespace ams::font4;
int main(int argc, char* argv[])
{
int ret = 0;
@@ -7,7 +9,9 @@ int main(int argc, char* argv[])
//ams::font4::test_getglyph1();
//ams::font4::test_getglyph2();
//ams::font4::test_facemetrics();
ams::font4::test_glyphrange_load();
//ams::font4::test_glyphrange_load();
test_load_fontfamily1();
return ret;
}