/* * @brief Sets the font * to display the sensors values. */ void setFont() { int nrFonts = maFontGetCount(); char fontName[BUFFER_SIZE]; // get first font. maFontGetName(0, fontName, BUFFER_SIZE); // Load first font with size 20. int fontHandle = maFontLoadWithName(fontName, TEXT_SIZE); maFontSetCurrent(fontHandle); }
void MainScreen::fontOverload() { char x[128]; int sz = maFontGetCount(); popProgress->setMessage(Lang::getString(GS_FONTREFRESH)); popProgress->setMaxVal(sz); popProgress->show(); for (int i = 0; i < sz; i++) { maFontGetName(i, x, 128); popProgress->setProgress(i + 1); } popProgress->hide(); }
/** * Creates and adds main layout to the screen. */ void MainScreen::createMainLayout() { // Create and add the main layout to the screen. mMainLayout = new VerticalLayout(); Screen::setMainWidget(mMainLayout); mButton = new Button(); mMainLayout->addChild(mButton); int result = mButton->setTextVerticalAlignment(MAW_ALIGNMENT_BOTTOM); printf("result setTextVerticalAlignment = %d", result); result = mButton->setTextHorizontalAlignment(MAW_ALIGNMENT_RIGHT); printf("result setTextHorizontalAlignment = %d", result); result = mButton->setFontColor(0xFF0000); printf("result setFontColor = %d", result); result = mButton->setFontSize(15.9); printf("result setFontSize = %d", result); // Print number of available fonts. int fontsCount = maFontGetCount(); Label* nrFontsLabel = new Label(); nrFontsLabel->setText(MAUtil::integerToString(fontsCount) + " fonts available."); nrFontsLabel->setFontColor(0xFF0000); mMainLayout->addChild(nrFontsLabel); // Get the first font char buf[256]; maFontGetName(0, buf, 256); Label* fontLoadedName = new Label(); // Print the name of the font fontLoadedName->setText(buf); fontLoadedName->setFontColor(0xFF0000); mMainLayout->addChild(fontLoadedName); // Load the font with size 10 and get a handle. int fontHandle = maFontLoadWithName(buf, 10); // Set the handle to a label mTestFontLabel = new Button(); mTestFontLabel->setText("Test for this font!"); mTestFontLabel->setFontColor(0xFF0000); mTestFontLabel->setFont(fontHandle); mMainLayout->addChild(mTestFontLabel); mEvents = new ListView(); mEvents->fillSpaceHorizontally(); mEvents->fillSpaceVertically(); mMainLayout->addChild(mEvents); }
/* * ctor */ TestMoblet::TestMoblet() { mShowing = 1; maSetColor(0xC1FFC1); int top = 10; maDrawText(10,top, "--------- Display number of fonts with current font ---------"); nrFonts = maFontGetCount(); MAUtil::String tempNrFonts; char buf1[10]; char buf2[256]; itoa(nrFonts,buf1, 10); tempNrFonts += buf1; tempNrFonts += " fonts."; top += 20; maDrawText(10,top,tempNrFonts.c_str()); maSetColor(0x00FFFF); top+=40; maDrawText(10,top,"--------- Display list of fonts with default font size --------- "); MAUtil::String tempFont; int getNameError; for ( int i=0; i<nrFonts; i++) { char buf[256]; getNameError = maFontGetName(i, buf, 256); if ( getNameError >= 0 ) { top += 20; fontNames.add(buf); maDrawText(10,top, buf); } else { top += 20; message = "Font on index:" + MAUtil::integerToString(i) + "returned error:" + MAUtil::integerToString(getNameError); maDrawText(10, top, message.c_str()); } } maDrawText(10, top+40, "Tap screen to test maLoadWithName for each font"); maUpdateScreen(); }
/** * Creates and adds main layout to the screen. */ void MainScreen::createMainLayout() { // Create and add the main layout to the screen. mMainLayout = new VerticalLayout(); mMainLayout->setBackgroundColor(0x9BCD9B); Screen::setMainWidget(mMainLayout); mLabel = new Label(); mMainLayout->addChild(mLabel); mLabel->setText("this is a label! 2 this is a label! 3 this is a label! 4 this is a label!"); mLabel->setFontColor(0xFF0000); mLabel->setWidth(50); mLabel->setMaxNumberOfLines(2); int result = mLabel->getMaxNumberOfLines(); printf("result getMaxNumberOfLines = %d", result); // Print number of available fonts. int fontsCount = maFontGetCount(); nrFontsLabel = new Label(); nrFontsLabel->setText(MAUtil::integerToString(fontsCount) + " fonts available."); nrFontsLabel->setFontColor(0xFF0000); mMainLayout->addChild(nrFontsLabel); // Get the first font char buf[256]; maFontGetName(0, buf, 256); fontLoadedName = new Label(); // Print the name of the font fontLoadedName->setText(buf); fontLoadedName->setFontColor(0xFF0000); mMainLayout->addChild(fontLoadedName); // Load the font with size 10 and get a handle. int fontHandle = maFontLoadWithName(buf, 10); // Set the handle to a label testFontLabel = new Label(); testFontLabel->setText("Test for this font!"); testFontLabel->setFontColor(0xFF0000); testFontLabel->setFont(fontHandle); mMainLayout->addChild(testFontLabel); }