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

Generated by: LCOV version 1.11