added a test app for BFont::GetBoundingBoxes* methods

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14073 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2005-08-26 08:49:30 +00:00
parent 3cf915cb23
commit fef6144999
1 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,62 @@
#include <Application.h>
#include <Font.h>
#include <Rect.h>
#include <stdio.h>
void
GetBoundingBoxesAsGlyphsTest(BFont *font)
{
const char string[] = "test string";
int32 numChars = 11;
BRect rectArray[numChars];
font->GetBoundingBoxesAsGlyphs(string, numChars, B_SCREEN_METRIC, rectArray);
for (int32 i=0; i<numChars; i++) {
rectArray[i].PrintToStream();
}
}
void
GetBoundingBoxesAsStringTest(BFont *font)
{
const char string[] = "test string";
int32 numChars = 11;
BRect rectArray[numChars];
escapement_delta delta = { 0.0, 0.0 };
font->GetBoundingBoxesAsString(string, numChars, B_SCREEN_METRIC, &delta, rectArray);
for (int32 i=0; i<numChars; i++) {
rectArray[i].PrintToStream();
}
}
void
GetBoundingBoxesForStringsTest(BFont *font)
{
char string[] = "test string";
int32 numStrings = 1;
const char* stringArray[numStrings];
stringArray[0] = string;
BRect rectArray[numStrings];
escapement_delta delta = { 0.0, 0.0 };
font->GetBoundingBoxesForStrings(stringArray, numStrings, B_SCREEN_METRIC, &delta, rectArray);
for (int32 i=0; i<numStrings; i++) {
rectArray[i].PrintToStream();
}
}
int main()
{
BApplication app("application/x-vnd-Test.GetBoundingBoxesTest");
BFont font(be_plain_font);
//font.SetRotation(45);
//font.SetShear(45);
font.SetSpacing(B_CHAR_SPACING);
printf("\nGetBoundingBoxesAsGlyphsTest\n");
GetBoundingBoxesAsGlyphsTest(&font);
printf("\nGetBoundingBoxesAsStringTest\n");
GetBoundingBoxesAsStringTest(&font);
printf("\nGetBoundingBoxesForStringsTest\n");
GetBoundingBoxesForStringsTest(&font);
}