make atlas packer ASCII only for now
This commit is contained in:
parent
38e4e44b4d
commit
c0d9de9c4e
23
fonts.d
23
fonts.d
@ -114,11 +114,13 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension)
|
|||||||
u32 current_h = 0;
|
u32 current_h = 0;
|
||||||
u32 count = 0;
|
u32 count = 0;
|
||||||
|
|
||||||
FT_UInt index;
|
foreach(FT_ULong char_code; 0 .. 0x7F)
|
||||||
FT_ULong char_code = FT_Get_First_Char(font, &index);
|
|
||||||
while (index != 0)
|
|
||||||
{
|
{
|
||||||
FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER);
|
FT_Error res = FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER);
|
||||||
|
if (res != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
u32 bmp_w = font.glyph.bitmap.width;
|
u32 bmp_w = font.glyph.bitmap.width;
|
||||||
u32 bmp_h = font.glyph.bitmap.rows;
|
u32 bmp_h = font.glyph.bitmap.rows;
|
||||||
@ -133,8 +135,6 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension)
|
|||||||
max_w += bmp_w;
|
max_w += bmp_w;
|
||||||
current_h = bmp_h > current_h ? bmp_h : current_h;
|
current_h = bmp_h > current_h ? bmp_h : current_h;
|
||||||
count += 1;
|
count += 1;
|
||||||
|
|
||||||
char_code = FT_Get_Next_Char(font, char_code, &index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
atlas.atlas.glyphs = AllocArray!(Glyph)(arena, count);
|
atlas.atlas.glyphs = AllocArray!(Glyph)(arena, count);
|
||||||
@ -147,10 +147,13 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension)
|
|||||||
u32 font_w = font.size.metrics.x_ppem;
|
u32 font_w = font.size.metrics.x_ppem;
|
||||||
u32 font_h = font.size.metrics.y_ppem;
|
u32 font_h = font.size.metrics.y_ppem;
|
||||||
|
|
||||||
char_code = FT_Get_First_Char(font, &index);
|
foreach(FT_ULong char_code; 0 .. 0x7F)
|
||||||
while (index != 0)
|
|
||||||
{
|
{
|
||||||
FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER);
|
FT_Error res = FT_Load_Char(font, char_code, cast(FT_Int32)FT_LOAD_RENDER);
|
||||||
|
if (res != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
FT_GlyphSlot glyph = font.glyph;
|
FT_GlyphSlot glyph = font.glyph;
|
||||||
FT_Bitmap* bmp = &font.glyph.bitmap;
|
FT_Bitmap* bmp = &font.glyph.bitmap;
|
||||||
@ -196,8 +199,6 @@ CreateAtlas(Arena* arena, FontFace font, f32 size, u32 dimension)
|
|||||||
max_w += bmp.width;
|
max_w += bmp.width;
|
||||||
current_h = bmp.rows > current_h ? bmp.rows : current_h;
|
current_h = bmp.rows > current_h ? bmp.rows : current_h;
|
||||||
|
|
||||||
char_code = FT_Get_Next_Char(font, char_code, &index);
|
|
||||||
|
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user