2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/text/font-layout.h>
22 #include <dali/integration-api/glyph-set.h>
33 const float INCH_TO_POINTS( 72.f );
34 const float POINT_TO_INCHES( 1.f / INCH_TO_POINTS );
37 FontLayout::FontLayout()
42 FontLayout::FontLayout( float unitsPerEM, Vector2 dpi )
43 :mUnitsPerEM(unitsPerEM),
48 void FontLayout::SetMetrics( const Dali::Integration::GlobalMetrics &metrics )
51 mUnitsPerEM = 1.0f / mMetrics.unitsPerEM;
54 float FontLayout::GetUnitsToPixels( const float pointSize ) const
56 const float meanDpi = (mDpi.height + mDpi.width) * 0.5f;
57 return ((meanDpi * POINT_TO_INCHES) * pointSize) * mUnitsPerEM;
60 const Dali::Integration::GlobalMetrics& FontLayout::GetGlobalMetrics() const
65 float FontLayout::GetLineHeight() const
67 return mMetrics.lineHeight;
70 float FontLayout::GetAscender() const
72 return mMetrics.ascender;
75 float FontLayout::GetUnderlinePosition() const
77 return mMetrics.underlinePosition;
80 float FontLayout::GetUnderlineThickness() const
82 return mMetrics.underlineThickness;
85 float FontLayout::GetUnitsPerEM() const
90 float FontLayout::GetMaxWidth() const
92 return mMetrics.maxWidth;
95 float FontLayout::GetMaxHeight() const
97 return mMetrics.maxHeight;
100 float FontLayout::GetPadAdjustX() const
102 return mMetrics.padAdjustX;
105 float FontLayout::GetPadAdjustY() const
107 return mMetrics.padAdjustY;
110 Vector2 FontLayout::GetDpi() const
115 } // namespace Internal