git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
started implementation of a z-buffer.
[swftools.git]
/
lib
/
modules
/
swffont.c
diff --git
a/lib/modules/swffont.c
b/lib/modules/swffont.c
index
6344fd3
..
876c139
100644
(file)
--- a/
lib/modules/swffont.c
+++ b/
lib/modules/swffont.c
@@
-51,6
+51,11
@@
void swf_SetLoadFontParameters(int _scale, int _skip_unused, int _full_unicode)
#include <freetype/ftoutln.h>
#endif
#include <freetype/ftoutln.h>
#endif
+/* Setting subpixels to 64 also means that the "point size" of the
+ font outlines will be 64. So the font, when rendered at original
+ size (i.e., the swf fontsize is 1024) will have the same size as
+ if it was rendered at 64pt */
+
#define FT_SCALE 1
#define FT_SUBPIXELS 64
#define FT_SCALE 1
#define FT_SUBPIXELS 64
@@
-251,15
+256,24
@@
SWFFONT* swf_LoadTrueTypeFont(char*filename)
error = FT_Load_Glyph(face, t, FT_LOAD_NO_BITMAP);
if(error) {
fprintf(stderr, "Couldn't load glyph %d, error:%d\n", t, error);
error = FT_Load_Glyph(face, t, FT_LOAD_NO_BITMAP);
if(error) {
fprintf(stderr, "Couldn't load glyph %d, error:%d\n", t, error);
- continue;
- }
- error = FT_Get_Glyph(face->glyph, &glyph);
- if(error) {
- fprintf(stderr, "Couldn't get glyph %d, error:%d\n", t, error);
- continue;
+ glyph=0;
+ if(skip_unused)
+ continue;
+ } else {
+ error = FT_Get_Glyph(face->glyph, &glyph);
+ if(error) {
+ fprintf(stderr, "Couldn't get glyph %d, error:%d\n", t, error);
+ glyph=0;
+ if(skip_unused)
+ continue;
+ }
}
}
- FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_unscaled, &bbox);
+ if(glyph)
+ FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_unscaled, &bbox);
+ else
+ memset(&bbox, 0, sizeof(bbox));
+
bbox.yMin = -bbox.yMin;
bbox.yMax = -bbox.yMax;
if(bbox.xMax < bbox.xMin) {
bbox.yMin = -bbox.yMin;
bbox.yMax = -bbox.yMax;
if(bbox.xMax < bbox.xMin) {
@@
-278,7
+292,10
@@
SWFFONT* swf_LoadTrueTypeFont(char*filename)
swf_Shape01DrawerInit(&draw, 0);
//error = FT_Outline_Decompose(&face->glyph->outline, &outline_functions, &draw);
swf_Shape01DrawerInit(&draw, 0);
//error = FT_Outline_Decompose(&face->glyph->outline, &outline_functions, &draw);
- error = FT_Outline_Decompose(&face->glyph->outline, &outline_functions, &draw);
+ if(glyph)
+ error = FT_Outline_Decompose(&face->glyph->outline, &outline_functions, &draw);
+ else
+ error = 0;
draw.finish(&draw);
if(error) {
draw.finish(&draw);
if(error) {
@@
-289,12
+306,15
@@
SWFFONT* swf_LoadTrueTypeFont(char*filename)
#if 0
if(bbox.xMin > 0) {
#if 0
if(bbox.xMin > 0) {
- font->glyph[font->numchars].advance = (bbox.xMax*FT_SCALE)/FT_SUBPIXELS;
+ font->glyph[font->numchars].advance = (bbox.xMax*20*FT_SCALE)/FT_SUBPIXELS;
} else {
} else {
- font->glyph[font->numchars].advance = ((bbox.xMax - bbox.xMin)*FT_SCALE)/FT_SUBPIXELS;
+ font->glyph[font->numchars].advance = ((bbox.xMax - bbox.xMin)*20*FT_SCALE)/FT_SUBPIXELS;
}
#else
}
#else
- font->glyph[font->numchars].advance = glyph->advance.x*20/65536;
+ if(glyph)
+ font->glyph[font->numchars].advance = glyph->advance.x*20/65536;
+ else
+ font->glyph[font->numchars].advance = 0;
#endif
font->glyph[font->numchars].shape = swf_ShapeDrawerToShape(&draw);
#endif
font->glyph[font->numchars].shape = swf_ShapeDrawerToShape(&draw);
@@
-306,7
+326,8
@@
SWFFONT* swf_LoadTrueTypeFont(char*filename)
draw.dealloc(&draw);
draw.dealloc(&draw);
- FT_Done_Glyph(glyph);
+ if(glyph)
+ FT_Done_Glyph(glyph);
font->glyph2ascii[font->numchars] = font->glyph2ascii[t];
glyph2glyph[t] = font->numchars;
font->numchars++;
font->glyph2ascii[font->numchars] = font->glyph2ascii[t];
glyph2glyph[t] = font->numchars;
font->numchars++;
@@
-471,7
+492,7
@@
SWFFONT* swf_LoadT1Font(char*filename)
}
last = pos;
outline = outline->link;
}
last = pos;
outline = outline->link;
- printf("(%f,%f) ", pos.x, pos.y);
+ printf("t1lib: (%f,%f) ", pos.x, pos.y);
}
printf("\n");
}
printf("\n");