2 * Copyright (c) 2019 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-toolkit/devel-api/text/bitmap-font.h>
22 #include <dali/devel-api/text-abstraction/bitmap-font.h>
26 #include <dali-toolkit/internal/text/character-set-conversion.h>
44 Glyph::Glyph( const std::string& url, const std::string utf8Character, float ascender, float descender )
48 descender{ descender }
50 DALI_ASSERT_DEBUG( utf8Character.size() <= 4u );
52 std::copy( utf8Character.begin(), utf8Character.end(), utf8 );
58 BitmapFontDescription::BitmapFontDescription()
61 underlinePosition{ 0.f },
62 underlineThickness{ 1.f },
66 BitmapFontDescription::~BitmapFontDescription()
69 void CreateBitmapFont( const BitmapFontDescription& description, TextAbstraction::BitmapFont& bitmapFont )
71 bitmapFont.glyphs.reserve( description.glyphs.size() );
72 bitmapFont.name = description.name;
73 bitmapFont.underlinePosition = description.underlinePosition;
74 bitmapFont.underlineThickness = description.underlineThickness;
75 bitmapFont.isColorFont = description.isColorFont;
77 for( const auto& glyph : description.glyphs )
80 Text::Utf8ToUtf32( glyph.utf8, Text::GetUtf8Length( glyph.utf8[0u] ), &c );
82 TextAbstraction::BitmapGlyph bitmapGlyph( glyph.url, c, glyph.ascender, glyph.descender );
84 bitmapFont.glyphs.push_back( std::move( bitmapGlyph ) );
88 } // namespace DevelText
90 } // namespace Toolkit