bcc
bcc copied to clipboard
[SCT] (brl.freetypefont): Identifier '_face' not found
test "framework/mod/brl/freetypefont/ft_01.bmx" contains outdated code:
SuperStrict
Framework BRL.StandardIO
Import BRL.FreeTypeFont
Local font:TFreeTypeFont = TFreeTypeFont.Load("DroidSansMono.ttf", 12, SMOOTHFONT)
If font Then
Print "Family = " + String.FromCString(font._face.fname)
Print "Style = " + String.FromCString(font._face.sname)
Print "Height = " + font.Height()
Else
Print "Could not load font"
End If
Compile Error: Identifier '_face' not found.
[tests/framework/mod/brl/freetypefont/ft_01.bmx;9;0]
To solve it, we would need to add some new stuff:
pub.mod/freetype.mod/glue.c replace
#include <ft2build.h>
#include FT_FREETYPE_H
with
#include <brl.mod/blitz.mod/blitz.h>
#include <ft2build.h>
#include FT_FREETYPE_H
BBString * bmx_freetype_Face_family_name(FT_Face ft_face){
return bbStringFromCString( ft_face->family_name );
}
BBString * bmx_freetype_Face_style_name(FT_Face ft_face){
return bbStringFromCString( ft_face->style_name );
}
pub.mod/freetype.mod/source.bmx: replace:
Function bmx_freetype_Face_numglyphs:Int(ft_face:Byte Ptr)
with
Function bmx_freetype_Face_family_name:String(ft_face:Byte Ptr)
Function bmx_freetype_Face_style_name:String(ft_face:Byte Ptr)
Function bmx_freetype_Face_numglyphs:Int(ft_face:Byte Ptr)
open brl.mod/freetypefont.mod/freetypefont.bmx: replace
Method Delete()
FT_Done_Face _ft_face
End Method
with
Method Delete()
FT_Done_Face _ft_face
End Method
Method FamilyName:String()
Return bmx_freetype_Face_family_name(_ft_face)
End Method
Method StyleName:String()
Return bmx_freetype_Face_style_name(_ft_face)
End Method
Now you have access to FamilyName and StyleName again. So final step - adjusting the SCT test:
SuperStrict
Framework BRL.StandardIO
Import BRL.FreeTypeFont
Local font:TFreeTypeFont = TFreeTypeFont.Load("DroidSansMono.ttf", 12, SMOOTHFONT)
If font Then
Print "Family = " + font.FamilyName()
Print "Style = " + font.StyleName()
Print "Height = " + font.Height()
Else
Print "Could not load font"
End If
it would again print out the desired "result".