Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsType1.cpp File Reference
#include "nsType1.h"
#include "gfx-config.h"
#include <string.h>
#include <unistd.h>
#include "nsPrintfCString.h"
#include "nsAutoBuffer.h"

Go to the source code of this file.

Classes

struct  FT2PT1_info

Defines

#define HEXASCII_LINE_LEN   64
#define nsFT_CONST

Functions

static int cubicto (nsFT_CONST FT_Vector *aControlPt1, nsFT_CONST FT_Vector *aControlPt2, nsFT_CONST FT_Vector *aEndPt, void *aClosure)
static int Type1CharStringCommand (unsigned char **aBufPtrPtr, int aCmd)
static int Type1EncodeCharStringInt (unsigned char **aBufPtrPtr, int aValue)
static void encryptAndHexOut (FILE *aFile, PRUint32 *aPos, PRUint16 *aKey, const char *aBuf, PRInt32 aLen=-1)
static void charStringOut (FILE *aFile, PRUint32 *aPos, PRUint16 *aKey, const char *aStr, PRUint32 aLen, PRUnichar aId)
static void flattenName (nsCString &aString)
static int csc (unsigned char **aBufPtrPtr, int aCmd)
static int ecsi (unsigned char **aBufPtrPtr, int aValue)
unsigned char Type1Encrypt (unsigned char aPlain, PRUint16 *aKeyPtr)
static void Type1EncryptString (unsigned char *aInBuf, unsigned char *aOutBuf, int aLen)
static PRBool sideWidthAndBearing (const FT_Vector *aEndPt, FT2PT1_info *aFti)
static int moveto (nsFT_CONST FT_Vector *aEndPt, void *aClosure)
static int lineto (nsFT_CONST FT_Vector *aEndPt, void *aClosure)
static int conicto (nsFT_CONST FT_Vector *aControlPt, nsFT_CONST FT_Vector *aEndPt, void *aClosure)
FT_Error FT2GlyphToType1CharString (nsIFreeType2 *aFt2, FT_Face aFace, PRUint32 aGlyphID, int aWmode, int aLenIV, unsigned char *aBuf)
static PRBool outputType1SubFont (nsIFreeType2 *aFt2, FT_Face aFace, const nsAString &aCharIDs, const char *aFontName, int aWmode, int aLenIV, FILE *aFile)
nsresult FT2ToType1FontName (FT_Face aFace, int aWmode, nsCString &aFontName)
PRBool FT2SubsetToType1FontSet (FT_Face aFace, const nsString &aSubset, int aWmode, FILE *aFile)

Variables

static const PRUint16 kType1EncryptionC1 = 52845
static const PRUint16 kType1EncryptionC2 = 22719
static const PRUint16 kType1CharstringEncryptionKey = 4330
static const PRUint16 kType1EexecEncryptionKey = 55665
static FT_Outline_Funcs ft_outline_funcs

Class Documentation

struct FT2PT1_info

Definition at line 86 of file nsType1.cpp.

Collaboration diagram for FT2PT1_info:
Class Members
unsigned char * buf
double cur_x
double cur_y
int elm_cnt
FT_Face face
int len
int wmode

Define Documentation

Definition at line 79 of file nsType1.cpp.

Definition at line 103 of file nsType1.cpp.


Function Documentation

void charStringOut ( FILE aFile,
PRUint32 aPos,
PRUint16 aKey,
const char *  aStr,
PRUint32  aLen,
PRUnichar  aId 
) [static]

Definition at line 755 of file nsType1.cpp.

