New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.bdf and .pcf fonts do not work #448

Closed
SuperV1234 opened this Issue Aug 12, 2013 · 15 comments

Comments

Projects
None yet
9 participants
@SuperV1234

SuperV1234 commented Aug 12, 2013

Loading them with sf::Font::loadFromFile returns true, but nothing is displayed when a sf::Text uses them.

@SuperV1234

This comment has been minimized.

Show comment
Hide comment
@SuperV1234

SuperV1234 commented Aug 12, 2013

@ghost ghost assigned LaurentGomila Aug 13, 2013

@LagodichYuriy

This comment has been minimized.

Show comment
Hide comment
@LagodichYuriy

LagodichYuriy Dec 8, 2013

Guys, fix it please. Dammit bug.

LagodichYuriy commented Dec 8, 2013

Guys, fix it please. Dammit bug.

@jeremyong

This comment has been minimized.

Show comment
Hide comment
@jeremyong

jeremyong Dec 8, 2013

@ThisNameWasFree Why not submit a fix yourself?

jeremyong commented Dec 8, 2013

@ThisNameWasFree Why not submit a fix yourself?

binary1248 added a commit that referenced this issue Apr 30, 2014

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Apr 30, 2014

Member

I just pushed a draft fix for this. The issue was that FT_Set_Pixel_Sizes would always return non-zero in the case of a BDF or PCF font because they are bitmap fonts and thus unscalable. Because SFML doesn't continue to do anything if resizing fails, no glyphs would be displayed.

Member

binary1248 commented Apr 30, 2014

I just pushed a draft fix for this. The issue was that FT_Set_Pixel_Sizes would always return non-zero in the case of a BDF or PCF font because they are bitmap fonts and thus unscalable. Because SFML doesn't continue to do anything if resizing fails, no glyphs would be displayed.

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Apr 30, 2014

Member

What happens then with your fix? Do these fonts render properly, at the chosen character size?

Member

LaurentGomila commented Apr 30, 2014

What happens then with your fix? Do these fonts render properly, at the chosen character size?

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Apr 30, 2014

Member

No... bitmap fonts can't be resized unless they contain separate faces for each required size. Most (if not almost all) bitmap fonts come with a single size and thus that size is commonly appended to their filename e.g. Arial-bold-11.bdf or something.

The fix merely allows processing to continue. If the user requests the characters at some other size than the font that they loaded themselves provides, it will just render at the provided size. This shouldn't be surprising to them since they know this would be the case when they chose to use the font.

Member

binary1248 commented Apr 30, 2014

No... bitmap fonts can't be resized unless they contain separate faces for each required size. Most (if not almost all) bitmap fonts come with a single size and thus that size is commonly appended to their filename e.g. Arial-bold-11.bdf or something.

The fix merely allows processing to continue. If the user requests the characters at some other size than the font that they loaded themselves provides, it will just render at the provided size. This shouldn't be surprising to them since they know this would be the case when they chose to use the font.

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Apr 30, 2014

Member

If the user requests the characters at some other size than the font that they loaded themselves provides, it will just render at the provided size.

Maybe this would deserve a special comment, for example in sf::Text::setCharacterSize and/or in sf::Font documentation?

Member

LaurentGomila commented Apr 30, 2014

If the user requests the characters at some other size than the font that they loaded themselves provides, it will just render at the provided size.

Maybe this would deserve a special comment, for example in sf::Text::setCharacterSize and/or in sf::Font documentation?

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Apr 30, 2014

Member

I'm sure a reminder somewhere that their bitmap font doesn't allow resizing wouldn't hurt. You can go ahead and add it wherever you see fit ;).

Member

binary1248 commented Apr 30, 2014

I'm sure a reminder somewhere that their bitmap font doesn't allow resizing wouldn't hurt. You can go ahead and add it wherever you see fit ;).

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 May 1, 2014

Member

I just added a few comments in places that people will hopefully look when they don't understand what is happening ;). Ammended commit: 692b860

Member

binary1248 commented May 1, 2014

I just added a few comments in places that people will hopefully look when they don't understand what is happening ;). Ammended commit: 692b860

@FRex

This comment has been minimized.

Show comment
Hide comment
@FRex

FRex May 1, 2014

Contributor

Maybe print to sf::err() as well?

Contributor

FRex commented May 1, 2014

Maybe print to sf::err() as well?

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 May 1, 2014

Member

Printing to sf::Err() will spam the console with useless messages too often even in situations where the user specified to use a font at the correct size, since SFML tries to set the font's size no matter what.

