Crystal Space
Welcome, Guest. Please login or register.
October 02, 2014, 02:15:12 pm

Login with username, password and session length
Search:     Advanced search
9020 Posts in 2053 Topics by 8581 Members
Latest Member: Vashikaranmantra33
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Problem about iFontServer and Fonts
« previous next »
Pages: [1] Print
Author Topic: Problem about iFontServer and Fonts  (Read 1935 times)
ArKangeL
Newbie
*
Posts: 11


View Profile
« on: September 26, 2005, 08:58:46 am »

Hi all

Im starting an application and i have some problems setting up the iFontServer and Font.

I use this code:

//-Declaration

struct FSrv;
struct Font;

...

// In class declatarion

csRef<iFontServer> FSrv;
csRef<iFont> Font;

...

// In initialization

...

  FSrv = CS_QUERY_REGISTRY (object_reg, iFontServer);
  if (FSrv == 0)
  {
    csReport (object_reg, CS_REPORTER_SEVERITY_ERROR,
        "crystalspace.application.simple1",
        "No iFontServer plugin!");
    return false;
  }

 Font = CS_QUERY_REGISTRY (object_reg, iFont);
  if (Font == 0)
  {
    csReport (object_reg, CS_REPORTER_SEVERITY_ERROR,
        "crystalspace.application.simple1",
        "No iFont plugin!");
    return false;
  }

...

// In use

...

   int fg = g2d->FindRGB (255, 0, 0);  // Red.
   FSrv = g2d->GetFontServer();
   Font = FSrv->LoadFont(CSFONT_COURIER);
   g2d->Write (Font, 200, 200, fg, -1, "This is text");

...


And the result is an error at begining of application like: No iFont plugin!
How can i setup Fonts in a correct way ? What need i change on my code ?
Thx a lot Devteam.

See you

ARKANGEL
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #1 on: September 26, 2005, 09:12:13 am »

You need to load a font server plugin. You could do this via a configuration file (see walktest.cfg, for instance), or you can request it when you invoke csInitializer::RequestPlugins(). You could even load a font server plugin manually with one of the CS_LOAD_PLUGIN() macros. Just to get it working, the simplest approach is probably RequestPlugins(...CS_REQUEST_FONTSERVER...). This will allow you to query it from the object registry using CS_QUERY_REGISTRY(), as you are already doing.

Once you have a handle to the font server, you then ask the font server to load a particular font. You do this by invoking iFontServer::LoadFont(). The value returned by this method is the one you assign to your csRef<iFont>.
Logged
ArKangeL
Newbie
*
Posts: 11


View Profile
« Reply #2 on: September 26, 2005, 09:18:22 am »

Hi

Thx for your fast answer, i will chek it as soon as i can.

See you

ARKANGEL
Logged
ArKangeL
Newbie
*
Posts: 11


View Profile
« Reply #3 on: September 26, 2005, 09:30:12 am »

Hi

I solve it, the problem on my code is when i try to Font = CS_QUERY_REGISTRY (object_reg, iFont);, it dosent work, so i delete it and let the structure iFont declared but not inicializet ( i ignore if it need to be initializet or not ), then i write this code:

   int fg = g2d->FindRGB (255, 0, 0);  // Red.
   FSrv = g2d->GetFontServer();
   Font = FSrv->LoadFont(CSFONT_COURIER);
   g2d->Write (Font, 200, 200, fg, -1, "This is text");

Now it works fine.

Thx for all.

ARKANGEL
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #4 on: September 26, 2005, 11:41:05 am »

Yes, that is what I explained in my earlier post. You assign the result of iFontServer::LoadFont() to your Font variable. You can't query the object registry for an iFont because you have only loaded the font server into the registry, not any particular fonts.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.628 seconds with 15 queries.