{
    // use a local buffer instead of nsPrintfCString to avoid alloc.
    char buf[30];
    int oLen;
    if (aId == 0)
      oLen = PR_snprintf(buf, 30, "/.notdef %d RD ", aLen); 
    else 
      oLen = PR_snprintf(buf, 30, "/uni%04X %d RD ", aId, aLen); 

    if (oLen >= 30) {
      NS_WARNING("buffer size exceeded. charstring will be truncated");
      encryptAndHexOut(aFile, aPos, aKey, buf, 30); 
    }
    else 
      encryptAndHexOut(aFile, aPos, aKey, buf); 

    encryptAndHexOut(aFile, aPos, aKey, aStr, aLen);

    encryptAndHexOut(aFile, aPos, aKey, "ND\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int conicto ( nsFT_CONST FT_Vector aControlPt,
nsFT_CONST FT_Vector aEndPt,
void aClosure 
) [static]

Definition at line 319 of file nsType1.cpp.

{
  FT2PT1_info *ftinfo = (FT2PT1_info *)aClosure;
  FT_UShort upm = ftinfo->face->units_per_EM;
  double ctl_x, ctl_y;
  double cur_x, cur_y, x3, y3;
  FT_Vector aControlPt1, aControlPt2;
  int rslt;

  cur_x = ftinfo->cur_x;
  cur_y = ftinfo->cur_y;
  ctl_x = toCS(upm, aControlPt->x);
  ctl_y = toCS(upm, aControlPt->y);
  x3 = toCS(upm, aEndPt->x);
  y3 = toCS(upm, aEndPt->y);

  // So we can use the cubic curve code convert quadradic to cubic; 

  // the 1st control point is 2/3 the way from the start to the control point
  aControlPt1.x = fromCS(upm, (cur_x + (2 * (ctl_x - cur_x) + 1)/3));
  aControlPt1.y = fromCS(upm, (cur_y + (2 * (ctl_y - cur_y) + 1)/3));

  // the 2nd control point is 1/3 the way from the control point to the end
  aControlPt2.x = fromCS(upm, (ctl_x + (x3 - ctl_x + 1)/3));
  aControlPt2.y = fromCS(upm, (ctl_y + (y3 - ctl_y + 1)/3));

  // call the cubic code
  rslt = cubicto(&aControlPt1, &aControlPt2, aEndPt, aClosure);
  return rslt;
}

Here is the call graph for this function:

static int csc ( unsigned char **  aBufPtrPtr,
int  aCmd 
) [inline, static]

Definition at line 121 of file nsType1.cpp.

{
  return Type1CharStringCommand(aBufPtrPtr, aCmd);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int cubicto ( nsFT_CONST FT_Vector aControlPt1,
nsFT_CONST FT_Vector aControlPt2,
nsFT_CONST FT_Vector aEndPt,
void aClosure 
) [static]

Definition at line 352 of file nsType1.cpp.

{
  FT2PT1_info *ftinfo = (FT2PT1_info *)aClosure;
  FT_UShort upm = ftinfo->face->units_per_EM;
  double cur_x, cur_y, x1, y1, x2, y2, x3, y3;

  cur_x = ftinfo->cur_x;
  cur_y = ftinfo->cur_y;

  x1 = toCS(upm, aControlPt1->x);
  y1 = toCS(upm, aControlPt1->y);

  x2 = toCS(upm, aControlPt2->x);
  y2 = toCS(upm, aControlPt2->y);

  x3 = toCS(upm, aEndPt->x);
  y3 = toCS(upm, aEndPt->y);

  /* horizontal to vertical curve */
  if (((int)(y1) == (int)(cur_y)) && ((int)(x3) == (int)(x2))) {
    ftinfo->len += ecsi(&ftinfo->buf, (int)(x1-cur_x));
    ftinfo->len += ecsi(&ftinfo->buf, (int)(x2-x1));
    ftinfo->len += ecsi(&ftinfo->buf, (int)(y2-y1));
    ftinfo->len += ecsi(&ftinfo->buf, (int)(y3-y2));
    ftinfo->len += csc(&ftinfo->buf, T1_HVCURVETO);
  }
  /* vertical to horizontal curve */
  else if (((int)(x1) == (int)(cur_x)) && ((int)(y3) == (int)(y2))) {
    ftinfo->len += ecsi(&ftinfo->buf, (int)(y1-cur_y));
    ftinfo->len += ecsi(&ftinfo->buf, (int)(x2-x1));
    ftinfo->len += ecsi(&ftinfo->buf, (int)(y2-y1));
    ftinfo->len += ecsi(&ftinfo->buf, (int)(x3-x2));
    ftinfo->len += csc(&ftinfo->buf, T1_VHCURVETO);
  }
  else {
    ftinfo->len += ecsi(&ftinfo->buf,  (int)(x1-cur_x));
    ftinfo->len += ecsi(&ftinfo->buf,  (int)(y1-cur_y));
    ftinfo->len += ecsi(&ftinfo->buf,  (int)(x2-x1));
    ftinfo->len += ecsi(&ftinfo->buf,  (int)(y2-y1));
    ftinfo->len += ecsi(&ftinfo->buf,  (int)(x3-x2));
    ftinfo->len += ecsi(&ftinfo->buf,  (int)(y3-y2));
    ftinfo->len += csc(&ftinfo->buf, T1_RRCURVETO);
  }
  ftinfo->cur_x = x3;
  ftinfo->cur_y = y3;
  ftinfo->elm_cnt++;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int ecsi ( unsigned char **  aBufPtrPtr,
int  aValue 
) [inline, static]

Definition at line 128 of file nsType1.cpp.

{
  return Type1EncodeCharStringInt(aBufPtrPtr, aValue);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void encryptAndHexOut ( FILE aFile,
PRUint32 aPos,
PRUint16 aKey,
const char *  aBuf,
PRInt32  aLen = -1 
) [static]

Definition at line 736 of file nsType1.cpp.

{
  if (aLen == -1) 
      aLen = strlen(aBuf); 

  PRInt32 i;
  for (i = 0; i < aLen; i++) {
    PRUint8 cipher = Type1Encrypt((unsigned char) aBuf[i], aKey);  
    fprintf(aFile, "%02X", cipher); 
    *aPos += 2;
    if (*aPos >= HEXASCII_LINE_LEN) {
      fprintf(aFile, "\n");
      *aPos = 0;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void flattenName ( nsCString aString) [static]

Definition at line 719 of file nsType1.cpp.

{
  nsCString::iterator start, end;
  aString.BeginWriting(start);
  aString.EndWriting(end);
  while(start != end) {
    if (*start == ' ')
      *start= '_';
    else if (*start == '(')
      *start = '_';
    else if (*start == ')')
      *start = '_';
    ++start;
  }
}

Here is the caller graph for this function:

FT_Error FT2GlyphToType1CharString ( nsIFreeType2 aFt2,
FT_Face  aFace,
PRUint32  aGlyphID,
int  aWmode,
int  aLenIV,
unsigned char *  aBuf 
)

Definition at line 416 of file nsType1.cpp.

{
  int j;
  FT_Int32 flags = FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
  FT_GlyphSlot slot;
  unsigned char *start = aBuf;
  FT2PT1_info fti;

#ifdef MOZ_ENABLE_XFT
  FT_Error error = FT_Load_Glyph(aFace, aGlyphID, flags);
  if (error) {
    NS_ERROR("failed to load aGlyphID");
    return error;
  }
#else
  nsresult rv = aFt2->LoadGlyph(aFace, aGlyphID, flags);
  if (NS_FAILED(rv)) {
    NS_ERROR("failed to load aGlyphID");
    return 1;
  }
#endif
  slot = aFace->glyph;

  if (slot->format != ft_glyph_format_outline) {
    NS_ERROR("aGlyphID is not an outline glyph");
    return 1;
  }

#ifdef MOZ_ENABLE_FREETYPE2
  fti.ft2     = aFt2;
#endif
  fti.face    = aFace;
  fti.buf     = aBuf;
  fti.elm_cnt = 0;
  fti.len     = 0;
  fti.wmode   = aWmode;

  /* add space for "random" bytes */
  for (j=0; j< aLenIV; j++) {
    fti.len += ecsi(&fti.buf, 0);
  }
#ifdef MOZ_ENABLE_XFT
  if (FT_Outline_Decompose(&slot->outline, &ft_outline_funcs, &fti))  {
    NS_ERROR("error decomposing aGlyphID");
    return 1;
  }
#else
  rv = aFt2->OutlineDecompose(&slot->outline, &ft_outline_funcs, &fti);
  if (NS_FAILED(rv)) {
    NS_ERROR("error decomposing aGlyphID");
    return 1;
  }
#endif

  if (fti.elm_cnt) {
    fti.len += csc(&fti.buf, T1_CLOSEPATH);
    fti.len += csc(&fti.buf, T1_ENDCHAR);
  }
  else {
    FT_Vector end_pt;
    end_pt.x = 0;
    end_pt.y = 1; /* dummy value to cause sbw instead of hsbw */
    PRBool rslt = sideWidthAndBearing(&end_pt, &fti);
    if (rslt != PR_TRUE) {
      return 1;
    }
    fti.len += csc(&fti.buf, T1_ENDCHAR);
  }
  if (fti.buf) {
    Type1EncryptString(start, start, fti.len);
  }

  return fti.len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool FT2SubsetToType1FontSet ( FT_Face  aFace,
const nsString aSubset,
int  aWmode,
FILE aFile 
)

Definition at line 515 of file nsType1.cpp.

{
#ifdef MOZ_ENABLE_FREETYPE2
  nsresult rv; 
  nsCOMPtr<nsIFreeType2> ft2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv);
  if (NS_FAILED(rv)) {
    NS_ERROR("Failed to get nsIFreeType2 service");
    return PR_FALSE;
  }
#endif

  nsCAutoString fontNameBase;
  FT2ToType1FontName(aFace, aWmode, fontNameBase);
  PRUint32 i = 0;
  for (; i <= aSubset.Length() / 255 ; i++) {
    nsCAutoString fontName(fontNameBase);
    fontName.AppendLiteral(".Set");
    fontName.AppendInt(i);
#ifdef MOZ_ENABLE_XFT
    outputType1SubFont(aFace,
#else
    outputType1SubFont(ft2, aFace, 
#endif
      Substring(aSubset, i * 255, PR_MIN(255, aSubset.Length() - i * 255)),
      fontName.get(), aWmode, 4, aFile);
  }
  return PR_TRUE;
}

Here is the call graph for this function:

nsresult FT2ToType1FontName ( FT_Face  aFace,
int  aWmode,
nsCString aFontName 
)

Definition at line 503 of file nsType1.cpp.

{
  aFontName = aFace->family_name;
  aFontName.AppendLiteral(".");
  aFontName += aFace->style_name;
  aFontName += nsPrintfCString(".%ld.%d", aFace->face_index, aWmode ? 1 : 0);
  flattenName(aFontName);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int lineto ( nsFT_CONST FT_Vector aEndPt,
void aClosure 
) [static]

Definition at line 293 of file nsType1.cpp.

{
  FT2PT1_info *fti = (FT2PT1_info *)aClosure;
  FT_UShort upm = fti->face->units_per_EM;

  if (toCS(upm, aEndPt->x) == fti->cur_x) {
    fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->y) - (int)fti->cur_y);
    fti->len += csc(&fti->buf, T1_VLINETO);
  }
  else if (toCS(upm, aEndPt->y) == fti->cur_y) {
    fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->x) - (int)fti->cur_x);
    fti->len += csc(&fti->buf, T1_HLINETO);
  }
  else {
    fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->x) - (int)fti->cur_x);
    fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->y) - (int)fti->cur_y);
    fti->len += csc(&fti->buf, T1_RLINETO);
  }

  fti->cur_x = toCS(upm, aEndPt->x);
  fti->cur_y = toCS(upm, aEndPt->y);
  fti->elm_cnt++;
  return 0;
}

Here is the call graph for this function:

static int moveto ( nsFT_CONST FT_Vector aEndPt,
void aClosure 
) [static]

Definition at line 256 of file nsType1.cpp.

{
  FT2PT1_info *fti = (FT2PT1_info *)aClosure;
  FT_UShort upm = fti->face->units_per_EM;
  PRBool rslt;

  if (fti->elm_cnt == 0) {
    rslt = sideWidthAndBearing(aEndPt, fti);
    if (rslt != PR_TRUE) {
      return 1;
    }
  }
  else {
    fti->len += csc(&fti->buf, T1_CLOSEPATH);
  }

  if (toCS(upm, aEndPt->x) == fti->cur_x) {
    fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->y) - (int)fti->cur_y);
    fti->len += csc(&fti->buf, T1_VMOVETO);
  }
  else if (toCS(upm, aEndPt->y) == fti->cur_y) {
    fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->x) - (int)fti->cur_x);
    fti->len += csc(&fti->buf, T1_HMOVETO);
  }
  else {
    fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->x) - (int)fti->cur_x);
    fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->y) - (int)fti->cur_y);
    fti->len += csc(&fti->buf, T1_RMOVETO);
  }

  fti->cur_x = toCS(upm, aEndPt->x);
  fti->cur_y = toCS(upm, aEndPt->y);
  fti->elm_cnt++;
  return 0;
}

