/[paragui]/paragui/src/font/pgfont.cpp
ViewVC logotype

Diff of /paragui/src/font/pgfont.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3.6.3 by braindead, Sat Jan 4 21:13:41 2003 UTC revision 1.3.6.3.2.1 by braindead, Mon Nov 24 09:17:22 2003 UTC
# Line 93  void PG_FontEngine::FontEngineError(FT_E Line 93  void PG_FontEngine::FontEngineError(FT_E
93    
94  PG_GlyphCacheItem* PG_FontEngine::GetGlyph(PG_Font *Param, int glyph_index) {  PG_GlyphCacheItem* PG_FontEngine::GetGlyph(PG_Font *Param, int glyph_index) {
95    
96          PG_GlyphCacheItem *GlyphCacheItem = Param->GetFaceCache()->GlyphCache[glyph_index];          PG_FontFaceCacheItem* facecache = Param->GetFaceCache();
97            PG_GlyphCacheItem *GlyphCacheItem = facecache->GlyphCache[glyph_index];
98    
99          if(GlyphCacheItem != NULL) {          if(GlyphCacheItem != NULL) {
100                  return GlyphCacheItem;                  return GlyphCacheItem;
101          }          }
102    
103          if (FT_Load_Glyph(Param->GetFaceCache()->Face, glyph_index, FT_LOAD_RENDER ))          FT_Face face = facecache->Face;
104    
105            if (FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER ))
106                  return NULL;                  return NULL;
107    
108          Uint32 bitmapsize = Param->GetFaceCache()->Face->glyph->bitmap.pitch * Param->GetFaceCache()->Face->glyph->bitmap.rows;          Uint32 bitmapsize = face->glyph->bitmap.pitch * face->glyph->bitmap.rows;
109          GlyphCacheItem =  new PG_GlyphCacheItem(bitmapsize);          GlyphCacheItem = new PG_GlyphCacheItem(bitmapsize);
110    
111          GlyphCacheItem->Glyph_Index = glyph_index;          GlyphCacheItem->Glyph_Index = glyph_index;
112          GlyphCacheItem->Bitmap = Param->GetFaceCache()->Face->glyph->bitmap;          GlyphCacheItem->Bitmap = face->glyph->bitmap;
113          GlyphCacheItem->Bitmap_left = Param->GetFaceCache()->Face->glyph->bitmap_left;          GlyphCacheItem->Bitmap_left = face->glyph->bitmap_left;
114          GlyphCacheItem->Bitmap_top = Param->GetFaceCache()->Face->glyph->bitmap_top;          GlyphCacheItem->Bitmap_top = face->glyph->bitmap_top;
115          GlyphCacheItem->Advance_x = FT_CEIL(Param->GetFaceCache()->Face->glyph->metrics.horiAdvance);          GlyphCacheItem->Advance_x = FT_CEIL(face->glyph->metrics.horiAdvance);
116          memcpy(GlyphCacheItem->data(), Param->GetFaceCache()->Face->glyph->bitmap.buffer, bitmapsize);          memcpy(GlyphCacheItem->data(), face->glyph->bitmap.buffer, bitmapsize);
117          GlyphCacheItem->Bitmap.buffer = (unsigned char*)GlyphCacheItem->data();          GlyphCacheItem->Bitmap.buffer = (unsigned char*)GlyphCacheItem->data();
118    
119          Param->GetFaceCache()->GlyphCache[glyph_index] = GlyphCacheItem;          facecache->GlyphCache[glyph_index] = GlyphCacheItem;
120          return GlyphCacheItem;          return GlyphCacheItem;
121  }  }
122    
# Line 154  inline void BlitTemplate(DT pixels, SDL_ Line 157  inline void BlitTemplate(DT pixels, SDL_
157          Uint32 color = 0;          Uint32 color = 0;
158          Sint32 v;          Sint32 v;
159    
160          SDL_Color fc = Param->GetColor();          PG_Color fc = Param->GetColor();
161          cr = fc.r;          cr = fc.r;
162          cg = fc.g;          cg = fc.g;
163          cb = fc.b;          cb = fc.b;
# Line 181  inline void BlitTemplate(DT pixels, SDL_ Line 184  inline void BlitTemplate(DT pixels, SDL_
184    
185                          // Get the pixel                          // Get the pixel
186                          color = *((DT) (dst_pixels));                          color = *((DT) (dst_pixels));
187                          if ( Surface->format->BytesPerPixel > 1 ) {                          switch(Surface->format->BytesPerPixel) {
188                            default:
189                                  // get the RGBA values                                  // get the RGBA values
190                                  rv = (color & Rmask) >> Rshift;                                  rv = (color & Rmask) >> Rshift;
191                                  r = (rv << Rloss) + (rv >> Rloss8);                                  r = (rv << Rloss) + (rv >> Rloss8);
# Line 221  inline void BlitTemplate(DT pixels, SDL_ Line 224  inline void BlitTemplate(DT pixels, SDL_
224    
225                                  // get the destination color                                  // get the destination color
226                                  color = (r >> Rloss) << Rshift                                  color = (r >> Rloss) << Rshift
227                              | (g >> Gloss) << Gshift                                          | (g >> Gloss) << Gshift
228                              | (b >> Bloss) << Bshift                                          | (b >> Bloss) << Bshift
229                              | ((a >> Aloss) << Ashift & Amask);                              | ((a >> Aloss) << Ashift & Amask);
230                                  // Set the pixel                                  // Set the pixel
231                          } else {                                  break;
232                                    
233                            case 1:
234                                  SDL_GetRGBA(color, format, &r, &g, &b, &a);                                  SDL_GetRGBA(color, format, &r, &g, &b, &a);
235    
236                                  // calculate new RGBA values                                  // calculate new RGBA values
# Line 249  inline void BlitTemplate(DT pixels, SDL_ Line 254  inline void BlitTemplate(DT pixels, SDL_
254                                          a = v;                                          a = v;
255                                  }                                  }
256                                  color = SDL_MapRGBA(format, r,g,b, a);                                  color = SDL_MapRGBA(format, r,g,b, a);
257                                    break;
258                          }                          }
259                          *((DT) (dst_pixels)) = color;                          *((DT) (dst_pixels)) = color;
260    
# Line 418  bool PG_FontEngine::BlitFTBitmap(SDL_Sur Line 424  bool PG_FontEngine::BlitFTBitmap(SDL_Sur
424                                                          //if (Param->Alpha != 255)                                                          //if (Param->Alpha != 255)
425                                                          //      a = (a * Param->Alpha) / 255;                                                          //      a = (a * Param->Alpha) / 255;
426    
427                                                          raw_pixels[int(ioffset) + x + (my_charSurface->pitch/4)*(y)] = SDL_MapRGBA(my_charSurface->format, Param->Color.r, Param->Color.g, Param->Color.b, a);                                                          raw_pixels[int(ioffset) + x + (my_charSurface->pitch/4)*(y)] = Param->Color.MapRGBA(my_charSurface->format, a);
428                                                  }                                                  }
429                                                  SrcPix -= x;                                                  SrcPix -= x;
430                                          }                                          }
# Line 436  bool PG_FontEngine::BlitFTBitmap(SDL_Sur Line 442  bool PG_FontEngine::BlitFTBitmap(SDL_Sur
442                                                  if (Param->Alpha != 255)                                                  if (Param->Alpha != 255)
443                                                          a = (a * Param->Alpha) / 255;                                                          a = (a * Param->Alpha) / 255;
444    
445                                                  *raw_pixels = SDL_MapRGBA(my_charSurface->format, Param->Color.r, Param->Color.g, Param->Color.b, a);                                                  *raw_pixels = Param->Color.MapRGBA(my_charSurface->format, a);
446                                                  raw_pixels++;                                                  raw_pixels++;
447                                          }                                          }
448                                          SrcPix -= x;                                          SrcPix -= x;
# Line 539  bool PG_FontEngine::RenderText(SDL_Surfa Line 545  bool PG_FontEngine::RenderText(SDL_Surfa
545                          SDL_FillRect(                          SDL_FillRect(
546                                  Surface,                                  Surface,
547                                  &und_rect,                                  &und_rect,
548                                  SDL_MapRGB(                                  font->GetColor().MapRGB(Surface->format)
                                         Surface->format,  
                                         font->GetColor().r,  
                                         font->GetColor().g,  
                                         font->GetColor().b  
                                         )  
549                                  );                                  );
550                  }                  }
551          }          }

Legend:
Removed from v.1.3.6.3  
changed lines
  Added in v.1.3.6.3.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26