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 |
|
|
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; |
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); |
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 |
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 |
|
|
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 |
} |
} |
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; |
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 |
} |
} |