| 2132 | } |
| 2133 | |
| 2134 | void ImFont::BuildLookupTable() |
| 2135 | { |
| 2136 | int max_codepoint = 0; |
| 2137 | for (int i = 0; i != Glyphs.Size; i++) |
| 2138 | max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint); |
| 2139 | |
| 2140 | IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved |
| 2141 | IndexAdvanceX.clear(); |
| 2142 | IndexLookup.clear(); |
| 2143 | GrowIndex(max_codepoint + 1); |
| 2144 | for (int i = 0; i < Glyphs.Size; i++) |
| 2145 | { |
| 2146 | int codepoint = (int)Glyphs[i].Codepoint; |
| 2147 | IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX; |
| 2148 | IndexLookup[codepoint] = (unsigned short)i; |
| 2149 | } |
| 2150 | |
| 2151 | // Create a glyph to handle TAB |
| 2152 | // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?) |
| 2153 | if (FindGlyph((unsigned short)' ')) |
| 2154 | { |
| 2155 | if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times |
| 2156 | Glyphs.resize(Glyphs.Size + 1); |
| 2157 | ImFontGlyph& tab_glyph = Glyphs.back(); |
| 2158 | tab_glyph = *FindGlyph((unsigned short)' '); |
| 2159 | tab_glyph.Codepoint = '\t'; |
| 2160 | tab_glyph.AdvanceX *= 4; |
| 2161 | IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX; |
| 2162 | IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1); |
| 2163 | } |
| 2164 | |
| 2165 | FallbackGlyph = NULL; |
| 2166 | FallbackGlyph = FindGlyph(FallbackChar); |
| 2167 | FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f; |
| 2168 | for (int i = 0; i < max_codepoint + 1; i++) |
| 2169 | if (IndexAdvanceX[i] < 0.0f) |
| 2170 | IndexAdvanceX[i] = FallbackAdvanceX; |
| 2171 | } |
| 2172 | |
| 2173 | void ImFont::SetFallbackChar(ImWchar c) |
| 2174 | { |
no test coverage detected