mirror of
https://github.com/dborth/fceugx.git
synced 2025-01-07 14:28:18 +01:00
This commit is contained in:
parent
587d836c0b
commit
179f55ba26
@ -26,7 +26,7 @@ static FT_Library ftLibrary; /**< FreeType FT_Library instance. */
|
|||||||
static FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
|
static FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
|
||||||
static FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */
|
static FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */
|
||||||
|
|
||||||
FreeTypeGX *fontSystem[50];
|
FreeTypeGX *fontSystem[MAX_FONT_SIZE+1];
|
||||||
|
|
||||||
void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize)
|
void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize)
|
||||||
{
|
{
|
||||||
|
@ -1,283 +1,285 @@
|
|||||||
/*
|
/*
|
||||||
* FreeTypeGX is a wrapper class for libFreeType which renders a compiled
|
* FreeTypeGX is a wrapper class for libFreeType which renders a compiled
|
||||||
* FreeType parsable font into a GX texture for Wii homebrew development.
|
* FreeType parsable font into a GX texture for Wii homebrew development.
|
||||||
* Copyright (C) 2008 Armin Tamzarian
|
* Copyright (C) 2008 Armin Tamzarian
|
||||||
* Modified by Tantric, 2009
|
* Modified by Tantric, 2009
|
||||||
*
|
*
|
||||||
* This file is part of FreeTypeGX.
|
* This file is part of FreeTypeGX.
|
||||||
*
|
*
|
||||||
* FreeTypeGX is free software: you can redistribute it and/or modify
|
* FreeTypeGX is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published
|
* it under the terms of the GNU Lesser General Public License as published
|
||||||
* by the Free Software Foundation, either version 3 of the License, or
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* FreeTypeGX is distributed in the hope that it will be useful,
|
* FreeTypeGX is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>.
|
* along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage FreeTypeGX
|
/** \mainpage FreeTypeGX
|
||||||
*
|
*
|
||||||
* \section sec_intro Introduction
|
* \section sec_intro Introduction
|
||||||
*
|
*
|
||||||
* FreeTypeGX is a wrapper class for libFreeType which renders a compiled FreeType parsable font into a GX texture for Wii homebrew development.
|
* FreeTypeGX is a wrapper class for libFreeType which renders a compiled FreeType parsable font into a GX texture for Wii homebrew development.
|
||||||
* <br>
|
* <br>
|
||||||
* FreeTypeGX is written in C++ and makes use of a selectable pre-buffered or buffer-on-demand methodology to allow fast and efficient printing of text to the EFB.
|
* FreeTypeGX is written in C++ and makes use of a selectable pre-buffered or buffer-on-demand methodology to allow fast and efficient printing of text to the EFB.
|
||||||
* <p>
|
* <p>
|
||||||
* This library was developed in-full by Armin Tamzarian with the support of developers in \#wiibrew on EFnet.
|
* This library was developed in-full by Armin Tamzarian with the support of developers in \#wiibrew on EFnet.
|
||||||
*
|
*
|
||||||
* \section sec_installation_source Installation (Source Code)
|
* \section sec_installation_source Installation (Source Code)
|
||||||
*
|
*
|
||||||
* -# Ensure that you have the <a href = "http://www.tehskeen.com/forums/showthread.php?t=9404">libFreeType</a> Wii library installed in your development environment with the library added to your Makefile where appropriate.
|
* -# Ensure that you have the <a href = "http://www.tehskeen.com/forums/showthread.php?t=9404">libFreeType</a> Wii library installed in your development environment with the library added to your Makefile where appropriate.
|
||||||
* -# Ensure that you have the <a href = "http://code.google.com/p/metaphrasis">Metaphrasis</a> library installed in your development environment with the library added to your Makefile where appropriate.
|
* -# Ensure that you have the <a href = "http://code.google.com/p/metaphrasis">Metaphrasis</a> library installed in your development environment with the library added to your Makefile where appropriate.
|
||||||
* -# Extract the FreeTypeGX archive.
|
* -# Extract the FreeTypeGX archive.
|
||||||
* -# Copy the contents of the <i>src</i> directory into your project's development path.
|
* -# Copy the contents of the <i>src</i> directory into your project's development path.
|
||||||
* -# Include the FreeTypeGX header file in your code using syntax such as the following:
|
* -# Include the FreeTypeGX header file in your code using syntax such as the following:
|
||||||
* \code
|
* \code
|
||||||
* #include "FreeTypeGX.h"
|
* #include "FreeTypeGX.h"
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \section sec_installation_library Installation (Library)
|
* \section sec_installation_library Installation (Library)
|
||||||
*
|
*
|
||||||
* -# Ensure that you have the <a href = "http://www.tehskeen.com/forums/showthread.php?t=9404">libFreeType</a> Wii library installed in your development environment with the library added to your Makefile where appropriate.
|
* -# Ensure that you have the <a href = "http://www.tehskeen.com/forums/showthread.php?t=9404">libFreeType</a> Wii library installed in your development environment with the library added to your Makefile where appropriate.
|
||||||
* -# Ensure that you have the <a href = "http://code.google.com/p/metaphrasis">Metaphrasis</a> library installed in your development environment with the library added to your Makefile where appropriate.
|
* -# Ensure that you have the <a href = "http://code.google.com/p/metaphrasis">Metaphrasis</a> library installed in your development environment with the library added to your Makefile where appropriate.
|
||||||
* -# Extract the FreeTypeGX archive.
|
* -# Extract the FreeTypeGX archive.
|
||||||
* -# Copy the contents of the <i>lib</i> directory into your <i>devKitPro/libogc</i> directory.
|
* -# Copy the contents of the <i>lib</i> directory into your <i>devKitPro/libogc</i> directory.
|
||||||
* -# Include the FreeTypeGX header file in your code using syntax such as the following:
|
* -# Include the FreeTypeGX header file in your code using syntax such as the following:
|
||||||
* \code
|
* \code
|
||||||
* #include "FreeTypeGX.h"
|
* #include "FreeTypeGX.h"
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \section sec_freetypegx_prerequisites FreeTypeGX Prerequisites
|
* \section sec_freetypegx_prerequisites FreeTypeGX Prerequisites
|
||||||
*
|
*
|
||||||
* Before you begin using FreeTypeGX in your project you must ensure that the desired font in compiled into your project. For this example I will assume you are building your project with a Makefile using devKitPro evironment and are attempting to include a font whose filename is rursus_compact_mono.ttf.
|
* Before you begin using FreeTypeGX in your project you must ensure that the desired font in compiled into your project. For this example I will assume you are building your project with a Makefile using devKitPro evironment and are attempting to include a font whose filename is rursus_compact_mono.ttf.
|
||||||
*
|
*
|
||||||
* -# Copy the font into a directory which will be processed by the project's Makefile. If you are unsure about where you should place your font just copy the it into your project's source directory.
|
* -# Copy the font into a directory which will be processed by the project's Makefile. If you are unsure about where you should place your font just copy the it into your project's source directory.
|
||||||
* \n\n
|
* \n\n
|
||||||
* -# Modify the Makefile to convert the font into an object file:
|
* -# Modify the Makefile to convert the font into an object file:
|
||||||
* \code
|
* \code
|
||||||
* %.ttf.o : %.ttf
|
* %.ttf.o : %.ttf
|
||||||
* @echo $(notdir $<)
|
* @echo $(notdir $<)
|
||||||
* $(bin2o)
|
* $(bin2o)
|
||||||
* \endcode
|
* \endcode
|
||||||
* \n
|
* \n
|
||||||
* -# Include the font object's generated header file in your source code:
|
* -# Include the font object's generated header file in your source code:
|
||||||
* \code
|
* \code
|
||||||
* #include "rursus_compact_mono_ttf.h"
|
* #include "rursus_compact_mono_ttf.h"
|
||||||
* \endcode
|
* \endcode
|
||||||
* This header file defines the two variables that you will need for use within your project:
|
* This header file defines the two variables that you will need for use within your project:
|
||||||
* \code
|
* \code
|
||||||
* extern const u8 rursus_compact_mono_ttf[]; A pointer to the font buffer within the compiled project.
|
* extern const u8 rursus_compact_mono_ttf[]; A pointer to the font buffer within the compiled project.
|
||||||
* extern const u32 rursus_compact_mono_ttf_size; The size of the font's buffer in bytes.
|
* extern const u32 rursus_compact_mono_ttf_size; The size of the font's buffer in bytes.
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \section sec_freetypegx_usage FreeTypeGX Usage
|
* \section sec_freetypegx_usage FreeTypeGX Usage
|
||||||
*
|
*
|
||||||
* -# Within the file you included the FreeTypeGX.h header create an instance object of the FreeTypeGX class:
|
* -# Within the file you included the FreeTypeGX.h header create an instance object of the FreeTypeGX class:
|
||||||
* \code
|
* \code
|
||||||
* FreeTypeGX *freeTypeGX = new FreeTypeGX();
|
* FreeTypeGX *freeTypeGX = new FreeTypeGX();
|
||||||
* \endcode
|
* \endcode
|
||||||
* Alternately you can specify a texture format to which you would like to render the font characters. Note that the default value for this parameter is GX_TF_RGBA8.
|
* Alternately you can specify a texture format to which you would like to render the font characters. Note that the default value for this parameter is GX_TF_RGBA8.
|
||||||
* \code
|
* \code
|
||||||
* FreeTypeGX *freeTypeGX = new FreeTypeGX(GX_TF_RGB565);
|
* FreeTypeGX *freeTypeGX = new FreeTypeGX(GX_TF_RGB565);
|
||||||
* \endcode
|
* \endcode
|
||||||
* Furthermore, you can also specify a vertex format index to avoid conflicts with concurrent libraries or other systems. Note that the default value for this parameter is GX_VTXFMT1.
|
* Furthermore, you can also specify a vertex format index to avoid conflicts with concurrent libraries or other systems. Note that the default value for this parameter is GX_VTXFMT1.
|
||||||
* \code
|
* \code
|
||||||
* FreeTypeGX *freeTypeGX = new FreeTypeGX(GX_TF_RGB565, GX_VTXFMT1);
|
* FreeTypeGX *freeTypeGX = new FreeTypeGX(GX_TF_RGB565, GX_VTXFMT1);
|
||||||
* \endcode
|
* \endcode
|
||||||
* \n
|
* \n
|
||||||
* Currently supported textures are:
|
* Currently supported textures are:
|
||||||
* \li <i>GX_TF_I4</i>
|
* \li <i>GX_TF_I4</i>
|
||||||
* \li <i>GX_TF_I8</i>
|
* \li <i>GX_TF_I8</i>
|
||||||
* \li <i>GX_TF_IA4</i>
|
* \li <i>GX_TF_IA4</i>
|
||||||
* \li <i>GX_TF_IA8</i>
|
* \li <i>GX_TF_IA8</i>
|
||||||
* \li <i>GX_TF_RGB565</i>
|
* \li <i>GX_TF_RGB565</i>
|
||||||
* \li <i>GX_TF_RGB5A3</i>
|
* \li <i>GX_TF_RGB5A3</i>
|
||||||
* \li <i>GX_TF_RGBA8</i>
|
* \li <i>GX_TF_RGBA8</i>
|
||||||
*
|
*
|
||||||
* \n
|
* \n
|
||||||
* -# Using the allocated FreeTypeGX instance object call the loadFont function to load the font from the compiled buffer and specify the desired point size. Note that this function can be called multiple times to load a new:
|
* -# Using the allocated FreeTypeGX instance object call the loadFont function to load the font from the compiled buffer and specify the desired point size. Note that this function can be called multiple times to load a new:
|
||||||
* \code
|
* \code
|
||||||
* freeTypeGX->loadFont(rursus_compact_mono_ttf, rursus_compact_mono_ttf_size, 64);
|
* freeTypeGX->loadFont(rursus_compact_mono_ttf, rursus_compact_mono_ttf_size, 64);
|
||||||
* \endcode
|
* \endcode
|
||||||
* Alternately you can specify a flag which will load and cache all available font glyphs immidiately. Note that on large font sets enabling this feature could take a significant amount of time.
|
* Alternately you can specify a flag which will load and cache all available font glyphs immidiately. Note that on large font sets enabling this feature could take a significant amount of time.
|
||||||
* \code
|
* \code
|
||||||
* freeTypeGX->loadFont(rursus_compact_mono_ttf, rursus_compact_mono_ttf_size, 64, true);
|
* freeTypeGX->loadFont(rursus_compact_mono_ttf, rursus_compact_mono_ttf_size, 64, true);
|
||||||
* \endcode
|
* \endcode
|
||||||
* \n
|
* \n
|
||||||
* -# If necessary you can enable compatibility modes with concurrent libraries or systems. For more information on this feature see the documentation for setCompatibilityMode:
|
* -# If necessary you can enable compatibility modes with concurrent libraries or systems. For more information on this feature see the documentation for setCompatibilityMode:
|
||||||
* \code
|
* \code
|
||||||
* freeTypeGX->setCompatibilityMode(FTGX_COMPATIBILITY_GRRLIB);
|
* freeTypeGX->setCompatibilityMode(FTGX_COMPATIBILITY_GRRLIB);
|
||||||
* \endcode
|
* \endcode
|
||||||
* -# Using the allocated FreeTypeGX instance object call the drawText function to print a string at the specified screen X and Y coordinates to the current EFB:
|
* -# Using the allocated FreeTypeGX instance object call the drawText function to print a string at the specified screen X and Y coordinates to the current EFB:
|
||||||
* \code
|
* \code
|
||||||
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"));
|
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"));
|
||||||
* \endcode
|
* \endcode
|
||||||
* Alternately you can specify a <i>GXColor</i> object you would like to apply to the printed characters:
|
* Alternately you can specify a <i>GXColor</i> object you would like to apply to the printed characters:
|
||||||
* \code
|
* \code
|
||||||
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"),
|
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"),
|
||||||
* (GXColor){0xff, 0xee, 0xaa, 0xff});
|
* (GXColor){0xff, 0xee, 0xaa, 0xff});
|
||||||
* \endcode
|
* \endcode
|
||||||
* Furthermore you can also specify a group of styling parameters which will modify the positioning or style of the text:
|
* Furthermore you can also specify a group of styling parameters which will modify the positioning or style of the text:
|
||||||
* \code
|
* \code
|
||||||
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"),
|
* freeTypeGX->drawText(10, 25, _TEXT("FreeTypeGX Rocks!"),
|
||||||
* (GXColor){0xff, 0xee, 0xaa, 0xff},
|
* (GXColor){0xff, 0xee, 0xaa, 0xff},
|
||||||
* FTGX_JUSTIFY_CENTER | FTGX_ALIGN_BOTTOM | FTGX_STYLE_UNDERLINE);
|
* FTGX_JUSTIFY_CENTER | FTGX_ALIGN_BOTTOM | FTGX_STYLE_UNDERLINE);
|
||||||
* \endcode
|
* \endcode
|
||||||
* \n
|
* \n
|
||||||
* Currently style parameters are:
|
* Currently style parameters are:
|
||||||
* \li <i>FTGX_JUSTIFY_LEFT</i>
|
* \li <i>FTGX_JUSTIFY_LEFT</i>
|
||||||
* \li <i>FTGX_JUSTIFY_CENTER</i>
|
* \li <i>FTGX_JUSTIFY_CENTER</i>
|
||||||
* \li <i>FTGX_JUSTIFY_RIGHT</i>
|
* \li <i>FTGX_JUSTIFY_RIGHT</i>
|
||||||
* \li <i>FTGX_ALIGN_TOP</i>
|
* \li <i>FTGX_ALIGN_TOP</i>
|
||||||
* \li <i>FTGX_ALIGN_MIDDLE</i>
|
* \li <i>FTGX_ALIGN_MIDDLE</i>
|
||||||
* \li <i>FTGX_ALIGN_BOTTOM</i>
|
* \li <i>FTGX_ALIGN_BOTTOM</i>
|
||||||
* \li <i>FTGX_STYLE_UNDERLINE</i>
|
* \li <i>FTGX_STYLE_UNDERLINE</i>
|
||||||
* \li <i>FTGX_STYLE_STRIKE</i>
|
* \li <i>FTGX_STYLE_STRIKE</i>
|
||||||
*
|
*
|
||||||
* \section sec_license License
|
* \section sec_license License
|
||||||
*
|
*
|
||||||
* FreeTypeGX is distributed under the GNU Lesser General Public License.
|
* FreeTypeGX is distributed under the GNU Lesser General Public License.
|
||||||
*
|
*
|
||||||
* \section sec_contact Contact
|
* \section sec_contact Contact
|
||||||
*
|
*
|
||||||
* If you have any suggestions, questions, or comments regarding this library feel free to e-mail me at tamzarian1989 [at] gmail [dawt] com.
|
* If you have any suggestions, questions, or comments regarding this library feel free to e-mail me at tamzarian1989 [at] gmail [dawt] com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FREETYPEGX_H_
|
#ifndef FREETYPEGX_H_
|
||||||
#define FREETYPEGX_H_
|
#define FREETYPEGX_H_
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
#include FT_BITMAP_H
|
#include FT_BITMAP_H
|
||||||
#include <Metaphrasis.h>
|
#include <Metaphrasis.h>
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
/*! \struct ftgxCharData_
|
#define MAX_FONT_SIZE 100
|
||||||
*
|
|
||||||
* Font face character glyph relevant data structure.
|
/*! \struct ftgxCharData_
|
||||||
*/
|
*
|
||||||
typedef struct ftgxCharData_ {
|
* Font face character glyph relevant data structure.
|
||||||
uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */
|
*/
|
||||||
uint16_t glyphIndex; /**< Charachter glyph index in the font face. */
|
typedef struct ftgxCharData_ {
|
||||||
|
uint16_t glyphAdvanceX; /**< Character glyph X coordinate advance in pixels. */
|
||||||
uint16_t textureWidth; /**< Texture width in pixels/bytes. */
|
uint16_t glyphIndex; /**< Charachter glyph index in the font face. */
|
||||||
uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */
|
|
||||||
|
uint16_t textureWidth; /**< Texture width in pixels/bytes. */
|
||||||
uint16_t renderOffsetY; /**< Texture Y axis bearing offset. */
|
uint16_t textureHeight; /**< Texture glyph height in pixels/bytes. */
|
||||||
uint16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */
|
|
||||||
uint16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */
|
uint16_t renderOffsetY; /**< Texture Y axis bearing offset. */
|
||||||
|
uint16_t renderOffsetMax; /**< Texture Y axis bearing maximum value. */
|
||||||
uint32_t* glyphDataTexture; /**< Glyph texture bitmap data buffer. */
|
uint16_t renderOffsetMin; /**< Texture Y axis bearing minimum value. */
|
||||||
} ftgxCharData;
|
|
||||||
|
uint32_t* glyphDataTexture; /**< Glyph texture bitmap data buffer. */
|
||||||
/*! \struct ftgxDataOffset_
|
} ftgxCharData;
|
||||||
*
|
|
||||||
* Offset structure which hold both a maximum and minimum value.
|
/*! \struct ftgxDataOffset_
|
||||||
*/
|
*
|
||||||
typedef struct ftgxDataOffset_ {
|
* Offset structure which hold both a maximum and minimum value.
|
||||||
int16_t max; /**< Maximum data offset. */
|
*/
|
||||||
int16_t min; /**< Minimum data offset. */
|
typedef struct ftgxDataOffset_ {
|
||||||
} ftgxDataOffset;
|
int16_t max; /**< Maximum data offset. */
|
||||||
|
int16_t min; /**< Minimum data offset. */
|
||||||
#define _TEXT(t) L ## t /**< Unicode helper macro. */
|
} ftgxDataOffset;
|
||||||
|
|
||||||
#define FTGX_NULL 0x0000
|
#define _TEXT(t) L ## t /**< Unicode helper macro. */
|
||||||
#define FTGX_JUSTIFY_LEFT 0x0001
|
|
||||||
#define FTGX_JUSTIFY_CENTER 0x0002
|
#define FTGX_NULL 0x0000
|
||||||
#define FTGX_JUSTIFY_RIGHT 0x0004
|
#define FTGX_JUSTIFY_LEFT 0x0001
|
||||||
|
#define FTGX_JUSTIFY_CENTER 0x0002
|
||||||
#define FTGX_ALIGN_TOP 0x0010
|
#define FTGX_JUSTIFY_RIGHT 0x0004
|
||||||
#define FTGX_ALIGN_MIDDLE 0x0020
|
|
||||||
#define FTGX_ALIGN_BOTTOM 0x0040
|
#define FTGX_ALIGN_TOP 0x0010
|
||||||
|
#define FTGX_ALIGN_MIDDLE 0x0020
|
||||||
#define FTGX_STYLE_UNDERLINE 0x0100
|
#define FTGX_ALIGN_BOTTOM 0x0040
|
||||||
#define FTGX_STYLE_STRIKE 0x0200
|
|
||||||
|
#define FTGX_STYLE_UNDERLINE 0x0100
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE 0X0001
|
#define FTGX_STYLE_STRIKE 0x0200
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL 0X0002
|
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_BLEND 0X0004
|
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE 0X0001
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_REPLACE 0X0008
|
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_DECAL 0X0002
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR 0X0010
|
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_BLEND 0X0004
|
||||||
|
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_REPLACE 0X0008
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE 0X0100
|
#define FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR 0X0010
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT 0X0200
|
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX8 0X0400
|
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE 0X0100
|
||||||
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX16 0X0800
|
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT 0X0200
|
||||||
|
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX8 0X0400
|
||||||
#define FTGX_COMPATIBILITY_NONE 0x0000
|
#define FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_INDEX16 0X0800
|
||||||
#define FTGX_COMPATIBILITY_GRRLIB FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE
|
|
||||||
#define FTGX_COMPATIBILITY_LIBWIISPRITE FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT
|
#define FTGX_COMPATIBILITY_NONE 0x0000
|
||||||
|
#define FTGX_COMPATIBILITY_GRRLIB FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE
|
||||||
const GXColor ftgxWhite = (GXColor){0xff, 0xff, 0xff, 0xff}; /**< Constant color value used only to sanitize Doxygen documentation. */
|
#define FTGX_COMPATIBILITY_LIBWIISPRITE FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_MODULATE | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_DIRECT
|
||||||
|
|
||||||
void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize);
|
const GXColor ftgxWhite = (GXColor){0xff, 0xff, 0xff, 0xff}; /**< Constant color value used only to sanitize Doxygen documentation. */
|
||||||
void ChangeFontSize(FT_UInt pixelSize);
|
|
||||||
wchar_t* charToWideChar(const char* p);
|
void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize);
|
||||||
void ClearFontData();
|
void ChangeFontSize(FT_UInt pixelSize);
|
||||||
|
wchar_t* charToWideChar(const char* p);
|
||||||
/*! \class FreeTypeGX
|
void ClearFontData();
|
||||||
* \brief Wrapper class for the libFreeType library with GX rendering.
|
|
||||||
* \author Armin Tamzarian
|
/*! \class FreeTypeGX
|
||||||
* \version 0.2.4
|
* \brief Wrapper class for the libFreeType library with GX rendering.
|
||||||
*
|
* \author Armin Tamzarian
|
||||||
* FreeTypeGX acts as a wrapper class for the libFreeType library. It supports precaching of transformed glyph data into
|
* \version 0.2.4
|
||||||
* a specified texture format. Rendering of the data to the EFB is accomplished through the application of high performance
|
*
|
||||||
* GX texture functions resulting in high throughput of string rendering.
|
* FreeTypeGX acts as a wrapper class for the libFreeType library. It supports precaching of transformed glyph data into
|
||||||
*/
|
* a specified texture format. Rendering of the data to the EFB is accomplished through the application of high performance
|
||||||
class FreeTypeGX {
|
* GX texture functions resulting in high throughput of string rendering.
|
||||||
|
*/
|
||||||
private:
|
class FreeTypeGX {
|
||||||
FT_UInt ftPointSize; /**< Requested size of the rendered font. */
|
|
||||||
bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */
|
private:
|
||||||
|
FT_UInt ftPointSize; /**< Requested size of the rendered font. */
|
||||||
uint8_t textureFormat; /**< Defined texture format of the target EFB. */
|
bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */
|
||||||
uint8_t vertexIndex; /**< Vertex format descriptor index. */
|
|
||||||
uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */
|
uint8_t textureFormat; /**< Defined texture format of the target EFB. */
|
||||||
std::map<wchar_t, ftgxCharData> fontData; /**< Map which holds the glyph data structures for the corresponding characters. */
|
uint8_t vertexIndex; /**< Vertex format descriptor index. */
|
||||||
|
uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */
|
||||||
static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat);
|
std::map<wchar_t, ftgxCharData> fontData; /**< Map which holds the glyph data structures for the corresponding characters. */
|
||||||
static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat);
|
|
||||||
|
static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat);
|
||||||
static uint16_t getStyleOffsetWidth(uint16_t width, uint16_t format);
|
static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat);
|
||||||
static uint16_t getStyleOffsetHeight(ftgxDataOffset offset, uint16_t format);
|
|
||||||
|
static uint16_t getStyleOffsetWidth(uint16_t width, uint16_t format);
|
||||||
void unloadFont();
|
static uint16_t getStyleOffsetHeight(ftgxDataOffset offset, uint16_t format);
|
||||||
ftgxCharData *cacheGlyphData(wchar_t charCode);
|
|
||||||
uint16_t cacheGlyphDataComplete();
|
void unloadFont();
|
||||||
void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData);
|
ftgxCharData *cacheGlyphData(wchar_t charCode);
|
||||||
|
uint16_t cacheGlyphDataComplete();
|
||||||
void setDefaultMode();
|
void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData);
|
||||||
|
|
||||||
void drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset offsetData, uint16_t format, GXColor color);
|
void setDefaultMode();
|
||||||
void copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color);
|
|
||||||
void copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color);
|
void drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset offsetData, uint16_t format, GXColor color);
|
||||||
|
void copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 texHeight, int16_t screenX, int16_t screenY, GXColor color);
|
||||||
public:
|
void copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color);
|
||||||
FreeTypeGX(FT_UInt pixelSize, uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1);
|
|
||||||
~FreeTypeGX();
|
public:
|
||||||
|
FreeTypeGX(FT_UInt pixelSize, uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1);
|
||||||
void setVertexFormat(uint8_t vertexIndex);
|
~FreeTypeGX();
|
||||||
void setCompatibilityMode(uint32_t compatibilityMode);
|
|
||||||
|
void setVertexFormat(uint8_t vertexIndex);
|
||||||
uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
|
void setCompatibilityMode(uint32_t compatibilityMode);
|
||||||
uint16_t drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
|
|
||||||
|
uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
|
||||||
uint16_t getWidth(wchar_t *text);
|
uint16_t drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
|
||||||
uint16_t getWidth(wchar_t const *text);
|
|
||||||
uint16_t getHeight(wchar_t *text);
|
uint16_t getWidth(wchar_t *text);
|
||||||
uint16_t getHeight(wchar_t const *text);
|
uint16_t getWidth(wchar_t const *text);
|
||||||
ftgxDataOffset getOffset(wchar_t *text);
|
uint16_t getHeight(wchar_t *text);
|
||||||
ftgxDataOffset getOffset(wchar_t const *text);
|
uint16_t getHeight(wchar_t const *text);
|
||||||
};
|
ftgxDataOffset getOffset(wchar_t *text);
|
||||||
|
ftgxDataOffset getOffset(wchar_t const *text);
|
||||||
#endif /* FREETYPEGX_H_ */
|
};
|
||||||
|
|
||||||
|
#endif /* FREETYPEGX_H_ */
|
||||||
|
@ -618,10 +618,14 @@ class GuiText : public GuiElement
|
|||||||
//!\param s Font size
|
//!\param s Font size
|
||||||
void SetFontSize(int s);
|
void SetFontSize(int s);
|
||||||
//!Sets the maximum width of the drawn texture image
|
//!Sets the maximum width of the drawn texture image
|
||||||
//!If the text exceeds this, it is wrapped to the next line
|
|
||||||
//!\param w Maximum width
|
//!\param w Maximum width
|
||||||
void SetMaxWidth(int width);
|
void SetMaxWidth(int width);
|
||||||
|
//!Enables/disables text scrolling
|
||||||
|
//!\param s Scrolling on/off
|
||||||
void SetScroll(int s);
|
void SetScroll(int s);
|
||||||
|
//!Enables/disables text wrapping
|
||||||
|
//!\param w Wrapping on/off
|
||||||
|
//!\param width Maximum width (0 to disable)
|
||||||
void SetWrap(bool w, int width = 0);
|
void SetWrap(bool w, int width = 0);
|
||||||
//!Sets the font color
|
//!Sets the font color
|
||||||
//!\param c Font color
|
//!\param c Font color
|
||||||
@ -636,16 +640,16 @@ class GuiText : public GuiElement
|
|||||||
//!Constantly called to draw the text
|
//!Constantly called to draw the text
|
||||||
void Draw();
|
void Draw();
|
||||||
protected:
|
protected:
|
||||||
char * origText;
|
char * origText; //!< Original text data
|
||||||
wchar_t* text; //!< Unicode text value
|
wchar_t* text; //!< Unicode text value
|
||||||
int size; //!< Font size
|
int size; //!< Font size
|
||||||
int maxWidth; //!< Maximum width of the generated text object (for text wrapping)
|
int maxWidth; //!< Maximum width of the generated text object (for text wrapping)
|
||||||
bool wrap;
|
bool wrap; //!< Wrapping toggle
|
||||||
wchar_t* textDyn;
|
wchar_t* textDyn; //!< Wrapped text value
|
||||||
int textScroll;
|
int textScroll; //!< Scrolling toggle
|
||||||
int textScrollPos;
|
int textScrollPos; //!< Current starting index of text string for scrolling
|
||||||
int textScrollInitialDelay;
|
int textScrollInitialDelay; //!< Delay to wait before starting to scroll
|
||||||
int textScrollDelay;
|
int textScrollDelay; //!< Scrolling speed
|
||||||
u16 style; //!< FreeTypeGX style attributes
|
u16 style; //!< FreeTypeGX style attributes
|
||||||
GXColor color; //!< Font color
|
GXColor color; //!< Font color
|
||||||
};
|
};
|
||||||
|
@ -216,6 +216,9 @@ void GuiText::Draw()
|
|||||||
|
|
||||||
int newSize = size*this->GetScale();
|
int newSize = size*this->GetScale();
|
||||||
|
|
||||||
|
if(newSize > MAX_FONT_SIZE)
|
||||||
|
newSize = MAX_FONT_SIZE;
|
||||||
|
|
||||||
if(newSize != currentSize)
|
if(newSize != currentSize)
|
||||||
{
|
{
|
||||||
ChangeFontSize(newSize);
|
ChangeFontSize(newSize);
|
||||||
|
Loading…
Reference in New Issue
Block a user