28 |
*/ |
*/ |
29 |
class GlyphInfo { |
class GlyphInfo { |
30 |
public: |
public: |
31 |
GlyphInfo(int top, int left, int width, int height, int xadvance) : |
GlyphInfo(float top, float left, float width, float height, |
32 |
top(top), left(left), width(width), height(height), xadvance(xadvance) { } |
float xadvance, float scaleFromPixels, |
33 |
|
short iwidth, short iheight) : |
34 |
|
top(top), left(left), width(width), height(height), |
35 |
|
xadvance(xadvance), scaleFromPixels(scaleFromPixels), |
36 |
|
iwidth(iwidth), iheight(iheight) { } |
37 |
GlyphInfo() : top(0), left(0), width(0), height(0), xadvance(0) { } |
GlyphInfo() : top(0), left(0), width(0), height(0), xadvance(0) { } |
38 |
int top; |
float top; |
39 |
int left; |
float left; |
40 |
int width; |
float width; |
41 |
int height; |
float height; |
42 |
int xadvance; |
float xadvance; |
43 |
|
float scaleFromPixels; |
44 |
|
short iwidth; |
45 |
|
short iheight; |
46 |
friend ostream& operator<<(ostream& o, const GlyphInfo &g) ; |
friend ostream& operator<<(ostream& o, const GlyphInfo &g) ; |
47 |
}; |
}; |
48 |
|
|
72 |
Glyph withBorder(int texels) { |
Glyph withBorder(int texels) { |
73 |
// Empty glyphs remain empty. |
// Empty glyphs remain empty. |
74 |
if(extents.width == 0) return *this; |
if(extents.width == 0) return *this; |
75 |
|
float scale = extents.scaleFromPixels; |
76 |
|
float st = scale * texels; |
77 |
return Glyph( |
return Glyph( |
78 |
GlyphInfo( |
GlyphInfo( |
79 |
extents.top - 1 * texels, extents.left - 1 * texels, |
extents.top - 1 * st, extents.left - 1 * st, |
80 |
extents.width + 2 * texels, extents.height + 2 * texels, |
extents.width + 2 * st, extents.height + 2 * st, |
81 |
extents.xadvance |
extents.xadvance, |
82 |
|
extents.scaleFromPixels, |
83 |
|
extents.iwidth + 2 * texels, extents.iheight + 2 * texels |
84 |
), |
), |
85 |
raster.addBorder(texels, 0)); |
raster.addBorder(texels, 0)); |
86 |
} |
} |
207 |
Glyph g = face->getRaster(i); |
Glyph g = face->getRaster(i); |
208 |
if(g.extents.width == 0 || g.extents.height == 0) |
if(g.extents.width == 0 || g.extents.height == 0) |
209 |
continue; |
continue; |
210 |
MosaicTile tile = mosaic.alloc(g.extents.width, g.extents.height); |
MosaicTile tile = mosaic.alloc(g.extents.iwidth, g.extents.iheight); |
211 |
DBG(dbg_glyphdetails) << "MTile: "<<tile<<"\n"; |
DBG(dbg_glyphdetails) << "MTile: "<<tile<<"\n"; |
212 |
tile.loadImage(g.raster); |
tile.loadImage(g.raster); |
213 |
glyphs[i] = QuadGlyph(g, tile.getRect()); |
glyphs[i] = QuadGlyph(g, tile.getRect()); |
236 |
} |
} |
237 |
/** Get the width of a single glyph. |
/** Get the width of a single glyph. |
238 |
*/ |
*/ |
239 |
int getGlyphWidth(Char c) { |
float getGlyphWidth(Char c) { |
240 |
if((unsigned)c >= glyphs.size()) return 0; |
if((unsigned)c >= glyphs.size()) return 0; |
241 |
DBG(dbg_glyphdetails) << "Glyphwidth: "<<((int)c)<<" "<<glyphs[c].glyph.extents.xadvance<<" valid:"<<glyphs[c].valid()<< "\n"; |
DBG(dbg_glyphdetails) << "Glyphwidth: "<<((int)c)<<" "<<glyphs[c].glyph.extents.xadvance<<" valid:"<<glyphs[c].valid()<< "\n"; |
242 |
if(!glyphs[c].valid() && c != ' ') return 0; |
if(!glyphs[c].valid() && c != ' ') return 0; |