Jump to content

Recommended Posts

Posted

I am using the Fixed_10x20 font and would like to use the degree symbol.  It doesn't seem to be available in the .c file that comes in the distribution.  It is in the .bdf file, so I thought I would would convert the .bdf file to a .c using the online font converter.  The online font converter does not work with the file and always gives a "Could not move file" error message.

So I used the mcufont.exe program in the tools directory.  I converted the .bdf file to a .dat file first.  Than I converted the .dat file to a .c file.  Using the .c font file, I was able to use the degree symbol as expected.  The problem that I have is the font characteristics for my converted .c file is not the same as the fixed_10x20.c file that comes with the distribution. 

The code below is from the distribution copy of the fixed_10x20.c file:

static const struct mf_bwfont_char_range_s mf_bwfont_fixed_10x20_char_ranges[] = {
    {
        32, /* first char */
        95, /* char count */
        0, /* offset x */
        0, /* offset y */
        3, /* height in bytes */
        17, /* height in pixels */
        0, /* width */
        mf_bwfont_fixed_10x20_glyph_widths_0, /* glyph widths */
        mf_bwfont_fixed_10x20_glyph_offsets_0, /* glyph offsets */
        mf_bwfont_fixed_10x20_glyph_data_0, /* glyph data */
    },
};

const struct mf_bwfont_s mf_bwfont_fixed_10x20 = {
    {
    "-Misc-Fixed-Medium-R-Normal--20-200-75-75-C-100-ISO8859-15",
    "fixed_10x20",
    9, /* width */
    17, /* height */
    10, /* min x advance */
    10, /* max x advance */
    -1, /* baseline x */
    13, /* baseline y */
    20, /* line height */
    3, /* flags */
    63, /* fallback character */
    &mf_bwfont_character_width,
    &mf_bwfont_render_character,
    },
    4, /* version */
    1, /* char range count */
    mf_bwfont_fixed_10x20_char_ranges,
};
 

This code is from the .c file that mcufont created:

static const struct mf_bwfont_char_range_s mf_bwfont_fixed_10x20_all_char_ranges[] = {
    {
        0, /* first char */
        127, /* char count */
        0, /* offset x */
        0, /* offset y */
        3, /* height in bytes */
        20, /* height in pixels */
        10, /* width */
        0, /* glyph widths */
        0, /* glyph offsets */
        mf_bwfont_fixed_10x20_all_glyph_data_0, /* glyph data */
    },
    {
        160, /* first char */
        96, /* char count */
        0, /* offset x */
        0, /* offset y */
        3, /* height in bytes */
        20, /* height in pixels */
        10, /* width */
        0, /* glyph widths */
        0, /* glyph offsets */
        mf_bwfont_fixed_10x20_all_glyph_data_1, /* glyph data */
    },
};

const struct mf_bwfont_s mf_bwfont_fixed_10x20_all = {
    {
    "-Misc-Fixed-Medium-R-Normal--20-200-75-75-C-100-ISO8859-15",
    "fixed_10x20_all",
    10, /* width */
    20, /* height */
    10, /* min x advance */
    10, /* max x advance */
    -1, /* baseline x */
    13, /* baseline y */
    17, /* line height */
    3, /* flags */
    0, /* fallback character */
    &mf_bwfont_character_width,
    &mf_bwfont_render_character,
    },
    4, /* version */
    2, /* char range count */
    mf_bwfont_fixed_10x20_all_char_ranges,
};
 

Notice the differences in the height, width and baseline values.  When I use this converted font my line spacing is different from the distributed copy of the font.  I would assume that that the .bdf file converted to a .c file using mcufont should create an identical .c file with the addition of the special characters.  

What could I be doing wrong?

Thanks

Posted

As you are using a different filter range (hence the availability of the degree symbol), and possibly because of other parameter changes, it has converted the font differently.

Posted

Your comment caused me to do some more investigation which resulted in success.

I originally used mcufont to convert from .bdf to .dat and then from .dat to .c format. I used the following 2 commands:

mcufont import_bdf fixed_10x20.bdf

mcufont bwfont_export fixed_10x20.dat fixed_10x20_all.c

This resulted in a .c file with all the characters but my line spacing was no longer the same.

After reading your response, I added this filter step before creating the .c file:

mcufont filter fixed_10x20.dat 32-127 176

This filter used the original range and just added the degree character that I needed.  Creating the .c file from that filtered .dat file worked properly.

What I don't understand is why when all the characters are added, the spacing values would change.  I would have thought that those values would remain stable within a font.

 

 

Posted

While the bdf format is a bitmap font format, it is not the same as the mcufont format. Some of the parameters (obviously including the spacing) is calculated from the font data itself.

I am not sure of the details of what is calculated and what is accepted verbatim from the source font. It will also change depending on the type of source font.

Mcufont was generously donated to ugfx, along with a compatible license, in the early days of ugfx. We have maintained it, fixed bugs, and updated portions over time but I wouldn't go so far as to say we understand as well as the rest of ugfx. Good font drawing is an incredibly difficult process particularly on low powered cpu's hence making the value of the mcufont contribution very significant.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...