| 204 | } |
| 205 | |
| 206 | void SDFGen::open(ax::Scene* scene) |
| 207 | { |
| 208 | refreshFontList(); |
| 209 | |
| 210 | _atlasViewer = Sprite::create(); |
| 211 | _atlasViewer->setTexture(Director::getInstance()->getTextureCache()->getWhiteTexture("/black-texture", 0)); |
| 212 | _atlasViewer->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); |
| 213 | _atlasViewer->retain(); |
| 214 | |
| 215 | auto defaultFontFile = FileUtils::getInstance()->fullPathForFilename(R"(fonts/arial.ttf)"); |
| 216 | |
| 217 | _atlasParams = new FontAtlasGenParams(); |
| 218 | _atlasParams->sourceFont = "fonts/arial.ttf"; |
| 219 | _atlasParams->fontAsset = "fonts/arial-SDF.xasset"; |
| 220 | |
| 221 | ImGuiPresenter::getInstance()->addFont(defaultFontFile); |
| 222 | /* For Simplified Chinese support, please use: |
| 223 | ImGuiPresenter::getInstance()->addFont(R"(C:\Windows\Fonts\msyh.ttc)", ImGuiPresenter::DEFAULT_FONT_SIZE, |
| 224 | ImGuiPresenter::GLYPH_RANGES::CHINESE_GENERAL); |
| 225 | */ |
| 226 | ImGuiPresenter::getInstance()->enableDPIScale(); // enable dpi scale for 4K display support, depends at least one |
| 227 | // valid ttf/ttc font was added. |
| 228 | ImGuiPresenter::getInstance()->addRenderLoop("#sdfg", AX_CALLBACK_0(SDFGen::onImGuiDraw, this), scene); |
| 229 | } |
| 230 | |
| 231 | void SDFGen::close() |
| 232 | { |
no test coverage detected