GError GFontsImpExp::DoRead(const GChar8 *FullFileName, GElement& Element, const GDynArray<GImpExpOption>& ParsedOptions) {

	GString metricsFile;
	GBool outerCCW = G_TRUE;
	GReal scale = 1; // a value of 0 indicates a normalization to square EM [0;1]

	// check each option
	GDynArray<GImpExpOption>::const_iterator it = ParsedOptions.begin();
	for (; it != ParsedOptions.end(); ++it) {
		if (StrUtils::SameText(it->OptionName, "outerccw")) {
			if (StrUtils::SameText(it->OptionValue, "false"))
				outerCCW = G_FALSE;
		}
		else
		if (StrUtils::SameText(it->OptionName, "metricsfile"))
			metricsFile = it->OptionValue;
		else
		if (StrUtils::SameText(it->OptionName, "scale"))
			scale = (GReal)StrUtils::ToDouble(it->OptionValue);
	}
	// init freetype2 library
	InitFTLibrary();
	// read the font
	GError err = ReadFont(FullFileName, Element, outerCCW, metricsFile, scale);
	// destroy freetype2 library
	FT_Done_FreeType(gFontLibrary);
	gFontLibraryInitialized = G_FALSE;
	return err;
}
Beispiel #2
0
/* 
| Function loads font to memory from file
| Return value: GLF_ERROR  - if error
|               >=0 - returned font descriptor (load success)
*/
int glfLoadFont(char *font_name)
{
	int i;
	char flag; /* Temporary flag */

	/* First we find free font descriptor */
	flag = 0; /* Descriptor not found yet */
	for (i=0; i<MAX_FONTS; i++)
		if (fonts[i] == NULL)
		{
			/* Initialize this font */
			fonts[i] = (struct glf_font *)malloc(sizeof(struct glf_font));
			flag = 1;
			break;
		}

	if (!flag) return GLF_ERROR; /* Free font not found */
	if (ReadFont(font_name, fonts[i]) == GLF_OK) 
	{
		curfont = i; /* Set curfont to just loaded font */
		return i;
	}
  
	if (fonts[i] != NULL)
	{
		free(fonts[i]);
		fonts[i] = NULL;
	}
	
	return GLF_ERROR;
}
Beispiel #3
0
bool  PPO_SeriesLegend::ReadFromFile()
{
    ReadObjectHeader();
    PPO_AnnoBase::ReadFromFile();
    ReadFuncObjRef(penSetObjRef);

    int nRead = 6; // old max
    if (currentObjReadMajorVersion > 0)
        nRead = ReadInt();

    for ( int i = 0; i < nRead; i++)
    {
        ReadFuncObjRef(legendData[i].seriesObjRef);
        legendData[i].doSeries   = ReadBool();
    }

    ulLocation.pX = ReadDouble();
    ulLocation.pY = ReadDouble();

    seriesSize = ReadDouble();
    seriesNpts = ReadInt();

    ReadText(legendTitle, PSC_AnnoSpec::legendTitleLen);

    frameLegend       = ReadBool();
    frameThick        = ReadInt();
    opaqueBackground  = ReadBool();
    legendPen         = ReadInt();

    ReadFont(legendFont);

    CheckForInputFailure("Reading PPO_SeriesLegend");
    return true;
}
void compatibleReadStyle()
{
	char styleFile[MAX_PATH];
	strcpy(styleFile, stylePath());

	ReadFont(styleFile);

	mSkin.borderWidth = ReadInt(styleFile, "borderWidth:", 1);
	mSkin.borderWidth = ReadInt(styleFile, "window.frame.borderWidth:", mSkin.borderWidth);

	strcpy(borderColorAsString, ReadString(styleFile, "borderColor:", "0x000000"));
	mSkin.focus_borderColor = ReadColor(styleFile, "window.frame.focus.borderColor:", borderColorAsString);
	mSkin.unfocus_borderColor = ReadColor(styleFile, "window.frame.unfocus.borderColor:", borderColorAsString);

	mSkin.handleHeight = ReadInt(styleFile, "handleWidth:", 5);
	mSkin.handleHeight = ReadInt(styleFile, "window.handleHeight:", mSkin.handleHeight);

	ReadStyleElement(styleFile, &mSkin.windowTitleFocus, "window.title.focus");
	ReadStyleElement(styleFile, &mSkin.windowLabelFocus, "window.label.focus");
	ReadStyleElement(styleFile, &mSkin.windowHandleFocus, "window.handle.focus");
	ReadStyleElement(styleFile, &mSkin.windowGripFocus, "window.grip.focus");
	ReadStyleElement(styleFile, &mSkin.windowButtonFocus, "window.button.focus");
	ReadStyleElement(styleFile, &mSkin.windowButtonPressed, "window.button.pressed");

	ReadStyleElement(styleFile, &mSkin.windowTitleUnfocus, "window.title.unfocus");
	ReadStyleElement(styleFile, &mSkin.windowLabelUnfocus, "window.label.unfocus");
	ReadStyleElement(styleFile, &mSkin.windowHandleUnfocus, "window.handle.unfocus");
	ReadStyleElement(styleFile, &mSkin.windowGripUnfocus, "window.grip.unfocus");
	ReadStyleElement(styleFile, &mSkin.windowButtonUnfocus, "window.button.unfocus");
}
Beispiel #5
0
int main(int ac, const char *av[])
{
	const uint8_t *p = nullptr;

	for (int i = 1; i < ac; ++i)
	{
		p = nullptr;

		/***/if (ac > 1 && strstr(av[i], "04x06") != nullptr) p = font_04x06;
		else if (ac > 1 && strstr(av[i], "05x08") != nullptr) p = font_05x08;
		else if (ac > 1 && strstr(av[i], "05x12") != nullptr) p = font_05x12;
		else if (ac > 1 && strstr(av[i], "06x08") != nullptr) p = font_06x08;
		else if (ac > 1 && strstr(av[i], "06x10") != nullptr) p = font_06x10;
		else if (ac > 1 && strstr(av[i], "07x12") != nullptr) p = font_07x12;
		else if (ac > 1 && strstr(av[i], "08x08") != nullptr) p = font_08x08;
		else if (ac > 1 && strstr(av[i], "08x12") != nullptr) p = font_08x12;
		else if (ac > 1 && strstr(av[i], "08x14") != nullptr) p = font_08x14;
		else if (ac > 1 && strstr(av[i], "10x16") != nullptr) p = font_10x16;
		else if (ac > 1 && strstr(av[i], "12x16") != nullptr) p = font_12x16;
		else if (ac > 1 && strstr(av[i], "12x20") != nullptr) p = font_12x20;
		else if (ac > 1 && strstr(av[i], "16x26") != nullptr) p = font_16x26;

		if (p)
			PrintFont(p);
		else
		{
			FILE *fin = stdin;
			if (ac > 1) fin = fopen(av[i], "r");
			ReadFont(fin);
			if (ac > 1) fclose(fin);
		}
	}
}
Beispiel #6
0
  explicit Achievement(GameEnv& env) :
    env_(env),
    localize_(*env.localize),
    active_(true),
    texture_(env.texMng->read(*env.path + "devdata/round.png")),
    params_(env.params->value().get<picojson::object>()["achievement"].get<picojson::object>()),
    font_(ReadFont("achievement", *env.fonts, *env.path, env.params->value().get<picojson::object>())),
    height_(font_->height()),
    title_(localize_.get(params_["title"].get<std::string>())),
    delay_(params_["delay"].get<double>()),
    draw_(),
    time_(),
    time_ed_(0.5),
    vct_st_(0, 0.7),
    vct_ed_(1, 1),
    ease_type_(CUBIC_OUT),
    agree_delay_(1.5),
    fin_exec_(),
    touched_()
  {
    DOUT << "Achievement()" << std::endl;

    const picojson::object& achievs = env_.settings->get<picojson::object>("achievement");
#ifdef _DEBUG
    if (env_.keyinp->press('u'))
    {
      DOUT << "All Achievement Unlock!" << std::endl;
      for (picojson::object::const_iterator it = achievs.begin(); it != achievs.end(); ++it)
      {
        AchievementUnlock(it->first, env_);
        // 全解除
      }
    }
#endif

    for (picojson::object::const_iterator it = achievs.begin(); it != achievs.end(); ++it)
    {
      if (!it->second.get<bool>() && env_.settings->get<bool>(it->first))
      {
        texts_.push_back(it->first);
      }
    }

    if (texts_.empty())
    {
      delay_ = 0;
      fin_exec_ = true;
      time_ = 0;
      time_ed_ = 0;
    }
  }
