Changing text into fonts

Discussion in 'Wii - Hacking' started by Keeley, Sep 7, 2009.

Sep 7, 2009

Changing text into fonts by Keeley at 3:43 AM (935 Views / 0 Likes) 0 replies

  1. Keeley
    OP

    Member Keeley GBAtemp Fan

    Joined:
    Nov 15, 2008
    Messages:
    421
    Location:
    Saskachewan
    Country:
    Canada
    Hey guys, this morning I've been trying to convert my text into Sans font but I keep falling into many problems <img src="style_emoticons/<#EMO_DIR#>/sleep.gif" style="vertical-align:middle" emoid="-_-" border="0" alt="sleep.gif" /> so I wondering if you guys could help me? ( I've been following this tut here ) <a href="http://arikadosblog.blogspot.com/2009/07/how-to-output-text-from-fonts-with.html" target="_blank">Click me for link</a>

    Here is my Makefile: ( Sorry no spoilers dunno how to make one I'll google it later )

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#---------------------------------------------------------------------------------
    # Clear the implicit built in rules
    #---------------------------------------------------------------------------------
    .SUFFIXES:
    #---------------------------------------------------------------------------------
    ifeq ($(strip $(DEVKITPPC)),)
    $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
    endif

    include $(DEVKITPPC)/wii_rules

    #---------------------------------------------------------------------------------
    # This rule links in binary data with the .ttf extension
    #---------------------------------------------------------------------------------
    %.ttf.o : %.ttf
    #---------------------------------------------------------------------------------
    ÂÂÂÂ@echo $(notdir $<) $(bin2o) -include $(DEPENDS)

    #---------------------------------------------------------------------------------
    # TARGET is the name of the output
    # BUILD is the directory where object files & intermediate files will be placed
    # SOURCES is a list of directories containing source code
    # INCLUDES is a list of directories containing extra header files
    #---------------------------------------------------------------------------------
    TARGETÂÂÂÂÂÂÂÂ:=ÂÂÂÂ$(notdir $(CURDIR))
    BUILDÂÂÂÂÂÂÂÂ:=ÂÂÂÂbuild
    SOURCESÂÂÂÂÂÂÂÂ:=ÂÂÂÂsource
    DATAÂÂÂÂÂÂÂÂ:=ÂÂÂÂdataÂÂ
    INCLUDESÂÂÂÂ:=ÂÂÂÂinclude

    #---------------------------------------------------------------------------------
    # options for code generation
    #---------------------------------------------------------------------------------

    CFLAGSÂÂÂÂ= -g -O2 -Wall $(MACHDEP) $(INCLUDE)
    CXXFLAGSÂÂÂÂ=ÂÂÂÂ$(CFLAGS)

    LDFLAGSÂÂÂÂ=ÂÂÂÂ-g $(MACHDEP) -Wl,-Map,$(notdir $@).map

    #---------------------------------------------------------------------------------
    # any extra libraries we wish to link with the project
    #---------------------------------------------------------------------------------
    LIBSÂÂÂÂ:=ÂÂÂÂ-lwiiuse -lbte -logc -lm -lfreetype -lftimage

    #---------------------------------------------------------------------------------
    # list of directories containing libraries, this must be the top level containing
    # include and lib
    #---------------------------------------------------------------------------------
    LIBDIRSÂÂÂÂ:=

    #---------------------------------------------------------------------------------
    # no real need to edit anything past this point unless you need to add additional
    # rules for different file extensions
    #---------------------------------------------------------------------------------



    ifneq ($(BUILD),$(notdir $(CURDIR)))

    #---------------------------------------------------------------------------------

    export OUTPUTÂÂÂÂ:=ÂÂÂÂ$(CURDIR)/$(TARGET)

    export VPATHÂÂÂÂ:=ÂÂÂÂ$(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ$(foreach dir,$(DATA),$(CURDIR)/$(dir))

    export DEPSDIRÂÂÂÂ:=ÂÂÂÂ$(CURDIR)/$(BUILD)

    #---------------------------------------------------------------------------------
    # automatically build a list of object files for our project
    #---------------------------------------------------------------------------------
    CFILESÂÂÂÂÂÂÂÂ:=ÂÂÂÂ$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
    CPPFILESÂÂÂÂ:=ÂÂÂÂ$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
    sFILESÂÂÂÂÂÂÂÂ:=ÂÂÂÂ$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
    SFILESÂÂÂÂÂÂÂÂ:=ÂÂÂÂ$(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
    BINFILESÂÂÂÂ:=ÂÂÂÂ$(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

    #---------------------------------------------------------------------------------
    # use CXX for linking C++ projects, CC for standard C
    #---------------------------------------------------------------------------------
    ifeq ($(strip $(CPPFILES)),)
    ÂÂÂÂexport LDÂÂÂÂ:=ÂÂÂÂ$(CC)
    else
    ÂÂÂÂexport LDÂÂÂÂ:=ÂÂÂÂ$(CXX)
    endif

    export OFILESÂÂÂÂ:=ÂÂÂÂ$(addsuffix .o,$(BINFILES)) \
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ$(sFILES:.s=.o) $(SFILES:.S=.o)

    #---------------------------------------------------------------------------------
    # build a list of include paths
    #---------------------------------------------------------------------------------
    export INCLUDEÂÂÂÂ:=ÂÂÂÂ$(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ-I$(CURDIR)/$(BUILD) \
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ-I$(LIBOGC_INC)

    #---------------------------------------------------------------------------------
    # build a list of library paths
    #---------------------------------------------------------------------------------
    export LIBPATHSÂÂÂÂ:=ÂÂÂÂ$(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ-L$(LIBOGC_LIB)

    export OUTPUTÂÂÂÂ:=ÂÂÂÂ$(CURDIR)/$(TARGET)
    .PHONY: $(BUILD) clean

    #---------------------------------------------------------------------------------
    $(BUILD):
    ÂÂÂÂ@[ -d $@ ] || mkdir -p $@
    ÂÂÂÂ@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

    #---------------------------------------------------------------------------------
    clean:
    ÂÂÂÂ@echo clean ...
    ÂÂÂÂ@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol

    #---------------------------------------------------------------------------------
    run:
    ÂÂÂÂpsoload $(TARGET).dol

    #---------------------------------------------------------------------------------
    reload:
    ÂÂÂÂpsoload -r $(TARGET).dol


    #---------------------------------------------------------------------------------
    else

    DEPENDSÂÂÂÂ:=ÂÂÂÂ$(OFILES:.o=.d)

    #---------------------------------------------------------------------------------
    # main targets
    #---------------------------------------------------------------------------------
    $(OUTPUT).dol: $(OUTPUT).elf
    $(OUTPUT).elf: $(OFILES)

    #---------------------------------------------------------------------------------
    # This rule links in binary data with the .jpg extension
    #---------------------------------------------------------------------------------
    %.jpg.oÂÂÂÂ:ÂÂÂÂ%.jpg
    #---------------------------------------------------------------------------------
    ÂÂÂÂ@echo $(notdir $<)
    ÂÂÂÂ$(bin2o)

    -include $(DEPENDS)

    #---------------------------------------------------------------------------------
    # This rule links in binary data
    #---------------------------------------------------------------------------------
    %.bin.oÂÂÂÂ:ÂÂÂÂ%.bin
    #---------------------------------------------------------------------------------
    ÂÂÂÂ@echo $(notdir $<)
    ÂÂÂÂ@$(bin2o)

    %.mod.oÂÂÂÂ:ÂÂÂÂ%.mod
    #---------------------------------------------------------------------------------
    ÂÂÂÂ@echo $(notdir $<)
    ÂÂÂÂ@$(bin2o)

    -include $(DEPENDS)

    #---------------------------------------------------------------------------------
    endif

    #---------------------------------------------------------------------------------<!--c2--></div><!--ec2-->

    For this

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#---------------------------------------------------------------------------------
    # This rule links in binary data with the .ttf extension
    #---------------------------------------------------------------------------------
    %.ttf.o : %.ttf
    #---------------------------------------------------------------------------------
    @echo $(notdir $<) $(bin2o) -include $(DEPENDS)<!--c2--></div><!--ec2-->

    I was getting a "Makefile:17: *** missing separator. Stop." Error till I realized I had to press tab, I dunno why it would make a difference though.

    And here is my main.c:

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <malloc.h>
    #include <ogcsys.h>
    #include <gccore.h>
    #include <wiiuse/wpad.h>
    #include <ftImage.h>
    #include <Sansation_Bold_ttf.h>

    static u32 *xfb;
    static GXRModeObj *rmode;


    void Initialise() {
    ÂÂ
    ÂÂÂÂVIDEO_Init();
    ÂÂÂÂWPAD_Init();

    ÂÂÂÂrmode = VIDEO_GetPreferredMode(NULL);

    ÂÂÂÂxfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
    ÂÂÂÂconsole_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);

    ÂÂÂÂVIDEO_Configure(rmode);
    ÂÂÂÂVIDEO_SetNextFramebuffer(xfb);
    ÂÂÂÂVIDEO_SetBlack(FALSE);
    ÂÂÂÂVIDEO_Flush();
    ÂÂÂÂVIDEO_WaitVSync();
    ÂÂÂÂif(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
    }


    int main() {

    ÂÂÂÂInitialise();
    ÂÂÂÂ
    ÂÂÂÂftImage print;(640, 480);
    ÂÂÂÂSprite; Text;
    ÂÂÂÂ
    ÂÂÂÂprint.setFont(Sansation_Bold_ttf, Sansation_Bold_ttf_32);
    ÂÂÂÂprint.setSize(32);
    ÂÂÂÂprint.setColor(Color::Color(255,40,40));
    ÂÂÂÂText.SetPosition(100, 50);
    ÂÂÂÂText.SetImage(&print);
    ÂÂÂÂ
    ÂÂÂÂprint.printf(" Hellow World!\n");
    ÂÂÂÂprint.flush();
    ÂÂÂÂText.Draw();
    ÂÂÂÂprint.clear();
    ÂÂÂÂprint.reset();

    ÂÂÂÂprintf("Keeley's 2nd project\n");
    ÂÂÂÂprintf("Testing if it is possible to see this line\n");
    ÂÂÂÂ
    ÂÂÂÂwhile(1) {
    ÂÂÂÂ
    ÂÂÂÂÂÂÂÂWPAD_ScanPads();
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂu16 buttonsDownÂÂÂÂ= WPAD_ButtonsDown(0);
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂif (buttonsDown & WPAD_BUTTON_A) {
    ÂÂÂÂÂÂÂÂÂÂÂÂprintf ("You pressed A.\n");
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂu16 buttonsHeld = WPAD_ButtonsHeld(0);
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂif (buttonsHeld & WPAD_BUTTON_A) {
    ÂÂÂÂÂÂÂÂÂÂÂÂprintf ("You are holding down A.\n");
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂ
    ÂÂÂÂÂÂÂÂu16 buttonsUp = WPAD_ButtonsUp(0);
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂif (buttonsUp & WPAD_BUTTON_A) {
    ÂÂÂÂÂÂÂÂÂÂÂÂprintf ("You let go of button A.\n");
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂ
    ÂÂÂÂÂÂÂÂif (buttonsDown & WPAD_BUTTON_HOME) {
    ÂÂÂÂÂÂÂÂÂÂÂÂexit(0);
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂ}
    ÂÂÂÂ
    ÂÂÂÂreturn (0);
    }<!--c2--></div><!--ec2-->

    So when I try to compile this I get the following errors:

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->> "make"
    main.c
    In file included from c:/devkitPro/libogc/include/gamewindow.h:10,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/wiisprite.h:8,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/rgbaImage.h:4,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/image.h:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wsp'
    In file included from c:/devkitPro/libogc/include/wiisprite.h:8,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/rgbaImage.h:4,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/gamewindow.h:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wsp'
    In file included from c:/devkitPro/libogc/include/layermanager.h:10,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/wiisprite.h:9,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/rgbaImage.h:4,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/layer.h:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wsp'
    In file included from c:/devkitPro/libogc/include/wiisprite.h:9,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/rgbaImage.h:4,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/layermanager.h:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wsp'
    In file included from c:/devkitPro/libogc/include/sprite.h:12,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/wiisprite.h:12,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/rgbaImage.h:4,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/tiledlayer.h:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wsp'
    In file included from c:/devkitPro/libogc/include/wiisprite.h:12,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/rgbaImage.h:4,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/sprite.h:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wsp'
    In file included from c:/devkitPro/libogc/include/wiisprite.h:14,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/rgbaImage.h:4,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/quad.h:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wsp'
    In file included from c:/devkitPro/libogc/include/ftText.h:18,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/rgbaImage.h:5,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/ftColor.h:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Color'
    In file included from c:/devkitPro/libogc/include/rgbaImage.h:5,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/ftText.h:30: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TextRender'
    In file included from c:/devkitPro/libogc/include/ftImage.h:3,
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/rgbaImage.h:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'
    c:/devkitPro/libogc/include/rgbaImage.h:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rgbaImage'
    In file included from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/ftImage.h:5:15: warning: set: No such file or directory
    In file included from c:/devkitPro/examples/gamecube/tutorial3/source/main.c:8:
    c:/devkitPro/libogc/include/ftImage.h:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    c:/devkitPro/libogc/include/ftImage.h:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ftImage'
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:9:32: warning: Sansation_Bold_ttf.h: No such file or directory
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c: In function 'main':
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:38: error: 'ftImage' undeclared (first use in this function)
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:38: error: (Each undeclared identifier is reported only once
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:38: error: for each function it appears in.)
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:38: error: expected ';' before 'print'
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:38: warning: left-hand operand of comma expression has no effect
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:38: warning: statement with no effect
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:39: error: 'Sprite' undeclared (first use in this function)
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:39: error: 'Text' undeclared (first use in this function)
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:41: error: 'print' undeclared (first use in this function)
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:41: error: 'Sansation_Bold_ttf' undeclared (first use in this function)
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:41: error: 'Sansation_Bold_ttf_32' undeclared (first use in this function)
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:43: error: 'Color' undeclared (first use in this function)
    c:/devkitPro/examples/gamecube/tutorial3/source/main.c:43: error: expected ')' before ':' token<!--c2--></div><!--ec2-->

    Hell I dunno if I even set up up FreeGX and ftimage right, so here's how I did it:

    FreeGX:

    1. Downloaded FreeTypePPC, FreeTypeGX, and Metaphrasis.
    2. Put all the .h files in C:devkitpro/devkitPPC/powerpc-gekko/include and in the libogc/include
    3. Put all the .a files in C:devkitpro/devkitPPC/powerpc-gekko/lib and /libogc/lib/wii

    ftimage:

    1. Same thing as FreeGX

    I know that it was quite lengthy so thanks for bearing withme and helping me!
     

Share This Page