#include "gfxfont.h"
#include "ttf.h"
#include "mem.h"
+#include "log.h"
static int loadfont_scale = 64;
static int full_unicode = 1;
int u = font->glyphs[t].unicode;
if(u>=0) {
assert(font->unicode2glyph[u]<0); // we took care of duplicates, right?
+ assert(u<font->max_unicode);
font->unicode2glyph[u] = t;
}
}
}
}
+ dest->bearing = dest->xmin;
dest->advance = src->advance*scale;
int u = font->glyphs[t].unicode;
- if(invalid_unicode(u)) {
- u = 0xe000 + remap_pos++;
- }
if(u > max_unicode)
max_unicode = u;
}
ttf->unicode_size = max_unicode+1;
ttf->unicode = rfx_calloc(sizeof(unicode_t)*ttf->unicode_size);
- remap_pos=0;
- for(t=0;t<font->num_glyphs;t++) {
- gfxglyph_t*src = &font->glyphs[t];
- int u = font->glyphs[t].unicode;
- if(invalid_unicode(u)) {
- u = 0xe000 + remap_pos++;
+
+ if(!font->unicode2glyph) {
+ for(t=0;t<font->num_glyphs;t++) {
+ gfxglyph_t*src = &font->glyphs[t];
+ int u = font->glyphs[t].unicode;
+ if(u<=0)
+ continue;
+ if(u<32) {
+ msg("<warning> gfxfont_to_ttf: glyph %d has an invalid unicode (%d)", t, u);
+ continue;
+ } else if(ttf->unicode[u]) {
+ msg("<warning> gfxfont_to_ttf: glyph %d has a duplicate unicode (%d)", t, u);
+ continue;
+ }
+ if(u<ttf->unicode_size)
+ ttf->unicode[u] = t+offset;
}
- if(u>=0 && u<ttf->unicode_size)
- ttf->unicode[u] = t+offset;
- }
- int u;
- if(font->unicode2glyph) {
- for(u=0;u<ttf->unicode_size;u++) {
+ } else {
+ int u;
+ for(u=1;u<font->max_unicode;u++) {
int g = font->unicode2glyph[u];
- if(invalid_unicode(u))
+ if(g>=0 && u<32) {
+ msg("<warning> gfxfont_to_ttf: Font contains an invalid unicode (%d)", u);
continue;
- if(g>=0 && !ttf->unicode[u]) {
+ }
+ if(g>=0 && g<font->num_glyphs && !ttf->unicode[u]) {
ttf->unicode[u] = g+offset;
}
}
}
+
ttf->ascent = font->ascent;
- ttf->descent = font->descent;
- ttf->lineGap = font->ascent + font->descent;
+ ttf->descent = -font->descent;
+ ttf->lineGap = 0;
ttf->full_name = strdup(font->id);
ttf->family_name = strdup(font->id);
ttf->subfamily_name = strdup(font->id);
+ ttf->postscript_name = strdup(font->id);
ttf->version_string = strdup("Version 1.0");
+ ttf->font_uid = strdup(font->id);
ttf_create_truetype_tables(ttf);
return ttf;