mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-25 16:22:20 +00:00
[CHG] FreeType is not needed in grrlib.h anymore
This commit is contained in:
parent
bc56c46e25
commit
6fc312d5e6
2 changed files with 19 additions and 15 deletions
|
@ -20,9 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <grrlib.h>
|
|
||||||
#include "grrlib/GRRLIB_ttf.h"
|
#include "grrlib/GRRLIB_ttf.h"
|
||||||
|
#include <grrlib.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
static FT_Library ftLibrary; /**< A handle to a FreeType library instance. */
|
static FT_Library ftLibrary; /**< A handle to a FreeType library instance. */
|
||||||
|
|
||||||
|
@ -56,14 +58,16 @@ void GRRLIB_ExitTTF (void) {
|
||||||
* @see GRRLIB_FreeTTF
|
* @see GRRLIB_FreeTTF
|
||||||
*/
|
*/
|
||||||
GRRLIB_ttfFont* GRRLIB_LoadTTF (const u8* file_base, s32 file_size) {
|
GRRLIB_ttfFont* GRRLIB_LoadTTF (const u8* file_base, s32 file_size) {
|
||||||
|
FT_Face Face;
|
||||||
GRRLIB_ttfFont* myFont = (GRRLIB_ttfFont*)malloc(sizeof(GRRLIB_ttfFont));
|
GRRLIB_ttfFont* myFont = (GRRLIB_ttfFont*)malloc(sizeof(GRRLIB_ttfFont));
|
||||||
FT_New_Memory_Face(ftLibrary, file_base, file_size, 0, &myFont->face);
|
FT_New_Memory_Face(ftLibrary, file_base, file_size, 0, &Face);
|
||||||
myFont->kerning = FT_HAS_KERNING(myFont->face);
|
myFont->kerning = FT_HAS_KERNING(Face);
|
||||||
/*
|
/*
|
||||||
if (FT_Set_Pixel_Sizes(myFont->face, 0, fontSize)) {
|
if (FT_Set_Pixel_Sizes(Face, 0, fontSize)) {
|
||||||
FT_Set_Pixel_Sizes(myFont->face, 0, 12);
|
FT_Set_Pixel_Sizes(Face, 0, 12);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
myFont->face = Face;
|
||||||
return myFont;
|
return myFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,16 +122,17 @@ void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *utf3
|
||||||
if(myFont == NULL || utf32 == NULL)
|
if(myFont == NULL || utf32 == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
FT_Face Face = (FT_Face)myFont->face;
|
||||||
unsigned int loop;
|
unsigned int loop;
|
||||||
int penX = 0;
|
int penX = 0;
|
||||||
int penY = fontSize;
|
int penY = fontSize;
|
||||||
FT_GlyphSlot slot = myFont->face->glyph;
|
FT_GlyphSlot slot = Face->glyph;
|
||||||
FT_UInt glyphIndex = 0;
|
FT_UInt glyphIndex = 0;
|
||||||
FT_UInt previousGlyph = 0;
|
FT_UInt previousGlyph = 0;
|
||||||
u8 cR = R(color), cG = G(color), cB = B(color);
|
u8 cR = R(color), cG = G(color), cB = B(color);
|
||||||
|
|
||||||
if (FT_Set_Pixel_Sizes(myFont->face, 0, fontSize)) {
|
if (FT_Set_Pixel_Sizes(Face, 0, fontSize)) {
|
||||||
FT_Set_Pixel_Sizes(myFont->face, 0, 12);
|
FT_Set_Pixel_Sizes(Face, 0, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t length = wcslen(utf32);
|
size_t length = wcslen(utf32);
|
||||||
|
@ -216,6 +221,7 @@ unsigned int GRRLIB_WidthTTFW(GRRLIB_ttfFont *myFont, const wchar_t *utf32, unsi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FT_Face Face = (FT_Face)myFont->face;
|
||||||
unsigned int loop;
|
unsigned int loop;
|
||||||
unsigned int penX = 0;
|
unsigned int penX = 0;
|
||||||
FT_UInt glyphIndex;
|
FT_UInt glyphIndex;
|
||||||
|
@ -233,14 +239,14 @@ unsigned int GRRLIB_WidthTTFW(GRRLIB_ttfFont *myFont, const wchar_t *utf32, unsi
|
||||||
|
|
||||||
if(myFont->kerning && previousGlyph && glyphIndex) {
|
if(myFont->kerning && previousGlyph && glyphIndex) {
|
||||||
FT_Vector delta;
|
FT_Vector delta;
|
||||||
FT_Get_Kerning(myFont->face, previousGlyph, glyphIndex, FT_KERNING_DEFAULT, &delta);
|
FT_Get_Kerning(Face, previousGlyph, glyphIndex, FT_KERNING_DEFAULT, &delta);
|
||||||
penX += delta.x >> 6;
|
penX += delta.x >> 6;
|
||||||
}
|
}
|
||||||
if(FT_Load_Glyph(myFont->face, glyphIndex, FT_LOAD_RENDER)) {
|
if(FT_Load_Glyph(Face, glyphIndex, FT_LOAD_RENDER)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
penX += myFont->face->glyph->advance.x >> 6;
|
penX += Face->glyph->advance.x >> 6;
|
||||||
previousGlyph = glyphIndex;
|
previousGlyph = glyphIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,6 @@ THE SOFTWARE.
|
||||||
// Includes
|
// Includes
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <ft2build.h>
|
|
||||||
#include FT_FREETYPE_H
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -159,8 +157,8 @@ typedef struct GRRLIB_bytemapFont {
|
||||||
* Structure to hold the TTF information.
|
* Structure to hold the TTF information.
|
||||||
*/
|
*/
|
||||||
typedef struct GRRLIB_Font {
|
typedef struct GRRLIB_Font {
|
||||||
FT_Face face; /**< A TTF face object. */
|
void *face; /**< A TTF face object. */
|
||||||
FT_Bool kerning; /**< true whenever a face object contains kerning data that can be accessed with FT_Get_Kerning. */
|
bool kerning; /**< true whenever a face object contains kerning data that can be accessed with FT_Get_Kerning. */
|
||||||
} GRRLIB_ttfFont;
|
} GRRLIB_ttfFont;
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
Loading…
Reference in a new issue