| 117 | } |
| 118 | |
| 119 | dp::TGlyphs StaticLabel::CacheStaticText(std::string const & text, char const * delimiters, dp::Anchor anchor, |
| 120 | dp::FontDecl const & font, ref_ptr<dp::TextureManager> mng, |
| 121 | LabelResult & result) |
| 122 | { |
| 123 | ASSERT(!text.empty(), ()); |
| 124 | |
| 125 | auto const textRatio = |
| 126 | font.m_size * static_cast<float>(df::VisualParams::Instance().GetVisualScale() / dp::kBaseFontSizePixels); |
| 127 | |
| 128 | dp::TextureManager::TMultilineGlyphsBuffer buffers; |
| 129 | auto const shapedLines = mng->ShapeMultilineText(dp::kBaseFontSizePixels, text, delimiters, buffers); |
| 130 | |
| 131 | ASSERT_EQUAL(shapedLines.size(), buffers.size(), ()); |
| 132 | |
| 133 | #ifdef DEBUG |
| 134 | for (size_t i = 0; i < buffers.size(); ++i) |
| 135 | { |
| 136 | ASSERT(!buffers[i].empty(), ()); |
| 137 | ASSERT_EQUAL(buffers[i].size(), shapedLines[i].m_glyphs.size(), ()); |
| 138 | } |
| 139 | |
| 140 | ref_ptr<dp::Texture> texture = buffers[0][0].GetTexture(); |
| 141 | for (dp::TextureManager::TGlyphsBuffer const & b : buffers) |
| 142 | for (dp::TextureManager::GlyphRegion const & reg : b) |
| 143 | ASSERT(texture == reg.GetTexture(), ()); |
| 144 | #endif |
| 145 | |
| 146 | dp::TextureManager::ColorRegion color; |
| 147 | dp::TextureManager::ColorRegion outline; |
| 148 | mng->GetColorRegion(font.m_color, color); |
| 149 | mng->GetColorRegion(font.m_outlineColor, outline); |
| 150 | ASSERT(color.GetTexture() == outline.GetTexture(), ()); |
| 151 | |
| 152 | glsl::vec2 colorTex = glsl::ToVec2(color.GetTexRect().Center()); |
| 153 | glsl::vec2 outlineTex = glsl::ToVec2(outline.GetTexRect().Center()); |
| 154 | |
| 155 | buffer_vector<float, 4> lineLengths; |
| 156 | lineLengths.reserve(buffers.size()); |
| 157 | |
| 158 | buffer_vector<size_t, 4> ranges; |
| 159 | ranges.reserve(buffers.size()); |
| 160 | |
| 161 | float fullHeight = 0.0; |
| 162 | |
| 163 | buffer_vector<Vertex, 128> & rb = result.m_buffer; |
| 164 | for (int i = static_cast<int>(buffers.size()) - 1; i >= 0; --i) |
| 165 | { |
| 166 | auto const & glyphs = shapedLines[i].m_glyphs; |
| 167 | |
| 168 | dp::TextureManager::TGlyphsBuffer & regions = buffers[i]; |
| 169 | lineLengths.push_back(0.0f); |
| 170 | float & currentLineLength = lineLengths.back(); |
| 171 | |
| 172 | float depth = 0.0; |
| 173 | glsl::vec2 pen(0.0, -fullHeight); |
| 174 | float prevLineHeight = 0.0; |
| 175 | for (size_t j = 0; j < regions.size(); ++j) |
| 176 | { |
nothing calls this directly
no test coverage detected