Openage: Font setting to size 12 error

Created on 28 Feb 2019  路  12Comments  路  Source: SFTtech/openage

Failed to set font size to 12
Font is installed
Windows 10 pro

Not sure where to turn, feel like this might be my last run error? (fingers crossed!)

image

image

bug c++ rendering windows

All 12 comments

So the error came from here:

    if (unlikely(FT_Set_Char_Size(ft_face, 0, this->description.size * FREETYPE_UNIT, 72, 72))) {
        throw Error(MSG(err) << "Failed to set font face size to " << this->description.size);
    }

https://www.freetype.org/freetype2/docs/tutorial/step1.html

When a new face object is created, all elements are set to 0 during initialization. To populate the structure with sensible values, you should call FT_Set_Char_Size.

https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Set_Char_Size

So we have to return the freetype error code in order to figure out why the operation didn't succeed.

So i hack about and see if swapping it to a native Windows font would run? - can try later today - maybe Arial or something.

Yes, but I think we should try to tackle that problem instead of trying a workaround :) I'd first throw the return value of FT_Set_Char_Size if it is not 0, then see why freetype fails populating the structure.

Ok
@TheJJ can you guys tell me what/why this would be a bad idea? i can tidy up some more of the other errors(?) once i find a suitable pattern which is acceptable to the project/styles.

    int did_set_font_size = FT_Set_Char_Size(ft_face, 0, this->description.size * FREETYPE_UNIT, 72, 72);

    if (did_set_font_size != 0) {
        throw Error(MSG(err) << "Failed to set font face from " << ft_library << " " << this->description.font_file.c_str() << ", to size " << this->description.size << ", FT exit code: " << did_set_font_size);
    }

i don't often write much c++ so i imagine i've annoyed the compiler by outputting an INT to a string? (i did try << std::to_string(x) but no luck).

My error as it happens was exit code 23 which is FT_ERRORDEF_( Invalid_Face_Handle, 0x23, "invalid face handle" ) - which sounds mad to me, but looking into it now.

Final error output i'm showing is:
Failed to set font face from 000002AA93B2A5C0 C:/WINDOWS/fonts/8514fix.fon, to size 12, FT exit code: 23

To start with that path / library sounds a bit weird:
this->description.font_file.c_str()

I'm not truncating the 't' from 'font' so not totally sure why i've got 8514fix.fon ?

I've read that 8541fix.fon is supposed to be an internal windows font file.
Which lead me back to Dejavu font face - now i'm not entirely sure what's occurring actually. I will try to map to a different font face/file for the moment and see if i can at least get this to run before retreating and seeing if i can locate exactly why

Arial... woop.

image

I've seen the other issue about font packaging and that it was a contentious issue - but i must say, i'd sort of expect a fallback; i had a feeling that was what Freetype was supposed to be doing; it may be that the fallback on this particular Windows 10 box is also dead (?).

I know this is ultimately an edge case but perhaps i could take a look into font fallbacks based on the system?

Failed to set font face from 000002AA93B2A5C0 C:/WINDOWS/fonts/8514fix.fon, to size 12, FT exit code: 23

From your code, it looks like you printed the returned value in decimal, i.e. 23 == 0x17.
From FreeType's fterrdef.h that is "Invalid_Pixel_Size".

Oh derp, thanks @tusharpm - i wasn't sure what to do with their response as the docs said it returns 0 on success and didn't mention the return type when it was a failure (which i thought was odd).

So we're saying i've got the font file/face but no access to that size?
Perhaps then we could iterate a bunch of sizes from 1px -> 120px in a quick loop to see if all sizes are available, and if not fallback to system default serif?

I do still find it a little odd that i have the font installed but size 12 is not available, it is my belief that size 12 would be fairly common

On my Windows VM, the font_file is C:/Windows/fonts/DejaVuSerif.ttf, which seems to work as expected.

From your log, it seems like FT has chosen to use C:/WINDOWS/fonts/8514fix.fon which I read is an old Microsoft default installed font. I suspect (going by "fix" in the name) that font doesn't support variable character sizes.

It might be worthwhile to check if DejaVuSerif.ttf is installed in the system fonts directory (%SystemRoot%\Fonts). We would have to investigate further why we couldn't find it where WordPad did.

We should probably add a check if the selected font supports the size we request from it. Otherwise, skip it or select another font.

I had this error too while trying to get the build script running, I was sure I installed everything, the fonts were where they belonged too. I saw that fonts also get installed just on a user basis, so I checked HKLM/Software/Microsoft/Windows NT/CurrentVersion/Fonts - no sign of the fonts, so I reinstalled the fonts by right-clicking "Install for all users". Restarting and the error was gone. I still try to figure out, how to do that automatically with the script. But for people who have the same problem, check that first.

EDIT: A fallback to a system standard font would be nice though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

okias picture okias  路  3Comments

ShadowCreator picture ShadowCreator  路  3Comments

kevinmartinjos picture kevinmartinjos  路  4Comments

heinezen picture heinezen  路  3Comments

k3x picture k3x  路  7Comments