LCOV - code coverage report
Current view: top level - libreoffice/vcl/generic/glyphs - graphite_serverfont.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 41 0.0 %
Date: 2012-12-27 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : // We need this to enable namespace support in libgrengine headers.
      22             : #define GR_NAMESPACE
      23             : 
      24             : // Header files
      25             : //
      26             : 
      27             : // Platform
      28             : #include <i18npool/languagetag.hxx>
      29             : #include <sallayout.hxx>
      30             : // Module
      31             : #include "gcach_ftyp.hxx"
      32             : #include "generic/glyphcache.hxx"
      33             : #include <graphite_features.hxx>
      34             : #include <graphite_serverfont.hxx>
      35             : 
      36           0 : float freetypeServerFontAdvance(const void* appFontHandle, gr_uint16 glyphId)
      37             : {
      38             :     ServerFont * pServerFont =
      39             :         const_cast<ServerFont*>
      40           0 :         (reinterpret_cast<const ServerFont*>(appFontHandle));
      41           0 :     if (pServerFont)
      42             :     {
      43           0 :         return static_cast<float>(pServerFont->GetGlyphMetric(glyphId).GetCharWidth());
      44             :     }
      45           0 :     return .0f;
      46             : }
      47             : 
      48             : //
      49             : // An implementation of the GraphiteLayout interface to enable Graphite enabled fonts to be used.
      50             : //
      51             : 
      52           0 : GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) throw()
      53             :   : ServerFontLayout(rServerFont),
      54           0 :     maImpl(rServerFont.GetGraphiteFace()->face(),
      55             :         rServerFont),
      56           0 :     mpFeatures(NULL)
      57             : {
      58           0 :     gr_font * pFont = rServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight);
      59           0 :     if (!pFont)
      60             :     {
      61             :         pFont = gr_make_font_with_advance_fn(
      62             :                // need to use mnHeight here, mfExactHeight can give wrong values
      63           0 :                static_cast<float>(rServerFont.GetFontSelData().mnHeight),
      64             :                &rServerFont,
      65             :                freetypeServerFontAdvance,
      66           0 :                rServerFont.GetGraphiteFace()->face());
      67           0 :         rServerFont.GetGraphiteFace()->addFont(rServerFont.GetFontSelData().mnHeight, pFont);
      68             :     }
      69           0 :     maImpl.SetFont(pFont);
      70           0 :     rtl::OString aLang("");
      71           0 :     if (rServerFont.GetFontSelData().meLanguage != LANGUAGE_DONTKNOW)
      72             :     {
      73           0 :         aLang = rtl::OUStringToOString( LanguageTag( rServerFont.GetFontSelData().meLanguage ).getBcp47(),
      74           0 :                 RTL_TEXTENCODING_UTF8 );
      75             :     }
      76             :     rtl::OString name = rtl::OUStringToOString(
      77           0 :         rServerFont.GetFontSelData().maTargetName, RTL_TEXTENCODING_UTF8 );
      78             : #ifdef DEBUG
      79             :     printf("GraphiteServerFontLayout %lx %s size %d %f\n", (long unsigned int)this, name.getStr(),
      80             :         rServerFont.GetMetricsFT().x_ppem,
      81             :         rServerFont.GetFontSelData().mfExactHeight);
      82             : #endif
      83           0 :     sal_Int32 nFeat = name.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + 1;
      84           0 :     if (nFeat > 0)
      85             :     {
      86           0 :         rtl::OString aFeat = name.copy(nFeat, name.getLength() - nFeat);
      87             :         mpFeatures = new grutils::GrFeatureParser(
      88           0 :             rServerFont.GetGraphiteFace()->face(), aFeat, aLang);
      89             : #ifdef DEBUG
      90             :         if (mpFeatures)
      91             :             printf("GraphiteServerFontLayout %s/%s/%s %x language %d features %d errors\n",
      92             :                 rtl::OUStringToOString( rServerFont.GetFontSelData().maName,
      93             :                 RTL_TEXTENCODING_UTF8 ).getStr(),
      94             :                 rtl::OUStringToOString( rServerFont.GetFontSelData().maTargetName,
      95             :                 RTL_TEXTENCODING_UTF8 ).getStr(),
      96             :                 rtl::OUStringToOString( rServerFont.GetFontSelData().maSearchName,
      97             :                 RTL_TEXTENCODING_UTF8 ).getStr(),
      98             :                 rServerFont.GetFontSelData().meLanguage,
      99             :                 (int)mpFeatures->numFeatures(), mpFeatures->parseErrors());
     100             : #endif
     101             :     }
     102             :     else
     103             :     {
     104             :         mpFeatures = new grutils::GrFeatureParser(
     105           0 :             rServerFont.GetGraphiteFace()->face(), aLang);
     106             :     }
     107           0 :     maImpl.SetFeatures(mpFeatures);
     108           0 : }
     109             : 
     110           0 : GraphiteServerFontLayout::~GraphiteServerFontLayout() throw()
     111             : {
     112           0 :     delete mpFeatures;
     113           0 :     mpFeatures = NULL;
     114           0 : }
     115             : 
     116           0 : bool GraphiteServerFontLayout::IsGraphiteEnabledFont(ServerFont& rServerFont)
     117             : {
     118           0 :     if (rServerFont.GetGraphiteFace())
     119             :     {
     120             : #ifdef DEBUG
     121             :         printf("IsGraphiteEnabledFont\n");
     122             : #endif
     123           0 :         return true;
     124             :     }
     125           0 :     return false;
     126             : }
     127             : 
     128           0 : sal_GlyphId GraphiteLayoutImpl::getKashidaGlyph(int & width)
     129             : {
     130           0 :     int nKashidaIndex = mrServerFont.GetGlyphIndex( 0x0640 );
     131           0 :     if( nKashidaIndex != 0 )
     132             :     {
     133           0 :         const GlyphMetric& rGM = mrServerFont.GetGlyphMetric( nKashidaIndex );
     134           0 :         width = rGM.GetCharWidth();
     135             :     }
     136             :     else
     137             :     {
     138           0 :         width = 0;
     139             :     }
     140           0 :     return nKashidaIndex;
     141             : }
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10