2 * Copyright (c) 2021 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.
17 #include <dali/internal/text/text-abstraction/plugin/embedded-item.h>
19 #include <dali/internal/text/text-abstraction/plugin/font-client-utils.h>
21 namespace Dali::TextAbstraction::Internal
23 void EmbeddedItem::GetGlyphMetrics(GlyphInfo& glyph)
25 glyph.width = static_cast<float>(width);
26 glyph.height = static_cast<float>(height);
28 glyph.yBearing = glyph.height;
29 glyph.advance = glyph.width;
30 glyph.scaleFactor = 1.f;
33 void EmbeddedItem::CreateBitmap(const std::vector<PixelBufferCacheItem>& pixelBufferCache,
34 Dali::TextAbstraction::FontClient::GlyphBufferData& data)
38 if(0u != pixelBufferId)
40 Devel::PixelBuffer pixelBuffer = pixelBufferCache[pixelBufferId - 1u].pixelBuffer;
43 ConvertBitmap(data, pixelBuffer.GetWidth(), pixelBuffer.GetHeight(), pixelBuffer.GetBuffer());
45 // Sets the pixel format.
46 data.format = pixelBuffer.GetPixelFormat();
51 // Creates the output buffer
52 const unsigned int bufferSize = data.width * data.height * 4u;
53 data.buffer = new unsigned char[bufferSize]; // @note The caller is responsible for deallocating the bitmap data using delete[].
55 memset(data.buffer, 0u, bufferSize);
57 // Just creates a void buffer. Doesn't matter what pixel format is set as is the application code the responsible of filling it.
61 } // namespace Dali::TextAbstraction::Internal