2 * Copyright (c) 2015 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 "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");
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);
45 if( ( NULL == table ) ||
46 ( value <= table[0] ) )
51 if( value >= table[maxIndex] )
56 for( unsigned int index = 0u; index < maxIndex; )
58 const int v1 = table[index];
59 const unsigned int indexPlus = ++index;
60 const int v2 = table[indexPlus];
61 if( ( v1 < value ) && ( value <= v2 ) )
63 const int result = ( ( value - v1 ) < ( v2 - value ) ) ? index : indexPlus;
64 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex result(%d)\n", result );
69 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex exit 0 <-- \n");
74 } // namespace Internal
76 } // namespace TextAbstraction