Changeset 405

Show
Ignore:
Timestamp:
07/21/08 14:30:18 (2 years ago)
Author:
mbensi
Message:

2008-07-21 Mario Bensi <mbensi@pleyo.com>

Reviewed by Olivier DOLE.
Fix Font documentation

  • WKAL/Skeletons/Fonts/Font.t:
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/BAL/ChangeLogOWB

    r403 r405  
     12008-07-21  Mario Bensi  <mbensi@pleyo.com> 
     2 
     3        Reviewed by Olivier DOLE. 
     4        Fix Font documentation 
     5 
     6        * WKAL/Skeletons/Fonts/Font.t: 
     7 
    182008-07-21  Olivier DOLE  <odole@pleyo.com> 
    29 
  • trunk/BAL/WKAL/Skeletons/Fonts/Font.t

    r404 r405  
    3838#include "BALBase.h" 
    3939 
     40#include "TextRun.h" 
    4041#include "FontDescription.h" 
    4142#include <wtf/HashMap.h> 
     
    5455class GraphicsContext; 
    5556class IntPoint; 
    56 class RenderObject; 
    5757class SimpleFontData; 
    5858class SVGFontElement; 
    59 class SVGPaintServer; 
    6059 
    6160struct GlyphData; 
    6261 
    63 class TextRun : public WKALBase { 
    64 publi 
    65  
    66  
    67     /** 
    68      *  Font description 
    69      * @param[in] : description 
    70      * @param[out] : description 
    71      * @code 
    72      * @endcode 
     62class Font : public WKALBase { 
     63public: 
     64    /** 
     65     *  Font default constructor 
    7366     */ 
    7467    Font(); 
    7568 
    76  
    77     /** 
    78      *  Font description 
    79      * @param[in] : description 
    80      * @param[out] : description 
    81      * @code 
     69    /** 
     70     * Font constructor 
     71     * @param[in] : FontDescription 
     72     * @param[in] : letter spacing 
     73     * @param[in] : word spacing 
     74     * @code 
     75     * Font *f = new Font(fd, 12, 12 ); 
    8276     * @endcode 
    8377     */ 
    8478    Font(const FontDescription&, short letterSpacing, short wordSpacing); 
    8579 
    86  
    87     /** 
    88      *  Font description 
    89      * @param[in] : description 
    90      * @param[out] : description 
    91      * @code 
    92      * @endcode 
    93      */ 
    94     Font(const FontPlatformData&, bool isPrinting); 
    95  
    96  
    97     /** 
    98      *  ~Font description 
    99      * @param[in] : description 
    100      * @param[out] : description 
    101      * @code 
     80    /** 
     81     * This constructor is only used if the platform wants to start with a native font 
     82     */ 
     83    Font(const FontPlatformData&, bool isPrinting); // This constructor is only used if the platform wants to start with a native font. 
     84 
     85    /** 
     86     * Font destructor 
     87     * @code 
     88     * delete font; 
    10289     * @endcode 
    10390     */ 
    10491    ~Font(); 
    10592 
    106  
    107     /** 
    108      *  Font description 
    109      * @param[in] : description 
    110      * @param[out] : description 
    111      * @code 
    112      * @endcode 
     93    /** 
     94     * constructor by copy 
    11395     */ 
    11496    Font(const Font&); 
    11597 
    116  
    117     /** 
    118      * operator= description 
    119      * @param[in] : description 
    120      * @param[out] : description 
    121      * @code 
     98    /** 
     99    * operator= 
     100     * @param[in] : Font 
     101     * @param[out] : Font 
     102     * @code 
     103     * Font f = currentFont; 
    122104     * @endcode 
    123105     */ 
    124106    Font& operator=(const Font&); 
    125107 
    126  
    127     /** 
    128      *  operator== description 
    129      * @param[in] : description 
    130      * @param[out] : description 
    131      * @code 
    132      * @endcode 
     108    /** 
     109     * operator==  
    133110     */ 
    134111    bool operator==(const Font& other) const; 
    135112 
    136  
    137     /** 
    138      * operator!= description 
    139      * @param[in] : description 
    140      * @param[out] : description 
    141      * @code 
     113    /** 
     114    * operator!=  
     115     * @param[in] : Font 
     116     * @param[out] : return true if the fonts are different 
     117     * @code 
     118     * bool d = f != currentFont; 
    142119     * @endcode 
    143120     */ 
    144121    bool operator!=(const Font& other) const ; 
    145122 
    146  
    147     /** 
    148      *  fontDescription description 
    149      * @param[in] : description 
    150      * @param[out] : description 
    151      * @code 
    152      * @endcode 
     123    /** 
     124     * get fontDescription 
    153125     */ 
    154126    const FontDescription& fontDescription() const ; 
    155127 
    156  
    157     /** 
    158      *  pixelSize description 
    159      * @param[in] : description 
    160      * @param[out] : description 
    161      * @code 
     128    ** 
     129     * get font pixel size 
     130     * @param[out] : pixel size 
     131     * @code 
     132     * int ps = f->pixelSize(); 
    162133     * @endcode 
    163134     */ 
    164135    int pixelSize() const ; 
    165136 
    166  
    167     /** 
    168      *  size description 
    169      * @param[in] : description 
    170      * @param[out] : description 
    171      * @code 
    172      * @endcode 
     137    /** 
     138     * get font size 
    173139     */ 
    174140    float size() const ; 
    175141 
    176  
    177     /** 
    178      *  update description 
    179      * @param[in] : description 
    180      * @param[out] : description 
    181      * @code 
     142    /** 
     143     * update font 
     144     * @param[in] : FontSelector 
     145     * @code 
     146     * f->update(fontSelector); 
    182147     * @endcode 
    183148     */ 
    184149    void update(PassRefPtr<FontSelector>) const; 
    185150 
    186  
    187     /** 
    188      *  drawText description 
    189      * @param[in] : description 
    190      * @param[out] : description 
    191      * @code 
    192      * @endcode 
     151    /** 
     152     * drawText 
    193153     */ 
    194154    void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; 
    195155 
    196  
    197     /** 
    198      * width descriptio
    199      * @param[in] : description 
    200      * @param[out] : description 
    201      * @code 
     156    /** 
     157    * return font width 
     158     * @param[in] : TextRu
     159     * @param[out] : width 
     160     * @code 
     161     * int w = f->width(textRun); 
    202162     * @endcode 
    203163     */ 
    204164    int width(const TextRun&) const; 
    205165 
    206  
    207     /** 
    208      * floatWidth descriptio
    209      * @param[in] : description 
    210      * @param[out] : description 
    211      * @code 
     166    /** 
     167    * return float width 
     168     * @param[in] : TextRu
     169     * @param[out] : float width 
     170     * @code 
     171     * float w = f->floatWidth(textRun); 
    212172     * @endcode 
    213173     */ 
    214174    float floatWidth(const TextRun&) const; 
    215175 
    216  
    217     /** 
    218      *  floatWidth description 
    219      * @param[in] : description 
    220      * @param[out] : description 
    221      * @code 
     176    /** 
     177     * return float width 
     178     * @param[in] : TextRun 
     179     * @param[in] : extra chars available 
     180     * @param[in] : chars consumed 
     181     * @param[in] : glyph name 
     182     * @param[out] : float width 
     183     * @code 
     184     * float w = f->floatWidth(textRun, 0, chars, name); 
    222185     * @endcode 
    223186     */ 
    224187    float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    225188 
    226  
    227     /** 
    228      *  offsetForPosition description 
    229      * @param[in] : description 
    230      * @param[out] : description 
    231      * @code 
    232      * @endcode 
     189    /** 
     190     * get offset for a position 
    233191     */ 
    234192    int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; 
    235193 
    236  
    237     /** 
    238      *  selectionRectForText description 
    239      * @param[in] : description 
    240      * @param[out] : description 
    241      * @code 
     194    ** 
     195     * get selection for text 
     196     * @param[in] : TextRun 
     197     * @param[in] : start point 
     198     * @param[in] : height 
     199     * @param[in] : start glyph range 
     200     * @param[in] : end glyph range 
     201     * @param[out] : float rect 
     202     * @code 
     203     * FloatRect f = f->selectionRectForText(textRun, IntPoint(0,0), 18); 
    242204     * @endcode 
    243205     */ 
    244206    FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const; 
    245207 
    246  
    247     /** 
    248      *  isSmallCaps description 
    249      * @param[in] : description 
    250      * @param[out] : description 
    251      * @code 
    252      * @endcode 
     208    /** 
     209     * test if the font is smallCaps 
    253210     */ 
    254211    bool isSmallCaps() const ; 
    255212 
    256  
    257     /** 
    258      *  wordSpacing description 
    259      * @param[in] : description 
    260      * @param[out] : description 
    261      * @code 
     213    /** 
     214     * get word spacing value 
     215     * @param[out] : word spacing value 
     216     * @code 
     217     * short ws = f->wordSpacing(); 
    262218     * @endcode 
    263219     */ 
    264220    short wordSpacing() const ; 
    265221 
    266  
    267     /** 
    268      *  letterSpacing description 
    269      * @param[in] : description 
    270      * @param[out] : description 
    271      * @code 
     222    /** 
     223     * get letter spacing value 
     224     * @param[out] : letter spacing value 
     225     * @code 
     226     * short ls = f->letterSpacing(); 
    272227     * @endcode 
    273228     */ 
    274229    short letterSpacing() const ; 
    275230 
    276  
    277     /** 
    278      *  setWordSpacing description 
    279      * @param[in] : description 
    280      * @param[out] : description 
    281      * @code 
     231    /** 
     232     * set word spacing value 
     233     * @param[in] : word spacing value 
     234     * @code 
     235     * f->setWordSpacing(12); 
    282236     * @endcode 
    283237     */ 
    284238    void setWordSpacing(short s) ; 
    285239 
    286  
    287     /** 
    288      *  setLetterSpacing description 
    289      * @param[in] : description 
    290      * @param[out] : description 
    291      * @code 
    292      * @endcode 
    293      */ 
    294     void setLetterSpacing(short s)  
    295  
    296 #if ENABLE(SVG_FON 
    297 #endif 
    298  
    299 private: 
    300     const UChar* m_characters; 
    301     int m_len; 
    302  
    303     bool m_allowTabs; 
    304     int m_xpos; 
    305     int m_padding; 
    306     bool m_rtl; 
    307     bool m_directionalOverride; 
    308     bool m_applyRunRounding; 
    309     bool m_applyWordRounding; 
    310     bool m_disableSpacing; 
    311  
    312 #if ENABLE(SVG_FONTS) 
    313     RenderObject* m_referencingRenderObject; 
    314     SVGPaintServer* m_activePaintServer; 
    315 #endif 
    316 }; 
    317  
    318 class Font : public WKALBase { 
    319 pub 
     240    /** 
     241     * set letter spacing value 
     242     * @param[in] : letter spacing value 
     243     * @code 
     244     * f->setLetterSpacing(12); 
     245     * @endcode 
     246     */ 
     247    void setLetterSpacing(short s) ; 
     248 
     249    /** 
     250     * test if the pitch is fixed 
     251     * @param[out] : true if the pitch is fixed 
     252     * @code 
     253     * bool fp = f->isFixedPitch(); 
     254     * @endcode 
     255     */ 
     256    bool isFixedPitch() const; 
     257 
     258    /** 
     259     * test if the font is printer 
     260     * @param[out] : true if the font is printer 
     261     * @code 
     262     * bool pf = f->isPrinterFont(); 
     263     * @endcode 
     264     */ 
     265    bool isPrinterFont() const ; 
    320266     
    321267    /** 
     
    326272     * @endcode 
    327273     */ 
    328     FontRenderingMode renderingMode() const  
     274    FontRenderingMode renderingMode() const ; 
     275 
     276    /** 
     277     * get first font family 
     278     * @param[out] : font family 
     279     * @code 
     280     * FontFamily ff = f->firstFamily(); 
     281     * @endcode 
     282     */ 
     283    FontFamily& firstFamily() ; 
    329284 
    330285    /** 
     
    335290     * @endcode 
    336291     */ 
    337     const FontFamily& family() const  
     292    const FontFamily& family() const ; 
     293 
     294    /** 
     295     * get the italic status 
     296     * @param[out] : italic status 
     297     * @code 
     298     * bool it = f->italic(); 
     299     * @endcode 
     300     */ 
     301    bool italic() const ; 
    338302 
    339303    /** 
     
    344308     * @endcode 
    345309     */ 
    346     FontWeight weight() const  
     310    FontWeight weight() const ; 
     311 
     312    /** 
     313     * get it's a platform font 
     314     * @param[out] : true if it's a platform font 
     315     * @code 
     316     * bool pf = f->isPlatformFont(); 
     317     * @endcode 
     318     */ 
     319    bool isPlatformFont() const ; 
    347320 
    348321 
     
    355328     * @endcode 
    356329     */ 
    357     int ascent() const 
     330    int ascent() const; 
     331 
     332    /** 
     333     * get descent value 
     334     * @param[out] : descent value 
     335     * @code 
     336     * int d = f->descent(); 
     337     * @endcode 
     338     */ 
     339    int descent() const; 
    358340 
    359341    /** 
     
    364346     * @endcode 
    365347     */ 
    366     int height() const  
     348    int height() const ; 
     349 
     350    /** 
     351     * get lineSpacing value 
     352     * @param[out] : lineSpacing value 
     353     * @code 
     354     * int ls = f->lineSpacing(); 
     355     * @endcode 
     356     */ 
     357    int lineSpacing() const; 
    367358 
    368359    /** 
     
    373364     * @endcode 
    374365     */ 
    375     float xHeight() const 
     366    float xHeight() const; 
     367 
     368    /** 
     369     * get unitsPerEm value 
     370     * @param[out] : untiPerEm value 
     371     * @code 
     372     * unsigned u = f->unitsPerEm(); 
     373     * @endcode 
     374     */ 
     375    unsigned unitsPerEm() const; 
    376376 
    377377    /** 
     
    382382     * @endcode 
    383383     */ 
    384     int spaceWidth() const 
     384    int spaceWidth() const; 
     385 
     386    /** 
     387     * get tabWidth value 
     388     * @param[out] : tabWidth value 
     389     * @code 
     390     * int tw = f->tabWidth(); 
     391     * @endcode 
     392     */ 
     393    int tabWidth() const ; 
    385394 
    386395    /** 
     
    391400     * @endcode 
    392401     */ 
    393     const SimpleFontData* primaryFont() const  
     402    const SimpleFontData* primaryFont() const ; 
     403 
     404    /** 
     405     * get fontData value at position 
     406     * @param[in] : position value 
     407     * @param[out] : font data 
     408     * @code 
     409     * FontData *fd = f->fontDataAt(0); 
     410     * @endcode 
     411     */ 
     412    const FontData* fontDataAt(unsigned) const; 
    394413 
    395414    /** 
     
    404423     */ 
    405424    const GlyphData& glyphDataForCharacter(UChar32, bool mirror, bool forceSmallCaps = false) const; 
    406     // Used for complex text, and does not utilize the glyph map cach 
     425 
     426    // Used for complex text, and does not utilize the glyph map cache. 
     427    /** 
     428     * get font data for a characters 
     429     * @param[in] : characters 
     430     * @param[in] : length 
     431     * @param[out] : font data 
     432     * @code 
     433     * FontData *fd = f->fontDataForCharacters(c, 12); 
     434     * @endcode 
     435     */ 
     436    const FontData* fontDataForCharacters(const UChar*, int length) const; 
    407437 
    408438private: 
     
    415445     * @endcode 
    416446     */ 
    417     bool canUseGlyphCache(const TextRun&) const 
     447    bool canUseGlyphCache(const TextRun&) const; 
     448 
     449    /** 
     450     * draw simple text 
     451     * @param[in] : graphics context 
     452     * @param[in] : textRun 
     453     * @param[in] : start point 
     454     * @param[in] : start glyph range 
     455     * @param[in] : end glyph range 
     456     * @code 
     457     * f->drawSimpleText(gc, textRun, FloatPoint(0,0), 0, 12); 
     458     * @endcode 
     459     */ 
     460    void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    418461#if ENABLE(SVG_FONTS) 
    419462    /** 
     
    590633     */ 
    591634    FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    592      
    593635 
    594636    /** 
     
    599641     */ 
    600642    void cachePrimaryFont() const; 
    601      
     643 
    602644    friend struct WidthIterator; 
    603645 
     
    605647public: 
    606648    enum CodePath { Auto, Simple, Complex }; 
     649 
    607650    /** 
    608651     * set code path 
     
    613656     */ 
    614657    static void setCodePath(CodePath); 
     658 
    615659    static CodePath codePath; 
    616660 
    617661    static const uint8_t gRoundingHackCharacterTable[256]; 
    618     /** 
    619      * get is rounding hack character 
    620      * @param[in] : character 
    621      * @param[out] : true or false 
    622      * @code 
    623      * bool r = f->isRoundingHackCharacter(c); 
    624      * @endcode 
    625      */ 
    626     static bool isRoundingHackCharacter(UChar32 c); 
    627  
    628     /** 
    629      * get fontSelector  
    630      * @param[out] : font selector 
    631      * @code 
    632      * FontSelector *fs = f->fontSelector(); 
    633      * @endcode 
    634      */ 
    635     FontSelector* fontSelector() const; 
    636  
    637     /** 
    638      * test if font treat character as space 
    639      * @param[in] : character 
    640      * @param[out] : true or false 
    641      * @code 
    642      * bool t = f->treatAsSpace(c); 
    643      * @endcode 
    644      */ 
    645     static bool treatAsSpace(UChar c) ; 
    646  
    647     /** 
    648      * test if font treat character as zero width space 
    649      * @param[in] : character 
    650      * @param[out] : true or false 
    651      * @code 
    652      * bool t = f->treatAsZeroWidthSpace(c); 
    653      * @endcode 
    654      */ 
    655     static bool treatAsZeroWidthSpace(UChar c) ; 
    656  
    657 #if ENABLE(SVG_FONTS) 
    658     /** 
    659      * test if font is SVG font 
    660      * @param[out] : true or false 
    661      * @code 
    662      * bool svgFont = f->isSVGFont(); 
    663      * @endcode 
    664      */ 
    665     bool isSVGFont() const/* 
    666  * Copyright (C) 2008 Pleyo.  All rights reserved. 
    667  * 
    668  * Redistribution and use in source and binary forms, with or without 
    669  * modification, are permitted provided that the following conditions 
    670  * are met: 
    671  * 
    672  * 1.  Redistributions of source code must retain the above copyright 
    673  *     notice, this list of conditions and the following disclaimer. 
    674  * 2.  Redistributions in binary form must reproduce the above copyright 
    675  *     notice, this list of conditions and the following disclaimer in the 
    676  *     documentation and/or other materials provided with the distribution. 
    677  * 3.  Neither the name of Pleyo nor the names of 
    678  *     its contributors may be used to endorse or promote products derived 
    679  *     from this software without specific prior written permission. 
    680  * 
    681  * THIS SOFTWARE IS PROVIDED BY PLEYO AND ITS CONTRIBUTORS "AS IS" AND ANY 
    682  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
    683  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    684  * DISCLAIMED. IN NO EVENT SHALL PLEYO OR ITS CONTRIBUTORS BE LIABLE FOR ANY 
    685  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    686  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    687  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    688  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    689  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    690  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    691  */ 
    692 #ifndef Font_h 
    693 #define Font_h 
    694 /** 
    695  *  @file  Font.t 
    696  *  Font description 
    697  *  Repository informations : 
    698  * - $URL$ 
    699  * - $Rev$ 
    700  * - $Date$ 
    701  */ 
    702 #include "BALBase.h" 
    703  
    704 #include "FontDescription.h" 
    705 #include <wtf/HashMap.h> 
    706  
    707  
    708 namespace WKAL { 
    709  
    710 class FloatPoint; 
    711 class FloatRect; 
    712 class FontData; 
    713 class FontFallbackList; 
    714 class FontPlatformData; 
    715 class FontSelector; 
    716 class GlyphBuffer; 
    717 class GlyphPageTreeNode; 
    718 class GraphicsContext; 
    719 class IntPoint; 
    720 class RenderObject; 
    721 class SimpleFontData; 
    722 class SVGFontElement; 
    723 class SVGPaintServer; 
    724  
    725 struct GlyphData; 
    726  
    727 class TextRun : public WKALBase { 
    728 publi 
    729  
    730  
    731     /** 
    732      *  Font description 
    733      * @param[in] : description 
    734      * @param[out] : description 
    735      * @code 
    736      * @endcode 
    737      */ 
    738     Font(); 
    739  
    740  
    741     /** 
    742      *  Font description 
    743      * @param[in] : description 
    744      * @param[out] : description 
    745      * @code 
    746      * @endcode 
    747      */ 
    748     Font(const FontDescription&, short letterSpacing, short wordSpacing); 
    749  
    750  
    751     /** 
    752      *  Font description 
    753      * @param[in] : description 
    754      * @param[out] : description 
    755      * @code 
    756      * @endcode 
    757      */ 
    758     Font(const FontPlatformData&, bool isPrinting); 
    759  
    760  
    761     /** 
    762      *  ~Font description 
    763      * @param[in] : description 
    764      * @param[out] : description 
    765      * @code 
    766      * @endcode 
    767      */ 
    768     ~Font(); 
    769  
    770  
    771     /** 
    772      *  Font description 
    773      * @param[in] : description 
    774      * @param[out] : description 
    775      * @code 
    776      * @endcode 
    777      */ 
    778     Font(const Font&); 
    779  
    780  
    781     /** 
    782      *  operator= description 
    783      * @param[in] : description 
    784      * @param[out] : description 
    785      * @code 
    786      * @endcode 
    787      */ 
    788     Font& operator=(const Font&); 
    789  
    790  
    791     /** 
    792      *  operator== description 
    793      * @param[in] : description 
    794      * @param[out] : description 
    795      * @code 
    796      * @endcode 
    797      */ 
    798     bool operator==(const Font& other) const; 
    799  
    800  
    801     /** 
    802      *  operator!= description 
    803      * @param[in] : description 
    804      * @param[out] : description 
    805      * @code 
    806      * @endcode 
    807      */ 
    808     bool operator!=(const Font& other) const ; 
    809  
    810  
    811     /** 
    812      *  fontDescription description 
    813      * @param[in] : description 
    814      * @param[out] : description 
    815      * @code 
    816      * @endcode 
    817      */ 
    818     const FontDescription& fontDescription() const ; 
    819  
    820  
    821     /** 
    822      *  pixelSize description 
    823      * @param[in] : description 
    824      * @param[out] : description 
    825      * @code 
    826      * @endcode 
    827      */ 
    828     int pixelSize() const ; 
    829  
    830  
    831     /** 
    832      *  size description 
    833      * @param[in] : description 
    834      * @param[out] : description 
    835      * @code 
    836      * @endcode 
    837      */ 
    838     float size() const ; 
    839  
    840  
    841     /** 
    842      *  update description 
    843      * @param[in] : description 
    844      * @param[out] : description 
    845      * @code 
    846      * @endcode 
    847      */ 
    848     void update(PassRefPtr<FontSelector>) const; 
    849  
    850  
    851     /** 
    852      *  drawText description 
    853      * @param[in] : description 
    854      * @param[out] : description 
    855      * @code 
    856      * @endcode 
    857      */ 
    858     void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; 
    859  
    860  
    861     /** 
    862      *  width description 
    863      * @param[in] : description 
    864      * @param[out] : description 
    865      * @code 
    866      * @endcode 
    867      */ 
    868     int width(const TextRun&) const; 
    869  
    870  
    871     /** 
    872      *  floatWidth description 
    873      * @param[in] : description 
    874      * @param[out] : description 
    875      * @code 
    876      * @endcode 
    877      */ 
    878     float floatWidth(const TextRun&) const; 
    879  
    880  
    881     /** 
    882      *  floatWidth description 
    883      * @param[in] : description 
    884      * @param[out] : description 
    885      * @code 
    886      * @endcode 
    887      */ 
    888     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    889  
    890  
    891     /** 
    892      *  offsetForPosition description 
    893      * @param[in] : description 
    894      * @param[out] : description 
    895      * @code 
    896      * @endcode 
    897      */ 
    898     int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; 
    899  
    900  
    901     /** 
    902      *  selectionRectForText description 
    903      * @param[in] : description 
    904      * @param[out] : description 
    905      * @code 
    906      * @endcode 
    907      */ 
    908     FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const; 
    909  
    910  
    911     /** 
    912      *  isSmallCaps description 
    913      * @param[in] : description 
    914      * @param[out] : description 
    915      * @code 
    916      * @endcode 
    917      */ 
    918     bool isSmallCaps() const ; 
    919  
    920  
    921     /** 
    922      *  wordSpacing description 
    923      * @param[in] : description 
    924      * @param[out] : description 
    925      * @code 
    926      * @endcode 
    927      */ 
    928     short wordSpacing() const ; 
    929  
    930  
    931     /** 
    932      *  letterSpacing description 
    933      * @param[in] : description 
    934      * @param[out] : description 
    935      * @code 
    936      * @endcode 
    937      */ 
    938     short letterSpacing() const ; 
    939  
    940  
    941     /** 
    942      *  setWordSpacing description 
    943      * @param[in] : description 
    944      * @param[out] : description 
    945      * @code 
    946      * @endcode 
    947      */ 
    948     void setWordSpacing(short s) ; 
    949  
    950  
    951     /** 
    952      *  setLetterSpacing description 
    953      * @param[in] : description 
    954      * @param[out] : description 
    955      * @code 
    956      * @endcode 
    957      */ 
    958     void setLetterSpacing(short s)  
    959  
    960 #if ENABLE(SVG_FONT 
    961  
    962     /** 
    963      * set referencing RenderObject 
    964      * @param[in] : RenderObject 
    965      * @code 
    966      * textRun->setReferencingRenderObject(rObj); 
    967      * @endcode 
    968      */ 
    969     void setReferencingRenderObject(RenderObject* object)  
    970  
    971     /** 
    972      * set active paint server 
    973      * @param[in] : SVGPaintServer 
    974      * @code 
    975      * textRun->setActivePaintServer(sps); 
    976      * @endcode 
    977      */ 
    978     void setActivePaintServer(SVGPaintServer* object) ; 
    979 #endif 
    980  
    981 private: 
    982     const UChar* m_characters; 
    983     int m_len; 
    984  
    985     bool m_allowTabs; 
    986     int m_xpos; 
    987     int m_padding; 
    988     bool m_rtl; 
    989     bool m_directionalOverride; 
    990     bool m_applyRunRounding; 
    991     bool m_applyWordRounding; 
    992     bool m_disableSpacing; 
    993  
    994 #if ENABLE(SVG_FONTS) 
    995     RenderObject* m_referencingRenderObject; 
    996     SVGPaintServer* m_activePaintServer; 
    997 #endif 
    998 }; 
    999  
    1000 class Font : public WKALBase { 
    1001 publi 
    1002  
    1003     /** 
    1004      * Font constructor 
    1005      * @param[in] : FontDescription 
    1006      * @param[in] : letter spacing 
    1007      * @param[in] : word spacing 
    1008      * @code 
    1009      * Font *f = new Font(fd, 12, 12 ); 
    1010      * @endcode 
    1011      */ 
    1012     Font(const FontDescription&, short letterSpacing, short wordSpacing) // This constructor is only used if the platform wants to start with a native font. 
    1013  
    1014     /** 
    1015      * ~Font destructor 
    1016      * @code 
    1017      * delete font; 
    1018      * @endcode 
    1019      */ 
    1020     ~Font( 
    1021  
    1022     /** 
    1023      * test if the font is printer 
    1024      * @param[out] : true if the font is printer 
    1025      * @code 
    1026      * bool pf = f->isPrinterFont(); 
    1027      * @endcode 
    1028      */ 
    1029     bool isPrinterFont() const ; 
    1030      
    1031     /** 
    1032      * get the font rendering mode 
    1033      * @param[out] : font rendering mode 
    1034      * @code 
    1035      * FontRenderingMode frm = f->renderingMode(); 
    1036      * @endcode 
    1037      */ 
    1038     FontRenderingMode renderingMode() const ; 
    1039  
    1040     /** 
    1041      * get first font family 
    1042      * @param[out] : font family 
    1043      * @code 
    1044      * FontFamily ff = f->firstFamily(); 
    1045      * @endcode 
    1046      */ 
    1047     FontFamily& firstFamily() ; 
    1048  
    1049     /** 
    1050      * get font family 
    1051      * @param[out] : font family 
    1052      * @code 
    1053      * FontFamily ff = f->family(); 
    1054      * @endcode 
    1055      */ 
    1056     const FontFamily& family() const ; 
    1057  
    1058     /** 
    1059      * get the italic status 
    1060      * @param[out] : italic status 
    1061      * @code 
    1062      * bool it = f->italic(); 
    1063      * @endcode 
    1064      */ 
    1065     bool italic() const ; 
    1066  
    1067     /** 
    1068      * get the font weight 
    1069      * @param[out] : font weight 
    1070      * @code 
    1071      * FontWeight fw = f->weight(); 
    1072      * @endcode 
    1073      */ 
    1074     FontWeight weight() const ; 
    1075  
    1076     /** 
    1077      * get it's a platform font 
    1078      * @param[out] : true if it's a platform font 
    1079      * @code 
    1080      * bool pf = f->isPlatformFont(); 
    1081      * @endcode 
    1082      */ 
    1083     bool isPlatformFont() const ; 
    1084  
    1085  
    1086     // Metrics that we query the FontFallbackList for. 
    1087     /** 
    1088      * get ascent value 
    1089      * @param[out] : ascent value 
    1090      * @code 
    1091      * int a = f->ascent(); 
    1092      * @endcode 
    1093      */ 
    1094     int ascent() const; 
    1095  
    1096     /** 
    1097      * get descent value 
    1098      * @param[out] : descent value 
    1099      * @code 
    1100      * int d = f->descent(); 
    1101      * @endcode 
    1102      */ 
    1103     int descent() const; 
    1104  
    1105     /** 
    1106      * get height value 
    1107      * @param[out] : height value 
    1108      * @code 
    1109      * int h = f->height(); 
    1110      * @endcode 
    1111      */ 
    1112     int height() const ; 
    1113  
    1114     /** 
    1115      * get lineSpacing value 
    1116      * @param[out] : lineSpacing value 
    1117      * @code 
    1118      * int ls = f->lineSpacing(); 
    1119      * @endcode 
    1120      */ 
    1121     int lineSpacing() const; 
    1122  
    1123     /** 
    1124      * get xHeight value 
    1125      * @param[out] : xHeight value 
    1126      * @code 
    1127      * float x = f->xHeight(); 
    1128      * @endcode 
    1129      */ 
    1130     float xHeight() const; 
    1131  
    1132     /** 
    1133      * get unitsPerEm value 
    1134      * @param[out] : untiPerEm value 
    1135      * @code 
    1136      * unsigned u = f->unitsPerEm(); 
    1137      * @endcode 
    1138      */ 
    1139     unsigned unitsPerEm() const; 
    1140  
    1141     /** 
    1142      * get spaceWidth value 
    1143      * @param[out] : spaceWidth value 
    1144      * @code 
    1145      * int sw = f->spaceWidth(); 
    1146      * @endcode 
    1147      */ 
    1148     int spaceWidth() const; 
    1149  
    1150     /** 
    1151      * get tabWidth value 
    1152      * @param[out] : tabWidth value 
    1153      * @code 
    1154      * int tw = f->tabWidth(); 
    1155      * @endcode 
    1156      */ 
    1157     int tabWidth() const ; 
    1158  
    1159     /** 
    1160      * get primary font value 
    1161      * @param[out] : primary font 
    1162      * @code 
    1163      * SimpleFontData *sfd = f->primaryFont(); 
    1164      * @endcode 
    1165      */ 
    1166     const SimpleFontData* primaryFont() const ; 
    1167  
    1168     /** 
    1169      * get fontData value at position 
    1170      * @param[in] : position value 
    1171      * @param[out] : font data 
    1172      * @code 
    1173      * FontData *fd = f->fontDataAt(0); 
    1174      * @endcode 
    1175      */ 
    1176     const FontData* fontDataAt(unsigned) const; 
    1177  
    1178     /** 
    1179      * get  glyph data for a character 
    1180      * @param[in] : character 
    1181      * @param[in] : mirror 
    1182      * @param[in] : force small caps 
    1183      * @param[out] : glyph data 
    1184      * @code 
    1185      * GlyphData gd = f->glyphDataForCharacter(c, false); 
    1186      * @endcode 
    1187      */ 
    1188     const GlyphData& glyphDataForCharacter(UChar32, bool mirror, bool forceSmallCaps = false) const; 
    1189     // Used for complex text, and does not utilize the glyph map cache. 
    1190     /** 
    1191      * get font data for a characters 
    1192      * @param[in] : characters 
    1193      * @param[in] : length 
    1194      * @param[out] : font data 
    1195      * @code 
    1196      * FontData *fd = f->fontDataForCharacters(c, 12); 
    1197      * @endcode 
    1198      */ 
    1199     const FontData* fontDataForCharacters(const UChar*, int length) const; 
    1200  
    1201 private: 
    1202     /** 
    1203      * test if you can use glyph cache 
    1204      * @param[in] : TextRun 
    1205      * @param[out] : true if you can 
    1206      * @code 
    1207      * bool u = f->canUseGlyphCache(textRun); 
    1208      * @endcode 
    1209      */ 
    1210     bool canUseGlyphCache(const TextRun&) const; 
    1211  
    1212     /** 
    1213      * draw simple text 
    1214      * @param[in] : graphics context 
    1215      * @param[in] : textRun 
    1216      * @param[in] : start point 
    1217      * @param[in] : start glyph range 
    1218      * @param[in] : end glyph range 
    1219      * @code 
    1220      * f->drawSimpleText(gc, textRun, FloatPoint(0,0), 0, 12); 
    1221      * @endcode 
    1222      */ 
    1223     void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    1224 #if ENABLE(SVG_FONTS) 
    1225     /** 
    1226      * draw text using SVG font 
    1227      * @param[in] : graphics contect 
    1228      * @param[in] : textRun 
    1229      * @param[in] : start point 
    1230      * @param[in] : start glyph range 
    1231      * @param[in] : end glyph range 
    1232      * @code 
    1233      * f->drawTextUsingSVGFont(gc, textRun, FloatPoint(0,0), 0, 12); 
    1234      * @endcode 
    1235      */ 
    1236     void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    1237  
    1238     /** 
    1239      * get float width using SVG font  
    1240      * @param[in] : textRun 
    1241      * @param[out] : float width 
    1242      * @code 
    1243      * float w = f->floatWidthUsingSVGFont(textRun); 
    1244      * @endcode 
    1245      */ 
    1246     float floatWidthUsingSVGFont(const TextRun&) const; 
    1247  
    1248     /** 
    1249      * get float width using SVG font  
    1250      * @param[in] : textRun 
    1251      * @param[in] : extra char available 
    1252      * @param[in] : character consumed 
    1253      * @param[in] : glyph name 
    1254      * @param[out] : float width 
    1255      * @code 
    1256      * float w = f->floatWidthUsingSVGFont(textRun, 0, chars, glyphName); 
    1257      * @endcode 
    1258      */ 
    1259     float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    1260  
    1261     /** 
    1262      * get  selection rect for text using SVG font 
    1263      * @param[in] : textRun 
    1264      * @param[in] : start point 
    1265      * @param[in] : heigth 
    1266      * @param[in] : start glyph range 
    1267      * @param[in] : end glyph range 
    1268      * @param[out] : float rect 
    1269      * @code 
    1270      * FloatRect r = selectionRectForTextUsingSVGFont(textRun, IntPoint(0, 0), 10, 0, 12); 
    1271      * @endcode 
    1272      */ 
    1273     FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    1274  
    1275     /** 
    1276      * get offset for a position for a text using SVG font 
    1277      * @param[in] : textRun 
    1278      * @param[in] : position 
    1279      * @param[in] : include partial glyphs 
    1280      * @param[out] : offset 
    1281      * @code 
    1282      * int o = f->offsetForPositionForTextUsingSVGFont(textRun, 0, true); 
    1283      * @endcode 
    1284      */ 
    1285     int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const; 
    1286 #endif 
    1287     /** 
    1288      * draw glyphs 
    1289      * @param[in] : graphics context 
    1290      * @param[in] : font data 
    1291      * @param[in] : glyph buffer 
    1292      * @param[in] : start glyph range 
    1293      * @param[in] : end glyph range 
    1294      * @param[in] : start point 
    1295      * @code 
    1296      * f->drawGlyphs(gc, s, g, 0, 12, FloatPoint(0,0)); 
    1297      * @endcode 
    1298      */ 
    1299     void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const; 
    1300  
    1301     /** 
    1302      * draw glyph buffer  
    1303      * @param[in] : graphics context 
    1304      * @param[in] : glyph buffer 
    1305      * @param[in] : textRun 
    1306      * @param[in] : start point 
    1307      * @code 
    1308      * f->drawGlyphBuffer(gc, gb, textRun, FloatPoint(0,0)); 
    1309      * @endcode 
    1310      */ 
    1311     void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const; 
    1312  
    1313     /** 
    1314      * draw complex text  
    1315      * @param[in] : graphics context 
    1316      * @param[in] : textRun 
    1317      * @param[in] : start point 
    1318      * @param[in] : start glyph range 
    1319      * @param[in] : end glyph range 
    1320      * @code 
    1321      * f->drawComplexText(gc, textRun, FloatPoint(0,0), 0, 12); 
    1322      * @endcode 
    1323      */ 
    1324     void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    1325  
    1326     /** 
    1327      * get float width for a simple text 
    1328      * @param[in] : textRun 
    1329      * @param[in] : glyph buffer 
    1330      * @param[out] : float width 
    1331      * @code 
    1332      * float w = f->floatWidthForSimpleText(textRun, gb); 
    1333      * @endcode 
    1334      */ 
    1335     float floatWidthForSimpleText(const TextRun&, GlyphBuffer*) const; 
    1336  
    1337     /** 
    1338      * get float width for complex text 
    1339      * @param[in] : textRun 
    1340      * @param[out] : float width 
    1341      * @code 
    1342      * float w = f->floatWidthForComplexText(textRun); 
    1343      * @endcode 
    1344      */ 
    1345     float floatWidthForComplexText(const TextRun&) const; 
    1346  
    1347     /** 
    1348      * get offset for a position for a simple text 
    1349      * @param[in] : textRun 
    1350      * @param[in] : position 
    1351      * @param[in] : include partial glyphs 
    1352      * @param[out] : offset 
    1353      * @code 
    1354      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    1355      * @endcode 
    1356      */ 
    1357     int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const; 
    1358  
    1359     /** 
    1360      * get offset for a position for a complex text 
    1361      * @param[in] : textRun 
    1362      * @param[in] : position 
    1363      * @param[in] : include partial glyphs 
    1364      * @param[out] : offset 
    1365      * @code 
    1366      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    1367      * @endcode 
    1368      */ 
    1369     int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const; 
    1370  
    1371     /** 
    1372      * get selection rect for a simple text 
    1373      * @param[in] : textRun 
    1374      * @param[in] : start point 
    1375      * @param[in] : height 
    1376      * @param[in] : start glyph range 
    1377      * @param[in] : end glyph range 
    1378      * @param[out] : float rect 
    1379      * @code 
    1380      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    1381      * @endcode 
    1382      */ 
    1383     FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    1384  
    1385     /** 
    1386      * get selection rect for a complex text 
    1387      * @param[in] : textRun 
    1388      * @param[in] : start point 
    1389      * @param[in] : height 
    1390      * @param[in] : start glyph range 
    1391      * @param[in] : end glyph range 
    1392      * @param[out] : float rect 
    1393      * @code 
    1394      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    1395      * @endcode 
    1396      */ 
    1397     FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    1398      
    1399  
    1400     /** 
    1401      * cache primary font 
    1402      * @code 
    1403      * f->cachePrimaryFont(); 
    1404      * @endcode 
    1405      */ 
    1406     void cachePrimaryFont() const; 
    1407      
    1408     friend struct WidthIterator; 
    1409  
    1410     // Useful for debugging the different font rendering code paths. 
    1411 public: 
    1412     enum CodePath { Auto, Simple, Complex }; 
    1413     /** 
    1414      * set code path 
    1415      * @param[in] : code path 
    1416      * @code 
    1417      * f->setCodePath(Auto); 
    1418      * @endcode 
    1419      */ 
    1420     static void setCodePath(CodePath); 
    1421     static CodePath codePath; 
    1422  
    1423     static const uint8_t gRoundingHackCharacterTable[256]; 
    1424     /** 
    1425      * get is rounding hack character 
    1426      * @param[in] : character 
    1427      * @param[out] : true or false 
    1428      * @code 
    1429      * bool r = f->isRoundingHackCharacter(c); 
    1430      * @endcode 
    1431      */ 
    1432     static bool isRoundingHackCharacter(UChar32 c); 
    1433  
    1434     /** 
    1435      * get fontSelector  
    1436      * @param[out] : font selector 
    1437      * @code 
    1438      * FontSelector *fs = f->fontSelector(); 
    1439      * @endcode 
    1440      */ 
    1441     FontSelector* fontSelector() const; 
    1442  
    1443     /** 
    1444      * test if font treat character as space 
    1445      * @param[in] : character 
    1446      * @param[out] : true or false 
    1447      * @code 
    1448      * bool t = f->treatAsSpace(c); 
    1449      * @endcode 
    1450      */ 
    1451     static bool treatAsSpace(UChar c) ; 
    1452  
    1453     /** 
    1454      * test if font treat character as zero width space 
    1455      * @param[in] : character 
    1456      * @param[out] : true or false 
    1457      * @code 
    1458      * bool t = f->treatAsZeroWidthSpace(c); 
    1459      * @endcode 
    1460      */ 
    1461     static bool treatAsZeroWidthSpace(UChar c) ; 
    1462  
    1463 #if ENABLE(SVG_FONTS) 
    1464     /** 
    1465      * test if font is SVG font 
    1466      * @param[out] : true or false 
    1467      * @code 
    1468      * bool svgFont = f->isSVGFont(); 
    1469      * @endcode 
    1470      */ 
    1471     bool isSVGFont() const/* 
    1472  * Copyright (C) 2008 Pleyo.  All rights reserved. 
    1473  * 
    1474  * Redistribution and use in source and binary forms, with or without 
    1475  * modification, are permitted provided that the following conditions 
    1476  * are met: 
    1477  * 
    1478  * 1.  Redistributions of source code must retain the above copyright 
    1479  *     notice, this list of conditions and the following disclaimer. 
    1480  * 2.  Redistributions in binary form must reproduce the above copyright 
    1481  *     notice, this list of conditions and the following disclaimer in the 
    1482  *     documentation and/or other materials provided with the distribution. 
    1483  * 3.  Neither the name of Pleyo nor the names of 
    1484  *     its contributors may be used to endorse or promote products derived 
    1485  *     from this software without specific prior written permission. 
    1486  * 
    1487  * THIS SOFTWARE IS PROVIDED BY PLEYO AND ITS CONTRIBUTORS "AS IS" AND ANY 
    1488  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
    1489  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    1490  * DISCLAIMED. IN NO EVENT SHALL PLEYO OR ITS CONTRIBUTORS BE LIABLE FOR ANY 
    1491  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    1492  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    1493  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    1494  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1495  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    1496  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    1497  */ 
    1498 #ifndef Font_h 
    1499 #define Font_h 
    1500 /** 
    1501  *  @file  Font.t 
    1502  *  Font description 
    1503  *  Repository informations : 
    1504  * - $URL$ 
    1505  * - $Rev$ 
    1506  * - $Date$ 
    1507  */ 
    1508 #include "BALBase.h" 
    1509  
    1510 #include "FontDescription.h" 
    1511 #include <wtf/HashMap.h> 
    1512  
    1513  
    1514 namespace WKAL { 
    1515  
    1516 class FloatPoint; 
    1517 class FloatRect; 
    1518 class FontData; 
    1519 class FontFallbackList; 
    1520 class FontPlatformData; 
    1521 class FontSelector; 
    1522 class GlyphBuffer; 
    1523 class GlyphPageTreeNode; 
    1524 class GraphicsContext; 
    1525 class IntPoint; 
    1526 class RenderObject; 
    1527 class SimpleFontData; 
    1528 class SVGFontElement; 
    1529 class SVGPaintServer; 
    1530  
    1531 struct GlyphData; 
    1532  
    1533 class TextRun : public WKALBase { 
    1534 publi 
    1535  
    1536  
    1537     /** 
    1538      *  Font description 
    1539      * @param[in] : description 
    1540      * @param[out] : description 
    1541      * @code 
    1542      * @endcode 
    1543      */ 
    1544     Font(); 
    1545  
    1546  
    1547     /** 
    1548      *  Font description 
    1549      * @param[in] : description 
    1550      * @param[out] : description 
    1551      * @code 
    1552      * @endcode 
    1553      */ 
    1554     Font(const FontDescription&, short letterSpacing, short wordSpacing); 
    1555  
    1556  
    1557     /** 
    1558      *  Font description 
    1559      * @param[in] : description 
    1560      * @param[out] : description 
    1561      * @code 
    1562      * @endcode 
    1563      */ 
    1564     Font(const FontPlatformData&, bool isPrinting); 
    1565  
    1566  
    1567     /** 
    1568      *  ~Font description 
    1569      * @param[in] : description 
    1570      * @param[out] : description 
    1571      * @code 
    1572      * @endcode 
    1573      */ 
    1574     ~Font(); 
    1575  
    1576  
    1577     /** 
    1578      *  Font description 
    1579      * @param[in] : description 
    1580      * @param[out] : description 
    1581      * @code 
    1582      * @endcode 
    1583      */ 
    1584     Font(const Font&); 
    1585  
    1586  
    1587     /** 
    1588      *  operator= description 
    1589      * @param[in] : description 
    1590      * @param[out] : description 
    1591      * @code 
    1592      * @endcode 
    1593      */ 
    1594     Font& operator=(const Font&); 
    1595  
    1596  
    1597     /** 
    1598      *  operator== description 
    1599      * @param[in] : description 
    1600      * @param[out] : description 
    1601      * @code 
    1602      * @endcode 
    1603      */ 
    1604     bool operator==(const Font& other) const; 
    1605  
    1606  
    1607     /** 
    1608      *  operator!= description 
    1609      * @param[in] : description 
    1610      * @param[out] : description 
    1611      * @code 
    1612      * @endcode 
    1613      */ 
    1614     bool operator!=(const Font& other) const ; 
    1615  
    1616  
    1617     /** 
    1618      *  fontDescription description 
    1619      * @param[in] : description 
    1620      * @param[out] : description 
    1621      * @code 
    1622      * @endcode 
    1623      */ 
    1624     const FontDescription& fontDescription() const ; 
    1625  
    1626  
    1627     /** 
    1628      *  pixelSize description 
    1629      * @param[in] : description 
    1630      * @param[out] : description 
    1631      * @code 
    1632      * @endcode 
    1633      */ 
    1634     int pixelSize() const ; 
    1635  
    1636  
    1637     /** 
    1638      *  size description 
    1639      * @param[in] : description 
    1640      * @param[out] : description 
    1641      * @code 
    1642      * @endcode 
    1643      */ 
    1644     float size() const ; 
    1645  
    1646  
    1647     /** 
    1648      *  update description 
    1649      * @param[in] : description 
    1650      * @param[out] : description 
    1651      * @code 
    1652      * @endcode 
    1653      */ 
    1654     void update(PassRefPtr<FontSelector>) const; 
    1655  
    1656  
    1657     /** 
    1658      *  drawText description 
    1659      * @param[in] : description 
    1660      * @param[out] : description 
    1661      * @code 
    1662      * @endcode 
    1663      */ 
    1664     void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; 
    1665  
    1666  
    1667     /** 
    1668      *  width description 
    1669      * @param[in] : description 
    1670      * @param[out] : description 
    1671      * @code 
    1672      * @endcode 
    1673      */ 
    1674     int width(const TextRun&) const; 
    1675  
    1676  
    1677     /** 
    1678      *  floatWidth description 
    1679      * @param[in] : description 
    1680      * @param[out] : description 
    1681      * @code 
    1682      * @endcode 
    1683      */ 
    1684     float floatWidth(const TextRun&) const; 
    1685  
    1686  
    1687     /** 
    1688      *  floatWidth description 
    1689      * @param[in] : description 
    1690      * @param[out] : description 
    1691      * @code 
    1692      * @endcode 
    1693      */ 
    1694     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    1695  
    1696  
    1697     /** 
    1698      *  offsetForPosition description 
    1699      * @param[in] : description 
    1700      * @param[out] : description 
    1701      * @code 
    1702      * @endcode 
    1703      */ 
    1704     int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; 
    1705  
    1706  
    1707     /** 
    1708      *  selectionRectForText description 
    1709      * @param[in] : description 
    1710      * @param[out] : description 
    1711      * @code 
    1712      * @endcode 
    1713      */ 
    1714     FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const; 
    1715  
    1716  
    1717     /** 
    1718      *  isSmallCaps description 
    1719      * @param[in] : description 
    1720      * @param[out] : description 
    1721      * @code 
    1722      * @endcode 
    1723      */ 
    1724     bool isSmallCaps() const ; 
    1725  
    1726  
    1727     /** 
    1728      *  wordSpacing description 
    1729      * @param[in] : description 
    1730      * @param[out] : description 
    1731      * @code 
    1732      * @endcode 
    1733      */ 
    1734     short wordSpacing() const ; 
    1735  
    1736  
    1737     /** 
    1738      *  letterSpacing description 
    1739      * @param[in] : description 
    1740      * @param[out] : description 
    1741      * @code 
    1742      * @endcode 
    1743      */ 
    1744     short letterSpacing() const ; 
    1745  
    1746  
    1747     /** 
    1748      *  setWordSpacing description 
    1749      * @param[in] : description 
    1750      * @param[out] : description 
    1751      * @code 
    1752      * @endcode 
    1753      */ 
    1754     void setWordSpacing(short s) ; 
    1755  
    1756  
    1757     /** 
    1758      *  setLetterSpacing description 
    1759      * @param[in] : description 
    1760      * @param[out] : description 
    1761      * @code 
    1762      * @endcode 
    1763      */ 
    1764     void setLetterSpacing(short s)  
    1765  
    1766 #if ENABLE(SVG_FONT 
    1767  
    1768     /** 
    1769      * set referencing RenderObject 
    1770      * @param[in] : RenderObject 
    1771      * @code 
    1772      * textRun->setReferencingRenderObject(rObj); 
    1773      * @endcode 
    1774      */ 
    1775     void setReferencingRenderObject(RenderObject* object)  
    1776  
    1777     /** 
    1778      * set active paint server 
    1779      * @param[in] : SVGPaintServer 
    1780      * @code 
    1781      * textRun->setActivePaintServer(sps); 
    1782      * @endcode 
    1783      */ 
    1784     void setActivePaintServer(SVGPaintServer* object) ; 
    1785 #endif 
    1786  
    1787 private: 
    1788     const UChar* m_characters; 
    1789     int m_len; 
    1790  
    1791     bool m_allowTabs; 
    1792     int m_xpos; 
    1793     int m_padding; 
    1794     bool m_rtl; 
    1795     bool m_directionalOverride; 
    1796     bool m_applyRunRounding; 
    1797     bool m_applyWordRounding; 
    1798     bool m_disableSpacing; 
    1799  
    1800 #if ENABLE(SVG_FONTS) 
    1801     RenderObject* m_referencingRenderObject; 
    1802     SVGPaintServer* m_activePaintServer; 
    1803 #endif 
    1804 }; 
    1805  
    1806 class Font : public WKALBase { 
    1807 publi 
    1808  
    1809     /** 
    1810      * Font constructor 
    1811      * @param[in] : FontDescription 
    1812      * @param[in] : letter spacing 
    1813      * @param[in] : word spacing 
    1814      * @code 
    1815      * Font *f = new Font(fd, 12, 12 ); 
    1816      * @endcode 
    1817      */ 
    1818     Font(const FontDescription&, short letterSpacing, short wordSpacing) // This constructor is only used if the platform wants to start with a native font. 
    1819  
    1820     /** 
    1821      * ~Font destructor 
    1822      * @code 
    1823      * delete font; 
    1824      * @endcode 
    1825      */ 
    1826     ~Font() 
    1827  
    1828     /** 
    1829      * operator= 
    1830      * @param[in] : Font 
    1831      * @param[out] : Font 
    1832      * @code 
    1833      * Font f = currentFont; 
    1834      * @endcode 
    1835      */ 
    1836     Font& operator=(const Font&) 
    1837  
    1838     /** 
    1839      * operator!=  
    1840      * @param[in] : Font 
    1841      * @param[out] : return true if the fonts are different 
    1842      * @code 
    1843      * bool d = f != currentFont; 
    1844      * @endcode 
    1845      */ 
    1846     bool operator!=(const Font& other) const 
    1847  
    1848     /** 
    1849      * test if the font is printer 
    1850      * @param[out] : true if the font is printer 
    1851      * @code 
    1852      * bool pf = f->isPrinterFont(); 
    1853      * @endcode 
    1854      */ 
    1855     bool isPrinterFont() const ; 
    1856      
    1857     /** 
    1858      * get the font rendering mode 
    1859      * @param[out] : font rendering mode 
    1860      * @code 
    1861      * FontRenderingMode frm = f->renderingMode(); 
    1862      * @endcode 
    1863      */ 
    1864     FontRenderingMode renderingMode() const ; 
    1865  
    1866     /** 
    1867      * get first font family 
    1868      * @param[out] : font family 
    1869      * @code 
    1870      * FontFamily ff = f->firstFamily(); 
    1871      * @endcode 
    1872      */ 
    1873     FontFamily& firstFamily() ; 
    1874  
    1875     /** 
    1876      * get font family 
    1877      * @param[out] : font family 
    1878      * @code 
    1879      * FontFamily ff = f->family(); 
    1880      * @endcode 
    1881      */ 
    1882     const FontFamily& family() const ; 
    1883  
    1884     /** 
    1885      * get the italic status 
    1886      * @param[out] : italic status 
    1887      * @code 
    1888      * bool it = f->italic(); 
    1889      * @endcode 
    1890      */ 
    1891     bool italic() const ; 
    1892  
    1893     /** 
    1894      * get the font weight 
    1895      * @param[out] : font weight 
    1896      * @code 
    1897      * FontWeight fw = f->weight(); 
    1898      * @endcode 
    1899      */ 
    1900     FontWeight weight() const ; 
    1901  
    1902     /** 
    1903      * get it's a platform font 
    1904      * @param[out] : true if it's a platform font 
    1905      * @code 
    1906      * bool pf = f->isPlatformFont(); 
    1907      * @endcode 
    1908      */ 
    1909     bool isPlatformFont() const ; 
    1910  
    1911  
    1912     // Metrics that we query the FontFallbackList for. 
    1913     /** 
    1914      * get ascent value 
    1915      * @param[out] : ascent value 
    1916      * @code 
    1917      * int a = f->ascent(); 
    1918      * @endcode 
    1919      */ 
    1920     int ascent() const; 
    1921  
    1922     /** 
    1923      * get descent value 
    1924      * @param[out] : descent value 
    1925      * @code 
    1926      * int d = f->descent(); 
    1927      * @endcode 
    1928      */ 
    1929     int descent() const; 
    1930  
    1931     /** 
    1932      * get height value 
    1933      * @param[out] : height value 
    1934      * @code 
    1935      * int h = f->height(); 
    1936      * @endcode 
    1937      */ 
    1938     int height() const ; 
    1939  
    1940     /** 
    1941      * get lineSpacing value 
    1942      * @param[out] : lineSpacing value 
    1943      * @code 
    1944      * int ls = f->lineSpacing(); 
    1945      * @endcode 
    1946      */ 
    1947     int lineSpacing() const; 
    1948  
    1949     /** 
    1950      * get xHeight value 
    1951      * @param[out] : xHeight value 
    1952      * @code 
    1953      * float x = f->xHeight(); 
    1954      * @endcode 
    1955      */ 
    1956     float xHeight() const; 
    1957  
    1958     /** 
    1959      * get unitsPerEm value 
    1960      * @param[out] : untiPerEm value 
    1961      * @code 
    1962      * unsigned u = f->unitsPerEm(); 
    1963      * @endcode 
    1964      */ 
    1965     unsigned unitsPerEm() const; 
    1966  
    1967     /** 
    1968      * get spaceWidth value 
    1969      * @param[out] : spaceWidth value 
    1970      * @code 
    1971      * int sw = f->spaceWidth(); 
    1972      * @endcode 
    1973      */ 
    1974     int spaceWidth() const; 
    1975  
    1976     /** 
    1977      * get tabWidth value 
    1978      * @param[out] : tabWidth value 
    1979      * @code 
    1980      * int tw = f->tabWidth(); 
    1981      * @endcode 
    1982      */ 
    1983     int tabWidth() const ; 
    1984  
    1985     /** 
    1986      * get primary font value 
    1987      * @param[out] : primary font 
    1988      * @code 
    1989      * SimpleFontData *sfd = f->primaryFont(); 
    1990      * @endcode 
    1991      */ 
    1992     const SimpleFontData* primaryFont() const ; 
    1993  
    1994     /** 
    1995      * get fontData value at position 
    1996      * @param[in] : position value 
    1997      * @param[out] : font data 
    1998      * @code 
    1999      * FontData *fd = f->fontDataAt(0); 
    2000      * @endcode 
    2001      */ 
    2002     const FontData* fontDataAt(unsigned) const; 
    2003  
    2004     /** 
    2005      * get  glyph data for a character 
    2006      * @param[in] : character 
    2007      * @param[in] : mirror 
    2008      * @param[in] : force small caps 
    2009      * @param[out] : glyph data 
    2010      * @code 
    2011      * GlyphData gd = f->glyphDataForCharacter(c, false); 
    2012      * @endcode 
    2013      */ 
    2014     const GlyphData& glyphDataForCharacter(UChar32, bool mirror, bool forceSmallCaps = false) const; 
    2015     // Used for complex text, and does not utilize the glyph map cache. 
    2016     /** 
    2017      * get font data for a characters 
    2018      * @param[in] : characters 
    2019      * @param[in] : length 
    2020      * @param[out] : font data 
    2021      * @code 
    2022      * FontData *fd = f->fontDataForCharacters(c, 12); 
    2023      * @endcode 
    2024      */ 
    2025     const FontData* fontDataForCharacters(const UChar*, int length) const; 
    2026  
    2027 private: 
    2028     /** 
    2029      * test if you can use glyph cache 
    2030      * @param[in] : TextRun 
    2031      * @param[out] : true if you can 
    2032      * @code 
    2033      * bool u = f->canUseGlyphCache(textRun); 
    2034      * @endcode 
    2035      */ 
    2036     bool canUseGlyphCache(const TextRun&) const; 
    2037  
    2038     /** 
    2039      * draw simple text 
    2040      * @param[in] : graphics context 
    2041      * @param[in] : textRun 
    2042      * @param[in] : start point 
    2043      * @param[in] : start glyph range 
    2044      * @param[in] : end glyph range 
    2045      * @code 
    2046      * f->drawSimpleText(gc, textRun, FloatPoint(0,0), 0, 12); 
    2047      * @endcode 
    2048      */ 
    2049     void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    2050 #if ENABLE(SVG_FONTS) 
    2051     /** 
    2052      * draw text using SVG font 
    2053      * @param[in] : graphics contect 
    2054      * @param[in] : textRun 
    2055      * @param[in] : start point 
    2056      * @param[in] : start glyph range 
    2057      * @param[in] : end glyph range 
    2058      * @code 
    2059      * f->drawTextUsingSVGFont(gc, textRun, FloatPoint(0,0), 0, 12); 
    2060      * @endcode 
    2061      */ 
    2062     void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    2063  
    2064     /** 
    2065      * get float width using SVG font  
    2066      * @param[in] : textRun 
    2067      * @param[out] : float width 
    2068      * @code 
    2069      * float w = f->floatWidthUsingSVGFont(textRun); 
    2070      * @endcode 
    2071      */ 
    2072     float floatWidthUsingSVGFont(const TextRun&) const; 
    2073  
    2074     /** 
    2075      * get float width using SVG font  
    2076      * @param[in] : textRun 
    2077      * @param[in] : extra char available 
    2078      * @param[in] : character consumed 
    2079      * @param[in] : glyph name 
    2080      * @param[out] : float width 
    2081      * @code 
    2082      * float w = f->floatWidthUsingSVGFont(textRun, 0, chars, glyphName); 
    2083      * @endcode 
    2084      */ 
    2085     float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    2086  
    2087     /** 
    2088      * get  selection rect for text using SVG font 
    2089      * @param[in] : textRun 
    2090      * @param[in] : start point 
    2091      * @param[in] : heigth 
    2092      * @param[in] : start glyph range 
    2093      * @param[in] : end glyph range 
    2094      * @param[out] : float rect 
    2095      * @code 
    2096      * FloatRect r = selectionRectForTextUsingSVGFont(textRun, IntPoint(0, 0), 10, 0, 12); 
    2097      * @endcode 
    2098      */ 
    2099     FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    2100  
    2101     /** 
    2102      * get offset for a position for a text using SVG font 
    2103      * @param[in] : textRun 
    2104      * @param[in] : position 
    2105      * @param[in] : include partial glyphs 
    2106      * @param[out] : offset 
    2107      * @code 
    2108      * int o = f->offsetForPositionForTextUsingSVGFont(textRun, 0, true); 
    2109      * @endcode 
    2110      */ 
    2111     int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const; 
    2112 #endif 
    2113     /** 
    2114      * draw glyphs 
    2115      * @param[in] : graphics context 
    2116      * @param[in] : font data 
    2117      * @param[in] : glyph buffer 
    2118      * @param[in] : start glyph range 
    2119      * @param[in] : end glyph range 
    2120      * @param[in] : start point 
    2121      * @code 
    2122      * f->drawGlyphs(gc, s, g, 0, 12, FloatPoint(0,0)); 
    2123      * @endcode 
    2124      */ 
    2125     void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const; 
    2126  
    2127     /** 
    2128      * draw glyph buffer  
    2129      * @param[in] : graphics context 
    2130      * @param[in] : glyph buffer 
    2131      * @param[in] : textRun 
    2132      * @param[in] : start point 
    2133      * @code 
    2134      * f->drawGlyphBuffer(gc, gb, textRun, FloatPoint(0,0)); 
    2135      * @endcode 
    2136      */ 
    2137     void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const; 
    2138  
    2139     /** 
    2140      * draw complex text  
    2141      * @param[in] : graphics context 
    2142      * @param[in] : textRun 
    2143      * @param[in] : start point 
    2144      * @param[in] : start glyph range 
    2145      * @param[in] : end glyph range 
    2146      * @code 
    2147      * f->drawComplexText(gc, textRun, FloatPoint(0,0), 0, 12); 
    2148      * @endcode 
    2149      */ 
    2150     void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    2151  
    2152     /** 
    2153      * get float width for a simple text 
    2154      * @param[in] : textRun 
    2155      * @param[in] : glyph buffer 
    2156      * @param[out] : float width 
    2157      * @code 
    2158      * float w = f->floatWidthForSimpleText(textRun, gb); 
    2159      * @endcode 
    2160      */ 
    2161     float floatWidthForSimpleText(const TextRun&, GlyphBuffer*) const; 
    2162  
    2163     /** 
    2164      * get float width for complex text 
    2165      * @param[in] : textRun 
    2166      * @param[out] : float width 
    2167      * @code 
    2168      * float w = f->floatWidthForComplexText(textRun); 
    2169      * @endcode 
    2170      */ 
    2171     float floatWidthForComplexText(const TextRun&) const; 
    2172  
    2173     /** 
    2174      * get offset for a position for a simple text 
    2175      * @param[in] : textRun 
    2176      * @param[in] : position 
    2177      * @param[in] : include partial glyphs 
    2178      * @param[out] : offset 
    2179      * @code 
    2180      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    2181      * @endcode 
    2182      */ 
    2183     int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const; 
    2184  
    2185     /** 
    2186      * get offset for a position for a complex text 
    2187      * @param[in] : textRun 
    2188      * @param[in] : position 
    2189      * @param[in] : include partial glyphs 
    2190      * @param[out] : offset 
    2191      * @code 
    2192      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    2193      * @endcode 
    2194      */ 
    2195     int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const; 
    2196  
    2197     /** 
    2198      * get selection rect for a simple text 
    2199      * @param[in] : textRun 
    2200      * @param[in] : start point 
    2201      * @param[in] : height 
    2202      * @param[in] : start glyph range 
    2203      * @param[in] : end glyph range 
    2204      * @param[out] : float rect 
    2205      * @code 
    2206      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    2207      * @endcode 
    2208      */ 
    2209     FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    2210  
    2211     /** 
    2212      * get selection rect for a complex text 
    2213      * @param[in] : textRun 
    2214      * @param[in] : start point 
    2215      * @param[in] : height 
    2216      * @param[in] : start glyph range 
    2217      * @param[in] : end glyph range 
    2218      * @param[out] : float rect 
    2219      * @code 
    2220      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    2221      * @endcode 
    2222      */ 
    2223     FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    2224      
    2225  
    2226     /** 
    2227      * cache primary font 
    2228      * @code 
    2229      * f->cachePrimaryFont(); 
    2230      * @endcode 
    2231      */ 
    2232     void cachePrimaryFont() const; 
    2233      
    2234     friend struct WidthIterator; 
    2235  
    2236     // Useful for debugging the different font rendering code paths. 
    2237 public: 
    2238     enum CodePath { Auto, Simple, Complex }; 
    2239     /** 
    2240      * set code path 
    2241      * @param[in] : code path 
    2242      * @code 
    2243      * f->setCodePath(Auto); 
    2244      * @endcode 
    2245      */ 
    2246     static void setCodePath(CodePath); 
    2247     static CodePath codePath; 
    2248  
    2249     static const uint8_t gRoundingHackCharacterTable[256]; 
    2250     /** 
    2251      * get is rounding hack character 
    2252      * @param[in] : character 
    2253      * @param[out] : true or false 
    2254      * @code 
    2255      * bool r = f->isRoundingHackCharacter(c); 
    2256      * @endcode 
    2257      */ 
    2258     static bool isRoundingHackCharacter(UChar32 c); 
    2259  
    2260     /** 
    2261      * get fontSelector  
    2262      * @param[out] : font selector 
    2263      * @code 
    2264      * FontSelector *fs = f->fontSelector(); 
    2265      * @endcode 
    2266      */ 
    2267     FontSelector* fontSelector() const; 
    2268  
    2269     /** 
    2270      * test if font treat character as space 
    2271      * @param[in] : character 
    2272      * @param[out] : true or false 
    2273      * @code 
    2274      * bool t = f->treatAsSpace(c); 
    2275      * @endcode 
    2276      */ 
    2277     static bool treatAsSpace(UChar c) ; 
    2278  
    2279     /** 
    2280      * test if font treat character as zero width space 
    2281      * @param[in] : character 
    2282      * @param[out] : true or false 
    2283      * @code 
    2284      * bool t = f->treatAsZeroWidthSpace(c); 
    2285      * @endcode 
    2286      */ 
    2287     static bool treatAsZeroWidthSpace(UChar c) ; 
    2288  
    2289 #if ENABLE(SVG_FONTS) 
    2290     /** 
    2291      * test if font is SVG font 
    2292      * @param[out] : true or false 
    2293      * @code 
    2294      * bool svgFont = f->isSVGFont(); 
    2295      * @endcode 
    2296      */ 
    2297     bool isSVGFont() const/* 
    2298  * Copyright (C) 2008 Pleyo.  All rights reserved. 
    2299  * 
    2300  * Redistribution and use in source and binary forms, with or without 
    2301  * modification, are permitted provided that the following conditions 
    2302  * are met: 
    2303  * 
    2304  * 1.  Redistributions of source code must retain the above copyright 
    2305  *     notice, this list of conditions and the following disclaimer. 
    2306  * 2.  Redistributions in binary form must reproduce the above copyright 
    2307  *     notice, this list of conditions and the following disclaimer in the 
    2308  *     documentation and/or other materials provided with the distribution. 
    2309  * 3.  Neither the name of Pleyo nor the names of 
    2310  *     its contributors may be used to endorse or promote products derived 
    2311  *     from this software without specific prior written permission. 
    2312  * 
    2313  * THIS SOFTWARE IS PROVIDED BY PLEYO AND ITS CONTRIBUTORS "AS IS" AND ANY 
    2314  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
    2315  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    2316  * DISCLAIMED. IN NO EVENT SHALL PLEYO OR ITS CONTRIBUTORS BE LIABLE FOR ANY 
    2317  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    2318  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    2319  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    2320  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    2321  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    2322  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2323  */ 
    2324 #ifndef Font_h 
    2325 #define Font_h 
    2326 /** 
    2327  *  @file  Font.t 
    2328  *  Font description 
    2329  *  Repository informations : 
    2330  * - $URL$ 
    2331  * - $Rev$ 
    2332  * - $Date$ 
    2333  */ 
    2334 #include "BALBase.h" 
    2335  
    2336 #include "FontDescription.h" 
    2337 #include <wtf/HashMap.h> 
    2338  
    2339  
    2340 namespace WKAL { 
    2341  
    2342 class FloatPoint; 
    2343 class FloatRect; 
    2344 class FontData; 
    2345 class FontFallbackList; 
    2346 class FontPlatformData; 
    2347 class FontSelector; 
    2348 class GlyphBuffer; 
    2349 class GlyphPageTreeNode; 
    2350 class GraphicsContext; 
    2351 class IntPoint; 
    2352 class RenderObject; 
    2353 class SimpleFontData; 
    2354 class SVGFontElement; 
    2355 class SVGPaintServer; 
    2356  
    2357 struct GlyphData; 
    2358  
    2359 class TextRun : public WKALBase { 
    2360 publi 
    2361  
    2362  
    2363     /** 
    2364      *  Font description 
    2365      * @param[in] : description 
    2366      * @param[out] : description 
    2367      * @code 
    2368      * @endcode 
    2369      */ 
    2370     Font(); 
    2371  
    2372  
    2373     /** 
    2374      *  Font description 
    2375      * @param[in] : description 
    2376      * @param[out] : description 
    2377      * @code 
    2378      * @endcode 
    2379      */ 
    2380     Font(const FontDescription&, short letterSpacing, short wordSpacing); 
    2381  
    2382  
    2383     /** 
    2384      *  Font description 
    2385      * @param[in] : description 
    2386      * @param[out] : description 
    2387      * @code 
    2388      * @endcode 
    2389      */ 
    2390     Font(const FontPlatformData&, bool isPrinting); 
    2391  
    2392  
    2393     /** 
    2394      *  ~Font description 
    2395      * @param[in] : description 
    2396      * @param[out] : description 
    2397      * @code 
    2398      * @endcode 
    2399      */ 
    2400     ~Font(); 
    2401  
    2402  
    2403     /** 
    2404      *  Font description 
    2405      * @param[in] : description 
    2406      * @param[out] : description 
    2407      * @code 
    2408      * @endcode 
    2409      */ 
    2410     Font(const Font&); 
    2411  
    2412  
    2413     /** 
    2414      *  operator= description 
    2415      * @param[in] : description 
    2416      * @param[out] : description 
    2417      * @code 
    2418      * @endcode 
    2419      */ 
    2420     Font& operator=(const Font&); 
    2421  
    2422  
    2423     /** 
    2424      *  operator== description 
    2425      * @param[in] : description 
    2426      * @param[out] : description 
    2427      * @code 
    2428      * @endcode 
    2429      */ 
    2430     bool operator==(const Font& other) const; 
    2431  
    2432  
    2433     /** 
    2434      *  operator!= description 
    2435      * @param[in] : description 
    2436      * @param[out] : description 
    2437      * @code 
    2438      * @endcode 
    2439      */ 
    2440     bool operator!=(const Font& other) const ; 
    2441  
    2442  
    2443     /** 
    2444      *  fontDescription description 
    2445      * @param[in] : description 
    2446      * @param[out] : description 
    2447      * @code 
    2448      * @endcode 
    2449      */ 
    2450     const FontDescription& fontDescription() const ; 
    2451  
    2452  
    2453     /** 
    2454      *  pixelSize description 
    2455      * @param[in] : description 
    2456      * @param[out] : description 
    2457      * @code 
    2458      * @endcode 
    2459      */ 
    2460     int pixelSize() const ; 
    2461  
    2462  
    2463     /** 
    2464      *  size description 
    2465      * @param[in] : description 
    2466      * @param[out] : description 
    2467      * @code 
    2468      * @endcode 
    2469      */ 
    2470     float size() const ; 
    2471  
    2472  
    2473     /** 
    2474      *  update description 
    2475      * @param[in] : description 
    2476      * @param[out] : description 
    2477      * @code 
    2478      * @endcode 
    2479      */ 
    2480     void update(PassRefPtr<FontSelector>) const; 
    2481  
    2482  
    2483     /** 
    2484      *  drawText description 
    2485      * @param[in] : description 
    2486      * @param[out] : description 
    2487      * @code 
    2488      * @endcode 
    2489      */ 
    2490     void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; 
    2491  
    2492  
    2493     /** 
    2494      *  width description 
    2495      * @param[in] : description 
    2496      * @param[out] : description 
    2497      * @code 
    2498      * @endcode 
    2499      */ 
    2500     int width(const TextRun&) const; 
    2501  
    2502  
    2503     /** 
    2504      *  floatWidth description 
    2505      * @param[in] : description 
    2506      * @param[out] : description 
    2507      * @code 
    2508      * @endcode 
    2509      */ 
    2510     float floatWidth(const TextRun&) const; 
    2511  
    2512  
    2513     /** 
    2514      *  floatWidth description 
    2515      * @param[in] : description 
    2516      * @param[out] : description 
    2517      * @code 
    2518      * @endcode 
    2519      */ 
    2520     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    2521  
    2522  
    2523     /** 
    2524      *  offsetForPosition description 
    2525      * @param[in] : description 
    2526      * @param[out] : description 
    2527      * @code 
    2528      * @endcode 
    2529      */ 
    2530     int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; 
    2531  
    2532  
    2533     /** 
    2534      *  selectionRectForText description 
    2535      * @param[in] : description 
    2536      * @param[out] : description 
    2537      * @code 
    2538      * @endcode 
    2539      */ 
    2540     FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const; 
    2541  
    2542  
    2543     /** 
    2544      *  isSmallCaps description 
    2545      * @param[in] : description 
    2546      * @param[out] : description 
    2547      * @code 
    2548      * @endcode 
    2549      */ 
    2550     bool isSmallCaps() const ; 
    2551  
    2552  
    2553     /** 
    2554      *  wordSpacing description 
    2555      * @param[in] : description 
    2556      * @param[out] : description 
    2557      * @code 
    2558      * @endcode 
    2559      */ 
    2560     short wordSpacing() const ; 
    2561  
    2562  
    2563     /** 
    2564      *  letterSpacing description 
    2565      * @param[in] : description 
    2566      * @param[out] : description 
    2567      * @code 
    2568      * @endcode 
    2569      */ 
    2570     short letterSpacing() const ; 
    2571  
    2572  
    2573     /** 
    2574      *  setWordSpacing description 
    2575      * @param[in] : description 
    2576      * @param[out] : description 
    2577      * @code 
    2578      * @endcode 
    2579      */ 
    2580     void setWordSpacing(short s) ; 
    2581  
    2582  
    2583     /** 
    2584      *  setLetterSpacing description 
    2585      * @param[in] : description 
    2586      * @param[out] : description 
    2587      * @code 
    2588      * @endcode 
    2589      */ 
    2590     void setLetterSpacing(short s)  
    2591  
    2592 #if ENABLE(SVG_FONT 
    2593  
    2594     /** 
    2595      * set referencing RenderObject 
    2596      * @param[in] : RenderObject 
    2597      * @code 
    2598      * textRun->setReferencingRenderObject(rObj); 
    2599      * @endcode 
    2600      */ 
    2601     void setReferencingRenderObject(RenderObject* object)  
    2602  
    2603     /** 
    2604      * set active paint server 
    2605      * @param[in] : SVGPaintServer 
    2606      * @code 
    2607      * textRun->setActivePaintServer(sps); 
    2608      * @endcode 
    2609      */ 
    2610     void setActivePaintServer(SVGPaintServer* object) ; 
    2611 #endif 
    2612  
    2613 private: 
    2614     const UChar* m_characters; 
    2615     int m_len; 
    2616  
    2617     bool m_allowTabs; 
    2618     int m_xpos; 
    2619     int m_padding; 
    2620     bool m_rtl; 
    2621     bool m_directionalOverride; 
    2622     bool m_applyRunRounding; 
    2623     bool m_applyWordRounding; 
    2624     bool m_disableSpacing; 
    2625  
    2626 #if ENABLE(SVG_FONTS) 
    2627     RenderObject* m_referencingRenderObject; 
    2628     SVGPaintServer* m_activePaintServer; 
    2629 #endif 
    2630 }; 
    2631  
    2632 class Font : public WKALBase { 
    2633 publi 
    2634  
    2635     /** 
    2636      * Font constructor 
    2637      * @param[in] : FontDescription 
    2638      * @param[in] : letter spacing 
    2639      * @param[in] : word spacing 
    2640      * @code 
    2641      * Font *f = new Font(fd, 12, 12 ); 
    2642      * @endcode 
    2643      */ 
    2644     Font(const FontDescription&, short letterSpacing, short wordSpacing) // This constructor is only used if the platform wants to start with a native font. 
    2645  
    2646     /** 
    2647      * ~Font destructor 
    2648      * @code 
    2649      * delete font; 
    2650      * @endcode 
    2651      */ 
    2652     ~Font() 
    2653  
    2654     /** 
    2655      * operator= 
    2656      * @param[in] : Font 
    2657      * @param[out] : Font 
    2658      * @code 
    2659      * Font f = currentFont; 
    2660      * @endcode 
    2661      */ 
    2662     Font& operator=(const Font&) 
    2663  
    2664     /** 
    2665      * operator!=  
    2666      * @param[in] : Font 
    2667      * @param[out] : return true if the fonts are different 
    2668      * @code 
    2669      * bool d = f != currentFont; 
    2670      * @endcode 
    2671      */ 
    2672     bool operator!=(const Font& other) const  
    2673  
    2674     /** 
    2675      * get font pixel size 
    2676      * @param[out] : pixel size 
    2677      * @code 
    2678      * int ps = f->pixelSize(); 
    2679      * @endcode 
    2680      */ 
    2681     int pixelSize() const  
    2682  
    2683     /** 
    2684      * update font 
    2685      * @param[in] : FontSelector 
    2686      * @code 
    2687      * f->update(fontSelector); 
    2688      * @endcode 
    2689      */ 
    2690     void update(PassRefPtr<FontSelector>) cons 
    2691  
    2692     /** 
    2693      * test if the font is printer 
    2694      * @param[out] : true if the font is printer 
    2695      * @code 
    2696      * bool pf = f->isPrinterFont(); 
    2697      * @endcode 
    2698      */ 
    2699     bool isPrinterFont() const ; 
    2700      
    2701     /** 
    2702      * get the font rendering mode 
    2703      * @param[out] : font rendering mode 
    2704      * @code 
    2705      * FontRenderingMode frm = f->renderingMode(); 
    2706      * @endcode 
    2707      */ 
    2708     FontRenderingMode renderingMode() const ; 
    2709  
    2710     /** 
    2711      * get first font family 
    2712      * @param[out] : font family 
    2713      * @code 
    2714      * FontFamily ff = f->firstFamily(); 
    2715      * @endcode 
    2716      */ 
    2717     FontFamily& firstFamily() ; 
    2718  
    2719     /** 
    2720      * get font family 
    2721      * @param[out] : font family 
    2722      * @code 
    2723      * FontFamily ff = f->family(); 
    2724      * @endcode 
    2725      */ 
    2726     const FontFamily& family() const ; 
    2727  
    2728     /** 
    2729      * get the italic status 
    2730      * @param[out] : italic status 
    2731      * @code 
    2732      * bool it = f->italic(); 
    2733      * @endcode 
    2734      */ 
    2735     bool italic() const ; 
    2736  
    2737     /** 
    2738      * get the font weight 
    2739      * @param[out] : font weight 
    2740      * @code 
    2741      * FontWeight fw = f->weight(); 
    2742      * @endcode 
    2743      */ 
    2744     FontWeight weight() const ; 
    2745  
    2746     /** 
    2747      * get it's a platform font 
    2748      * @param[out] : true if it's a platform font 
    2749      * @code 
    2750      * bool pf = f->isPlatformFont(); 
    2751      * @endcode 
    2752      */ 
    2753     bool isPlatformFont() const ; 
    2754  
    2755  
    2756     // Metrics that we query the FontFallbackList for. 
    2757     /** 
    2758      * get ascent value 
    2759      * @param[out] : ascent value 
    2760      * @code 
    2761      * int a = f->ascent(); 
    2762      * @endcode 
    2763      */ 
    2764     int ascent() const; 
    2765  
    2766     /** 
    2767      * get descent value 
    2768      * @param[out] : descent value 
    2769      * @code 
    2770      * int d = f->descent(); 
    2771      * @endcode 
    2772      */ 
    2773     int descent() const; 
    2774  
    2775     /** 
    2776      * get height value 
    2777      * @param[out] : height value 
    2778      * @code 
    2779      * int h = f->height(); 
    2780      * @endcode 
    2781      */ 
    2782     int height() const ; 
    2783  
    2784     /** 
    2785      * get lineSpacing value 
    2786      * @param[out] : lineSpacing value 
    2787      * @code 
    2788      * int ls = f->lineSpacing(); 
    2789      * @endcode 
    2790      */ 
    2791     int lineSpacing() const; 
    2792  
    2793     /** 
    2794      * get xHeight value 
    2795      * @param[out] : xHeight value 
    2796      * @code 
    2797      * float x = f->xHeight(); 
    2798      * @endcode 
    2799      */ 
    2800     float xHeight() const; 
    2801  
    2802     /** 
    2803      * get unitsPerEm value 
    2804      * @param[out] : untiPerEm value 
    2805      * @code 
    2806      * unsigned u = f->unitsPerEm(); 
    2807      * @endcode 
    2808      */ 
    2809     unsigned unitsPerEm() const; 
    2810  
    2811     /** 
    2812      * get spaceWidth value 
    2813      * @param[out] : spaceWidth value 
    2814      * @code 
    2815      * int sw = f->spaceWidth(); 
    2816      * @endcode 
    2817      */ 
    2818     int spaceWidth() const; 
    2819  
    2820     /** 
    2821      * get tabWidth value 
    2822      * @param[out] : tabWidth value 
    2823      * @code 
    2824      * int tw = f->tabWidth(); 
    2825      * @endcode 
    2826      */ 
    2827     int tabWidth() const ; 
    2828  
    2829     /** 
    2830      * get primary font value 
    2831      * @param[out] : primary font 
    2832      * @code 
    2833      * SimpleFontData *sfd = f->primaryFont(); 
    2834      * @endcode 
    2835      */ 
    2836     const SimpleFontData* primaryFont() const ; 
    2837  
    2838     /** 
    2839      * get fontData value at position 
    2840      * @param[in] : position value 
    2841      * @param[out] : font data 
    2842      * @code 
    2843      * FontData *fd = f->fontDataAt(0); 
    2844      * @endcode 
    2845      */ 
    2846     const FontData* fontDataAt(unsigned) const; 
    2847  
    2848     /** 
    2849      * get  glyph data for a character 
    2850      * @param[in] : character 
    2851      * @param[in] : mirror 
    2852      * @param[in] : force small caps 
    2853      * @param[out] : glyph data 
    2854      * @code 
    2855      * GlyphData gd = f->glyphDataForCharacter(c, false); 
    2856      * @endcode 
    2857      */ 
    2858     const GlyphData& glyphDataForCharacter(UChar32, bool mirror, bool forceSmallCaps = false) const; 
    2859     // Used for complex text, and does not utilize the glyph map cache. 
    2860     /** 
    2861      * get font data for a characters 
    2862      * @param[in] : characters 
    2863      * @param[in] : length 
    2864      * @param[out] : font data 
    2865      * @code 
    2866      * FontData *fd = f->fontDataForCharacters(c, 12); 
    2867      * @endcode 
    2868      */ 
    2869     const FontData* fontDataForCharacters(const UChar*, int length) const; 
    2870  
    2871 private: 
    2872     /** 
    2873      * test if you can use glyph cache 
    2874      * @param[in] : TextRun 
    2875      * @param[out] : true if you can 
    2876      * @code 
    2877      * bool u = f->canUseGlyphCache(textRun); 
    2878      * @endcode 
    2879      */ 
    2880     bool canUseGlyphCache(const TextRun&) const; 
    2881  
    2882     /** 
    2883      * draw simple text 
    2884      * @param[in] : graphics context 
    2885      * @param[in] : textRun 
    2886      * @param[in] : start point 
    2887      * @param[in] : start glyph range 
    2888      * @param[in] : end glyph range 
    2889      * @code 
    2890      * f->drawSimpleText(gc, textRun, FloatPoint(0,0), 0, 12); 
    2891      * @endcode 
    2892      */ 
    2893     void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    2894 #if ENABLE(SVG_FONTS) 
    2895     /** 
    2896      * draw text using SVG font 
    2897      * @param[in] : graphics contect 
    2898      * @param[in] : textRun 
    2899      * @param[in] : start point 
    2900      * @param[in] : start glyph range 
    2901      * @param[in] : end glyph range 
    2902      * @code 
    2903      * f->drawTextUsingSVGFont(gc, textRun, FloatPoint(0,0), 0, 12); 
    2904      * @endcode 
    2905      */ 
    2906     void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    2907  
    2908     /** 
    2909      * get float width using SVG font  
    2910      * @param[in] : textRun 
    2911      * @param[out] : float width 
    2912      * @code 
    2913      * float w = f->floatWidthUsingSVGFont(textRun); 
    2914      * @endcode 
    2915      */ 
    2916     float floatWidthUsingSVGFont(const TextRun&) const; 
    2917  
    2918     /** 
    2919      * get float width using SVG font  
    2920      * @param[in] : textRun 
    2921      * @param[in] : extra char available 
    2922      * @param[in] : character consumed 
    2923      * @param[in] : glyph name 
    2924      * @param[out] : float width 
    2925      * @code 
    2926      * float w = f->floatWidthUsingSVGFont(textRun, 0, chars, glyphName); 
    2927      * @endcode 
    2928      */ 
    2929     float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    2930  
    2931     /** 
    2932      * get  selection rect for text using SVG font 
    2933      * @param[in] : textRun 
    2934      * @param[in] : start point 
    2935      * @param[in] : heigth 
    2936      * @param[in] : start glyph range 
    2937      * @param[in] : end glyph range 
    2938      * @param[out] : float rect 
    2939      * @code 
    2940      * FloatRect r = selectionRectForTextUsingSVGFont(textRun, IntPoint(0, 0), 10, 0, 12); 
    2941      * @endcode 
    2942      */ 
    2943     FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    2944  
    2945     /** 
    2946      * get offset for a position for a text using SVG font 
    2947      * @param[in] : textRun 
    2948      * @param[in] : position 
    2949      * @param[in] : include partial glyphs 
    2950      * @param[out] : offset 
    2951      * @code 
    2952      * int o = f->offsetForPositionForTextUsingSVGFont(textRun, 0, true); 
    2953      * @endcode 
    2954      */ 
    2955     int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const; 
    2956 #endif 
    2957     /** 
    2958      * draw glyphs 
    2959      * @param[in] : graphics context 
    2960      * @param[in] : font data 
    2961      * @param[in] : glyph buffer 
    2962      * @param[in] : start glyph range 
    2963      * @param[in] : end glyph range 
    2964      * @param[in] : start point 
    2965      * @code 
    2966      * f->drawGlyphs(gc, s, g, 0, 12, FloatPoint(0,0)); 
    2967      * @endcode 
    2968      */ 
    2969     void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const; 
    2970  
    2971     /** 
    2972      * draw glyph buffer  
    2973      * @param[in] : graphics context 
    2974      * @param[in] : glyph buffer 
    2975      * @param[in] : textRun 
    2976      * @param[in] : start point 
    2977      * @code 
    2978      * f->drawGlyphBuffer(gc, gb, textRun, FloatPoint(0,0)); 
    2979      * @endcode 
    2980      */ 
    2981     void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const; 
    2982  
    2983     /** 
    2984      * draw complex text  
    2985      * @param[in] : graphics context 
    2986      * @param[in] : textRun 
    2987      * @param[in] : start point 
    2988      * @param[in] : start glyph range 
    2989      * @param[in] : end glyph range 
    2990      * @code 
    2991      * f->drawComplexText(gc, textRun, FloatPoint(0,0), 0, 12); 
    2992      * @endcode 
    2993      */ 
    2994     void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    2995  
    2996     /** 
    2997      * get float width for a simple text 
    2998      * @param[in] : textRun 
    2999      * @param[in] : glyph buffer 
    3000      * @param[out] : float width 
    3001      * @code 
    3002      * float w = f->floatWidthForSimpleText(textRun, gb); 
    3003      * @endcode 
    3004      */ 
    3005     float floatWidthForSimpleText(const TextRun&, GlyphBuffer*) const; 
    3006  
    3007     /** 
    3008      * get float width for complex text 
    3009      * @param[in] : textRun 
    3010      * @param[out] : float width 
    3011      * @code 
    3012      * float w = f->floatWidthForComplexText(textRun); 
    3013      * @endcode 
    3014      */ 
    3015     float floatWidthForComplexText(const TextRun&) const; 
    3016  
    3017     /** 
    3018      * get offset for a position for a simple text 
    3019      * @param[in] : textRun 
    3020      * @param[in] : position 
    3021      * @param[in] : include partial glyphs 
    3022      * @param[out] : offset 
    3023      * @code 
    3024      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    3025      * @endcode 
    3026      */ 
    3027     int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const; 
    3028  
    3029     /** 
    3030      * get offset for a position for a complex text 
    3031      * @param[in] : textRun 
    3032      * @param[in] : position 
    3033      * @param[in] : include partial glyphs 
    3034      * @param[out] : offset 
    3035      * @code 
    3036      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    3037      * @endcode 
    3038      */ 
    3039     int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const; 
    3040  
    3041     /** 
    3042      * get selection rect for a simple text 
    3043      * @param[in] : textRun 
    3044      * @param[in] : start point 
    3045      * @param[in] : height 
    3046      * @param[in] : start glyph range 
    3047      * @param[in] : end glyph range 
    3048      * @param[out] : float rect 
    3049      * @code 
    3050      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    3051      * @endcode 
    3052      */ 
    3053     FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    3054  
    3055     /** 
    3056      * get selection rect for a complex text 
    3057      * @param[in] : textRun 
    3058      * @param[in] : start point 
    3059      * @param[in] : height 
    3060      * @param[in] : start glyph range 
    3061      * @param[in] : end glyph range 
    3062      * @param[out] : float rect 
    3063      * @code 
    3064      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    3065      * @endcode 
    3066      */ 
    3067     FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    3068      
    3069  
    3070     /** 
    3071      * cache primary font 
    3072      * @code 
    3073      * f->cachePrimaryFont(); 
    3074      * @endcode 
    3075      */ 
    3076     void cachePrimaryFont() const; 
    3077      
    3078     friend struct WidthIterator; 
    3079  
    3080     // Useful for debugging the different font rendering code paths. 
    3081 public: 
    3082     enum CodePath { Auto, Simple, Complex }; 
    3083     /** 
    3084      * set code path 
    3085      * @param[in] : code path 
    3086      * @code 
    3087      * f->setCodePath(Auto); 
    3088      * @endcode 
    3089      */ 
    3090     static void setCodePath(CodePath); 
    3091     static CodePath codePath; 
    3092  
    3093     static const uint8_t gRoundingHackCharacterTable[256]; 
    3094     /** 
    3095      * get is rounding hack character 
    3096      * @param[in] : character 
    3097      * @param[out] : true or false 
    3098      * @code 
    3099      * bool r = f->isRoundingHackCharacter(c); 
    3100      * @endcode 
    3101      */ 
    3102     static bool isRoundingHackCharacter(UChar32 c); 
    3103  
    3104     /** 
    3105      * get fontSelector  
    3106      * @param[out] : font selector 
    3107      * @code 
    3108      * FontSelector *fs = f->fontSelector(); 
    3109      * @endcode 
    3110      */ 
    3111     FontSelector* fontSelector() const; 
    3112  
    3113     /** 
    3114      * test if font treat character as space 
    3115      * @param[in] : character 
    3116      * @param[out] : true or false 
    3117      * @code 
    3118      * bool t = f->treatAsSpace(c); 
    3119      * @endcode 
    3120      */ 
    3121     static bool treatAsSpace(UChar c) ; 
    3122  
    3123     /** 
    3124      * test if font treat character as zero width space 
    3125      * @param[in] : character 
    3126      * @param[out] : true or false 
    3127      * @code 
    3128      * bool t = f->treatAsZeroWidthSpace(c); 
    3129      * @endcode 
    3130      */ 
    3131     static bool treatAsZeroWidthSpace(UChar c) ; 
    3132  
    3133 #if ENABLE(SVG_FONTS) 
    3134     /** 
    3135      * test if font is SVG font 
    3136      * @param[out] : true or false 
    3137      * @code 
    3138      * bool svgFont = f->isSVGFont(); 
    3139      * @endcode 
    3140      */ 
    3141     bool isSVGFont() const/* 
    3142  * Copyright (C) 2008 Pleyo.  All rights reserved. 
    3143  * 
    3144  * Redistribution and use in source and binary forms, with or without 
    3145  * modification, are permitted provided that the following conditions 
    3146  * are met: 
    3147  * 
    3148  * 1.  Redistributions of source code must retain the above copyright 
    3149  *     notice, this list of conditions and the following disclaimer. 
    3150  * 2.  Redistributions in binary form must reproduce the above copyright 
    3151  *     notice, this list of conditions and the following disclaimer in the 
    3152  *     documentation and/or other materials provided with the distribution. 
    3153  * 3.  Neither the name of Pleyo nor the names of 
    3154  *     its contributors may be used to endorse or promote products derived 
    3155  *     from this software without specific prior written permission. 
    3156  * 
    3157  * THIS SOFTWARE IS PROVIDED BY PLEYO AND ITS CONTRIBUTORS "AS IS" AND ANY 
    3158  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
    3159  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    3160  * DISCLAIMED. IN NO EVENT SHALL PLEYO OR ITS CONTRIBUTORS BE LIABLE FOR ANY 
    3161  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    3162  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    3163  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    3164  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    3165  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3166  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3167  */ 
    3168 #ifndef Font_h 
    3169 #define Font_h 
    3170 /** 
    3171  *  @file  Font.t 
    3172  *  Font description 
    3173  *  Repository informations : 
    3174  * - $URL$ 
    3175  * - $Rev$ 
    3176  * - $Date$ 
    3177  */ 
    3178 #include "BALBase.h" 
    3179  
    3180 #include "FontDescription.h" 
    3181 #include <wtf/HashMap.h> 
    3182  
    3183  
    3184 namespace WKAL { 
    3185  
    3186 class FloatPoint; 
    3187 class FloatRect; 
    3188 class FontData; 
    3189 class FontFallbackList; 
    3190 class FontPlatformData; 
    3191 class FontSelector; 
    3192 class GlyphBuffer; 
    3193 class GlyphPageTreeNode; 
    3194 class GraphicsContext; 
    3195 class IntPoint; 
    3196 class RenderObject; 
    3197 class SimpleFontData; 
    3198 class SVGFontElement; 
    3199 class SVGPaintServer; 
    3200  
    3201 struct GlyphData; 
    3202  
    3203 class TextRun : public WKALBase { 
    3204 publi 
    3205  
    3206  
    3207     /** 
    3208      *  Font description 
    3209      * @param[in] : description 
    3210      * @param[out] : description 
    3211      * @code 
    3212      * @endcode 
    3213      */ 
    3214     Font(); 
    3215  
    3216  
    3217     /** 
    3218      *  Font description 
    3219      * @param[in] : description 
    3220      * @param[out] : description 
    3221      * @code 
    3222      * @endcode 
    3223      */ 
    3224     Font(const FontDescription&, short letterSpacing, short wordSpacing); 
    3225  
    3226  
    3227     /** 
    3228      *  Font description 
    3229      * @param[in] : description 
    3230      * @param[out] : description 
    3231      * @code 
    3232      * @endcode 
    3233      */ 
    3234     Font(const FontPlatformData&, bool isPrinting); 
    3235  
    3236  
    3237     /** 
    3238      *  ~Font description 
    3239      * @param[in] : description 
    3240      * @param[out] : description 
    3241      * @code 
    3242      * @endcode 
    3243      */ 
    3244     ~Font(); 
    3245  
    3246  
    3247     /** 
    3248      *  Font description 
    3249      * @param[in] : description 
    3250      * @param[out] : description 
    3251      * @code 
    3252      * @endcode 
    3253      */ 
    3254     Font(const Font&); 
    3255  
    3256  
    3257     /** 
    3258      *  operator= description 
    3259      * @param[in] : description 
    3260      * @param[out] : description 
    3261      * @code 
    3262      * @endcode 
    3263      */ 
    3264     Font& operator=(const Font&); 
    3265  
    3266  
    3267     /** 
    3268      *  operator== description 
    3269      * @param[in] : description 
    3270      * @param[out] : description 
    3271      * @code 
    3272      * @endcode 
    3273      */ 
    3274     bool operator==(const Font& other) const; 
    3275  
    3276  
    3277     /** 
    3278      *  operator!= description 
    3279      * @param[in] : description 
    3280      * @param[out] : description 
    3281      * @code 
    3282      * @endcode 
    3283      */ 
    3284     bool operator!=(const Font& other) const ; 
    3285  
    3286  
    3287     /** 
    3288      *  fontDescription description 
    3289      * @param[in] : description 
    3290      * @param[out] : description 
    3291      * @code 
    3292      * @endcode 
    3293      */ 
    3294     const FontDescription& fontDescription() const ; 
    3295  
    3296  
    3297     /** 
    3298      *  pixelSize description 
    3299      * @param[in] : description 
    3300      * @param[out] : description 
    3301      * @code 
    3302      * @endcode 
    3303      */ 
    3304     int pixelSize() const ; 
    3305  
    3306  
    3307     /** 
    3308      *  size description 
    3309      * @param[in] : description 
    3310      * @param[out] : description 
    3311      * @code 
    3312      * @endcode 
    3313      */ 
    3314     float size() const ; 
    3315  
    3316  
    3317     /** 
    3318      *  update description 
    3319      * @param[in] : description 
    3320      * @param[out] : description 
    3321      * @code 
    3322      * @endcode 
    3323      */ 
    3324     void update(PassRefPtr<FontSelector>) const; 
    3325  
    3326  
    3327     /** 
    3328      *  drawText description 
    3329      * @param[in] : description 
    3330      * @param[out] : description 
    3331      * @code 
    3332      * @endcode 
    3333      */ 
    3334     void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; 
    3335  
    3336  
    3337     /** 
    3338      *  width description 
    3339      * @param[in] : description 
    3340      * @param[out] : description 
    3341      * @code 
    3342      * @endcode 
    3343      */ 
    3344     int width(const TextRun&) const; 
    3345  
    3346  
    3347     /** 
    3348      *  floatWidth description 
    3349      * @param[in] : description 
    3350      * @param[out] : description 
    3351      * @code 
    3352      * @endcode 
    3353      */ 
    3354     float floatWidth(const TextRun&) const; 
    3355  
    3356  
    3357     /** 
    3358      *  floatWidth description 
    3359      * @param[in] : description 
    3360      * @param[out] : description 
    3361      * @code 
    3362      * @endcode 
    3363      */ 
    3364     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    3365  
    3366  
    3367     /** 
    3368      *  offsetForPosition description 
    3369      * @param[in] : description 
    3370      * @param[out] : description 
    3371      * @code 
    3372      * @endcode 
    3373      */ 
    3374     int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; 
    3375  
    3376  
    3377     /** 
    3378      *  selectionRectForText description 
    3379      * @param[in] : description 
    3380      * @param[out] : description 
    3381      * @code 
    3382      * @endcode 
    3383      */ 
    3384     FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const; 
    3385  
    3386  
    3387     /** 
    3388      *  isSmallCaps description 
    3389      * @param[in] : description 
    3390      * @param[out] : description 
    3391      * @code 
    3392      * @endcode 
    3393      */ 
    3394     bool isSmallCaps() const ; 
    3395  
    3396  
    3397     /** 
    3398      *  wordSpacing description 
    3399      * @param[in] : description 
    3400      * @param[out] : description 
    3401      * @code 
    3402      * @endcode 
    3403      */ 
    3404     short wordSpacing() const ; 
    3405  
    3406  
    3407     /** 
    3408      *  letterSpacing description 
    3409      * @param[in] : description 
    3410      * @param[out] : description 
    3411      * @code 
    3412      * @endcode 
    3413      */ 
    3414     short letterSpacing() const ; 
    3415  
    3416  
    3417     /** 
    3418      *  setWordSpacing description 
    3419      * @param[in] : description 
    3420      * @param[out] : description 
    3421      * @code 
    3422      * @endcode 
    3423      */ 
    3424     void setWordSpacing(short s) ; 
    3425  
    3426  
    3427     /** 
    3428      *  setLetterSpacing description 
    3429      * @param[in] : description 
    3430      * @param[out] : description 
    3431      * @code 
    3432      * @endcode 
    3433      */ 
    3434     void setLetterSpacing(short s)  
    3435  
    3436 #if ENABLE(SVG_FONT 
    3437  
    3438     /** 
    3439      * set referencing RenderObject 
    3440      * @param[in] : RenderObject 
    3441      * @code 
    3442      * textRun->setReferencingRenderObject(rObj); 
    3443      * @endcode 
    3444      */ 
    3445     void setReferencingRenderObject(RenderObject* object)  
    3446  
    3447     /** 
    3448      * set active paint server 
    3449      * @param[in] : SVGPaintServer 
    3450      * @code 
    3451      * textRun->setActivePaintServer(sps); 
    3452      * @endcode 
    3453      */ 
    3454     void setActivePaintServer(SVGPaintServer* object) ; 
    3455 #endif 
    3456  
    3457 private: 
    3458     const UChar* m_characters; 
    3459     int m_len; 
    3460  
    3461     bool m_allowTabs; 
    3462     int m_xpos; 
    3463     int m_padding; 
    3464     bool m_rtl; 
    3465     bool m_directionalOverride; 
    3466     bool m_applyRunRounding; 
    3467     bool m_applyWordRounding; 
    3468     bool m_disableSpacing; 
    3469  
    3470 #if ENABLE(SVG_FONTS) 
    3471     RenderObject* m_referencingRenderObject; 
    3472     SVGPaintServer* m_activePaintServer; 
    3473 #endif 
    3474 }; 
    3475  
    3476 class Font : public WKALBase { 
    3477 publi 
    3478  
    3479     /** 
    3480      * Font constructor 
    3481      * @param[in] : FontDescription 
    3482      * @param[in] : letter spacing 
    3483      * @param[in] : word spacing 
    3484      * @code 
    3485      * Font *f = new Font(fd, 12, 12 ); 
    3486      * @endcode 
    3487      */ 
    3488     Font(const FontDescription&, short letterSpacing, short wordSpacing) // This constructor is only used if the platform wants to start with a native font. 
    3489  
    3490     /** 
    3491      * ~Font destructor 
    3492      * @code 
    3493      * delete font; 
    3494      * @endcode 
    3495      */ 
    3496     ~Font() 
    3497  
    3498     /** 
    3499      * operator= 
    3500      * @param[in] : Font 
    3501      * @param[out] : Font 
    3502      * @code 
    3503      * Font f = currentFont; 
    3504      * @endcode 
    3505      */ 
    3506     Font& operator=(const Font&) 
    3507  
    3508     /** 
    3509      * operator!=  
    3510      * @param[in] : Font 
    3511      * @param[out] : return true if the fonts are different 
    3512      * @code 
    3513      * bool d = f != currentFont; 
    3514      * @endcode 
    3515      */ 
    3516     bool operator!=(const Font& other) const  
    3517  
    3518     /** 
    3519      * get font pixel size 
    3520      * @param[out] : pixel size 
    3521      * @code 
    3522      * int ps = f->pixelSize(); 
    3523      * @endcode 
    3524      */ 
    3525     int pixelSize() const  
    3526  
    3527     /** 
    3528      * update font 
    3529      * @param[in] : FontSelector 
    3530      * @code 
    3531      * f->update(fontSelector); 
    3532      * @endcode 
    3533      */ 
    3534     void update(PassRefPtr<FontSelector>) const 
    3535  
    3536     /** 
    3537      * return font width 
    3538      * @param[in] : TextRun 
    3539      * @param[out] : width 
    3540      * @code 
    3541      * int w = f->width(textRun); 
    3542      * @endcode 
    3543      */ 
    3544     int width(const TextRun&) const 
    3545  
    3546     /** 
    3547      * return float width 
    3548      * @param[in] : TextRun 
    3549      * @param[in] : extra chars available 
    3550      * @param[in] : chars consumed 
    3551      * @param[in] : glyph name 
    3552      * @param[out] : float width 
    3553      * @code 
    3554      * float w = f->floatWidth(textRun, 0, chars, name); 
    3555      * @endcode 
    3556      */ 
    3557     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) cons 
    3558  
    3559     /** 
    3560      * test if the font is printer 
    3561      * @param[out] : true if the font is printer 
    3562      * @code 
    3563      * bool pf = f->isPrinterFont(); 
    3564      * @endcode 
    3565      */ 
    3566     bool isPrinterFont() const ; 
    3567      
    3568     /** 
    3569      * get the font rendering mode 
    3570      * @param[out] : font rendering mode 
    3571      * @code 
    3572      * FontRenderingMode frm = f->renderingMode(); 
    3573      * @endcode 
    3574      */ 
    3575     FontRenderingMode renderingMode() const ; 
    3576  
    3577     /** 
    3578      * get first font family 
    3579      * @param[out] : font family 
    3580      * @code 
    3581      * FontFamily ff = f->firstFamily(); 
    3582      * @endcode 
    3583      */ 
    3584     FontFamily& firstFamily() ; 
    3585  
    3586     /** 
    3587      * get font family 
    3588      * @param[out] : font family 
    3589      * @code 
    3590      * FontFamily ff = f->family(); 
    3591      * @endcode 
    3592      */ 
    3593     const FontFamily& family() const ; 
    3594  
    3595     /** 
    3596      * get the italic status 
    3597      * @param[out] : italic status 
    3598      * @code 
    3599      * bool it = f->italic(); 
    3600      * @endcode 
    3601      */ 
    3602     bool italic() const ; 
    3603  
    3604     /** 
    3605      * get the font weight 
    3606      * @param[out] : font weight 
    3607      * @code 
    3608      * FontWeight fw = f->weight(); 
    3609      * @endcode 
    3610      */ 
    3611     FontWeight weight() const ; 
    3612  
    3613     /** 
    3614      * get it's a platform font 
    3615      * @param[out] : true if it's a platform font 
    3616      * @code 
    3617      * bool pf = f->isPlatformFont(); 
    3618      * @endcode 
    3619      */ 
    3620     bool isPlatformFont() const ; 
    3621  
    3622  
    3623     // Metrics that we query the FontFallbackList for. 
    3624     /** 
    3625      * get ascent value 
    3626      * @param[out] : ascent value 
    3627      * @code 
    3628      * int a = f->ascent(); 
    3629      * @endcode 
    3630      */ 
    3631     int ascent() const; 
    3632  
    3633     /** 
    3634      * get descent value 
    3635      * @param[out] : descent value 
    3636      * @code 
    3637      * int d = f->descent(); 
    3638      * @endcode 
    3639      */ 
    3640     int descent() const; 
    3641  
    3642     /** 
    3643      * get height value 
    3644      * @param[out] : height value 
    3645      * @code 
    3646      * int h = f->height(); 
    3647      * @endcode 
    3648      */ 
    3649     int height() const ; 
    3650  
    3651     /** 
    3652      * get lineSpacing value 
    3653      * @param[out] : lineSpacing value 
    3654      * @code 
    3655      * int ls = f->lineSpacing(); 
    3656      * @endcode 
    3657      */ 
    3658     int lineSpacing() const; 
    3659  
    3660     /** 
    3661      * get xHeight value 
    3662      * @param[out] : xHeight value 
    3663      * @code 
    3664      * float x = f->xHeight(); 
    3665      * @endcode 
    3666      */ 
    3667     float xHeight() const; 
    3668  
    3669     /** 
    3670      * get unitsPerEm value 
    3671      * @param[out] : untiPerEm value 
    3672      * @code 
    3673      * unsigned u = f->unitsPerEm(); 
    3674      * @endcode 
    3675      */ 
    3676     unsigned unitsPerEm() const; 
    3677  
    3678     /** 
    3679      * get spaceWidth value 
    3680      * @param[out] : spaceWidth value 
    3681      * @code 
    3682      * int sw = f->spaceWidth(); 
    3683      * @endcode 
    3684      */ 
    3685     int spaceWidth() const; 
    3686  
    3687     /** 
    3688      * get tabWidth value 
    3689      * @param[out] : tabWidth value 
    3690      * @code 
    3691      * int tw = f->tabWidth(); 
    3692      * @endcode 
    3693      */ 
    3694     int tabWidth() const ; 
    3695  
    3696     /** 
    3697      * get primary font value 
    3698      * @param[out] : primary font 
    3699      * @code 
    3700      * SimpleFontData *sfd = f->primaryFont(); 
    3701      * @endcode 
    3702      */ 
    3703     const SimpleFontData* primaryFont() const ; 
    3704  
    3705     /** 
    3706      * get fontData value at position 
    3707      * @param[in] : position value 
    3708      * @param[out] : font data 
    3709      * @code 
    3710      * FontData *fd = f->fontDataAt(0); 
    3711      * @endcode 
    3712      */ 
    3713     const FontData* fontDataAt(unsigned) const; 
    3714  
    3715     /** 
    3716      * get  glyph data for a character 
    3717      * @param[in] : character 
    3718      * @param[in] : mirror 
    3719      * @param[in] : force small caps 
    3720      * @param[out] : glyph data 
    3721      * @code 
    3722      * GlyphData gd = f->glyphDataForCharacter(c, false); 
    3723      * @endcode 
    3724      */ 
    3725     const GlyphData& glyphDataForCharacter(UChar32, bool mirror, bool forceSmallCaps = false) const; 
    3726     // Used for complex text, and does not utilize the glyph map cache. 
    3727     /** 
    3728      * get font data for a characters 
    3729      * @param[in] : characters 
    3730      * @param[in] : length 
    3731      * @param[out] : font data 
    3732      * @code 
    3733      * FontData *fd = f->fontDataForCharacters(c, 12); 
    3734      * @endcode 
    3735      */ 
    3736     const FontData* fontDataForCharacters(const UChar*, int length) const; 
    3737  
    3738 private: 
    3739     /** 
    3740      * test if you can use glyph cache 
    3741      * @param[in] : TextRun 
    3742      * @param[out] : true if you can 
    3743      * @code 
    3744      * bool u = f->canUseGlyphCache(textRun); 
    3745      * @endcode 
    3746      */ 
    3747     bool canUseGlyphCache(const TextRun&) const; 
    3748  
    3749     /** 
    3750      * draw simple text 
    3751      * @param[in] : graphics context 
    3752      * @param[in] : textRun 
    3753      * @param[in] : start point 
    3754      * @param[in] : start glyph range 
    3755      * @param[in] : end glyph range 
    3756      * @code 
    3757      * f->drawSimpleText(gc, textRun, FloatPoint(0,0), 0, 12); 
    3758      * @endcode 
    3759      */ 
    3760     void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    3761 #if ENABLE(SVG_FONTS) 
    3762     /** 
    3763      * draw text using SVG font 
    3764      * @param[in] : graphics contect 
    3765      * @param[in] : textRun 
    3766      * @param[in] : start point 
    3767      * @param[in] : start glyph range 
    3768      * @param[in] : end glyph range 
    3769      * @code 
    3770      * f->drawTextUsingSVGFont(gc, textRun, FloatPoint(0,0), 0, 12); 
    3771      * @endcode 
    3772      */ 
    3773     void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    3774  
    3775     /** 
    3776      * get float width using SVG font  
    3777      * @param[in] : textRun 
    3778      * @param[out] : float width 
    3779      * @code 
    3780      * float w = f->floatWidthUsingSVGFont(textRun); 
    3781      * @endcode 
    3782      */ 
    3783     float floatWidthUsingSVGFont(const TextRun&) const; 
    3784  
    3785     /** 
    3786      * get float width using SVG font  
    3787      * @param[in] : textRun 
    3788      * @param[in] : extra char available 
    3789      * @param[in] : character consumed 
    3790      * @param[in] : glyph name 
    3791      * @param[out] : float width 
    3792      * @code 
    3793      * float w = f->floatWidthUsingSVGFont(textRun, 0, chars, glyphName); 
    3794      * @endcode 
    3795      */ 
    3796     float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    3797  
    3798     /** 
    3799      * get  selection rect for text using SVG font 
    3800      * @param[in] : textRun 
    3801      * @param[in] : start point 
    3802      * @param[in] : heigth 
    3803      * @param[in] : start glyph range 
    3804      * @param[in] : end glyph range 
    3805      * @param[out] : float rect 
    3806      * @code 
    3807      * FloatRect r = selectionRectForTextUsingSVGFont(textRun, IntPoint(0, 0), 10, 0, 12); 
    3808      * @endcode 
    3809      */ 
    3810     FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    3811  
    3812     /** 
    3813      * get offset for a position for a text using SVG font 
    3814      * @param[in] : textRun 
    3815      * @param[in] : position 
    3816      * @param[in] : include partial glyphs 
    3817      * @param[out] : offset 
    3818      * @code 
    3819      * int o = f->offsetForPositionForTextUsingSVGFont(textRun, 0, true); 
    3820      * @endcode 
    3821      */ 
    3822     int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const; 
    3823 #endif 
    3824     /** 
    3825      * draw glyphs 
    3826      * @param[in] : graphics context 
    3827      * @param[in] : font data 
    3828      * @param[in] : glyph buffer 
    3829      * @param[in] : start glyph range 
    3830      * @param[in] : end glyph range 
    3831      * @param[in] : start point 
    3832      * @code 
    3833      * f->drawGlyphs(gc, s, g, 0, 12, FloatPoint(0,0)); 
    3834      * @endcode 
    3835      */ 
    3836     void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const; 
    3837  
    3838     /** 
    3839      * draw glyph buffer  
    3840      * @param[in] : graphics context 
    3841      * @param[in] : glyph buffer 
    3842      * @param[in] : textRun 
    3843      * @param[in] : start point 
    3844      * @code 
    3845      * f->drawGlyphBuffer(gc, gb, textRun, FloatPoint(0,0)); 
    3846      * @endcode 
    3847      */ 
    3848     void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const; 
    3849  
    3850     /** 
    3851      * draw complex text  
    3852      * @param[in] : graphics context 
    3853      * @param[in] : textRun 
    3854      * @param[in] : start point 
    3855      * @param[in] : start glyph range 
    3856      * @param[in] : end glyph range 
    3857      * @code 
    3858      * f->drawComplexText(gc, textRun, FloatPoint(0,0), 0, 12); 
    3859      * @endcode 
    3860      */ 
    3861     void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    3862  
    3863     /** 
    3864      * get float width for a simple text 
    3865      * @param[in] : textRun 
    3866      * @param[in] : glyph buffer 
    3867      * @param[out] : float width 
    3868      * @code 
    3869      * float w = f->floatWidthForSimpleText(textRun, gb); 
    3870      * @endcode 
    3871      */ 
    3872     float floatWidthForSimpleText(const TextRun&, GlyphBuffer*) const; 
    3873  
    3874     /** 
    3875      * get float width for complex text 
    3876      * @param[in] : textRun 
    3877      * @param[out] : float width 
    3878      * @code 
    3879      * float w = f->floatWidthForComplexText(textRun); 
    3880      * @endcode 
    3881      */ 
    3882     float floatWidthForComplexText(const TextRun&) const; 
    3883  
    3884     /** 
    3885      * get offset for a position for a simple text 
    3886      * @param[in] : textRun 
    3887      * @param[in] : position 
    3888      * @param[in] : include partial glyphs 
    3889      * @param[out] : offset 
    3890      * @code 
    3891      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    3892      * @endcode 
    3893      */ 
    3894     int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const; 
    3895  
    3896     /** 
    3897      * get offset for a position for a complex text 
    3898      * @param[in] : textRun 
    3899      * @param[in] : position 
    3900      * @param[in] : include partial glyphs 
    3901      * @param[out] : offset 
    3902      * @code 
    3903      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    3904      * @endcode 
    3905      */ 
    3906     int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const; 
    3907  
    3908     /** 
    3909      * get selection rect for a simple text 
    3910      * @param[in] : textRun 
    3911      * @param[in] : start point 
    3912      * @param[in] : height 
    3913      * @param[in] : start glyph range 
    3914      * @param[in] : end glyph range 
    3915      * @param[out] : float rect 
    3916      * @code 
    3917      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    3918      * @endcode 
    3919      */ 
    3920     FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    3921  
    3922     /** 
    3923      * get selection rect for a complex text 
    3924      * @param[in] : textRun 
    3925      * @param[in] : start point 
    3926      * @param[in] : height 
    3927      * @param[in] : start glyph range 
    3928      * @param[in] : end glyph range 
    3929      * @param[out] : float rect 
    3930      * @code 
    3931      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    3932      * @endcode 
    3933      */ 
    3934     FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    3935      
    3936  
    3937     /** 
    3938      * cache primary font 
    3939      * @code 
    3940      * f->cachePrimaryFont(); 
    3941      * @endcode 
    3942      */ 
    3943     void cachePrimaryFont() const; 
    3944      
    3945     friend struct WidthIterator; 
    3946  
    3947     // Useful for debugging the different font rendering code paths. 
    3948 public: 
    3949     enum CodePath { Auto, Simple, Complex }; 
    3950     /** 
    3951      * set code path 
    3952      * @param[in] : code path 
    3953      * @code 
    3954      * f->setCodePath(Auto); 
    3955      * @endcode 
    3956      */ 
    3957     static void setCodePath(CodePath); 
    3958     static CodePath codePath; 
    3959  
    3960     static const uint8_t gRoundingHackCharacterTable[256]; 
    3961     /** 
    3962      * get is rounding hack character 
    3963      * @param[in] : character 
    3964      * @param[out] : true or false 
    3965      * @code 
    3966      * bool r = f->isRoundingHackCharacter(c); 
    3967      * @endcode 
    3968      */ 
    3969     static bool isRoundingHackCharacter(UChar32 c); 
    3970  
    3971     /** 
    3972      * get fontSelector  
    3973      * @param[out] : font selector 
    3974      * @code 
    3975      * FontSelector *fs = f->fontSelector(); 
    3976      * @endcode 
    3977      */ 
    3978     FontSelector* fontSelector() const; 
    3979  
    3980     /** 
    3981      * test if font treat character as space 
    3982      * @param[in] : character 
    3983      * @param[out] : true or false 
    3984      * @code 
    3985      * bool t = f->treatAsSpace(c); 
    3986      * @endcode 
    3987      */ 
    3988     static bool treatAsSpace(UChar c) ; 
    3989  
    3990     /** 
    3991      * test if font treat character as zero width space 
    3992      * @param[in] : character 
    3993      * @param[out] : true or false 
    3994      * @code 
    3995      * bool t = f->treatAsZeroWidthSpace(c); 
    3996      * @endcode 
    3997      */ 
    3998     static bool treatAsZeroWidthSpace(UChar c) ; 
    3999  
    4000 #if ENABLE(SVG_FONTS) 
    4001     /** 
    4002      * test if font is SVG font 
    4003      * @param[out] : true or false 
    4004      * @code 
    4005      * bool svgFont = f->isSVGFont(); 
    4006      * @endcode 
    4007      */ 
    4008     bool isSVGFont() const/* 
    4009  * Copyright (C) 2008 Pleyo.  All rights reserved. 
    4010  * 
    4011  * Redistribution and use in source and binary forms, with or without 
    4012  * modification, are permitted provided that the following conditions 
    4013  * are met: 
    4014  * 
    4015  * 1.  Redistributions of source code must retain the above copyright 
    4016  *     notice, this list of conditions and the following disclaimer. 
    4017  * 2.  Redistributions in binary form must reproduce the above copyright 
    4018  *     notice, this list of conditions and the following disclaimer in the 
    4019  *     documentation and/or other materials provided with the distribution. 
    4020  * 3.  Neither the name of Pleyo nor the names of 
    4021  *     its contributors may be used to endorse or promote products derived 
    4022  *     from this software without specific prior written permission. 
    4023  * 
    4024  * THIS SOFTWARE IS PROVIDED BY PLEYO AND ITS CONTRIBUTORS "AS IS" AND ANY 
    4025  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
    4026  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    4027  * DISCLAIMED. IN NO EVENT SHALL PLEYO OR ITS CONTRIBUTORS BE LIABLE FOR ANY 
    4028  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    4029  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    4030  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    4031  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    4032  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    4033  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    4034  */ 
    4035 #ifndef Font_h 
    4036 #define Font_h 
    4037 /** 
    4038  *  @file  Font.t 
    4039  *  Font description 
    4040  *  Repository informations : 
    4041  * - $URL$ 
    4042  * - $Rev$ 
    4043  * - $Date$ 
    4044  */ 
    4045 #include "BALBase.h" 
    4046  
    4047 #include "FontDescription.h" 
    4048 #include <wtf/HashMap.h> 
    4049  
    4050  
    4051 namespace WKAL { 
    4052  
    4053 class FloatPoint; 
    4054 class FloatRect; 
    4055 class FontData; 
    4056 class FontFallbackList; 
    4057 class FontPlatformData; 
    4058 class FontSelector; 
    4059 class GlyphBuffer; 
    4060 class GlyphPageTreeNode; 
    4061 class GraphicsContext; 
    4062 class IntPoint; 
    4063 class RenderObject; 
    4064 class SimpleFontData; 
    4065 class SVGFontElement; 
    4066 class SVGPaintServer; 
    4067  
    4068 struct GlyphData; 
    4069  
    4070 class TextRun : public WKALBase { 
    4071 publi 
    4072  
    4073  
    4074     /** 
    4075      *  Font description 
    4076      * @param[in] : description 
    4077      * @param[out] : description 
    4078      * @code 
    4079      * @endcode 
    4080      */ 
    4081     Font(); 
    4082  
    4083  
    4084     /** 
    4085      *  Font description 
    4086      * @param[in] : description 
    4087      * @param[out] : description 
    4088      * @code 
    4089      * @endcode 
    4090      */ 
    4091     Font(const FontDescription&, short letterSpacing, short wordSpacing); 
    4092  
    4093  
    4094     /** 
    4095      *  Font description 
    4096      * @param[in] : description 
    4097      * @param[out] : description 
    4098      * @code 
    4099      * @endcode 
    4100      */ 
    4101     Font(const FontPlatformData&, bool isPrinting); 
    4102  
    4103  
    4104     /** 
    4105      *  ~Font description 
    4106      * @param[in] : description 
    4107      * @param[out] : description 
    4108      * @code 
    4109      * @endcode 
    4110      */ 
    4111     ~Font(); 
    4112  
    4113  
    4114     /** 
    4115      *  Font description 
    4116      * @param[in] : description 
    4117      * @param[out] : description 
    4118      * @code 
    4119      * @endcode 
    4120      */ 
    4121     Font(const Font&); 
    4122  
    4123  
    4124     /** 
    4125      *  operator= description 
    4126      * @param[in] : description 
    4127      * @param[out] : description 
    4128      * @code 
    4129      * @endcode 
    4130      */ 
    4131     Font& operator=(const Font&); 
    4132  
    4133  
    4134     /** 
    4135      *  operator== description 
    4136      * @param[in] : description 
    4137      * @param[out] : description 
    4138      * @code 
    4139      * @endcode 
    4140      */ 
    4141     bool operator==(const Font& other) const; 
    4142  
    4143  
    4144     /** 
    4145      *  operator!= description 
    4146      * @param[in] : description 
    4147      * @param[out] : description 
    4148      * @code 
    4149      * @endcode 
    4150      */ 
    4151     bool operator!=(const Font& other) const ; 
    4152  
    4153  
    4154     /** 
    4155      *  fontDescription description 
    4156      * @param[in] : description 
    4157      * @param[out] : description 
    4158      * @code 
    4159      * @endcode 
    4160      */ 
    4161     const FontDescription& fontDescription() const ; 
    4162  
    4163  
    4164     /** 
    4165      *  pixelSize description 
    4166      * @param[in] : description 
    4167      * @param[out] : description 
    4168      * @code 
    4169      * @endcode 
    4170      */ 
    4171     int pixelSize() const ; 
    4172  
    4173  
    4174     /** 
    4175      *  size description 
    4176      * @param[in] : description 
    4177      * @param[out] : description 
    4178      * @code 
    4179      * @endcode 
    4180      */ 
    4181     float size() const ; 
    4182  
    4183  
    4184     /** 
    4185      *  update description 
    4186      * @param[in] : description 
    4187      * @param[out] : description 
    4188      * @code 
    4189      * @endcode 
    4190      */ 
    4191     void update(PassRefPtr<FontSelector>) const; 
    4192  
    4193  
    4194     /** 
    4195      *  drawText description 
    4196      * @param[in] : description 
    4197      * @param[out] : description 
    4198      * @code 
    4199      * @endcode 
    4200      */ 
    4201     void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; 
    4202  
    4203  
    4204     /** 
    4205      *  width description 
    4206      * @param[in] : description 
    4207      * @param[out] : description 
    4208      * @code 
    4209      * @endcode 
    4210      */ 
    4211     int width(const TextRun&) const; 
    4212  
    4213  
    4214     /** 
    4215      *  floatWidth description 
    4216      * @param[in] : description 
    4217      * @param[out] : description 
    4218      * @code 
    4219      * @endcode 
    4220      */ 
    4221     float floatWidth(const TextRun&) const; 
    4222  
    4223  
    4224     /** 
    4225      *  floatWidth description 
    4226      * @param[in] : description 
    4227      * @param[out] : description 
    4228      * @code 
    4229      * @endcode 
    4230      */ 
    4231     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    4232  
    4233  
    4234     /** 
    4235      *  offsetForPosition description 
    4236      * @param[in] : description 
    4237      * @param[out] : description 
    4238      * @code 
    4239      * @endcode 
    4240      */ 
    4241     int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; 
    4242  
    4243  
    4244     /** 
    4245      *  selectionRectForText description 
    4246      * @param[in] : description 
    4247      * @param[out] : description 
    4248      * @code 
    4249      * @endcode 
    4250      */ 
    4251     FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const; 
    4252  
    4253  
    4254     /** 
    4255      *  isSmallCaps description 
    4256      * @param[in] : description 
    4257      * @param[out] : description 
    4258      * @code 
    4259      * @endcode 
    4260      */ 
    4261     bool isSmallCaps() const ; 
    4262  
    4263  
    4264     /** 
    4265      *  wordSpacing description 
    4266      * @param[in] : description 
    4267      * @param[out] : description 
    4268      * @code 
    4269      * @endcode 
    4270      */ 
    4271     short wordSpacing() const ; 
    4272  
    4273  
    4274     /** 
    4275      *  letterSpacing description 
    4276      * @param[in] : description 
    4277      * @param[out] : description 
    4278      * @code 
    4279      * @endcode 
    4280      */ 
    4281     short letterSpacing() const ; 
    4282  
    4283  
    4284     /** 
    4285      *  setWordSpacing description 
    4286      * @param[in] : description 
    4287      * @param[out] : description 
    4288      * @code 
    4289      * @endcode 
    4290      */ 
    4291     void setWordSpacing(short s) ; 
    4292  
    4293  
    4294     /** 
    4295      *  setLetterSpacing description 
    4296      * @param[in] : description 
    4297      * @param[out] : description 
    4298      * @code 
    4299      * @endcode 
    4300      */ 
    4301     void setLetterSpacing(short s)  
    4302  
    4303 #if ENABLE(SVG_FONT 
    4304  
    4305     /** 
    4306      * set referencing RenderObject 
    4307      * @param[in] : RenderObject 
    4308      * @code 
    4309      * textRun->setReferencingRenderObject(rObj); 
    4310      * @endcode 
    4311      */ 
    4312     void setReferencingRenderObject(RenderObject* object)  
    4313  
    4314     /** 
    4315      * set active paint server 
    4316      * @param[in] : SVGPaintServer 
    4317      * @code 
    4318      * textRun->setActivePaintServer(sps); 
    4319      * @endcode 
    4320      */ 
    4321     void setActivePaintServer(SVGPaintServer* object) ; 
    4322 #endif 
    4323  
    4324 private: 
    4325     const UChar* m_characters; 
    4326     int m_len; 
    4327  
    4328     bool m_allowTabs; 
    4329     int m_xpos; 
    4330     int m_padding; 
    4331     bool m_rtl; 
    4332     bool m_directionalOverride; 
    4333     bool m_applyRunRounding; 
    4334     bool m_applyWordRounding; 
    4335     bool m_disableSpacing; 
    4336  
    4337 #if ENABLE(SVG_FONTS) 
    4338     RenderObject* m_referencingRenderObject; 
    4339     SVGPaintServer* m_activePaintServer; 
    4340 #endif 
    4341 }; 
    4342  
    4343 class Font : public WKALBase { 
    4344 publi 
    4345  
    4346     /** 
    4347      * Font constructor 
    4348      * @param[in] : FontDescription 
    4349      * @param[in] : letter spacing 
    4350      * @param[in] : word spacing 
    4351      * @code 
    4352      * Font *f = new Font(fd, 12, 12 ); 
    4353      * @endcode 
    4354      */ 
    4355     Font(const FontDescription&, short letterSpacing, short wordSpacing) // This constructor is only used if the platform wants to start with a native font. 
    4356  
    4357     /** 
    4358      * ~Font destructor 
    4359      * @code 
    4360      * delete font; 
    4361      * @endcode 
    4362      */ 
    4363     ~Font() 
    4364  
    4365     /** 
    4366      * operator= 
    4367      * @param[in] : Font 
    4368      * @param[out] : Font 
    4369      * @code 
    4370      * Font f = currentFont; 
    4371      * @endcode 
    4372      */ 
    4373     Font& operator=(const Font&) 
    4374  
    4375     /** 
    4376      * operator!=  
    4377      * @param[in] : Font 
    4378      * @param[out] : return true if the fonts are different 
    4379      * @code 
    4380      * bool d = f != currentFont; 
    4381      * @endcode 
    4382      */ 
    4383     bool operator!=(const Font& other) const  
    4384  
    4385     /** 
    4386      * get font pixel size 
    4387      * @param[out] : pixel size 
    4388      * @code 
    4389      * int ps = f->pixelSize(); 
    4390      * @endcode 
    4391      */ 
    4392     int pixelSize() const  
    4393  
    4394     /** 
    4395      * update font 
    4396      * @param[in] : FontSelector 
    4397      * @code 
    4398      * f->update(fontSelector); 
    4399      * @endcode 
    4400      */ 
    4401     void update(PassRefPtr<FontSelector>) const 
    4402  
    4403     /** 
    4404      * return font width 
    4405      * @param[in] : TextRun 
    4406      * @param[out] : width 
    4407      * @code 
    4408      * int w = f->width(textRun); 
    4409      * @endcode 
    4410      */ 
    4411     int width(const TextRun&) const 
    4412  
    4413     /** 
    4414      * return float width 
    4415      * @param[in] : TextRun 
    4416      * @param[in] : extra chars available 
    4417      * @param[in] : chars consumed 
    4418      * @param[in] : glyph name 
    4419      * @param[out] : float width 
    4420      * @code 
    4421      * float w = f->floatWidth(textRun, 0, chars, name); 
    4422      * @endcode 
    4423      */ 
    4424     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const 
    4425  
    4426     /** 
    4427      * get selection for text 
    4428      * @param[in] : TextRun 
    4429      * @param[in] : start point 
    4430      * @param[in] : height 
    4431      * @param[in] : start glyph range 
    4432      * @param[in] : end glyph range 
    4433      * @param[out] : float rect 
    4434      * @code 
    4435      * FloatRect f = f->selectionRectForText(textRun, IntPoint(0,0), 18); 
    4436      * @endcode 
    4437      */ 
    4438     FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const 
    4439  
    4440     /** 
    4441      * get word spacing value 
    4442      * @param[out] : word spacing value 
    4443      * @code 
    4444      * short ws = f->wordSpacing(); 
    4445      * @endcode 
    4446      */ 
    4447     short wordSpacing() const 
    4448  
    4449     /** 
    4450      * test if the font is printer 
    4451      * @param[out] : true if the font is printer 
    4452      * @code 
    4453      * bool pf = f->isPrinterFont(); 
    4454      * @endcode 
    4455      */ 
    4456     bool isPrinterFont() const ; 
    4457      
    4458     /** 
    4459      * get the font rendering mode 
    4460      * @param[out] : font rendering mode 
    4461      * @code 
    4462      * FontRenderingMode frm = f->renderingMode(); 
    4463      * @endcode 
    4464      */ 
    4465     FontRenderingMode renderingMode() const ; 
    4466  
    4467     /** 
    4468      * get first font family 
    4469      * @param[out] : font family 
    4470      * @code 
    4471      * FontFamily ff = f->firstFamily(); 
    4472      * @endcode 
    4473      */ 
    4474     FontFamily& firstFamily() ; 
    4475  
    4476     /** 
    4477      * get font family 
    4478      * @param[out] : font family 
    4479      * @code 
    4480      * FontFamily ff = f->family(); 
    4481      * @endcode 
    4482      */ 
    4483     const FontFamily& family() const ; 
    4484  
    4485     /** 
    4486      * get the italic status 
    4487      * @param[out] : italic status 
    4488      * @code 
    4489      * bool it = f->italic(); 
    4490      * @endcode 
    4491      */ 
    4492     bool italic() const ; 
    4493  
    4494     /** 
    4495      * get the font weight 
    4496      * @param[out] : font weight 
    4497      * @code 
    4498      * FontWeight fw = f->weight(); 
    4499      * @endcode 
    4500      */ 
    4501     FontWeight weight() const ; 
    4502  
    4503     /** 
    4504      * get it's a platform font 
    4505      * @param[out] : true if it's a platform font 
    4506      * @code 
    4507      * bool pf = f->isPlatformFont(); 
    4508      * @endcode 
    4509      */ 
    4510     bool isPlatformFont() const ; 
    4511  
    4512  
    4513     // Metrics that we query the FontFallbackList for. 
    4514     /** 
    4515      * get ascent value 
    4516      * @param[out] : ascent value 
    4517      * @code 
    4518      * int a = f->ascent(); 
    4519      * @endcode 
    4520      */ 
    4521     int ascent() const; 
    4522  
    4523     /** 
    4524      * get descent value 
    4525      * @param[out] : descent value 
    4526      * @code 
    4527      * int d = f->descent(); 
    4528      * @endcode 
    4529      */ 
    4530     int descent() const; 
    4531  
    4532     /** 
    4533      * get height value 
    4534      * @param[out] : height value 
    4535      * @code 
    4536      * int h = f->height(); 
    4537      * @endcode 
    4538      */ 
    4539     int height() const ; 
    4540  
    4541     /** 
    4542      * get lineSpacing value 
    4543      * @param[out] : lineSpacing value 
    4544      * @code 
    4545      * int ls = f->lineSpacing(); 
    4546      * @endcode 
    4547      */ 
    4548     int lineSpacing() const; 
    4549  
    4550     /** 
    4551      * get xHeight value 
    4552      * @param[out] : xHeight value 
    4553      * @code 
    4554      * float x = f->xHeight(); 
    4555      * @endcode 
    4556      */ 
    4557     float xHeight() const; 
    4558  
    4559     /** 
    4560      * get unitsPerEm value 
    4561      * @param[out] : untiPerEm value 
    4562      * @code 
    4563      * unsigned u = f->unitsPerEm(); 
    4564      * @endcode 
    4565      */ 
    4566     unsigned unitsPerEm() const; 
    4567  
    4568     /** 
    4569      * get spaceWidth value 
    4570      * @param[out] : spaceWidth value 
    4571      * @code 
    4572      * int sw = f->spaceWidth(); 
    4573      * @endcode 
    4574      */ 
    4575     int spaceWidth() const; 
    4576  
    4577     /** 
    4578      * get tabWidth value 
    4579      * @param[out] : tabWidth value 
    4580      * @code 
    4581      * int tw = f->tabWidth(); 
    4582      * @endcode 
    4583      */ 
    4584     int tabWidth() const ; 
    4585  
    4586     /** 
    4587      * get primary font value 
    4588      * @param[out] : primary font 
    4589      * @code 
    4590      * SimpleFontData *sfd = f->primaryFont(); 
    4591      * @endcode 
    4592      */ 
    4593     const SimpleFontData* primaryFont() const ; 
    4594  
    4595     /** 
    4596      * get fontData value at position 
    4597      * @param[in] : position value 
    4598      * @param[out] : font data 
    4599      * @code 
    4600      * FontData *fd = f->fontDataAt(0); 
    4601      * @endcode 
    4602      */ 
    4603     const FontData* fontDataAt(unsigned) const; 
    4604  
    4605     /** 
    4606      * get  glyph data for a character 
    4607      * @param[in] : character 
    4608      * @param[in] : mirror 
    4609      * @param[in] : force small caps 
    4610      * @param[out] : glyph data 
    4611      * @code 
    4612      * GlyphData gd = f->glyphDataForCharacter(c, false); 
    4613      * @endcode 
    4614      */ 
    4615     const GlyphData& glyphDataForCharacter(UChar32, bool mirror, bool forceSmallCaps = false) const; 
    4616     // Used for complex text, and does not utilize the glyph map cache. 
    4617     /** 
    4618      * get font data for a characters 
    4619      * @param[in] : characters 
    4620      * @param[in] : length 
    4621      * @param[out] : font data 
    4622      * @code 
    4623      * FontData *fd = f->fontDataForCharacters(c, 12); 
    4624      * @endcode 
    4625      */ 
    4626     const FontData* fontDataForCharacters(const UChar*, int length) const; 
    4627  
    4628 private: 
    4629     /** 
    4630      * test if you can use glyph cache 
    4631      * @param[in] : TextRun 
    4632      * @param[out] : true if you can 
    4633      * @code 
    4634      * bool u = f->canUseGlyphCache(textRun); 
    4635      * @endcode 
    4636      */ 
    4637     bool canUseGlyphCache(const TextRun&) const; 
    4638  
    4639     /** 
    4640      * draw simple text 
    4641      * @param[in] : graphics context 
    4642      * @param[in] : textRun 
    4643      * @param[in] : start point 
    4644      * @param[in] : start glyph range 
    4645      * @param[in] : end glyph range 
    4646      * @code 
    4647      * f->drawSimpleText(gc, textRun, FloatPoint(0,0), 0, 12); 
    4648      * @endcode 
    4649      */ 
    4650     void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    4651 #if ENABLE(SVG_FONTS) 
    4652     /** 
    4653      * draw text using SVG font 
    4654      * @param[in] : graphics contect 
    4655      * @param[in] : textRun 
    4656      * @param[in] : start point 
    4657      * @param[in] : start glyph range 
    4658      * @param[in] : end glyph range 
    4659      * @code 
    4660      * f->drawTextUsingSVGFont(gc, textRun, FloatPoint(0,0), 0, 12); 
    4661      * @endcode 
    4662      */ 
    4663     void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    4664  
    4665     /** 
    4666      * get float width using SVG font  
    4667      * @param[in] : textRun 
    4668      * @param[out] : float width 
    4669      * @code 
    4670      * float w = f->floatWidthUsingSVGFont(textRun); 
    4671      * @endcode 
    4672      */ 
    4673     float floatWidthUsingSVGFont(const TextRun&) const; 
    4674  
    4675     /** 
    4676      * get float width using SVG font  
    4677      * @param[in] : textRun 
    4678      * @param[in] : extra char available 
    4679      * @param[in] : character consumed 
    4680      * @param[in] : glyph name 
    4681      * @param[out] : float width 
    4682      * @code 
    4683      * float w = f->floatWidthUsingSVGFont(textRun, 0, chars, glyphName); 
    4684      * @endcode 
    4685      */ 
    4686     float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    4687  
    4688     /** 
    4689      * get  selection rect for text using SVG font 
    4690      * @param[in] : textRun 
    4691      * @param[in] : start point 
    4692      * @param[in] : heigth 
    4693      * @param[in] : start glyph range 
    4694      * @param[in] : end glyph range 
    4695      * @param[out] : float rect 
    4696      * @code 
    4697      * FloatRect r = selectionRectForTextUsingSVGFont(textRun, IntPoint(0, 0), 10, 0, 12); 
    4698      * @endcode 
    4699      */ 
    4700     FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    4701  
    4702     /** 
    4703      * get offset for a position for a text using SVG font 
    4704      * @param[in] : textRun 
    4705      * @param[in] : position 
    4706      * @param[in] : include partial glyphs 
    4707      * @param[out] : offset 
    4708      * @code 
    4709      * int o = f->offsetForPositionForTextUsingSVGFont(textRun, 0, true); 
    4710      * @endcode 
    4711      */ 
    4712     int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const; 
    4713 #endif 
    4714     /** 
    4715      * draw glyphs 
    4716      * @param[in] : graphics context 
    4717      * @param[in] : font data 
    4718      * @param[in] : glyph buffer 
    4719      * @param[in] : start glyph range 
    4720      * @param[in] : end glyph range 
    4721      * @param[in] : start point 
    4722      * @code 
    4723      * f->drawGlyphs(gc, s, g, 0, 12, FloatPoint(0,0)); 
    4724      * @endcode 
    4725      */ 
    4726     void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const; 
    4727  
    4728     /** 
    4729      * draw glyph buffer  
    4730      * @param[in] : graphics context 
    4731      * @param[in] : glyph buffer 
    4732      * @param[in] : textRun 
    4733      * @param[in] : start point 
    4734      * @code 
    4735      * f->drawGlyphBuffer(gc, gb, textRun, FloatPoint(0,0)); 
    4736      * @endcode 
    4737      */ 
    4738     void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const; 
    4739  
    4740     /** 
    4741      * draw complex text  
    4742      * @param[in] : graphics context 
    4743      * @param[in] : textRun 
    4744      * @param[in] : start point 
    4745      * @param[in] : start glyph range 
    4746      * @param[in] : end glyph range 
    4747      * @code 
    4748      * f->drawComplexText(gc, textRun, FloatPoint(0,0), 0, 12); 
    4749      * @endcode 
    4750      */ 
    4751     void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 
    4752  
    4753     /** 
    4754      * get float width for a simple text 
    4755      * @param[in] : textRun 
    4756      * @param[in] : glyph buffer 
    4757      * @param[out] : float width 
    4758      * @code 
    4759      * float w = f->floatWidthForSimpleText(textRun, gb); 
    4760      * @endcode 
    4761      */ 
    4762     float floatWidthForSimpleText(const TextRun&, GlyphBuffer*) const; 
    4763  
    4764     /** 
    4765      * get float width for complex text 
    4766      * @param[in] : textRun 
    4767      * @param[out] : float width 
    4768      * @code 
    4769      * float w = f->floatWidthForComplexText(textRun); 
    4770      * @endcode 
    4771      */ 
    4772     float floatWidthForComplexText(const TextRun&) const; 
    4773  
    4774     /** 
    4775      * get offset for a position for a simple text 
    4776      * @param[in] : textRun 
    4777      * @param[in] : position 
    4778      * @param[in] : include partial glyphs 
    4779      * @param[out] : offset 
    4780      * @code 
    4781      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    4782      * @endcode 
    4783      */ 
    4784     int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const; 
    4785  
    4786     /** 
    4787      * get offset for a position for a complex text 
    4788      * @param[in] : textRun 
    4789      * @param[in] : position 
    4790      * @param[in] : include partial glyphs 
    4791      * @param[out] : offset 
    4792      * @code 
    4793      * int o = f->offsetForPositionForSimpleText(textRun, 0, true); 
    4794      * @endcode 
    4795      */ 
    4796     int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const; 
    4797  
    4798     /** 
    4799      * get selection rect for a simple text 
    4800      * @param[in] : textRun 
    4801      * @param[in] : start point 
    4802      * @param[in] : height 
    4803      * @param[in] : start glyph range 
    4804      * @param[in] : end glyph range 
    4805      * @param[out] : float rect 
    4806      * @code 
    4807      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    4808      * @endcode 
    4809      */ 
    4810     FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    4811  
    4812     /** 
    4813      * get selection rect for a complex text 
    4814      * @param[in] : textRun 
    4815      * @param[in] : start point 
    4816      * @param[in] : height 
    4817      * @param[in] : start glyph range 
    4818      * @param[in] : end glyph range 
    4819      * @param[out] : float rect 
    4820      * @code 
    4821      * FloatRect fr = f->selectionRectForSimpleText(textRun, IntPoint&(0,0), 10, 0, 12); 
    4822      * @endcode 
    4823      */ 
    4824     FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const; 
    4825      
    4826  
    4827     /** 
    4828      * cache primary font 
    4829      * @code 
    4830      * f->cachePrimaryFont(); 
    4831      * @endcode 
    4832      */ 
    4833     void cachePrimaryFont() const; 
    4834      
    4835     friend struct WidthIterator; 
    4836  
    4837     // Useful for debugging the different font rendering code paths. 
    4838 public: 
    4839     enum CodePath { Auto, Simple, Complex }; 
    4840     /** 
    4841      * set code path 
    4842      * @param[in] : code path 
    4843      * @code 
    4844      * f->setCodePath(Auto); 
    4845      * @endcode 
    4846      */ 
    4847     static void setCodePath(CodePath); 
    4848     static CodePath codePath; 
    4849  
    4850     static const uint8_t gRoundingHackCharacterTable[256]; 
    4851     /** 
    4852      * get is rounding hack character 
    4853      * @param[in] : character 
    4854      * @param[out] : true or false 
    4855      * @code 
    4856      * bool r = f->isRoundingHackCharacter(c); 
    4857      * @endcode 
    4858      */ 
    4859     static bool isRoundingHackCharacter(UChar32 c); 
    4860  
    4861     /** 
    4862      * get fontSelector  
    4863      * @param[out] : font selector 
    4864      * @code 
    4865      * FontSelector *fs = f->fontSelector(); 
    4866      * @endcode 
    4867      */ 
    4868     FontSelector* fontSelector() const; 
    4869  
    4870     /** 
    4871      * test if font treat character as space 
    4872      * @param[in] : character 
    4873      * @param[out] : true or false 
    4874      * @code 
    4875      * bool t = f->treatAsSpace(c); 
    4876      * @endcode 
    4877      */ 
    4878     static bool treatAsSpace(UChar c) ; 
    4879  
    4880     /** 
    4881      * test if font treat character as zero width space 
    4882      * @param[in] : character 
    4883      * @param[out] : true or false 
    4884      * @code 
    4885      * bool t = f->treatAsZeroWidthSpace(c); 
    4886      * @endcode 
    4887      */ 
    4888     static bool treatAsZeroWidthSpace(UChar c) ; 
    4889  
    4890 #if ENABLE(SVG_FONTS) 
    4891     /** 
    4892      * test if font is SVG font 
    4893      * @param[out] : true or false 
    4894      * @code 
    4895      * bool svgFont = f->isSVGFont(); 
    4896      * @endcode 
    4897      */ 
    4898     bool isSVGFont() const/* 
    4899  * Copyright (C) 2008 Pleyo.  All rights reserved. 
    4900  * 
    4901  * Redistribution and use in source and binary forms, with or without 
    4902  * modification, are permitted provided that the following conditions 
    4903  * are met: 
    4904  * 
    4905  * 1.  Redistributions of source code must retain the above copyright 
    4906  *     notice, this list of conditions and the following disclaimer. 
    4907  * 2.  Redistributions in binary form must reproduce the above copyright 
    4908  *     notice, this list of conditions and the following disclaimer in the 
    4909  *     documentation and/or other materials provided with the distribution. 
    4910  * 3.  Neither the name of Pleyo nor the names of 
    4911  *     its contributors may be used to endorse or promote products derived 
    4912  *     from this software without specific prior written permission. 
    4913  * 
    4914  * THIS SOFTWARE IS PROVIDED BY PLEYO AND ITS CONTRIBUTORS "AS IS" AND ANY 
    4915  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
    4916  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    4917  * DISCLAIMED. IN NO EVENT SHALL PLEYO OR ITS CONTRIBUTORS BE LIABLE FOR ANY 
    4918  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
    4919  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    4920  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
    4921  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    4922  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    4923  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    4924  */ 
    4925 #ifndef Font_h 
    4926 #define Font_h 
    4927 /** 
    4928  *  @file  Font.t 
    4929  *  Font description 
    4930  *  Repository informations : 
    4931  * - $URL$ 
    4932  * - $Rev$ 
    4933  * - $Date$ 
    4934  */ 
    4935 #include "BALBase.h" 
    4936  
    4937 #include "FontDescription.h" 
    4938 #include <wtf/HashMap.h> 
    4939  
    4940  
    4941 namespace WKAL { 
    4942  
    4943 class FloatPoint; 
    4944 class FloatRect; 
    4945 class FontData; 
    4946 class FontFallbackList; 
    4947 class FontPlatformData; 
    4948 class FontSelector; 
    4949 class GlyphBuffer; 
    4950 class GlyphPageTreeNode; 
    4951 class GraphicsContext; 
    4952 class IntPoint; 
    4953 class RenderObject; 
    4954 class SimpleFontData; 
    4955 class SVGFontElement; 
    4956 class SVGPaintServer; 
    4957  
    4958 struct GlyphData; 
    4959  
    4960 class TextRun : public WKALBase { 
    4961 publi 
    4962  
    4963  
    4964     /** 
    4965      *  Font description 
    4966      * @param[in] : description 
    4967      * @param[out] : description 
    4968      * @code 
    4969      * @endcode 
    4970      */ 
    4971     Font(); 
    4972  
    4973  
    4974     /** 
    4975      *  Font description 
    4976      * @param[in] : description 
    4977      * @param[out] : description 
    4978      * @code 
    4979      * @endcode 
    4980      */ 
    4981     Font(const FontDescription&, short letterSpacing, short wordSpacing); 
    4982  
    4983  
    4984     /** 
    4985      *  Font description 
    4986      * @param[in] : description 
    4987      * @param[out] : description 
    4988      * @code 
    4989      * @endcode 
    4990      */ 
    4991     Font(const FontPlatformData&, bool isPrinting); 
    4992  
    4993  
    4994     /** 
    4995      *  ~Font description 
    4996      * @param[in] : description 
    4997      * @param[out] : description 
    4998      * @code 
    4999      * @endcode 
    5000      */ 
    5001     ~Font(); 
    5002  
    5003  
    5004     /** 
    5005      *  Font description 
    5006      * @param[in] : description 
    5007      * @param[out] : description 
    5008      * @code 
    5009      * @endcode 
    5010      */ 
    5011     Font(const Font&); 
    5012  
    5013  
    5014     /** 
    5015      *  operator= description 
    5016      * @param[in] : description 
    5017      * @param[out] : description 
    5018      * @code 
    5019      * @endcode 
    5020      */ 
    5021     Font& operator=(const Font&); 
    5022  
    5023  
    5024     /** 
    5025      *  operator== description 
    5026      * @param[in] : description 
    5027      * @param[out] : description 
    5028      * @code 
    5029      * @endcode 
    5030      */ 
    5031     bool operator==(const Font& other) const; 
    5032  
    5033  
    5034     /** 
    5035      *  operator!= description 
    5036      * @param[in] : description 
    5037      * @param[out] : description 
    5038      * @code 
    5039      * @endcode 
    5040      */ 
    5041     bool operator!=(const Font& other) const ; 
    5042  
    5043  
    5044     /** 
    5045      *  fontDescription description 
    5046      * @param[in] : description 
    5047      * @param[out] : description 
    5048      * @code 
    5049      * @endcode 
    5050      */ 
    5051     const FontDescription& fontDescription() const ; 
    5052  
    5053  
    5054     /** 
    5055      *  pixelSize description 
    5056      * @param[in] : description 
    5057      * @param[out] : description 
    5058      * @code 
    5059      * @endcode 
    5060      */ 
    5061     int pixelSize() const ; 
    5062  
    5063  
    5064     /** 
    5065      *  size description 
    5066      * @param[in] : description 
    5067      * @param[out] : description 
    5068      * @code 
    5069      * @endcode 
    5070      */ 
    5071     float size() const ; 
    5072  
    5073  
    5074     /** 
    5075      *  update description 
    5076      * @param[in] : description 
    5077      * @param[out] : description 
    5078      * @code 
    5079      * @endcode 
    5080      */ 
    5081     void update(PassRefPtr<FontSelector>) const; 
    5082  
    5083  
    5084     /** 
    5085      *  drawText description 
    5086      * @param[in] : description 
    5087      * @param[out] : description 
    5088      * @code 
    5089      * @endcode 
    5090      */ 
    5091     void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const; 
    5092  
    5093  
    5094     /** 
    5095      *  width description 
    5096      * @param[in] : description 
    5097      * @param[out] : description 
    5098      * @code 
    5099      * @endcode 
    5100      */ 
    5101     int width(const TextRun&) const; 
    5102  
    5103  
    5104     /** 
    5105      *  floatWidth description 
    5106      * @param[in] : description 
    5107      * @param[out] : description 
    5108      * @code 
    5109      * @endcode 
    5110      */ 
    5111     float floatWidth(const TextRun&) const; 
    5112  
    5113  
    5114     /** 
    5115      *  floatWidth description 
    5116      * @param[in] : description 
    5117      * @param[out] : description 
    5118      * @code 
    5119      * @endcode 
    5120      */ 
    5121     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; 
    5122  
    5123  
    5124     /** 
    5125      *  offsetForPosition description 
    5126      * @param[in] : description 
    5127      * @param[out] : description 
    5128      * @code 
    5129      * @endcode 
    5130      */ 
    5131     int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; 
    5132  
    5133  
    5134     /** 
    5135      *  selectionRectForText description 
    5136      * @param[in] : description 
    5137      * @param[out] : description 
    5138      * @code 
    5139      * @endcode 
    5140      */ 
    5141     FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const; 
    5142  
    5143  
    5144     /** 
    5145      *  isSmallCaps description 
    5146      * @param[in] : description 
    5147      * @param[out] : description 
    5148      * @code 
    5149      * @endcode 
    5150      */ 
    5151     bool isSmallCaps() const ; 
    5152  
    5153  
    5154     /** 
    5155      *  wordSpacing description 
    5156      * @param[in] : description 
    5157      * @param[out] : description 
    5158      * @code 
    5159      * @endcode 
    5160      */ 
    5161     short wordSpacing() const ; 
    5162  
    5163  
    5164     /** 
    5165      *  letterSpacing description 
    5166      * @param[in] : description 
    5167      * @param[out] : description 
    5168      * @code 
    5169      * @endcode 
    5170      */ 
    5171     short letterSpacing() const ; 
    5172  
    5173  
    5174     /** 
    5175      *  setWordSpacing description 
    5176      * @param[in] : description 
    5177      * @param[out] : description 
    5178      * @code 
    5179      * @endcode 
    5180      */ 
    5181     void setWordSpacing(short s) ; 
    5182  
    5183  
    5184     /** 
    5185      *  setLetterSpacing description 
    5186      * @param[in] : description 
    5187      * @param[out] : description 
    5188      * @code 
    5189      * @endcode 
    5190      */ 
    5191     void setLetterSpacing(short s)  
    5192  
    5193 #if ENABLE(SVG_FONT 
    5194  
    5195     /** 
    5196      * set referencing RenderObject 
    5197      * @param[in] : RenderObject 
    5198      * @code 
    5199      * textRun->setReferencingRenderObject(rObj); 
    5200      * @endcode 
    5201      */ 
    5202     void setReferencingRenderObject(RenderObject* object)  
    5203  
    5204     /** 
    5205      * set active paint server 
    5206      * @param[in] : SVGPaintServer 
    5207      * @code 
    5208      * textRun->setActivePaintServer(sps); 
    5209      * @endcode 
    5210      */ 
    5211     void setActivePaintServer(SVGPaintServer* object) ; 
    5212 #endif 
    5213  
    5214 private: 
    5215     const UChar* m_characters; 
    5216     int m_len; 
    5217  
    5218     bool m_allowTabs; 
    5219     int m_xpos; 
    5220     int m_padding; 
    5221     bool m_rtl; 
    5222     bool m_directionalOverride; 
    5223     bool m_applyRunRounding; 
    5224     bool m_applyWordRounding; 
    5225     bool m_disableSpacing; 
    5226  
    5227 #if ENABLE(SVG_FONTS) 
    5228     RenderObject* m_referencingRenderObject; 
    5229     SVGPaintServer* m_activePaintServer; 
    5230 #endif 
    5231 }; 
    5232  
    5233 class Font : public WKALBase { 
    5234 publi 
    5235  
    5236     /** 
    5237      * Font constructor 
    5238      * @param[in] : FontDescription 
    5239      * @param[in] : letter spacing 
    5240      * @param[in] : word spacing 
    5241      * @code 
    5242      * Font *f = new Font(fd, 12, 12 ); 
    5243      * @endcode 
    5244      */ 
    5245     Font(const FontDescription&, short letterSpacing, short wordSpacing) // This constructor is only used if the platform wants to start with a native font. 
    5246  
    5247     /** 
    5248      * ~Font destructor 
    5249      * @code 
    5250      * delete font; 
    5251      * @endcode 
    5252      */ 
    5253     ~Font() 
    5254  
    5255     /** 
    5256      * operator= 
    5257      * @param[in] : Font 
    5258      * @param[out] : Font 
    5259      * @code 
    5260      * Font f = currentFont; 
    5261      * @endcode 
    5262      */ 
    5263     Font& operator=(const Font&) 
    5264  
    5265     /** 
    5266      * operator!=  
    5267      * @param[in] : Font 
    5268      * @param[out] : return true if the fonts are different 
    5269      * @code 
    5270      * bool d = f != currentFont; 
    5271      * @endcode 
    5272      */ 
    5273     bool operator!=(const Font& other) const  
    5274  
    5275     /** 
    5276      * get font pixel size 
    5277      * @param[out] : pixel size 
    5278      * @code 
    5279      * int ps = f->pixelSize(); 
    5280      * @endcode 
    5281      */ 
    5282     int pixelSize() const  
    5283  
    5284     /** 
    5285      * update font 
    5286      * @param[in] : FontSelector 
    5287      * @code 
    5288      * f->update(fontSelector); 
    5289      * @endcode 
    5290      */ 
    5291     void update(PassRefPtr<FontSelector>) const 
    5292  
    5293     /** 
    5294      * return font width 
    5295      * @param[in] : TextRun 
    5296      * @param[out] : width 
    5297      * @code 
    5298      * int w = f->width(textRun); 
    5299      * @endcode 
    5300      */ 
    5301     int width(const TextRun&) const 
    5302  
    5303     /** 
    5304      * return float width 
    5305      * @param[in] : TextRun 
    5306      * @param[in] : extra chars available 
    5307      * @param[in] : chars consumed 
    5308      * @param[in] : glyph name 
    5309      * @param[out] : float width 
    5310      * @code 
    5311      * float w = f->floatWidth(textRun, 0, chars, name); 
    5312      * @endcode 
    5313      */ 
    5314     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const 
    5315  
    5316     /** 
    5317      * get selection for text 
    5318      * @param[in] : TextRun 
    5319      * @param[in] : start point 
    5320      * @param[in] : height 
    5321      * @param[in] : start glyph range 
    5322      * @param[in] : end glyph range 
    5323      * @param[out] : float rect 
    5324      * @code