Beispiel #7
0
void ReadTA(Setting& s, TextAttributes& taResult)
{
	s.lookupValue("position", (int&)taResult.position);
	s.lookupValue("posType", (int&)taResult.posType);
	s.lookupValue("xPosRatio", taResult.xPosRatio);
	s.lookupValue("yPosRatio", taResult.yPosRatio);
	std::string text;
	s.lookupValue("text", text);
	taResult.text = text.c_str();
	s.lookupValue("backgroundColor", (int&)taResult.backgroundColor);
	s.lookupValue("textColor", (int&)taResult.textColor);
	s.lookupValue("isFontSelected", taResult.isFontSelected);
	if (s.exists("Font"))
		ReadFont(s["Font"], taResult.logfont);
}
Beispiel #8
0
void ReadAnnoSpec(PSC_AnnoSpec& annoSpec)
{
    int ver = ReadInt();

    annoSpec.ulLocation.pX = ReadDouble();
    annoSpec.ulLocation.pY = ReadDouble();

    ReadText(annoSpec.legendTitle, PSC_AnnoSpec::legendTitleLen);

    annoSpec.frameLegend        = ReadBool();
    annoSpec.frameThick         = ReadInt ();
    annoSpec.opaqueBackground   = ReadBool();
    annoSpec.legendPen          = ReadInt ();

    ReadFont(annoSpec.legendFont);
}
Beispiel #9
0
void ReadXYZLabelSpec(PSC_XYZLabelSpec& labelSpec, bool oldVer)
{
    int ver = 0;
    if (!oldVer)
        ver = ReadInt();

    labelSpec.labelPen = ReadInt();
    ReadFont(labelSpec.labelFont);

    labelSpec.labelAttitude     = PSC_XYZLabelSpec::LabelAttitude(ReadInt());
    labelSpec.autoLabelRotation = ReadBool();
    labelSpec.rotationAngle     = ReadDouble();

    labelSpec.horizontalPos = HorizontalTextAlignment(ReadInt());
    labelSpec.verticalPos   = VerticalTextAlignment(ReadInt());
    if (ver > 0)
        labelSpec.clipToAxes = ReadBool();
}
TextureFont::TextureFont(char* filename)
{
	m_Initialized = false;

    m_ImageName[0] = 0;
    m_Chars = 0;
    m_KerningPairs = 0;
    m_NumChars = 0;
    m_NumKerningPairs = 0;

	//read in the font properties and character values
    int length;
    char* buffer = LoadFile( filename, &length, false );
    ReadFont( buffer, length );

	//load the bitmap with the fonts
	LoadFontImage();
}
Beispiel #11
0
void ReadXYLabelSpec(PSC_XYLabelSpec& labelSpec, int ver)
{
    if (ver > 2)        // start at 2
        ver = ReadInt();

    labelSpec.labelPen = ReadInt();
    ReadFont(labelSpec.labelFont);
    if (ver == 0)
        labelSpec.labelFont.fontRotation = PSC_Font::FontRotation(ReadInt());

    labelSpec.horizontalPos = HorizontalTextAlignment(ReadInt());
    labelSpec.verticalPos   = VerticalTextAlignment(ReadInt());

    if (ver > 1)
    {
        labelSpec.pixelOffset = ReadInt();
        labelSpec.clipToAxes = ReadBool();
    }
}
Beispiel #12
0
bool  PPO_DataLabels::ReadFromFile()
{
    ReadObjectHeader();
    PPO_AnnoBase::ReadFromFile();
    ReadFuncObjRef(penSetObjRef);

    int nread = PFO_DataLabels::maxDataLabels;
    if (currentObjReadMajorVersion < 1)
        nread = 6;

    for ( int i = 0; i < nread; i++)
    {
        ReadFuncObjRef(labelData[i].labelObjRef);
        labelData[i].doLabel   = ReadBool();
        labelData[i].labAlign  = HorizontalTextAlignment(ReadInt());

        labelData[i].overrideFormat                 = ReadBool();
        labelData[i].labelFormat.format             = NumConvFormat(ReadInt());
        labelData[i].labelFormat.digitsPrecision    = ReadInt();

        labelData[i].overrideMainLabel     = ReadBool();
        ReadText(labelData[i].mainLabel, DO_Label::maxLabelLen);
        ReadText(labelData[i].unitsLabel, DO_Label::maxLabelLen);
    }

    ulLocation.pX = ReadDouble();
    ulLocation.pY = ReadDouble();

    ReadText(legendTitle, PSC_AnnoSpec::legendTitleLen);

    frameLegend        = ReadBool();
    frameThick         = ReadInt();
    opaqueBackground   = ReadBool();
    legendPen          = ReadInt();
    minDataFieldWidth  = ReadInt();

    ReadFont(legendFont);

    CheckForInputFailure("Reading PPO_DataLabels");
    return true;
}
Beispiel #13
0
void TextComp::Read (istream& in) {
    GraphicComp::Read(in);
    int lineHt;

    in >> lineHt;
    char* string = ReadString(in);
    TextGraphic* text = new TextGraphic(string, lineHt);
    delete string;

    text->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    text->SetColors(fg, bg);
    text->SetFont(ReadFont(in));

    Transformer* t = ReadTransformer(in);
    text->SetTransformer(t);
    Unref(t);

    SetGraphic(text);
}
Beispiel #14
0
  Ranking(GameEnv& env, const int mode, const bool record) :
    env_(env),
    active_(true),
    mode_(mode),
    record_(record),
    params_(env.params->value().get<picojson::object>()["ranking"].get<picojson::object>()),
    rank_tbl_(env.params->value().get<picojson::object>()["rank_tbl"].get<picojson::array>()),
    json_(isSavedParamExists(*env.savePath + "results.json") ? *env.savePath + "results.json" : *env.path + "devdata/results.json"),
    font_(ReadFont("ranking", *env.fonts, *env.path, env.params->value().get<picojson::object>())),
    texture_(env.texMng->read(*env.path + "devdata/round.png")),
    title_(params_["title"].get<picojson::array>()[mode_].get<std::string>()),
    skip_delay_(params_["skip_delay"].get<double>()),
    do_skip_(),
    wipe_(true),
    time_cur_(),
    time_ed_(params_["time_ed"].get<double>()),
    ofs_st_(1, 0, 1),
    ofs_ed_(0, 1, 0),
    scale_(),
    scale_st_(0),
    scale_ed_(1),
    scale_time_ed_(time_ed_ * 0.4),
    disp_time_(record ? 0 : params_["disp_time"].get<double>()),
    col_(1, 1, 1, 1),
    col_index_(),
    col_timer_(),
    col_demo_time_(10000),                          // 最初は動かさない
    col_demo_time_ed_(params_["col_demo_time"].get<double>()),
    col_demo_index_(RESULT_NUM),
    agree_(),
    touched_(),
    finish_()
  {
    DOUT << "Ranking()" << std::endl;

    static const char *record_tbl[] = {
      "normal",
      "advanced",
      "survival"
    };

    picojson::array& array = json_.value().get<picojson::object>()[record_tbl[mode_]].get<picojson::array>();
    // FIXME:コードの下の方でも array を使ってます
    for (picojson::array::iterator it = array.begin(); it != array.end(); ++it)
    {
      int level = it->get<picojson::object>()["level"].get<double>();
      int konahen = it->get<picojson::object>()["konahen"].get<double>();
      int score = it->get<picojson::object>()["score"].get<double>();
      int rank = it->get<picojson::object>()["rank"].get<double>();
      
      GameResult result = {
        level,
        konahen,
        score,
        rank,
        false
      };
      results_.push_back(result);
    }

    if (record_)
    {
      GameResult result = {
        env_.level + 1,
        env_.konahen,
        env_.score,
        env_.rank,
        true
      };
      results_.push_back(result);

      {
        picojson::object obj;
        obj["level"] = picojson::value((float)result.level);
        obj["konahen"] = picojson::value((float)result.konahen);
        obj["score"] = picojson::value((float)result.score);
        obj["rank"] = picojson::value((float)result.rank);

        array.push_back(picojson::value(obj));

        std::string fpath = *env_.savePath + "results.json";
        json_.write(fpath);
      }
    }
    std::sort(results_.begin(), results_.end());
    std::reverse(results_.begin(), results_.end());
    results_.resize(RESULT_NUM);

    bool played = false;
    int index = 0;
    for (std::vector<GameResult>::iterator it = results_.begin(); it != results_.end(); ++it, ++index)
    {
      if (it->played)
      {
        played = it->played;
        break;
      }
    }
    // FIXME:ここはアルゴリズムを使うべきか…

    if (played && (index < RANKIN_INDEX))
    {
      switch (env_.game_mode)
      {
      case GAME_MODE_NORMAL:
        {
          AchievementUnlock("advanced", env_);
        }
        break;

      case GAME_MODE_ADVANCED:
        {
          AchievementUnlock("survival", env_);
        }
        break;

      case GAME_MODE_SURVIVAL:
        {
          AchievementUnlock("earth_texture", env_);
        }
        break;
      }
      // ランクインしたら実績解除
    }

    env_.sound->play("ranking", 1, 0.6);
    env_.touch->resistCallBack(this);
  }