Home | History | Annotate | Download | only in letest
      1 /*
      2  *******************************************************************************
      3  *
      4  *   Copyright (C) 1999-2007, International Business Machines
      5  *   Corporation and others.  All Rights Reserved.
      6  *
      7  *******************************************************************************
      8  *   file name:  SimpleFontInstance.cpp
      9  *
     10  *   created on: 03/30/2006
     11  *   created by: Eric R. Mader
     12  */
     13 
     14 #include "unicode/utypes.h"
     15 #include "unicode/uchar.h"
     16 
     17 #include "layout/LETypes.h"
     18 #include "layout/LEFontInstance.h"
     19 
     20 #include "CanonShaping.h"
     21 #include "SimpleFontInstance.h"
     22 
     23 SimpleFontInstance::SimpleFontInstance(float pointSize, LEErrorCode &status)
     24     : fPointSize(pointSize), fAscent(0), fDescent(0)
     25 {
     26     if (LE_FAILURE(status)) {
     27         return;
     28     }
     29 
     30     fAscent  = (le_int32) yUnitsToPoints(2000.0);
     31     fDescent = (le_int32) yUnitsToPoints(600.0);
     32 
     33     return;
     34 }
     35 
     36 SimpleFontInstance::~SimpleFontInstance()
     37 {
     38     // nothing to do...
     39 }
     40 
     41 const void *SimpleFontInstance::getFontTable(LETag tableTag) const
     42 {
     43     if (tableTag == LE_GSUB_TABLE_TAG) {
     44         return CanonShaping::glyphSubstitutionTable;
     45     }
     46 
     47     if (tableTag == LE_GDEF_TABLE_TAG) {
     48         return CanonShaping::glyphDefinitionTable;
     49     }
     50 
     51     return NULL;
     52 }
     53 
     54 void SimpleFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
     55 {
     56 #if 0
     57     if (u_getCombiningClass((UChar32) glyph) == 0) {
     58         advance.fX = xUnitsToPoints(2048);
     59     } else {
     60         advance.fX = 0;
     61     }
     62 #else
     63     advance.fX = xUnitsToPoints(2048);
     64 #endif
     65 
     66     advance.fY = 0;
     67 }
     68 
     69 le_int32 SimpleFontInstance::getUnitsPerEM() const
     70 {
     71     return 2048;
     72 }
     73 
     74 le_int32 SimpleFontInstance::getAscent() const
     75 {
     76     return fAscent;
     77 }
     78 
     79 le_int32 SimpleFontInstance::getDescent() const
     80 {
     81     return fDescent;
     82 }
     83 
     84 le_int32 SimpleFontInstance::getLeading() const
     85 {
     86     return 0;
     87 }
     88 
     89 // We really want to inherit this method from the superclass, but some compilers
     90 // issue a warning if we don't implement it...
     91 LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper, le_bool filterZeroWidth) const
     92 {
     93     return LEFontInstance::mapCharToGlyph(ch, mapper, filterZeroWidth);
     94 }
     95 
     96 // We really want to inherit this method from the superclass, but some compilers
     97 // issue a warning if we don't implement it...
     98 LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
     99 {
    100     return LEFontInstance::mapCharToGlyph(ch, mapper);
    101 }
    102 
    103 LEGlyphID SimpleFontInstance::mapCharToGlyph(LEUnicode32 ch) const
    104 {
    105     return (LEGlyphID) ch;
    106 }
    107 
    108 float SimpleFontInstance::getXPixelsPerEm() const
    109 {
    110     return fPointSize;
    111 }
    112 
    113 float SimpleFontInstance::getYPixelsPerEm() const
    114 {
    115     return fPointSize;
    116 }
    117 
    118 float SimpleFontInstance::getScaleFactorX() const
    119 {
    120     return 1.0;
    121 }
    122 
    123 float SimpleFontInstance::getScaleFactorY() const
    124 {
    125     return 1.0;
    126 }
    127 
    128 le_bool SimpleFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const
    129 {
    130     return FALSE;
    131 }
    132 
    133