예제 #1
0
static void
test_is_glyph_extended_shape (void)
{
  hb_codepoint_t glyph;
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert(!hb_ot_math_is_glyph_extended_shape (hb_face, glyph)); // MathGlyphInfo not available
  closeFont();

  openFont("fonts/MathTestFontPartial1.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert(!hb_ot_math_is_glyph_extended_shape (hb_face, glyph)); // MathGlyphInfo empty
  closeFont();

  openFont("fonts/MathTestFontFull.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "G", -1, &glyph));
  g_assert(!hb_ot_math_is_glyph_extended_shape (hb_face, glyph));
  g_assert(hb_font_get_glyph_from_name (hb_font, "H", -1, &glyph));
  g_assert(hb_ot_math_is_glyph_extended_shape (hb_face, glyph));
  closeFont();

  cleanupFreeType();
}
예제 #2
0
static void
test_get_glyph_italics_correction (void)
{
  hb_codepoint_t glyph;
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 0); // MathGlyphInfo not available
  closeFont();

  openFont("fonts/MathTestFontPartial1.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 0); // MathGlyphInfo empty
  closeFont();

  openFont("fonts/MathTestFontPartial2.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 0); // MathItalicsCorrectionInfo empty
  closeFont();

  openFont("fonts/MathTestFontFull.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 0); // Glyph without italic correction.
  g_assert(hb_font_get_glyph_from_name (hb_font, "A", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 394);
  g_assert(hb_font_get_glyph_from_name (hb_font, "B", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 300);
  g_assert(hb_font_get_glyph_from_name (hb_font, "C", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_italics_correction (hb_font, glyph), ==, 904);
  closeFont();

  cleanupFreeType();
}
예제 #3
0
static void
test_get_glyph_top_accent_attachment (void)
{
  hb_codepoint_t glyph;
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 1000); // MathGlyphInfo not available
  closeFont();

  openFont("fonts/MathTestFontPartial1.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 1000); // MathGlyphInfo empty
  closeFont();

  openFont("fonts/MathTestFontPartial2.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 1000); // MathTopAccentAttachment empty
  closeFont();

  openFont("fonts/MathTestFontFull.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 1000); // Glyph without top accent attachment.
  g_assert(hb_font_get_glyph_from_name (hb_font, "D", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 748);
  g_assert(hb_font_get_glyph_from_name (hb_font, "E", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 692);
  g_assert(hb_font_get_glyph_from_name (hb_font, "F", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_top_accent_attachment (hb_font, glyph), ==, 636);
  closeFont();

  cleanupFreeType();
}
예제 #4
0
static void
test_get_glyph_kerning (void)
{
  hb_codepoint_t glyph;
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathGlyphInfo not available
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathGlyphInfo not available
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathGlyphInfo not available
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathGlyphInfo not available
  closeFont();

  openFont("fonts/MathTestFontPartial2.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathKernInfo empty
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathKernInfo empty
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathKernInfo empty
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathKernInfo empty
  closeFont();

  openFont("fonts/MathTestFontPartial3.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 0), ==, 0); // MathKernInfoRecords empty
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 0), ==, 0); // MathKernInfoRecords empty
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0), ==, 0); // MathKernInfoRecords empty
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 0), ==, 0); // MathKernInfoRecords empty
  closeFont();

  openFont("fonts/MathTestFontFull.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "I", -1, &glyph));

  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 7), ==, 62); // lower than min heigth
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 14), ==, 62); // equal to min height
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 20), ==, 104);
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 23), ==, 104);
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 31), ==, 146);
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 32), ==, 146);
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 86), ==, 398); // equal to max height
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 91), ==, 440); // larger than max height
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 96), ==, 440); // larger than max height

  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_RIGHT, 39), ==, 188); // top right
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_TOP_LEFT, 39), ==, 110); // top left
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_RIGHT, 39), ==, 44); // bottom right
  g_assert_cmpint(hb_ot_math_get_glyph_kerning (hb_font, glyph, HB_OT_MATH_KERN_BOTTOM_LEFT, 39), ==, 100); // bottom left

  closeFont();

  cleanupFreeType();
}
예제 #5
0
static void
test_has_data (void)
{
  initFreeType();

  openFont("fonts/MathTestFontNone.otf");
  g_assert(!hb_ot_math_has_data (hb_face)); // MATH table not available
  closeFont();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert(hb_ot_math_has_data (hb_face)); // MATH table available
  closeFont();

  cleanupFreeType();
}
예제 #6
0
void FontMap::getMaxMetrics()
{
    for (le_int32 i = 0; i < fFontCount; i += 1) {
        LEErrorCode status = LE_NO_ERROR;
        le_int32 ascent, descent, leading;

        if (fFontInstances[i] == NULL) {
            fFontInstances[i] = openFont(fFontNames[i], fPointSize, status);

            if (LE_FAILURE(status)) {
                continue;
            }
        }

        ascent  = fFontInstances[i]->getAscent();
        descent = fFontInstances[i]->getDescent();
        leading = fFontInstances[i]->getLeading();

        if (ascent > fAscent) {
            fAscent = ascent;
        }

        if (descent > fDescent) {
            fDescent = descent;
        }

        if (leading > fLeading) {
            fLeading = leading;
        }
    }
}
예제 #7
0
const LEFontInstance *FontMap::getScriptFont(le_int32 scriptCode, LEErrorCode &status)
{
    if (LE_FAILURE(status)) {
        return NULL;
    }

    if (scriptCode <= -1 || scriptCode >= scriptCodeCount) {
        status = LE_ILLEGAL_ARGUMENT_ERROR;
        return NULL;
    }


    le_int32 fontIndex = fFontIndices[scriptCode];

    if (fontIndex < 0) {
        sprintf(errorMessage, "No font was set for script %s", uscript_getName((UScriptCode) scriptCode));
        fGUISupport->postErrorMessage(errorMessage, "Font Map Error");
        status = LE_FONT_FILE_NOT_FOUND_ERROR;
        return NULL;
    }

    if (fFontInstances[fontIndex] == NULL) {
        fFontInstances[fontIndex] = openFont(fFontNames[fontIndex], fPointSize, status);

        if (LE_FAILURE(status)) {
            sprintf(errorMessage, "Could not open font file %s", fFontNames[fontIndex]);
            fGUISupport->postErrorMessage(errorMessage, "Font Map Error");
            return NULL;
        }
    }

    return fFontInstances[fontIndex];
}
예제 #8
0
파일: font.cpp 프로젝트: Rawng/ManaPlus
void Font::loadFont(std::string filename,
                    const int size,
                    const int style)
{
    if (fontCounter == 0 && TTF_Init() == -1)
    {
        logger->log("Unable to initialize SDL_ttf: " +
                    std::string(TTF_GetError()));
        return;
    }

    fixDirSeparators(filename);
    TTF_Font *const font = openFont(filename.c_str(), size);

    if (!font)
    {
        logger->log("Font::Font: " +
                    std::string(TTF_GetError()));
        return;
    }

    if (mFont)
        TTF_CloseFont(mFont);

    mFont = font;
    TTF_SetFontStyle(mFont, style);
    clear();
}
예제 #9
0
static void
test_get_min_connector_overlap (void)
{
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert_cmpint(hb_ot_math_get_min_connector_overlap(hb_font, FALSE), ==, 0); // MathVariants not available
  g_assert_cmpint(hb_ot_math_get_min_connector_overlap(hb_font, TRUE), ==, 0); // MathVariants not available
  closeFont();

  openFont("fonts/MathTestFontPartial1.otf");
  g_assert_cmpint(hb_ot_math_get_min_connector_overlap(hb_font, HB_DIRECTION_LTR), ==, 108);
  g_assert_cmpint(hb_ot_math_get_min_connector_overlap(hb_font, HB_DIRECTION_TTB), ==, 54);
  closeFont();

  cleanupFreeType();
}
예제 #10
0
파일: font.cpp 프로젝트: Rawng/ManaPlus
Font::Font(std::string filename,
           const int size,
           const int style) :
    mFont(nullptr),
    mCreateCounter(0),
    mDeleteCounter(0),
    mCleanTime(cur_time + CLEAN_TIME)
{
    if (fontCounter == 0)
    {
        mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE;
        if (TTF_Init() == -1)
        {
            logger->error("Unable to initialize SDL_ttf: " +
                std::string(TTF_GetError()));
        }
    }

    if (!fontCounter)
    {
        strBuf = new char[65535];
        memset(strBuf, 0, 65535);
    }

    ++fontCounter;

    fixDirSeparators(filename);
    mFont = openFont(filename.c_str(), size);

    if (!mFont)
    {
        logger->log("Error finding font " + filename);
        std::string backFile("fonts/dejavusans.ttf");
        mFont = openFont(fixDirSeparators(backFile).c_str(), size);
        if (!mFont)
        {
            logger->error("Font::Font: " +
                          std::string(TTF_GetError()));
        }
    }

    TTF_SetFontStyle(mFont, style);
}
예제 #11
0
bool CGViewer::loadFiles()
{
    background = loadImage( "../res/background_L.png" );
    if( background.get() == NULL )
    {
        return false;
    }

	active = loadImage( "../res/active_s.png" );
    if( active.get() == NULL )
    {
        return false;
    }

	inactive = loadImage( "../res/inactive_s.png" );
    if( inactive.get() == NULL )
    {
        return false;
    }

	unknown = loadImage( "../res/unknown_s.png" );
    if( unknown.get() == NULL )
    {
        return false;
    }

	// ladowanie czcionek
	font = openFont( "../res/verdana.ttf", 10 ); 

	font_large = openFont("../res/verdana.ttf", 24 );
	
	if( font.get() == NULL || font_large.get() == NULL ) 
	{ 
		return false; 
	} 

    return true;
}
예제 #12
0
static void
test_get_glyph_assembly_italics_correction (void)
{
  hb_codepoint_t glyph;
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, TRUE), ==, 0); // MathVariants not available
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, FALSE), ==, 0); // MathVariants not available
  closeFont();

  openFont("fonts/MathTestFontPartial1.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, TRUE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage absent
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, FALSE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage absent
  closeFont();

  openFont("fonts/MathTestFontPartial2.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, TRUE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage empty
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, FALSE), ==, 0); // VertGlyphCoverage and HorizGlyphCoverage empty
  closeFont();

  openFont("fonts/MathTestFontPartial3.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, TRUE), ==, 0); // HorizGlyphConstruction and VertGlyphConstruction empty
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, FALSE), ==, 0);  // HorizGlyphConstruction and VertGlyphConstruction empty
  closeFont();

  openFont("fonts/MathTestFontPartial4.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, TRUE), ==, 0);
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, FALSE), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontFull.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowleft", -1, &glyph));
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, TRUE), ==, 248);
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, FALSE), ==, 0);
  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowup", -1, &glyph));
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, TRUE), ==, 0);
  g_assert_cmpint(get_glyph_assembly_italics_correction (hb_font, glyph, FALSE), ==, 662);
  closeFont();

  cleanupFreeType();
}
예제 #13
0
파일: sdlsvgdrv.c 프로젝트: intgr/sc2-uqm
static mg_font_t drv_loadFont(const char* name, double size, const char* filename)
{
	struct mg_font* fnt;

	if (!filename)
	{
		mg_verbose(1, "sdlsvg: filename not specified for font '%s'\n", name);
		return 0;
	}

	fnt = calloc(1, sizeof(*fnt));
	if (!fnt)
		return 0;
	fnt->size = size;
	fnt->name = strdup(name ? name : "<Unknown>");
	fnt->font = openFont(filename, inchToPixelsY(fnt->size));
	if (!fnt->font)
	{
		free(fnt);
		return 0;
	}

	return fnt;
}
예제 #14
0
static void
test_get_constant (void)
{
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert_cmpint(hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT), ==, 0); // MathConstants not available
  closeFont();

  openFont("fonts/MathTestFontFull.otf");
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT)), ==, 100);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT)), ==, 200);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_MATH_LEADING)), ==, 300);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_AXIS_HEIGHT)), ==, 400);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT)), ==, 500);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT)), ==, 600);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN)), ==, 700);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX)), ==, 800);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN)), ==, 900);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP)), ==, 1100);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED)), ==, 1200);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN)), ==, 1300);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX)), ==, 1400);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN)), ==, 1500);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT)), ==, 1600);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT)), ==, 3400);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN)), ==, 1800);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN)), ==, 1900);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN)), ==, 2200);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN)), ==, 2300);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP)), ==, 2400);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP)), ==, 2500);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN)), ==, 2600);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN)), ==, 2700);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_GAP_MIN)), ==, 2800);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN)), ==, 2900);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP)), ==, 3000);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN)), ==, 3100);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN)), ==, 3200);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN)), ==, 3300);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP)), ==, 3400);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP)), ==, 3500);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN)), ==, 3600);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN)), ==, 3700);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN)), ==, 3800);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN)), ==, 3900);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS)), ==, 4000);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN)), ==, 4100);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN)), ==, 4200);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP)), ==, 8600);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP)), ==, 4400);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP)), ==, 4500);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS)), ==, 4600);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_OVERBAR_EXTRA_ASCENDER)), ==, 4700);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP)), ==, 4800);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS)), ==, 4900);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_UNDERBAR_EXTRA_DESCENDER)), ==, 5000);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP)), ==, 5100);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP)), ==, 5200);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS)), ==, 5300);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_EXTRA_ASCENDER)), ==, 5400);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE)), ==, 11000);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE)), ==, 11200);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN)), ==, 87);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN)), ==, 76);
  g_assert_cmpint((hb_ot_math_get_constant (hb_font, HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT)), ==, 65);
  closeFont();

  cleanupFreeType();
}
예제 #15
0
static void
test_get_glyph_assembly (void)
{
  hb_codepoint_t glyph;
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontPartial1.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontPartial2.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontPartial3.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontPartial4.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontFull.otf");

  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowright", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font,
                                                 glyph,
                                                 HB_DIRECTION_BTT,
                                                 0,
                                                 NULL,
                                                 NULL,
                                                 NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font,
                                                 glyph,
                                                 HB_DIRECTION_RTL,
                                                 0,
                                                 NULL,
                                                 NULL,
                                                 NULL), ==, 3);

  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowdown", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font,
                                                 glyph,
                                                 HB_DIRECTION_BTT,
                                                 0,
                                                 NULL,
                                                 NULL,
                                                 NULL), ==, 5);
  g_assert_cmpint(hb_ot_math_get_glyph_assembly (hb_font,
                                                 glyph,
                                                 HB_DIRECTION_RTL,
                                                 0,
                                                 NULL,
                                                 NULL,
                                                 NULL), ==, 0);

  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowright", -1, &glyph));
  hb_ot_math_glyph_part_t parts[20];
  unsigned partsSize = sizeof (parts) / sizeof (parts[0]);
  unsigned int count;
  unsigned int offset = 0;
  do {
    count = partsSize;
    hb_ot_math_get_glyph_assembly (hb_font,
                                   glyph,
                                   HB_DIRECTION_RTL,
                                   offset,
                                   &count,
                                   parts,
                                   NULL);
    offset += count;
  } while (count == partsSize);
  g_assert_cmpint(offset, ==, 3);
  g_assert(hb_font_get_glyph_from_name (hb_font, "left", -1, &glyph));
  g_assert_cmpint(parts[0].glyph, ==, glyph);
  g_assert_cmpint(parts[0].start_connector_length, ==, 800);
  g_assert_cmpint(parts[0].end_connector_length, ==, 384);
  g_assert_cmpint(parts[0].full_advance, ==, 2000);
  g_assert(!(parts[0].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));
  g_assert(hb_font_get_glyph_from_name (hb_font, "horizontal", -1, &glyph));
  g_assert_cmpint(parts[1].glyph, ==, glyph);
  g_assert_cmpint(parts[1].start_connector_length, ==, 524);
  g_assert_cmpint(parts[1].end_connector_length, ==, 800);
  g_assert_cmpint(parts[1].full_advance, ==, 2000);
  g_assert(parts[1].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER);
  g_assert(hb_font_get_glyph_from_name (hb_font, "right", -1, &glyph));
  g_assert_cmpint(parts[2].glyph, ==, glyph);
  g_assert_cmpint(parts[2].start_connector_length, ==, 316);
  g_assert_cmpint(parts[2].end_connector_length, ==, 454);
  g_assert_cmpint(parts[2].full_advance, ==, 2000);
  g_assert(!(parts[2].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));

  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowdown", -1, &glyph));
  offset = 0;
  do {
    count = partsSize;
    hb_ot_math_get_glyph_assembly (hb_font,
                                   glyph,
                                   HB_DIRECTION_BTT,
                                   offset,
                                   &count,
                                   parts,
                                   NULL);
    offset += count;
  } while (count == partsSize);
  g_assert_cmpint(offset, ==, 5);
  g_assert(hb_font_get_glyph_from_name (hb_font, "bottom", -1, &glyph));
  g_assert_cmpint(parts[0].glyph, ==, glyph);
  g_assert_cmpint(parts[0].start_connector_length, ==, 365);
  g_assert_cmpint(parts[0].end_connector_length, ==, 158);
  g_assert_cmpint(parts[0].full_advance, ==, 1000);
  g_assert(!(parts[0].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));
  g_assert(hb_font_get_glyph_from_name (hb_font, "vertical", -1, &glyph));
  g_assert_cmpint(parts[1].glyph, ==, glyph);
  g_assert_cmpint(parts[1].glyph, ==, glyph);
  g_assert_cmpint(parts[1].start_connector_length, ==, 227);
  g_assert_cmpint(parts[1].end_connector_length, ==, 365);
  g_assert_cmpint(parts[1].full_advance, ==, 1000);
  g_assert(parts[1].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER);
  g_assert(hb_font_get_glyph_from_name (hb_font, "center", -1, &glyph));
  g_assert_cmpint(parts[2].glyph, ==, glyph);
  g_assert_cmpint(parts[2].start_connector_length, ==, 54);
  g_assert_cmpint(parts[2].end_connector_length, ==, 158);
  g_assert_cmpint(parts[2].full_advance, ==, 1000);
  g_assert(!(parts[2].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));
  g_assert(hb_font_get_glyph_from_name (hb_font, "vertical", -1, &glyph));
  g_assert_cmpint(parts[3].glyph, ==, glyph);
  g_assert_cmpint(parts[3].glyph, ==, glyph);
  g_assert_cmpint(parts[3].glyph, ==, glyph);
  g_assert_cmpint(parts[3].start_connector_length, ==, 400);
  g_assert_cmpint(parts[3].end_connector_length, ==, 296);
  g_assert_cmpint(parts[3].full_advance, ==, 1000);
  g_assert(parts[1].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER);
  g_assert(hb_font_get_glyph_from_name (hb_font, "top", -1, &glyph));
  g_assert_cmpint(parts[4].glyph, ==, glyph);
  g_assert_cmpint(parts[4].start_connector_length, ==, 123);
  g_assert_cmpint(parts[4].end_connector_length, ==, 192);
  g_assert_cmpint(parts[4].full_advance, ==, 1000);
  g_assert(!(parts[4].flags & HB_MATH_GLYPH_PART_FLAG_EXTENDER));

  closeFont();

  cleanupFreeType();
}
예제 #16
0
static void
test_get_glyph_variants (void)
{
  hb_codepoint_t glyph;
  initFreeType();

  openFont("fonts/MathTestFontEmpty.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontPartial1.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontPartial2.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontPartial3.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontPartial4.otf");
  g_assert(hb_font_get_glyph_from_name (hb_font, "space", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_RTL, 0, NULL, NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font, glyph, HB_DIRECTION_BTT, 0, NULL, NULL), ==, 0);
  closeFont();

  openFont("fonts/MathTestFontFull.otf");

  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowleft", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font,
                                                 glyph,
                                                 HB_DIRECTION_BTT,
                                                 0,
                                                 NULL,
                                                 NULL), ==, 0);
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font,
                                                 glyph,
                                                 HB_DIRECTION_RTL,
                                                 0,
                                                 NULL,
                                                 NULL), ==, 3);

  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowup", -1, &glyph));
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font,
                                                 glyph,
                                                 HB_DIRECTION_BTT,
                                                 0,
                                                 NULL,
                                                 NULL), ==, 4);
  g_assert_cmpint(hb_ot_math_get_glyph_variants (hb_font,
                                                 glyph,
                                                 HB_DIRECTION_RTL,
                                                 0,
                                                 NULL,
                                                 NULL), ==, 0);

  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowleft", -1, &glyph));
  hb_ot_math_glyph_variant_t variants[20];
  unsigned variantsSize = sizeof (variants) / sizeof (variants[0]);
  unsigned int count;
  unsigned int offset = 0;
  do {
    count = variantsSize;
    hb_ot_math_get_glyph_variants (hb_font,
                                   glyph,
                                   HB_DIRECTION_RTL,
                                   offset,
                                   &count,
                                   variants);
    offset += count;
  } while (count == variantsSize);
  g_assert_cmpint(offset, ==, 3);
  g_assert(hb_font_get_glyph_from_name (hb_font, "uni2190_size2", -1, &glyph));
  g_assert_cmpint(variants[0].glyph, ==, glyph);
  g_assert_cmpint(variants[0].advance, ==, 4302);
  g_assert(hb_font_get_glyph_from_name (hb_font, "uni2190_size3", -1, &glyph));
  g_assert_cmpint(variants[1].glyph, ==, glyph);
  g_assert_cmpint(variants[1].advance, ==, 4802);
  g_assert(hb_font_get_glyph_from_name (hb_font, "uni2190_size4", -1, &glyph));
  g_assert_cmpint(variants[2].glyph, ==, glyph);
  g_assert_cmpint(variants[2].advance, ==, 5802);

  g_assert(hb_font_get_glyph_from_name (hb_font, "arrowup", -1, &glyph));
  offset = 0;
  do {
    count = variantsSize;
    hb_ot_math_get_glyph_variants (hb_font,
                                   glyph,
                                   HB_DIRECTION_BTT,
                                   offset,
                                   &count,
                                   variants);
    offset += count;
  } while (count == variantsSize);
  g_assert_cmpint(offset, ==, 4);
  g_assert(hb_font_get_glyph_from_name (hb_font, "uni2191_size2", -1, &glyph));
  g_assert_cmpint(variants[0].glyph, ==, glyph);
  g_assert_cmpint(variants[0].advance, ==, 2251);
  g_assert(hb_font_get_glyph_from_name (hb_font, "uni2191_size3", -1, &glyph));
  g_assert_cmpint(variants[1].glyph, ==, glyph);
  g_assert_cmpint(variants[1].advance, ==, 2501);
  g_assert(hb_font_get_glyph_from_name (hb_font, "uni2191_size4", -1, &glyph));
  g_assert_cmpint(variants[2].glyph, ==, glyph);
  g_assert_cmpint(variants[2].advance, ==, 3001);
  g_assert(hb_font_get_glyph_from_name (hb_font, "uni2191_size5", -1, &glyph));
  g_assert_cmpint(variants[3].glyph, ==, glyph);
  g_assert_cmpint(variants[3].advance, ==, 3751);

  closeFont();

  cleanupFreeType();
}
예제 #17
0
int main(int argc, char **argv) {

	// Init all SDl stuff

	SDL_Routine SDL_hdl;
	if (SDL_hdl.InitSDL()) {
		logSDLError(std::cout, "SDL Init");
		return 1;
	}

	SDL_Texture *bg = loadTexture("res/bg.png", SDL_hdl.Render);
	Character Alice;

	Alice.loadTex("res/Alice_spritesheet.png", SDL_hdl.Render);

	if (bg == nullptr || Alice.char_tex == nullptr)
			return 4;

	const Uint8 *keys = SDL_GetKeyboardState(nullptr);


	// Main Loop

	Mix_Music *bg_mus = loadBGMusic("res/bg.mp3");
	playBGMusic(bg_mus);
	bool mus_status = true;

	SDL_Event e;
	bool show_fps = true;
	bool quit = false;

	TTF_Font* fps_font = openFont("res/beau.ttf", 25);
	SDL_Color textColor = {0, 0, 0};

	std::stringstream fps_text;
	SDL_Texture* txt_image;
	//SDL_Texture* txt_image = renderText("FPS test text", fps_font, textColor, renderer);
	//if (txt_image == nullptr) {
	//	return 1;
	//}

	LTimer fpsTimer;
	int countedFrames = 0;
	std::stringstream fpsText;
	float avgFPS = 0;

	fpsTimer.start();


	while (!quit) {

		SDL_RenderClear(SDL_hdl.Render);

		int bW, bH;
		SDL_QueryTexture(bg, NULL, NULL, &bW, &bH);

		// Calculate FPS
		avgFPS = countedFrames / ( fpsTimer.getTicks() / 1000.f );
		if ( avgFPS > 2000000 )
			avgFPS = 0;
		fps_text.str("");
		fps_text << "FPS: " << avgFPS;

		// Render BG
		SDL_Rect bg_box;
		bg_box.x = 0;
		bg_box.y = 0;
		bg_box.w = SCREEN_WIDTH;
		bg_box.h = SCREEN_HEIGHT;
		renderTexture(bg, SDL_hdl.Render, bg_box, nullptr);

		// Show FPS
		if (show_fps) {
			txt_image = renderText(fps_text.str().c_str(), fps_font, textColor, SDL_hdl.Render);
			if (txt_image == nullptr) {
				return 1;
			}
		}

		//SDL_PumpEvents();
		if (SDL_PollEvent(&e)) {
			if (e.type == SDL_QUIT)
				quit = true;
			if (e.type == SDL_MOUSEBUTTONDOWN)
				quit = true;
		}

		if (keys[SDL_SCANCODE_LEFT]) {
			Alice.direction_state = 6;
			Alice.anim_frame = Alice.frame / 4;
			if (Alice.char_box.x > 0)
				Alice.char_box.x -= VELOCITY;
		}
		if (keys[SDL_SCANCODE_RIGHT]) {
			Alice.direction_state = 2;
			Alice.anim_frame = Alice.frame / 4;
			if (Alice.char_box.x <= (SCREEN_WIDTH - SPRITE_SIZE * 3))
				Alice.char_box.x += VELOCITY;
		}
		if (keys[SDL_SCANCODE_UP]) {
			Alice.direction_state = 0;
			Alice.anim_frame = Alice.frame / 4;
			if (Alice.char_box.y > 0)
				Alice.char_box.y -= VELOCITY;
		}
		if (keys[SDL_SCANCODE_DOWN]) {
			Alice.direction_state = 4;
			Alice.anim_frame = Alice.frame / 4;
			if (Alice.char_box.y < (SCREEN_HEIGHT - SPRITE_SIZE * 3))
				Alice.char_box.y += VELOCITY;
		}
		if (keys[SDL_SCANCODE_UP] && keys[SDL_SCANCODE_RIGHT]) {
			Alice.direction_state = 1;
			Alice.anim_frame = Alice.frame / 4;
			if ((Alice.char_box.y > 0) && (Alice.char_box.x < (SCREEN_WIDTH - SPRITE_SIZE * 3))) {
				Alice.char_box.x += VELOCITY / 4;
				Alice.char_box.y -= VELOCITY / 4;
			}
		}
		if (keys[SDL_SCANCODE_UP] && keys[SDL_SCANCODE_LEFT]) {
			Alice.direction_state = 5;
			Alice.anim_frame = Alice.frame / 4;
			if ((Alice.char_box.y > 0) && (Alice.char_box.x > 0)) {
				Alice.char_box.x -= VELOCITY / 4;
				Alice.char_box.y -= VELOCITY / 4;
			}
		}
		if (keys[SDL_SCANCODE_DOWN] && keys[SDL_SCANCODE_RIGHT]) {
			Alice.direction_state = 3;
			Alice.anim_frame = Alice.frame / 4;
			if ((Alice.char_box.y < (SCREEN_HEIGHT - SPRITE_SIZE * 3)) &&
					(Alice.char_box.x < (SCREEN_WIDTH - SPRITE_SIZE * 3))) {
				Alice.char_box.x += VELOCITY / 4;
				Alice.char_box.y += VELOCITY / 4;
			}
		}
		if (keys[SDL_SCANCODE_DOWN] && keys[SDL_SCANCODE_LEFT]) {
			Alice.direction_state = 7;
			Alice.anim_frame = Alice.frame / 4;
			if ((Alice.char_box.y < (SCREEN_HEIGHT - SPRITE_SIZE * 3)) && (Alice.char_box.x > 0)) {
				Alice.char_box.x -= VELOCITY / 4;
				Alice.char_box.y += VELOCITY / 4;
			}
		}
		if (keys[SDL_SCANCODE_P]) {
			if (mus_status) {
				pauseBGMusic();
				mus_status = false;
			}
			else {
				resumeBGMusic();
				mus_status = true;
			}
		}
		if (keys[SDL_SCANCODE_GRAVE]) {
			if (show_fps)
				show_fps = false;
			else {
				show_fps = true;
			}
		}
		if (keys[SDL_SCANCODE_ESCAPE]) {
			quit = true;
		}

		renderTexture(Alice.char_tex, SDL_hdl.Render, Alice.char_box, &Alice.char_clips[Alice.anim_frame][Alice.direction_state]);

		if (show_fps)
			renderTexture(txt_image, SDL_hdl.Render, 20, 20, nullptr);

		SDL_RenderPresent(SDL_hdl.Render);

		++Alice.frame;
		if ( Alice.frame / 4 >= ANIMATION_FRAMES )
			Alice.frame = 0;

		++countedFrames;
	}


	// Cleanup

	unloadBGMusic(bg_mus);

	TTF_CloseFont(fps_font);

	SDL_DestroyTexture(bg);
	SDL_DestroyTexture(Alice.char_tex);

	SDL_hdl.CleanupSDL();

	return 0;
}