The problem is that SFML relies on FreeType tracking the current size of the face. This works for outline/scaleable fonts, but if the font is not scalable, the size will always be 0, since it is not supposed to be used in that case anyway. Since the comparison in setCurrentSize will always fail, it will keep trying to set the font's size and spam over and over. One could consider checking the requested size against face->available_sizes but I couldn't tell from the FreeType documentation if it is always going to be populated for bitmap fonts, they only mention that it is optional for scalable fonts.

I think if we put up enough warning signs and the user understands what kind of a font they are using, they shouldn't be too surprised, even without messages on sf::Err().

Member

binary1248 commented May 1, 2014

Printing to sf::Err() will spam the console with useless messages too often even in situations where the user specified to use a font at the correct size, since SFML tries to set the font's size no matter what.

The problem is that SFML relies on FreeType tracking the current size of the face. This works for outline/scaleable fonts, but if the font is not scalable, the size will always be 0, since it is not supposed to be used in that case anyway. Since the comparison in setCurrentSize will always fail, it will keep trying to set the font's size and spam over and over. One could consider checking the requested size against face->available_sizes but I couldn't tell from the FreeType documentation if it is always going to be populated for bitmap fonts, they only mention that it is optional for scalable fonts.

I think if we put up enough warning signs and the user understands what kind of a font they are using, they shouldn't be too surprised, even without messages on sf::Err().

@FRex

This comment has been minimized.

Show comment
Hide comment
@FRex

FRex May 1, 2014

Contributor

One could consider checking the requested size against face->available_sizes but I couldn't tell from the FreeType documentation if it is always going to be populated for bitmap fonts, they only mention that it is optional for scalable fonts.

That's what I meant, spam only if the size used in Text wouldn't match bitmaps' actual size.

Contributor

FRex commented May 1, 2014

One could consider checking the requested size against face->available_sizes but I couldn't tell from the FreeType documentation if it is always going to be populated for bitmap fonts, they only mention that it is optional for scalable fonts.

That's what I meant, spam only if the size used in Text wouldn't match bitmaps' actual size.

@TankOs

This comment has been minimized.

Show comment
Hide comment
@TankOs

TankOs May 1, 2014

Member

There should definitely be a notice at least.

Member

TankOs commented May 1, 2014

There should definitely be a notice at least.

binary1248 added a commit that referenced this issue May 6, 2014

Fix BDF and PCF fonts not being used properly because setting the pix…
…el size in freetype fails for bitmap fonts (#448), fixed getKerning returning scaled values even for bitmap fonts.

binary1248 added a commit that referenced this issue May 6, 2014

Fix bitmap font resize failing silently when resizing to an unsupport…
…ed pixel size (#448), fixed getKerning returning scaled values even for bitmap fonts.

@Bromeon Bromeon added the s:accepted label Jun 6, 2014

binary1248 added a commit that referenced this issue Jun 11, 2014

Fix bitmap font resize failing silently when resizing to an unsupport…
…ed pixel size (#448), fixed getKerning returning scaled values even for bitmap fonts.
@TankOs

This comment has been minimized.

Show comment
Hide comment
@TankOs

TankOs Jun 11, 2014

Member

Fixed in master.

Member

TankOs commented Jun 11, 2014

Fixed in master.

@TankOs TankOs closed this Jun 11, 2014

@Bromeon Bromeon modified the milestones: 2.2, 2.x Jun 12, 2014

MarioLiebisch added a commit to MarioLiebisch/SFML that referenced this issue Jun 13, 2014

Fix bitmap font resize failing silently when resizing to an unsupport…
…ed pixel size (SFML#448), fixed getKerning returning scaled values even for bitmap fonts.

jcowgill added a commit to jcowgill/SFML that referenced this issue Sep 22, 2014

Fix bitmap font resize failing silently when resizing to an unsupport…
…ed pixel size (SFML#448), fixed getKerning returning scaled values even for bitmap fonts.

(cherry picked from commit da79517)
@neagix

This comment has been minimized.

Show comment
Hide comment
@neagix

neagix May 31, 2016

I tried 2.2 and 2.3.2, this issue is still present. For example use -Misc-Fixed-Medium-R-Normal--10-100-75-75-C-60-ISO10646-1 from https://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html and try to set size to anything different than 10: nothing is rendered. I have also tried converting the font first to PCF, same result.

neagix commented May 31, 2016

I tried 2.2 and 2.3.2, this issue is still present. For example use -Misc-Fixed-Medium-R-Normal--10-100-75-75-C-60-ISO10646-1 from https://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html and try to set size to anything different than 10: nothing is rendered. I have also tried converting the font first to PCF, same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment