2 * Copyright (c) 2017 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/text/text-abstraction/font-client-helper.h>
23 #include <dali/integration-api/debug.h>
27 #if defined(DEBUG_ENABLED)
28 Dali::Integration::Log::Filter* gLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_FONT_CLIENT_VALUE_TO_INDEX");
35 namespace TextAbstraction
41 int ValueToIndex( int value, const int* const table, unsigned int maxIndex )
43 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->FontClient::Plugin::ValueToIndex value(%d)\n", value);
47 // Return an invalid index if there is no table.
51 if( value <= table[0] )
56 if( value >= table[maxIndex] )
61 for( unsigned int index = 0u; index < maxIndex; ++index )
63 const int v1 = table[index];
64 const unsigned int indexPlus = index + 1u;
65 const int v2 = table[indexPlus];
66 if( ( v1 < value ) && ( value <= v2 ) )
68 const int result = ( ( v1 > 0 ) && ( ( value - v1 ) < ( v2 - value ) ) ) ? index : indexPlus;
69 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex result(%d)\n", result );
74 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex exit 0 <-- \n");
79 } // namespace Internal
81 } // namespace TextAbstraction