1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
24 #include <i18nlangtag/languagetag.hxx>
25 #include <sallayout.hxx>
27 #include "gcach_ftyp.hxx"
28 #include "generic/glyphcache.hxx"
29 #include <graphite_features.hxx>
30 #include <graphite_serverfont.hxx>
32 float freetypeServerFontAdvance(const void* appFontHandle
, gr_uint16 glyphId
)
34 ServerFont
* pServerFont
=
35 const_cast<ServerFont
*>
36 (reinterpret_cast<const ServerFont
*>(appFontHandle
));
39 return static_cast<float>(pServerFont
->GetGlyphMetric(glyphId
).GetCharWidth());
45 // An implementation of the GraphiteLayout interface to enable Graphite enabled fonts to be used.
48 GraphiteServerFontLayout::GraphiteServerFontLayout(ServerFont
& rServerFont
) throw()
49 : ServerFontLayout(rServerFont
),
50 maImpl(rServerFont
.GetGraphiteFace()->face(),
54 gr_font
* pFont
= rServerFont
.GetGraphiteFace()->font(rServerFont
.GetFontSelData().mnHeight
);
57 pFont
= gr_make_font_with_advance_fn(
58 // need to use mnHeight here, mfExactHeight can give wrong values
59 static_cast<float>(rServerFont
.GetFontSelData().mnHeight
),
61 freetypeServerFontAdvance
,
62 rServerFont
.GetGraphiteFace()->face());
63 rServerFont
.GetGraphiteFace()->addFont(rServerFont
.GetFontSelData().mnHeight
, pFont
);
65 maImpl
.SetFont(pFont
);
67 if (rServerFont
.GetFontSelData().meLanguage
!= LANGUAGE_DONTKNOW
)
69 aLang
= OUStringToOString( LanguageTag( rServerFont
.GetFontSelData().meLanguage
).getBcp47(),
70 RTL_TEXTENCODING_UTF8
);
72 OString name
= OUStringToOString(
73 rServerFont
.GetFontSelData().maTargetName
, RTL_TEXTENCODING_UTF8
);
75 printf("GraphiteServerFontLayout %lx %s size %d %f\n", (long unsigned int)this, name
.getStr(),
76 rServerFont
.GetMetricsFT().x_ppem
,
77 rServerFont
.GetFontSelData().mfExactHeight
);
79 sal_Int32 nFeat
= name
.indexOf(grutils::GrFeatureParser::FEAT_PREFIX
) + 1;
82 OString aFeat
= name
.copy(nFeat
, name
.getLength() - nFeat
);
83 mpFeatures
= new grutils::GrFeatureParser(
84 rServerFont
.GetGraphiteFace()->face(), aFeat
, aLang
);
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());
100 mpFeatures
= new grutils::GrFeatureParser(
101 rServerFont
.GetGraphiteFace()->face(), aLang
);
103 maImpl
.SetFeatures(mpFeatures
);
106 GraphiteServerFontLayout::~GraphiteServerFontLayout() throw()
112 bool GraphiteServerFontLayout::IsGraphiteEnabledFont(ServerFont
& rServerFont
)
114 if (rServerFont
.GetGraphiteFace())
117 printf("IsGraphiteEnabledFont\n");
124 sal_GlyphId
GraphiteLayoutImpl::getKashidaGlyph(int & width
)
126 int nKashidaIndex
= mrServerFont
.GetGlyphIndex( 0x0640 );
127 if( nKashidaIndex
!= 0 )
129 const GlyphMetric
& rGM
= mrServerFont
.GetGlyphMetric( nKashidaIndex
);
130 width
= rGM
.GetCharWidth();
136 return nKashidaIndex
;
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */