Back to index

supertuxkart  0.5+dfsg1
BMF_Api.cpp
Go to the documentation of this file.
00001 
00038 #include "BMF_Api.h"
00039 
00040 #include "BMF_BitmapFont.h"
00041 
00042 
00043 #if BMF_INCLUDE_HELV10
00044 extern BMF_FontData BMF_font_helv10;
00045 static BMF_BitmapFont bmfHelv10(&BMF_font_helv10);
00046 #endif // BMF_INCLUDE_HELV10
00047 #if BMF_INCLUDE_HELV12
00048 extern BMF_FontData BMF_font_helv12;
00049 static BMF_BitmapFont bmfHelv12(&BMF_font_helv12);
00050 #endif // BMF_INCLUDE_HELV12
00051 #if BMF_INCLUDE_HELVB8
00052 extern BMF_FontData BMF_font_helvb8;
00053 static BMF_BitmapFont bmfHelvb8(&BMF_font_helvb8);
00054 #endif // BMF_INCLUDE_HELVB8
00055 #if BMF_INCLUDE_HELVB10
00056 extern BMF_FontData BMF_font_helvb10;
00057 static BMF_BitmapFont bmfHelvb10(&BMF_font_helvb10);
00058 #endif // BMF_INCLUDE_HELVB10
00059 #if BMF_INCLUDE_HELVB12
00060 extern BMF_FontData BMF_font_helvb12;
00061 static BMF_BitmapFont bmfHelvb12(&BMF_font_helvb12);
00062 #endif // BMF_INCLUDE_HELVB12
00063 #if BMF_INCLUDE_HELVB14
00064 extern BMF_FontData BMF_font_helvb14;
00065 static BMF_BitmapFont bmfHelvb14(&BMF_font_helvb14);
00066 #endif // BMF_INCLUDE_HELVB14
00067 #if BMF_INCLUDE_SCR12
00068 extern BMF_FontData BMF_font_scr12;
00069 static BMF_BitmapFont bmfScreen12(&BMF_font_scr12);
00070 #endif // BMF_INCLUDE_SCR12
00071 #if BMF_INCLUDE_SCR14
00072 extern BMF_FontData BMF_font_scr14;
00073 static BMF_BitmapFont bmfScreen14(&BMF_font_scr14);
00074 #endif // BMF_INCLUDE_SCR14
00075 #if BMF_INCLUDE_SCR15
00076 extern BMF_FontData BMF_font_scr15;
00077 static BMF_BitmapFont bmfScreen15(&BMF_font_scr15);
00078 #endif // BMF_INCLUDE_SCR15
00079 
00080 
00081 BMF_Font* BMF_GetFont(BMF_FontType font)
00082 {
00083        switch (font)
00084        {
00085 #if BMF_INCLUDE_HELV10
00086        case BMF_kHelvetica10:      return (BMF_Font*) &bmfHelv10;
00087 #endif // BMF_INCLUDE_HELV10
00088 #if BMF_INCLUDE_HELV12
00089        case BMF_kHelvetica12:      return (BMF_Font*) &bmfHelv12;
00090 #endif // BMF_INCLUDE_HELV12
00091 #if BMF_INCLUDE_HELVB8
00092        case BMF_kHelveticaBold8:   return (BMF_Font*) &bmfHelvb8;
00093 #endif // BMF_INCLUDE_HELVB8
00094 #if BMF_INCLUDE_HELVB10
00095        case BMF_kHelveticaBold10:  return (BMF_Font*) &bmfHelvb10;
00096 #endif // BMF_INCLUDE_HELVB10
00097 #if BMF_INCLUDE_HELVB12
00098        case BMF_kHelveticaBold12:  return (BMF_Font*) &bmfHelvb12;
00099 #endif // BMF_INCLUDE_HELVB12
00100 #if BMF_INCLUDE_HELVB14
00101        case BMF_kHelveticaBold14:  return (BMF_Font*) &bmfHelvb14;
00102 #endif // BMF_INCLUDE_HELVB12
00103 #if BMF_INCLUDE_SCR12
00104        case BMF_kScreen12:  return (BMF_Font*) &bmfScreen12;
00105 #endif // BMF_INCLUDE_SCR12
00106 #if BMF_INCLUDE_SCR14
00107        case BMF_kScreen14:  return (BMF_Font*) &bmfScreen14;
00108 #endif // BMF_INCLUDE_SCR14
00109 #if BMF_INCLUDE_SCR15
00110        case BMF_kScreen15:  return (BMF_Font*) &bmfScreen15;
00111 #endif // BMF_INCLUDE_SCR15
00112        default:
00113               break;
00114        }
00115        return 0;
00116 }
00117 
00118 
00119 int BMF_DrawCharacter(BMF_Font* font, char c)
00120 {
00121        char str[2] = {c, '\0'};
00122        return BMF_DrawString(font, str);
00123 }
00124 
00125 
00126 int BMF_DrawString(BMF_Font* font, const char* str)
00127 {
00128        if (!font) return 0;
00129        ((BMF_BitmapFont*)font)->drawString(str);
00130        return 1;
00131 }
00132 
00133 
00134 int BMF_GetCharacterWidth(BMF_Font* font, char c)
00135 {
00136        char str[2] = {c, '\0'};
00137        return BMF_GetStringWidth(font, str);
00138 }
00139 
00140 
00141 int BMF_GetStringWidth(BMF_Font* font, char* str)
00142 {
00143        if (!font) return 0;
00144        return ((BMF_BitmapFont*)font)->getStringWidth(str);
00145 }
00146 
00147 
00148 void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, int *ymax_r)
00149 {
00150        if (!font) return;
00151        ((BMF_BitmapFont*)font)->getBoundingBox(*xmin_r, *ymin_r, *xmax_r, *ymax_r);
00152 }
00153 
00154 int BMF_GetFontTexture(BMF_Font* font) {
00155        if (!font) return -1;
00156        return ((BMF_BitmapFont*)font)->getTexture();
00157 }
00158 
00159 void BMF_DrawStringTexture(BMF_Font* font, char *string, float x, float y, float z) {
00160        if (!font) return;
00161        ((BMF_BitmapFont*)font)->drawStringTexture(string, x, y, z);
00162 }