FreeBASIC マニュアルのトップに戻る

FreeBASIC ExtLibfreetype2

目次→その他→ライブラリ・ヘッダー索引Freetype2←オリジナル・サイト

Freetype2


無料で、高品質で、移植可能な、フォント・エンジン

ウエブ・サイト: http://www.freetype.org
利用できる環境: Win32, Linux
include するヘッダー: freetype2/freetype.bi
ヘッダー・バージョン: 2.5.5
使用例: 有り, examples/graphics/FreeType/

例:
'' freetype を使って、文字で下塗りする例

#include "freetype2/freetype.bi"

#ifdef __FB_LINUX__
Const TTF_FONT = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"
#else
Const TTF_FONT = "Vera.ttf"
#endif

Dim As FT_Library library
If (FT_Init_FreeType(@library) <> 0) Then
    Print "FT_Init_FreeType() failed" : Sleep : End 1
End If

''
'' フォントをロードし、ビットマップ上に「@」文字を下塗りします。
''

Dim As FT_Face face
If (FT_New_Face(library, TTF_FONT, 0, @face) <> 0) Then
    Print "FT_New_Face() failed (font file '" & TTF_FONT & "' not found?)" : Sleep : End 1
End If

If (FT_Set_Pixel_Sizes(face, 0, 200) <> 0) Then
    Print "FT_Set_Pixel_Sizes() failed" : Sleep : End 1
End If

If (FT_Load_Char(face, Asc("@"), FT_LOAD_DEFAULT) <> 0) Then
    Print "FT_Load_Char() failed" : Sleep : End 1
End If

If (FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL) <> 0) Then
    Print "FT_Render_Glyph() failed" : Sleep : End 1
End If

''
'' 下塗りされたビットマップを描画します
''

ScreenRes 320, 200, 32

Dim As FT_Bitmap Ptr bitmap = @face->glyph->bitmap

For y As Integer = 0 To (bitmap->rows - 1)
    For x As Integer = 0 To (bitmap->width - 1)
        Dim As Integer col = bitmap->buffer[y * bitmap->pitch + x]
        PSet(x, y), RGB(col, col, col)
    Next
next

Sleep


ライブラリ・ヘッダー索引に戻る

←リンク元に戻る プログラム開発関連に戻る

ページ歴史:2016-02-10 15:50:31
日本語翻訳:WATANABE Makoto、原文著作者:SirMud

ホームページのトップに戻る

表示-非営利-継承