LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/generic/glyphs - graphite_serverfont.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 42 9.5 %
Date: 2013-07-09 Functions: 3 8 37.5 %
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             : // Header files
      21             : //
      22             : 
      23             : // Platform
      24             : #include <i18nlangtag/languagetag.hxx>
      25             : #include <sallayout.hxx>
      26             : // Module
      27             : #include "gcach_ftyp.hxx"
      28             : #include "generic/glyphcache.hxx"
      29             : #include <graphite_features.hxx>
      30             : #include <graphite_serverfont.hxx>
      31             : 
      32           0 : float freetypeServerFontAdvance(const void* appFontHandle, gr_uint16 glyphId)
      33             : {
      34             :     ServerFont * pServerFont =
      35             :         const_cast<ServerFont*>
      36           0 :         (reinterpret_cast<const ServerFont*>(appFontHandle));
      37           0 :     if (pServerFont)
      38             :     {
      39           0 :         return static_cast<float>(pServerFont->GetGlyphMetric(glyphId).GetCharWidth());
      40             :     }
      41           0 :     return .0f;
      42             : }
      43             : 
      44             : //
      45             : // An implementation of the GraphiteLayout interface to enable Graphite enabled fonts to be used.
      46             : //
      47             : 
      48           0 : GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont& rServerFont) throw()
      49             :   : ServerFontLayout(rServerFont),
      50           0 :     maImpl(rServerFont.GetGraphiteFace()->face(),
      51             :         rServerFont),
      52           0 :     mpFeatures(NULL)
      53             : {
      54           0 :     gr_font * pFont = rServerFont.GetGraphiteFace()->font(rServerFont.GetFontSelData().mnHeight);
      55           0 :     if (!pFont)
      56             :     {
      57             :         pFont = gr_make_font_with_advance_fn(
      58             :                // need to use mnHeight here, mfExactHeight can give wrong values
      59           0 :                static_cast<float>(rServerFont.GetFontSelData().mnHeight),
      60             :                &rServerFont,
      61             :                freetypeServerFontAdvance,
      62           0 :                rServerFont.GetGraphiteFace()->face());
      63           0 :         rServerFont.GetGraphiteFace()->addFont(rServerFont.GetFontSelData().mnHeight, pFont);
      64             :     }
      65           0 :     maImpl.SetFont(pFont);
      66           0 :     OString aLang("");
      67           0 :     if (rServerFont.GetFontSelData().meLanguage != LANGUAGE_DONTKNOW)
      68             :     {
      69           0 :         aLang = OUStringToOString( LanguageTag( rServerFont.GetFontSelData().meLanguage ).getBcp47(),
      70           0 :                 RTL_TEXTENCODING_UTF8 );
      71             :     }
      72             :     OString name = OUStringToOString(
      73           0 :         rServerFont.GetFontSelData().maTargetName, RTL_TEXTENCODING_UTF8 );
      74             : #ifdef DEBUG
      75             :     printf("GraphiteServerFontLayout %lx %s size %d %f\n", (long unsigned int)this, name.getStr(),
      76             :         rServerFont.GetMetricsFT().x_ppem,
      77             :         rServerFont.GetFontSelData().mfExactHeight);
      78             : #endif
      79           0 :     sal_Int32 nFeat = name.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + 1;
      80           0 :     if (nFeat > 0)
      81             :     {
      82           0 :         OString aFeat = name.copy(nFeat, name.getLength() - nFeat);
      83             :         mpFeatures = new grutils::GrFeatureParser(
      84           0 :             rServerFont.GetGraphiteFace()->face(), aFeat, aLang);
      85             : #ifdef DEBUG
      86             :         if (mpFeatures)
      87             :             printf("GraphiteServerFontLayout %s/%s/%s %x language %d features %d errors\n",
      88             :                 OUStringToOString( rServerFont.GetFontSelData().GetFamilyName(),
      89             :                 RTL_TEXTENCODING_UTF8 ).getStr(),
      90             :                 OUStringToOString( rServerFont.GetFontSelData().maTargetName,
      91             :                 RTL_TEXTENCODING_UTF8 ).getStr(),
      92             :                 OUStringToOString( rServerFont.GetFontSelData().maSearchName,
      93             :                 RTL_TEXTENCODING_UTF8 ).getStr(),
      94             :                 rServerFont.GetFontSelData().meLanguage,
      95             :                 (int)mpFeatures->numFeatures(), mpFeatures->parseErrors());
      96             : #endif
      97             :     }
      98             :     else
      99             :     {
     100             :         mpFeatures = new grutils::GrFeatureParser(
     101           0 :             rServerFont.GetGraphiteFace()->face(), aLang);
     102             :     }
     103           0 :     maImpl.SetFeatures(mpFeatures);
     104           0 : }
     105             : 
     106           0 : GraphiteServerFontLayout::~GraphiteServerFontLayout() throw()
     107             : {
     108           0 :     delete mpFeatures;
     109           0 :     mpFeatures = NULL;
     110           0 : }
     111             : 
     112        1051 : bool GraphiteServerFontLayout::IsGraphiteEnabledFont(ServerFont& rServerFont)
     113             : {
     114        1051 :     if (rServerFont.GetGraphiteFace())
     115             :     {
     116             : #ifdef DEBUG
     117             :         printf("IsGraphiteEnabledFont\n");
     118             : #endif
     119           0 :         return true;
     120             :     }
     121        1051 :     return false;
     122             : }
     123             : 
     124           0 : sal_GlyphId GraphiteLayoutImpl::getKashidaGlyph(int & width)
     125             : {
     126           0 :     int nKashidaIndex = mrServerFont.GetGlyphIndex( 0x0640 );
     127           0 :     if( nKashidaIndex != 0 )
     128             :     {
     129           0 :         const GlyphMetric& rGM = mrServerFont.GetGlyphMetric( nKashidaIndex );
     130           0 :         width = rGM.GetCharWidth();
     131             :     }
     132             :     else
     133             :     {
     134           0 :         width = 0;
     135             :     }
     136           0 :     return nKashidaIndex;
     137         465 : }
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10