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 <dali-toolkit/internal/text/text-io.h>
22 #include <dali/devel-api/text-abstraction/font-client.h>
23 #include <dali/devel-api/text-abstraction/script.h>
32 std::ostream& operator<<(std::ostream& o, const Vector<Character>& text)
36 for(unsigned int i = 0; i < text.Count(); ++i)
39 if(i + 1 < text.Count())
48 std::ostream& operator<<(std::ostream& o, const Vector<ScriptRun>& scriptRun)
50 for(unsigned int i = 0; i < scriptRun.Count(); ++i)
52 // e.g. Print "0->9: LATIN" for a ten character run staring from beginning of the model
53 o << scriptRun[i].characterRun.characterIndex << "->" << (scriptRun[i].characterRun.characterIndex + scriptRun[i].characterRun.numberOfCharacters) << ": ";
54 o << TextAbstraction::ScriptName[scriptRun[i].script];
56 if(i + 1 < scriptRun.Count())
65 std::ostream& operator<<(std::ostream& o, const Vector<FontRun>& fontRun)
67 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
69 for(unsigned int i = 0; i < fontRun.Count(); ++i)
71 // e.g. Print "0->9: ID:1 TizenSansKorean style:Regular size:10.0" for a ten character run staring from beginning of the model
72 o << fontRun[i].characterRun.characterIndex << "->" << (fontRun[i].characterRun.characterIndex + fontRun[i].characterRun.numberOfCharacters) << ": ";
74 FontId id = fontRun[i].fontId;
75 TextAbstraction::FontDescription fontDescription;
76 fontClient.GetDescription(id, fontDescription);
77 o << "ID:" << id << ", " << fontDescription.family << " width: " << fontDescription.width << " weight: " << fontDescription.weight << " slant: " << fontDescription.slant << " size:" << (fontClient.GetPointSize(id) / 64);
79 if(i + 1 < fontRun.Count())
88 std::ostream& operator<<(std::ostream& o, const Vector<LineRun>& lineRuns)
90 for(unsigned int i = 0; i < lineRuns.Count(); ++i)
92 // e.g. Print "Line 0 Glyphs: 0->9 Characters: 0->9 (10)" for a ten character run staring from beginning of the model
93 o << "Line " << i << " Glyphs: " << lineRuns[i].glyphRun.glyphIndex << "->" << (lineRuns[i].glyphRun.glyphIndex + lineRuns[i].glyphRun.numberOfGlyphs);
94 o << " Characters: " << lineRuns[i].characterRun.characterIndex << "->" << (lineRuns[i].characterRun.characterIndex + lineRuns[i].characterRun.numberOfCharacters);
95 o << " Width: " << lineRuns[i].width;
96 o << " Ascender: " << lineRuns[i].ascender;
97 o << " Descender: " << lineRuns[i].descender;
99 if(i + 1 < lineRuns.Count())
105 return o << std::dec;
110 } // namespace Toolkit