Here is the call graph for this function:

static PRBool outputType1SubFont ( nsIFreeType2 aFt2,
FT_Face  aFace,
const nsAString &  aCharIDs,
const char *  aFontName,
int  aWmode,
int  aLenIV,
FILE aFile 
) [static]

Definition at line 550 of file nsType1.cpp.

{
  FT_UShort upm = aFace->units_per_EM;

  fprintf(aFile, "%%%%BeginResource: font %s\n"
                 "%%!PS-AdobeFont-1.0-3.0 %s 1.0\n"
                 "%%%%Creator: Mozilla Freetype2 Printing code 2.0\n"
                 "%%%%Title: %s\n"
                 "%%%%Pages: 0\n"
                 "%%%%EndComments\n"
                 "8 dict begin\n", aFontName, aFontName, aFontName);

  fprintf(aFile, "/FontName /%s def\n"
                 "/FontType 1 def\n"
                 "/FontMatrix [ 0.001 0 0 0.001 0 0 ]readonly def\n"
                 "/PaintType 0 def\n", aFontName);

  fprintf(aFile, "/FontBBox [%d %d %d %d]readonly def\n", 
                 toCS(upm, aFace->bbox.xMin),
                 toCS(upm, aFace->bbox.yMin),
                 toCS(upm, aFace->bbox.xMax),
                 toCS(upm, aFace->bbox.yMax));

  nsString charIDstr(aCharIDs);
  PRUint32 len = aCharIDs.Length();
  
  if (len < 10) { 
    // Add a small set of characters to the subset of the user
    // defined font to produce to make sure the font ends up
    // being larger than 2000 bytes, a threshold under which
    // some printers will consider the font invalid.  (bug 253219)
    // XXX : need to check if this is true of type 1 fonts as well.
    // I suspect it's only the case of CID-keyed fonts (type 9) we used to
    // generate. 
    charIDstr.AppendLiteral("1234567890"); 
    len += 10;
  }
  
  const PRUnichar *charIDs = charIDstr.get();

  PRUint32 i;

  // construct an Encoding vector : the 0th element
  // is /.notdef
  fputs("/Encoding [\n/.notdef\n", aFile); 
  for (i = 0; i < len; ++i) {
      fprintf(aFile, "/uni%04X", charIDs[i]); 
      if (i % 8 == 7) fputc('\n', aFile);
  }

  for (i = len; i < 255; ++i) {
      fputs("/.notdef", aFile);
      if (i % 8 == 7) fputc('\n', aFile);
  }
  fputs("] def\n", aFile); 

  fprintf(aFile, "currentdict end\n"
                 "currentfile eexec\n");

  PRUint32 pos = 0;
  PRUint16 key = kType1EexecEncryptionKey;

  // add 'random' bytes (a sequence of zeros would suffice)
  for (i = 0; i < PRUint32(aLenIV); ++i)
    encryptAndHexOut(aFile, &pos, &key, "\0", 1);

  // We don't need any fancy stuff (hint, subroutines, etc) in 
  // 'Private' dictionary. (ref. Adobe Type 1 Spec. Chapters 2 and 5)
  encryptAndHexOut(aFile, &pos, &key,
                   "dup /Private 6 dict dup begin\n"
                   "/RD {string currentfile exch readstring pop} executeonly def\n"
                   "/ND {noaccess def} executeonly def\n"
                   "/NP {noaccess put} executeonly def\n"
                   "/BlueValues [] def\n"
                   "/MinFeature {16 16} def\n"
                   "/password 5839 def\n"); 

  // get the maximum charstring length without actually filling up the buffer
  PRInt32 charStringLen;
  PRInt32 maxCharStringLen =
#ifdef MOZ_ENABLE_XFT
    FT2GlyphToType1CharString(aFace, 0, aWmode, aLenIV, nsnull);
#else
    FT2GlyphToType1CharString(aFt2, aFace, 0, aWmode, aLenIV, nsnull);
#endif

  PRUint32 glyphID;

  for (i = 0; i < len; i++) {
#ifdef MOZ_ENABLE_XFT
    glyphID = FT_Get_Char_Index(aFace, charIDs[i]);
    charStringLen =
      FT2GlyphToType1CharString(aFace, glyphID, aWmode, aLenIV, nsnull);
#else
    aFt2->GetCharIndex(aFace, charIDs[i], &glyphID);
    charStringLen =
      FT2GlyphToType1CharString(aFt2, aFace, glyphID, aWmode, aLenIV, nsnull);
#endif

    if (charStringLen > maxCharStringLen)
      maxCharStringLen = charStringLen;
  }

  nsAutoBuffer<PRUint8, 1024> charString;

  if (!charString.EnsureElemCapacity(maxCharStringLen)) {
    NS_ERROR("Failed to alloc bytes for charstring");
    return PR_FALSE;
  }

  // output CharString 
  encryptAndHexOut(aFile, &pos, &key,
                   nsPrintfCString(60, "2 index /CharStrings %d dict dup begin\n",
                                   len + 1).get()); 

  // output the notdef glyph
#ifdef MOZ_ENABLE_XFT
  charStringLen = FT2GlyphToType1CharString(aFace, 0, aWmode, aLenIV,
                                            charString.get());
#else
  charStringLen = FT2GlyphToType1CharString(aFt2, aFace, 0, aWmode, aLenIV,
                                            charString.get());
#endif

  // enclose charString with  "/.notdef RD .....  ND" 
  charStringOut(aFile, &pos, &key, NS_REINTERPRET_CAST(const char*, charString.get()),
                charStringLen, 0); 


  // output the charstrings for each glyph in this sub font
  for (i = 0; i < len; i++) {
#ifdef MOZ_ENABLE_XFT
    glyphID = FT_Get_Char_Index(aFace, charIDs[i]);
    charStringLen = FT2GlyphToType1CharString(aFace, glyphID, aWmode,
                                              aLenIV, charString.get());
#else
    aFt2->GetCharIndex(aFace, charIDs[i], &glyphID);
    charStringLen = FT2GlyphToType1CharString(aFt2, aFace, glyphID, aWmode,
                                              aLenIV, charString.get());
#endif
    charStringOut(aFile, &pos, &key, NS_REINTERPRET_CAST(const char*, charString.get()),
                  charStringLen, charIDs[i]);
  }

  // wrap up the encrypted part of the font definition
  encryptAndHexOut(aFile, &pos, &key,
                   "end\nend\n"
                   "readonly put\n"
                   "noaccess put\n"
                   "dup /FontName get exch definefont pop\n"
                   "mark currentfile closefile\n");
  if (pos) 
    fputc('\n', aFile);

  // output mandatory 512 0's
  const static char sixtyFourZeros[] =  
      "0000000000000000000000000000000000000000000000000000000000000000\n";
  for (i = 0; i < 8; i++) 
    fprintf(aFile, sixtyFourZeros);

  fprintf(aFile, "cleartomark\n%%%%EndResource\n"); 

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool sideWidthAndBearing ( const FT_Vector aEndPt,
FT2PT1_info aFti 
) [static]

Definition at line 206 of file nsType1.cpp.

{
  int aw = 0;
  int ah = 0;
  FT_UShort upm = aFti->face->units_per_EM;
  FT_GlyphSlot slot;
  FT_Glyph glyph;
  FT_BBox bbox;

  slot = aFti->face->glyph;

#ifdef MOZ_ENABLE_XFT
  FT_Error error = FT_Get_Glyph(slot, &glyph);
  if (error) {
    NS_ERROR("sideWidthAndBearing failed to get glyph");
    return PR_FALSE;
  }
  FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_unscaled, &bbox);
#else
  nsresult rv = aFti->ft2->GetGlyph(slot, &glyph);
  if (NS_FAILED(rv)) {
    NS_ERROR("sideWidthAndBearing failed to get glyph");
    return PR_FALSE;
  }
  aFti->ft2->GlyphGetCBox(glyph, ft_glyph_bbox_unscaled, &bbox);
#endif

  if (aFti->wmode == 0)
    aw = toCS(upm, slot->metrics.horiAdvance);
  else
    aw = -toCS(upm, slot->metrics.vertAdvance);

  if (aEndPt->y == 0) {
    aFti->len += ecsi(&aFti->buf, (int)(aFti->cur_x = toCS(upm, bbox.xMin)));
    aFti->cur_y = 0;
    aFti->len += ecsi(&aFti->buf, aw);
    aFti->len += csc(&aFti->buf, T1_HSBW);
  }
  else {
    aFti->len += ecsi(&aFti->buf, (int)(aFti->cur_x = toCS(upm, bbox.xMin)));
    aFti->len += ecsi(&aFti->buf, (int)(aFti->cur_y = toCS(upm, bbox.yMin)));
    aFti->len += ecsi(&aFti->buf, aw);
    aFti->len += ecsi(&aFti->buf, ah);
    aFti->len += csc(&aFti->buf, T1_ESC_CMD);
    aFti->len += csc(&aFti->buf, T1_ESC_SBW);
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int Type1CharStringCommand ( unsigned char **  aBufPtrPtr,
int  aCmd 
) [static]

Definition at line 134 of file nsType1.cpp.

{
  unsigned char *p = *aBufPtrPtr;
  if (p) {
    *p = aCmd;
    *aBufPtrPtr = p + 1;
  }
  return 1;
}

Here is the caller graph for this function:

static int Type1EncodeCharStringInt ( unsigned char **  aBufPtrPtr,
int  aValue 
) [static]

Definition at line 145 of file nsType1.cpp.

{
  unsigned char *p = *aBufPtrPtr;

  if ((aValue >= -107) && (aValue <= 107)) { 
    if (p) {
      p[0] = aValue + 139;
      *aBufPtrPtr = p + 1;
    }
    return 1;
  }
  else if ((aValue >= 108) && (aValue <= 1131)) {
    if (p) {
      p[0] = ((aValue - 108)>>8) + 247; 
      p[1] = (aValue - 108) & 0xFF;
      *aBufPtrPtr = p + 2;
    }
    return 2;
  }
  else if ((aValue <= -108) && (aValue >= -1131)) {
    if (p) {
      p[0] = ((-aValue - 108)>>8) + 251;
      p[1] = (-aValue - 108) & 0xFF;
      *aBufPtrPtr = p + 2;
    }
    return 2;
  }
  else {
    unsigned int tmp = (unsigned int)aValue;
    if (p) {
      p[0] = 255;
      p[1] = (tmp>>24) & 0xFF;
      p[2] = (tmp>>16) & 0xFF;
      p[3] = (tmp>>8) & 0xFF;
      p[4] = tmp & 0xFF;
      *aBufPtrPtr = p + 5;
    }
    return 5;
  }
}

Here is the caller graph for this function:

unsigned char Type1Encrypt ( unsigned char  aPlain,
PRUint16 aKeyPtr 
) [inline]

Definition at line 187 of file nsType1.cpp.

{
  unsigned char cipher;
  cipher = (aPlain ^ (*aKeyPtr >> 8));
  *aKeyPtr = (cipher + *aKeyPtr) * kType1EncryptionC1 + kType1EncryptionC2;
  return cipher;
}

Here is the caller graph for this function:

static void Type1EncryptString ( unsigned char *  aInBuf,
unsigned char *  aOutBuf,
int  aLen 
) [static]

Definition at line 196 of file nsType1.cpp.

{
  int i;
  PRUint16 key = kType1CharstringEncryptionKey;

  for (i=0; i<aLen; i++)
    aOutBuf[i] = Type1Encrypt(aInBuf[i], &key);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

FT_Outline_Funcs ft_outline_funcs [static]
Initial value:
 {
  moveto,
  lineto,
  conicto,
  cubicto,
  0,
  0
}

Definition at line 402 of file nsType1.cpp.

Definition at line 83 of file nsType1.cpp.

Definition at line 84 of file nsType1.cpp.

const PRUint16 kType1EncryptionC1 = 52845 [static]

Definition at line 81 of file nsType1.cpp.

const PRUint16 kType1EncryptionC2 = 22719 [static]

Definition at line 82 of file nsType1.cpp.