Back to index

lightning-sunbird  0.9+nobinonly
nsType1.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Golden Hills Computer Services code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Brian Stell <bstell@ix.netcom.com>.
00019  * Portions created by the Initial Developer are Copyright (C) 2002
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Brian Stell <bstell@ix.netcom.com>.
00024  *   Jungshik Shin <jshin@i18nl10n.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 //
00041 // For genernal information on Postscript see:
00042 //   Adobe Solutions Network: Technical Notes - Fonts
00043 //   http://partners.adobe.com/asn/developer/technotes/fonts.html
00044 //
00045 // For information on Postscript Type 1 fonts see:
00046 //
00047 //   Adobe Type 1 Font Format
00048 //   http://partners.adobe.com/asn/developer/pdfs/tn/T1_SPEC.PDF
00049 //
00050 
00051 #ifndef TYPE1_H
00052 #define TYPE1_H
00053 
00054 #include <stdio.h>
00055 #include "nspr.h"
00056 #ifdef MOZ_ENABLE_XFT
00057 #include "nsISupports.h"
00058 #include <ft2build.h>
00059 #include FT_FREETYPE_H
00060 #include FT_GLYPH_H
00061 #include FT_OUTLINE_H
00062 #else
00063 #include "nsIFreeType2.h"
00064 #endif
00065 
00066 /* to/from Character Space */
00067 inline int
00068 toCS(double upm, double x)
00069 {
00070   return (int)((x*1000.0)/upm);
00071 }
00072 
00073 inline int
00074 fromCS(double upm, double x)
00075 {
00076   return (int) (x*upm/1000.0);
00077 }
00078 
00079 /* the 1 byte Postscript Type 1 commands */
00080 #define T1_HSTEM      1  /* 0x01 */
00081 #define T1_VSTEM      3  /* 0x03 */
00082 #define T1_VMOVETO    4  /* 0x04 */
00083 #define T1_RLINETO    5  /* 0x05 */
00084 #define T1_HLINETO    6  /* 0x06 */
00085 #define T1_VLINETO    7  /* 0x07 */
00086 #define T1_RRCURVETO  8  /* 0x08 */
00087 #define T1_CLOSEPATH  9  /* 0x09 */
00088 #define T1_CALLSUBR  10  /* 0x0a */
00089 #define T1_RETURN    11  /* 0x0b */
00090 #define T1_ESC_CMD   12  /* 0x0c */
00091 #define T1_HSBW      13  /* 0x0d */
00092 #define T1_ENDCHAR   14  /* 0x0e */
00093 #define T1_RMOVETO   21  /* 0x15 */
00094 #define T1_HMOVETO   22  /* 0x16 */
00095 #define T1_VHCURVETO 30  /* 0x1e */
00096 #define T1_HVCURVETO 31  /* 0x1f */
00097 
00098 /* the 2 byte (escaped) Postscript Type 1 commands */
00099 #define T1_ESC_SBW    7  /* 0x07 */
00100 
00101 #define TYPE1_ENCRYPTION_KEY 4330
00102 #define TYPE1_ENCRYPTION_C1  52845
00103 #define TYPE1_ENCRYPTION_C2  22719
00104 
00105 #ifdef MOZ_ENABLE_XFT  
00106 FT_Error FT2GlyphToType1CharString(FT_Face aFace,
00107 #else /* MOZ_ENABLE_FREETYPE2 */
00108 FT_Error FT2GlyphToType1CharString(nsIFreeType2 *aFt2, FT_Face aFace,
00109 #endif
00110                                    PRUint32 aGlyphID, int aWmode, int aLenIV,
00111                                    unsigned char *aBuf);
00112 #ifdef MOZ_ENABLE_XFT
00113 // macros to handle FreeType2 26.6 numbers (26 bit number with 6 bit fraction)
00114 #define FT_REG_TO_16_16(x) ((x)<<16)
00115 #ifndef FT_MulFix
00116 #define FT_MulFix(v, s) (((v)*(s))>>16)
00117 #endif
00118 #define FT_ROUND(x) (((x) + 32) & ~63) // 63 = 2^6 - 1
00119 #define FT_TRUNC(x) ((x) >> 6)
00120 #define FT_DESIGN_UNITS_TO_PIXELS(v, s) FT_TRUNC(FT_ROUND(FT_MulFix((v) , (s))))
00121 #endif /* MOZ_ENABLE_XFT */
00122 
00123 class nsString;
00124 class nsCString;
00125 
00126 PRBool FT2SubsetToType1FontSet(FT_Face aFace, const nsString& aSubset,
00127                                int aWmode,  FILE *aFile);
00128 nsresult FT2ToType1FontName(FT_Face aFace, int aWmode,
00129                             nsCString& aFontName);
00130   
00131 
00132 #endif /* TYPE1_H */