int range_cmp(const void *, const void *);
unsigned round_to_pot(unsigned);
void *alloc_image_data(size_t, size_t);
-int init_font(Font *, FT_Face, const Range *, unsigned, bool, unsigned);
-int init_glyphs(Font *, FT_Face, const Range *, bool, unsigned);
+int init_font(Font *, FT_Face, const Range *, unsigned, bool, unsigned, unsigned);
+int init_glyphs(Font *, FT_Face, const Range *, bool, unsigned, unsigned);
int copy_bitmap(const FT_Bitmap *, Image *);
unsigned sqrti(unsigned);
unsigned find_distance_to_edge(const Image *, int, int, unsigned);
unsigned padding = 1;
bool npot = 0;
unsigned distfield = 0;
+ unsigned border = 0;
FT_Library freetype;
FT_Face face;
return 1;
}
- while((i = getopt(argc, argv, "r:s:l:c:o:atvh?ed:pim:n:gf:")) != -1)
+ while((i = getopt(argc, argv, "r:s:l:c:o:atvh?ed:pim:n:gf:b:")) != -1)
{
switch(i)
{
case 'f':
distfield = convert_numeric_option('f', 1);
break;
+ case 'b':
+ border = convert_numeric_option('b', 1);
+ break;
}
}
if(!strcmp(out_fn, "-"))
font.size = size;
if(distfield)
+ {
+ if(!border)
+ border = sqrti(font.size);
size *= distfield;
+ }
err = FT_Set_Pixel_Sizes(face, 0, size);
if(err)
else
sort_and_compact_ranges(ranges, &n_ranges);
- err = init_font(&font, face, ranges, n_ranges, autohinter, distfield);
+ err = init_font(&font, face, ranges, n_ranges, autohinter, distfield, border);
if(err)
return 1;
return ptr;
}
-int init_font(Font *font, FT_Face face, const Range *ranges, unsigned n_ranges, bool autohinter, unsigned distfield)
+int init_font(Font *font, FT_Face face, const Range *ranges, unsigned n_ranges, bool autohinter, unsigned distfield, unsigned border)
{
unsigned i, j;
unsigned size = 0;
font->n_glyphs = 0;
font->glyphs = NULL;
for(i=0; i<n_ranges; ++i)
- if(init_glyphs(font, face, &ranges[i], autohinter, distfield))
+ if(init_glyphs(font, face, &ranges[i], autohinter, distfield, border))
return -1;
if(verbose>=1)
return 0;
}
-int init_glyphs(Font *font, FT_Face face, const Range *range, bool autohinter, unsigned distfield)
+int init_glyphs(Font *font, FT_Face face, const Range *range, bool autohinter, unsigned distfield, unsigned border)
{
unsigned i, j;
unsigned size = font->n_glyphs;
start from the bottom. */
if(distfield)
{
- unsigned margin = 3;
-
- glyph->offset_x -= margin;
- glyph->offset_y -= margin;
- create_distance_field(bmp, &glyph->image, distfield, margin);
+ glyph->offset_x -= border;
+ glyph->offset_y -= border;
+ create_distance_field(bmp, &glyph->image, distfield, border);
}
else
{