summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2009-02-23 21:28:20 +0100
committerTor Andersson <tor@ghostscript.com>2009-02-23 21:28:20 +0100
commit6f9e2167d235a6b89ee13e3c98e5120a8c85fe29 (patch)
tree81fae599803e0ec2ff32f8098c27fd84bd63eeb2 /include
parent5d500fad85344dcad7e6c0cf0463f5d58f6acea3 (diff)
downloadmupdf-6f9e2167d235a6b89ee13e3c98e5120a8c85fe29.tar.xz
Refactor fz_font and pdf_font mess into fz_font and pdf_fontdesc with more font logic on the PDF side and freetype rendering on the fitz side.
Diffstat (limited to 'include')
-rw-r--r--include/fitz-world.h1
-rw-r--r--include/fitz/wld_font.h60
-rw-r--r--include/fitz/wld_text.h5
-rw-r--r--include/mupdf/content.h2
-rw-r--r--include/mupdf/rsrc.h77
5 files changed, 81 insertions, 64 deletions
diff --git a/include/fitz-world.h b/include/fitz-world.h
index f810e07b..ddf9a445 100644
--- a/include/fitz-world.h
+++ b/include/fitz-world.h
@@ -15,6 +15,7 @@
#include "fitz/wld_color.h"
#include "fitz/wld_image.h"
#include "fitz/wld_shade.h"
+
#include "fitz/wld_tree.h"
#include "fitz/wld_path.h"
#include "fitz/wld_text.h"
diff --git a/include/fitz/wld_font.h b/include/fitz/wld_font.h
index 27217c6c..8bcffb60 100644
--- a/include/fitz/wld_font.h
+++ b/include/fitz/wld_font.h
@@ -1,43 +1,22 @@
typedef struct fz_font_s fz_font;
-typedef struct fz_hmtx_s fz_hmtx;
-typedef struct fz_vmtx_s fz_vmtx;
typedef struct fz_glyph_s fz_glyph;
typedef struct fz_glyphcache_s fz_glyphcache;
-struct fz_hmtx_s
-{
- unsigned short lo;
- unsigned short hi;
- int w; /* type3 fonts can be big! */
-};
-
-struct fz_vmtx_s
-{
- unsigned short lo;
- unsigned short hi;
- short x;
- short y;
- short w;
-};
+char *ft_errorstring(int err);
struct fz_font_s
{
int refs;
char name[32];
- fz_error* (*render)(fz_glyph*, fz_font*, int, fz_matrix);
- void (*drop)(fz_font *);
+ void *ftface; /* has an FT_Face if used */
+ int ftsubstitute; /* ... substitute metrics */
- int wmode;
- fz_irect bbox;
+ struct fz_tree_s **t3procs; /* has 256 entries if used */
+ fz_matrix t3matrix;
- int nhmtx, hmtxcap;
- fz_hmtx dhmtx;
- fz_hmtx *hmtx;
+ fz_irect bbox;
- int nvmtx, vmtxcap;
- fz_vmtx dvmtx;
- fz_vmtx *vmtx;
};
struct fz_glyph_s
@@ -46,23 +25,24 @@ struct fz_glyph_s
unsigned char *samples;
};
-void fz_initfont(fz_font *font, char *name);
-fz_font *fz_keepfont(fz_font *font);
+fz_error * fz_newfreetypefont(fz_font **fontp, char *name, int substitute);
+fz_error * fz_loadfreetypefontfile(fz_font *font, char *path, int index);
+fz_error * fz_loadfreetypefontbuffer(fz_font *font, unsigned char *data, int len, int index);
+fz_error * fz_newtype3font(fz_font **fontp, char *name, fz_matrix matrix, void **procs);
+
+fz_error * fz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index);
+fz_error * fz_newfontfromfile(fz_font **fontp, char *path, int index);
+
+fz_font * fz_keepfont(fz_font *font);
void fz_dropfont(fz_font *font);
+
void fz_debugfont(fz_font *font);
-void fz_setfontwmode(fz_font *font, int wmode);
void fz_setfontbbox(fz_font *font, int xmin, int ymin, int xmax, int ymax);
-void fz_setdefaulthmtx(fz_font *font, int w);
-void fz_setdefaultvmtx(fz_font *font, int y, int w);
-fz_error *fz_addhmtx(fz_font *font, int lo, int hi, int w);
-fz_error *fz_addvmtx(fz_font *font, int lo, int hi, int x, int y, int w);
-fz_error *fz_endhmtx(fz_font *font);
-fz_error *fz_endvmtx(fz_font *font);
-fz_hmtx fz_gethmtx(fz_font *font, int cid);
-fz_vmtx fz_getvmtx(fz_font *font, int cid);
-fz_error *fz_newglyphcache(fz_glyphcache **arenap, int slots, int size);
-fz_error *fz_renderglyph(fz_glyphcache*, fz_glyph*, fz_font*, int, fz_matrix);
+fz_error * fz_renderftglyph(fz_glyph *glyph, fz_font *font, int cid, fz_matrix trm);
+fz_error * fz_rendert3glyph(fz_glyph *glyph, fz_font *font, int cid, fz_matrix trm);
+fz_error * fz_newglyphcache(fz_glyphcache **arenap, int slots, int size);
+fz_error * fz_renderglyph(fz_glyphcache*, fz_glyph*, fz_font*, int, fz_matrix);
void fz_debugglyphcache(fz_glyphcache *);
void fz_dropglyphcache(fz_glyphcache *);
diff --git a/include/fitz/wld_text.h b/include/fitz/wld_text.h
index 619aae83..d9e5c980 100644
--- a/include/fitz/wld_text.h
+++ b/include/fitz/wld_text.h
@@ -25,7 +25,8 @@ typedef struct fz_textel_s fz_textel;
struct fz_textel_s
{
float x, y;
- int cid;
+ int gid;
+ int ucs;
};
struct fz_textnode_s
@@ -39,6 +40,6 @@ struct fz_textnode_s
fz_error *fz_newtextnode(fz_textnode **textp, fz_font *face);
fz_error *fz_clonetextnode(fz_textnode **textp, fz_textnode *oldtext);
-fz_error *fz_addtext(fz_textnode *text, int g, float x, float y);
+fz_error *fz_addtext(fz_textnode *text, int gid, int ucs, float x, float y);
fz_error *fz_endtext(fz_textnode *text);
diff --git a/include/mupdf/content.h b/include/mupdf/content.h
index c28a33f3..a77a7296 100644
--- a/include/mupdf/content.h
+++ b/include/mupdf/content.h
@@ -54,7 +54,7 @@ struct pdf_gstate_s
float wordspace;
float scale;
float leading;
- pdf_font *font;
+ pdf_fontdesc *font;
float size;
int render;
float rise;
diff --git a/include/mupdf/rsrc.h b/include/mupdf/rsrc.h
index aa1935b5..65f9e536 100644
--- a/include/mupdf/rsrc.h
+++ b/include/mupdf/rsrc.h
@@ -189,11 +189,31 @@ extern const char * const pdf_expert[256];
extern const char * const pdf_symbol[256];
extern const char * const pdf_zapfdingbats[256];
-typedef struct pdf_font_s pdf_font;
+typedef struct pdf_hmtx_s pdf_hmtx;
+typedef struct pdf_vmtx_s pdf_vmtx;
+typedef struct pdf_fontdesc_s pdf_fontdesc;
-struct pdf_font_s
+struct pdf_hmtx_s
{
- fz_font super;
+ unsigned short lo;
+ unsigned short hi;
+ int w; /* type3 fonts can be big! */
+};
+
+struct pdf_vmtx_s
+{
+ unsigned short lo;
+ unsigned short hi;
+ short x;
+ short y;
+ short w;
+};
+
+struct pdf_fontdesc_s
+{
+ int refs;
+
+ fz_font *font;
/* FontDescriptor */
int flags;
@@ -215,32 +235,47 @@ struct pdf_font_s
int ncidtoucs;
unsigned short *cidtoucs;
- /* Freetype */
- int substitute;
- void *ftface;
- char *filename;
- fz_buffer *fontdata;
+ /* Metrics (given in the PDF file) */
+ int wmode;
- /* Type3 data */
- fz_matrix matrix;
- fz_tree *charprocs[256];
+ int nhmtx, hmtxcap;
+ pdf_hmtx dhmtx;
+ pdf_hmtx *hmtx;
+
+ int nvmtx, vmtxcap;
+ pdf_vmtx dvmtx;
+ pdf_vmtx *vmtx;
};
+/* fontmtx.c */
+void pdf_setfontwmode(pdf_fontdesc *font, int wmode);
+void pdf_setdefaulthmtx(pdf_fontdesc *font, int w);
+void pdf_setdefaultvmtx(pdf_fontdesc *font, int y, int w);
+fz_error *pdf_addhmtx(pdf_fontdesc *font, int lo, int hi, int w);
+fz_error *pdf_addvmtx(pdf_fontdesc *font, int lo, int hi, int x, int y, int w);
+fz_error *pdf_endhmtx(pdf_fontdesc *font);
+fz_error *pdf_endvmtx(pdf_fontdesc *font);
+pdf_hmtx pdf_gethmtx(pdf_fontdesc *font, int cid);
+pdf_vmtx pdf_getvmtx(pdf_fontdesc *font, int cid);
+
/* unicode.c */
-fz_error *pdf_loadtounicode(pdf_font *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm);
+fz_error *pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm);
/* fontfile.c */
-fz_error *pdf_loadbuiltinfont(pdf_font *font, char *basefont);
-fz_error *pdf_loadembeddedfont(pdf_font *font, pdf_xref *xref, fz_obj *stmref);
-fz_error *pdf_loadsystemfont(pdf_font *font, char *basefont, char *collection);
-fz_error *pdf_loadsubstitutefont(pdf_font *font, int fdflags, char *collection);
+fz_error *pdf_loadbuiltinfont(pdf_fontdesc *font, char *basefont);
+fz_error *pdf_loadembeddedfont(pdf_fontdesc *font, pdf_xref *xref, fz_obj *stmref);
+fz_error *pdf_loadsystemfont(pdf_fontdesc *font, char *basefont, char *collection);
+fz_error *pdf_loadsubstitutefont(pdf_fontdesc *font, int fdflags, char *collection);
/* type3.c */
-fz_error *pdf_loadtype3font(pdf_font **fontp, pdf_xref *xref, fz_obj *obj, fz_obj *ref);
+fz_error *pdf_loadtype3font(pdf_fontdesc **fontp, pdf_xref *xref, fz_obj *obj, fz_obj *ref);
/* font.c */
-char *ft_errstr(int err);
-fz_error *pdf_loadfontdescriptor(pdf_font *font, pdf_xref *xref, fz_obj *desc, char *collection);
-fz_error *pdf_loadfont(pdf_font **fontp, pdf_xref *xref, fz_obj *obj, fz_obj *ref);
-void pdf_dropfont(pdf_font *font);
+int pdf_fontcidtogid(pdf_fontdesc *fontdesc, int cid);
+fz_error *pdf_loadfontdescriptor(pdf_fontdesc *font, pdf_xref *xref, fz_obj *desc, char *collection);
+fz_error *pdf_loadfont(pdf_fontdesc **fontp, pdf_xref *xref, fz_obj *obj, fz_obj *ref);
+pdf_fontdesc * pdf_newfontdesc(void);
+pdf_fontdesc * pdf_keepfont(pdf_fontdesc *fontdesc);
+void pdf_dropfont(pdf_fontdesc *font);
+void pdf_debugfont(pdf_fontdesc *fontdesc);