806 |
continue; |
continue; |
807 |
} |
} |
808 |
|
|
809 |
|
printf ("inserting font '%s':'%s'\n", face->family_name, |
810 |
|
face->style_name); |
811 |
|
|
812 |
font_cache_insert (face->family_name, face->style_name, full_path); |
font_cache_insert (face->family_name, face->style_name, full_path); |
813 |
FT_Done_Face (face); |
FT_Done_Face (face); |
814 |
} |
} |
836 |
return true; |
return true; |
837 |
} |
} |
838 |
|
|
839 |
|
/* Obtain a font handle for font <FONT_NAME, STYLE_NAME>. Returns negative |
840 |
|
if we can not fond that font. */ |
841 |
|
int |
842 |
|
GXFontGetHandle (char *font_name, char *style_name) |
843 |
|
{ |
844 |
|
return font_cache_lookup (font_name, style_name); |
845 |
|
} |
846 |
|
|
847 |
|
|
848 |
void |
void |
849 |
GFContextShowTextAtPoint (GFContextRef context, float x, float y, |
GFContextShowTextAtPoint (GFContextRef context, float x, float y, |
850 |
char *string, int string_length) |
char *string, int string_length) |
890 |
paintserver_free (context, state->fill_space); |
paintserver_free (context, state->fill_space); |
891 |
} |
} |
892 |
|
|
893 |
|
/* Graphics extention function to render STRING into DST_IMG at (X, Y). |
894 |
|
FONT_HANDLE is obtained from GXFontGetHandle. */ |
895 |
|
/* ??? add color. */ |
896 |
|
void |
897 |
|
GFImageRenderTextAtPoint (GFImageRef dst_img, float x, float y, |
898 |
|
char *string, int string_length, |
899 |
|
int font_handle, float font_size, float value[]) |
900 |
|
{ |
901 |
|
int glyph_xy[2], dim [2], x0, y0, x1, y1, i; |
902 |
|
ArtPixMaxDepth color[8]; |
903 |
|
struct glyph *glyph; |
904 |
|
ArtRender *render; |
905 |
|
double affine[6]; |
906 |
|
|
907 |
|
#if 0 |
908 |
|
art_affine_translate (affine, x, y); |
909 |
|
#else |
910 |
|
art_affine_identity (affine); |
911 |
|
#endif |
912 |
|
|
913 |
|
/* Render STRING into GLYPH. */ |
914 |
|
glyph = render_string (font_handle, string, string_length, |
915 |
|
font_size, font_size, affine, glyph_xy, 1, dim); |
916 |
|
if (glyph == 0) |
917 |
|
return; |
918 |
|
|
919 |
|
render = art_render_new (dst_img->x0 , dst_img->y0, dst_img->x1, dst_img->y1, |
920 |
|
dst_img->pixels, GFImageRowStride (dst_img), 3, 8, |
921 |
|
ART_ALPHA_SEPARATE, ART_ALPHA_LAST, NULL); |
922 |
|
art_render_mask_solid (render, 0x10000); |
923 |
|
|
924 |
|
/* ??? SOLID COLOR HERE. */ |
925 |
|
for (i = 0; i < dst_img->samples; i++) |
926 |
|
color [i] = value [i] * 255; |
927 |
|
|
928 |
|
x0 = glyph_xy [0] + dst_img->x0 + (int) x; |
929 |
|
#if 0 |
930 |
|
y0 = glyph_xy [1] + dst_img->y0 + (int) y; |
931 |
|
#else |
932 |
|
y0 = dst_img->y0 + (int) y - glyph->underline_position |
933 |
|
+ glyph->underline_thickness; |
934 |
|
#endif |
935 |
|
x1 = x0 + glyph->width; |
936 |
|
y1 = y0 + glyph->height; |
937 |
|
|
938 |
|
art_render_image_solid (render, color); |
939 |
|
art_render_mask (render, x0, y0, x1, y1, glyph->buf, glyph->rowstride); |
940 |
|
art_render_invoke (render); |
941 |
|
} |
942 |
|
|
943 |
GFSize |
GFSize |
944 |
GFContextMeasureText (GFContextRef context, char *string, int string_length) |
GFContextMeasureText (GFContextRef context, char *string, int string_length) |
945 |
{ |
{ |
952 |
return GFSizeMake (dim [0], dim [1]); |
return GFSizeMake (dim [0], dim [1]); |
953 |
} |
} |
954 |
|
|
955 |
|
GFSize |
956 |
|
GFFontMeasureText (GFFontHandle font_handle, float size, char *string, int string_length) |
957 |
|
{ |
958 |
|
int glyph_xy[2], dim [2]; |
959 |
|
double affine[6]; |
960 |
|
|
961 |
|
art_affine_identity (affine); |
962 |
|
|
963 |
|
render_string (font_handle, string, string_length, size, size, |
964 |
|
affine, glyph_xy, 0, dim); |
965 |
|
return GFSizeMake (dim [0], dim [1]); |
966 |
|
} |
967 |
|
|
968 |
|
|