}
}
-ttf_t* gfxfont_to_ttf(gfxfont_t*font)
+ttf_t* gfxfont_to_ttf(gfxfont_t*font, char eot)
{
ttf_t*ttf = ttf_new();
int num_glyphs = font->num_glyphs;
}
}
- dest->bearing = dest->xmin;
- /* make sure coordinates are always to the right of the origin */
- int xshift=0;
- if(dest->xmin < 0) {
- xshift = -dest->xmin;
- for(s=0;s<count;s++) {
- dest->points[s].x += xshift;
+ if(eot) {
+ dest->bearing = dest->xmin;
+ /* for windows font rendering, make sure coordinates are always
+ to the right of the origin (and use bearing to shift them "back".)
+ Don't do this for non-windows platforms though because e.g. OS X
+ ignores bearing. */
+ int xshift=0;
+ if(dest->xmin < 0) {
+ xshift = -dest->xmin;
+ for(s=0;s<count;s++) {
+ dest->points[s].x += xshift;
+ }
+ dest->xmin += xshift;
+ dest->xmax += xshift;
}
- dest->xmin += xshift;
- dest->xmax += xshift;
}
+ dest->advance = src->advance*scale;
//dest->xmin=0; //TODO: might be necessary for some font engines?
void gfxfont_save(gfxfont_t*font, const char*filename)
{
- ttf_t*ttf = gfxfont_to_ttf(font);
+ ttf_t*ttf = gfxfont_to_ttf(font, 0);
ttf_save(ttf, filename);
ttf_destroy(ttf);
}
void gfxfont_save_eot(gfxfont_t*font, const char*filename)
{
- ttf_t*ttf = gfxfont_to_ttf(font);
+ ttf_t*ttf = gfxfont_to_ttf(font, 1);
ttf_save_eot(ttf, filename);
ttf_destroy(ttf);
}
for(t=0;t<ttf->num_glyphs;t++) {
if(ttf->glyphs[t].advance > hea->advanceWidthMax)
hea->advanceWidthMax = ttf->glyphs[t].advance;
- if(ttf->glyphs[t].xmin < hea->minLeftSideBearing)
- hea->minLeftSideBearing = ttf->glyphs[t].xmin;
+ if(ttf->glyphs[t].bearing < hea->minLeftSideBearing)
+ hea->minLeftSideBearing = ttf->glyphs[t].bearing;
if(ttf->glyphs[t].xmax < hea->minRightSideBearing)
hea->minRightSideBearing = ttf->glyphs[t].xmax;
int width = ttf->glyphs[t].xmax - ttf->glyphs[t].xmin;